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
|
@@ -1,865 +0,0 @@
|
|
|
1
|
-
import * as Arr from "../../Array.js";
|
|
2
|
-
import * as Equal from "../../Equal.js";
|
|
3
|
-
import { format } from "../../Formatter.js";
|
|
4
|
-
import { escapeToken } from "../../JsonPointer.js";
|
|
5
|
-
import * as Predicate from "../../Predicate.js";
|
|
6
|
-
import * as Rec from "../../Record.js";
|
|
7
|
-
import * as RegEx from "../../RegExp.js";
|
|
8
|
-
import * as SchemaAST from "../../SchemaAST.js";
|
|
9
|
-
import * as InternalAnnotations from "./annotations.js";
|
|
10
|
-
import * as InternalSchema from "./schema.js";
|
|
11
|
-
/** @internal */
|
|
12
|
-
export function fromAST(ast) {
|
|
13
|
-
const {
|
|
14
|
-
references,
|
|
15
|
-
representations: schemas
|
|
16
|
-
} = fromASTs([ast]);
|
|
17
|
-
return {
|
|
18
|
-
representation: schemas[0],
|
|
19
|
-
references
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
/** @internal */
|
|
23
|
-
export function fromASTs(asts) {
|
|
24
|
-
const references = {};
|
|
25
|
-
const referenceMap = new Map();
|
|
26
|
-
const uniqueReferences = new Set();
|
|
27
|
-
const visiting = new Set();
|
|
28
|
-
const schemas = Arr.map(asts, ast => recur(ast));
|
|
29
|
-
return {
|
|
30
|
-
representations: schemas,
|
|
31
|
-
references
|
|
32
|
-
};
|
|
33
|
-
function gen(prefix) {
|
|
34
|
-
let candidate = prefix;
|
|
35
|
-
let suffix = 0;
|
|
36
|
-
while (uniqueReferences.has(candidate)) {
|
|
37
|
-
candidate = `${prefix}${++suffix}`;
|
|
38
|
-
}
|
|
39
|
-
uniqueReferences.add(candidate);
|
|
40
|
-
return candidate;
|
|
41
|
-
}
|
|
42
|
-
function recur(ast, prefix) {
|
|
43
|
-
const found = referenceMap.get(ast);
|
|
44
|
-
if (found !== undefined) {
|
|
45
|
-
return {
|
|
46
|
-
_tag: "Reference",
|
|
47
|
-
$ref: found
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
const last = SchemaAST.getLastEncoding(ast);
|
|
51
|
-
const identifier = InternalAnnotations.resolveIdentifier(ast) ?? prefix;
|
|
52
|
-
if (ast !== last) {
|
|
53
|
-
return recur(last, identifier);
|
|
54
|
-
}
|
|
55
|
-
// Has identifier → always create reference
|
|
56
|
-
if (identifier !== undefined) {
|
|
57
|
-
const reference = gen(identifier);
|
|
58
|
-
referenceMap.set(ast, reference);
|
|
59
|
-
const out = on(ast);
|
|
60
|
-
const found = references[identifier];
|
|
61
|
-
// Reuse existing references when duplicate identifiers have the same representation
|
|
62
|
-
if (found !== undefined && Equal.equals(out, found)) {
|
|
63
|
-
referenceMap.set(ast, identifier);
|
|
64
|
-
return {
|
|
65
|
-
_tag: "Reference",
|
|
66
|
-
$ref: identifier
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
references[reference] = out;
|
|
70
|
-
return {
|
|
71
|
-
_tag: "Reference",
|
|
72
|
-
$ref: reference
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
// Recursion detected → create reference
|
|
76
|
-
if (visiting.has(ast)) {
|
|
77
|
-
const reference = gen(`${ast._tag}_`);
|
|
78
|
-
referenceMap.set(ast, reference);
|
|
79
|
-
return {
|
|
80
|
-
_tag: "Reference",
|
|
81
|
-
$ref: reference
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
// Normal case → inline
|
|
85
|
-
visiting.add(ast);
|
|
86
|
-
const out = on(ast);
|
|
87
|
-
visiting.delete(ast);
|
|
88
|
-
// A descendant triggered reference creation (recursion)
|
|
89
|
-
const ref = referenceMap.get(ast);
|
|
90
|
-
if (ref !== undefined) {
|
|
91
|
-
references[ref] = out;
|
|
92
|
-
return {
|
|
93
|
-
_tag: "Reference",
|
|
94
|
-
$ref: ref
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
return out;
|
|
98
|
-
}
|
|
99
|
-
function getEncodedSchema(last) {
|
|
100
|
-
const getLink = last.annotations?.toCodecJson ?? last.annotations?.toCodec;
|
|
101
|
-
if (Predicate.isFunction(getLink)) {
|
|
102
|
-
return SchemaAST.replaceEncoding(last, [getLink(last.typeParameters.map(tp => InternalSchema.make(SchemaAST.toEncoded(tp))))]);
|
|
103
|
-
}
|
|
104
|
-
return SchemaAST.null;
|
|
105
|
-
}
|
|
106
|
-
function on(last) {
|
|
107
|
-
const annotations = fromASTAnnotations(last.annotations);
|
|
108
|
-
switch (last._tag) {
|
|
109
|
-
case "Declaration":
|
|
110
|
-
{
|
|
111
|
-
// this must be executed before transforming the type parameters
|
|
112
|
-
const encodedSchema = recur(getEncodedSchema(last));
|
|
113
|
-
return {
|
|
114
|
-
_tag: "Declaration",
|
|
115
|
-
typeParameters: last.typeParameters.map(ast => recur(ast)),
|
|
116
|
-
encodedSchema,
|
|
117
|
-
checks: fromASTChecks(last.checks),
|
|
118
|
-
...annotations
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
case "Null":
|
|
122
|
-
case "Undefined":
|
|
123
|
-
case "Void":
|
|
124
|
-
case "Never":
|
|
125
|
-
case "Unknown":
|
|
126
|
-
case "Any":
|
|
127
|
-
case "Boolean":
|
|
128
|
-
case "Symbol":
|
|
129
|
-
case "ObjectKeyword":
|
|
130
|
-
return {
|
|
131
|
-
_tag: last._tag,
|
|
132
|
-
...annotations
|
|
133
|
-
};
|
|
134
|
-
case "String":
|
|
135
|
-
{
|
|
136
|
-
const contentMediaType = last.annotations?.contentMediaType;
|
|
137
|
-
const contentSchema = last.annotations?.contentSchema;
|
|
138
|
-
return {
|
|
139
|
-
_tag: last._tag,
|
|
140
|
-
checks: fromASTChecks(last.checks),
|
|
141
|
-
...annotations,
|
|
142
|
-
...(typeof contentMediaType === "string" && SchemaAST.isAST(contentSchema) ? {
|
|
143
|
-
contentSchema: recur(contentSchema)
|
|
144
|
-
} : undefined)
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
case "Number":
|
|
148
|
-
case "BigInt":
|
|
149
|
-
return {
|
|
150
|
-
_tag: last._tag,
|
|
151
|
-
checks: fromASTChecks(last.checks),
|
|
152
|
-
...annotations
|
|
153
|
-
};
|
|
154
|
-
case "Literal":
|
|
155
|
-
return {
|
|
156
|
-
_tag: last._tag,
|
|
157
|
-
literal: last.literal,
|
|
158
|
-
...annotations
|
|
159
|
-
};
|
|
160
|
-
case "UniqueSymbol":
|
|
161
|
-
return {
|
|
162
|
-
_tag: last._tag,
|
|
163
|
-
symbol: last.symbol,
|
|
164
|
-
...annotations
|
|
165
|
-
};
|
|
166
|
-
case "Enum":
|
|
167
|
-
return {
|
|
168
|
-
_tag: last._tag,
|
|
169
|
-
enums: last.enums,
|
|
170
|
-
...annotations
|
|
171
|
-
};
|
|
172
|
-
case "TemplateLiteral":
|
|
173
|
-
return {
|
|
174
|
-
_tag: last._tag,
|
|
175
|
-
parts: last.parts.map(ast => recur(ast)),
|
|
176
|
-
...annotations
|
|
177
|
-
};
|
|
178
|
-
case "Arrays":
|
|
179
|
-
return {
|
|
180
|
-
_tag: last._tag,
|
|
181
|
-
elements: last.elements.map(e => {
|
|
182
|
-
const last = SchemaAST.getLastEncoding(e);
|
|
183
|
-
return {
|
|
184
|
-
isOptional: SchemaAST.isOptional(last),
|
|
185
|
-
type: recur(e),
|
|
186
|
-
...fromASTAnnotations(last.context?.annotations)
|
|
187
|
-
};
|
|
188
|
-
}),
|
|
189
|
-
rest: last.rest.map(ast => recur(ast)),
|
|
190
|
-
checks: fromASTChecks(last.checks),
|
|
191
|
-
...annotations
|
|
192
|
-
};
|
|
193
|
-
case "Objects":
|
|
194
|
-
return {
|
|
195
|
-
_tag: last._tag,
|
|
196
|
-
propertySignatures: last.propertySignatures.map(ps => {
|
|
197
|
-
const last = SchemaAST.getLastEncoding(ps.type);
|
|
198
|
-
return {
|
|
199
|
-
name: ps.name,
|
|
200
|
-
type: recur(ps.type),
|
|
201
|
-
isOptional: SchemaAST.isOptional(last),
|
|
202
|
-
isMutable: SchemaAST.isMutable(last),
|
|
203
|
-
...fromASTAnnotations(last.context?.annotations)
|
|
204
|
-
};
|
|
205
|
-
}),
|
|
206
|
-
indexSignatures: last.indexSignatures.map(is => ({
|
|
207
|
-
parameter: recur(is.parameter),
|
|
208
|
-
type: recur(is.type)
|
|
209
|
-
})),
|
|
210
|
-
checks: fromASTChecks(last.checks),
|
|
211
|
-
...annotations
|
|
212
|
-
};
|
|
213
|
-
case "Union":
|
|
214
|
-
{
|
|
215
|
-
const types = InternalSchema.jsonReorder(last.types);
|
|
216
|
-
return {
|
|
217
|
-
_tag: last._tag,
|
|
218
|
-
types: types.map(ast => recur(ast)),
|
|
219
|
-
mode: last.mode,
|
|
220
|
-
...annotations
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
case "Suspend":
|
|
224
|
-
{
|
|
225
|
-
return {
|
|
226
|
-
_tag: "Suspend",
|
|
227
|
-
checks: [],
|
|
228
|
-
thunk: recur(last.thunk()),
|
|
229
|
-
...annotations
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
function fromASTChecks(checks) {
|
|
235
|
-
if (!checks) return [];
|
|
236
|
-
return checks.map(getCheck).filter(c => c !== undefined);
|
|
237
|
-
function getCheck(c) {
|
|
238
|
-
switch (c._tag) {
|
|
239
|
-
case "Filter":
|
|
240
|
-
{
|
|
241
|
-
const meta = c.annotations?.meta;
|
|
242
|
-
if (meta) {
|
|
243
|
-
return {
|
|
244
|
-
_tag: "Filter",
|
|
245
|
-
meta: meta._tag === "isPropertyNames" ? {
|
|
246
|
-
_tag: "isPropertyNames",
|
|
247
|
-
propertyNames: recur(meta.propertyNames)
|
|
248
|
-
} : meta,
|
|
249
|
-
...fromASTAnnotations(c.annotations)
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
return undefined;
|
|
253
|
-
}
|
|
254
|
-
case "FilterGroup":
|
|
255
|
-
{
|
|
256
|
-
const checks = fromASTChecks(c.checks);
|
|
257
|
-
if (Arr.isArrayNonEmpty(checks)) {
|
|
258
|
-
return {
|
|
259
|
-
_tag: "FilterGroup",
|
|
260
|
-
checks,
|
|
261
|
-
...fromASTAnnotations(c.annotations)
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
/** @internal */
|
|
270
|
-
export const fromASTBlacklist = /*#__PURE__*/new Set([
|
|
271
|
-
// `expected` is preserved because is useful to generate descriptions in JSON Schemas
|
|
272
|
-
"~structural", "~sentinels", "meta", "arbitrary", "toArbitrary", "toEquivalence", "toFormatter", "toCodec", "toCodecJson", "toCodecIso", SchemaAST.ClassTypeId]);
|
|
273
|
-
const standardJsonSchemaAnnotationKeys = /*#__PURE__*/new Set(["title", "description", "default", "examples", "readOnly", "writeOnly", "format", "contentEncoding", "contentMediaType", "contentSchema"]);
|
|
274
|
-
function fromASTAnnotations(annotations) {
|
|
275
|
-
if (annotations !== undefined) {
|
|
276
|
-
const filtered = Rec.filter(annotations, (_, k) => !fromASTBlacklist.has(k));
|
|
277
|
-
if (!Rec.isEmptyRecord(filtered)) {
|
|
278
|
-
return {
|
|
279
|
-
annotations: filtered
|
|
280
|
-
};
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
return undefined;
|
|
284
|
-
}
|
|
285
|
-
/** @internal */
|
|
286
|
-
export function toJsonSchemaDocument(document, options) {
|
|
287
|
-
const {
|
|
288
|
-
definitions,
|
|
289
|
-
dialect: source,
|
|
290
|
-
schemas
|
|
291
|
-
} = toJsonSchemaMultiDocument({
|
|
292
|
-
representations: [document.representation],
|
|
293
|
-
references: document.references
|
|
294
|
-
}, options);
|
|
295
|
-
const schema = schemas[0];
|
|
296
|
-
return {
|
|
297
|
-
dialect: source,
|
|
298
|
-
schema,
|
|
299
|
-
definitions
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
/** @internal */
|
|
303
|
-
export function toJsonSchemaMultiDocument(multiDocument, options) {
|
|
304
|
-
const generateDescriptions = options?.generateDescriptions ?? false;
|
|
305
|
-
const additionalProperties = options?.additionalProperties ?? false;
|
|
306
|
-
const includeAnnotationKey = options?.includeAnnotationKey;
|
|
307
|
-
const definitions = Rec.map(multiDocument.references, d => recur(d));
|
|
308
|
-
return {
|
|
309
|
-
dialect: "draft-2020-12",
|
|
310
|
-
schemas: Arr.map(multiDocument.representations, s => recur(s)),
|
|
311
|
-
definitions
|
|
312
|
-
};
|
|
313
|
-
function recur(s) {
|
|
314
|
-
let js = on(s);
|
|
315
|
-
if ("annotations" in s) {
|
|
316
|
-
const a = collectJsonSchemaAnnotations(s.annotations);
|
|
317
|
-
if (a) {
|
|
318
|
-
js = {
|
|
319
|
-
...js,
|
|
320
|
-
...a
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
if ("checks" in s) {
|
|
325
|
-
const checks = collectJsonSchemaChecks(s.checks, js.type);
|
|
326
|
-
for (const check of checks) {
|
|
327
|
-
js = appendJsonSchema(js, check);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
return js;
|
|
331
|
-
}
|
|
332
|
-
function on(schema) {
|
|
333
|
-
switch (schema._tag) {
|
|
334
|
-
case "Any":
|
|
335
|
-
case "Unknown":
|
|
336
|
-
return {};
|
|
337
|
-
case "ObjectKeyword":
|
|
338
|
-
return {
|
|
339
|
-
anyOf: [{
|
|
340
|
-
type: "object"
|
|
341
|
-
}, {
|
|
342
|
-
type: "array"
|
|
343
|
-
}]
|
|
344
|
-
};
|
|
345
|
-
case "Void":
|
|
346
|
-
case "Undefined":
|
|
347
|
-
return {
|
|
348
|
-
type: "null"
|
|
349
|
-
};
|
|
350
|
-
case "BigInt":
|
|
351
|
-
return {
|
|
352
|
-
"type": "string",
|
|
353
|
-
"allOf": [{
|
|
354
|
-
"pattern": "^-?\\d+$"
|
|
355
|
-
}]
|
|
356
|
-
};
|
|
357
|
-
case "Symbol":
|
|
358
|
-
case "UniqueSymbol":
|
|
359
|
-
return {
|
|
360
|
-
"type": "string",
|
|
361
|
-
"allOf": [{
|
|
362
|
-
"pattern": "^Symbol\\((.*)\\)$"
|
|
363
|
-
}]
|
|
364
|
-
};
|
|
365
|
-
case "Declaration":
|
|
366
|
-
return recur(schema.encodedSchema);
|
|
367
|
-
case "Suspend":
|
|
368
|
-
return recur(schema.thunk);
|
|
369
|
-
case "Reference":
|
|
370
|
-
return {
|
|
371
|
-
$ref: `#/$defs/${escapeToken(schema.$ref)}`
|
|
372
|
-
};
|
|
373
|
-
case "Null":
|
|
374
|
-
return {
|
|
375
|
-
type: "null"
|
|
376
|
-
};
|
|
377
|
-
case "Never":
|
|
378
|
-
return {
|
|
379
|
-
not: {}
|
|
380
|
-
};
|
|
381
|
-
case "String":
|
|
382
|
-
{
|
|
383
|
-
const out = {
|
|
384
|
-
type: "string"
|
|
385
|
-
};
|
|
386
|
-
if (schema.contentMediaType !== undefined) {
|
|
387
|
-
out.contentMediaType = schema.contentMediaType;
|
|
388
|
-
}
|
|
389
|
-
if (schema.contentSchema !== undefined) {
|
|
390
|
-
out.contentSchema = recur(schema.contentSchema);
|
|
391
|
-
}
|
|
392
|
-
return out;
|
|
393
|
-
}
|
|
394
|
-
case "Number":
|
|
395
|
-
return hasCheck(schema.checks, "isInt") ? {
|
|
396
|
-
type: "integer"
|
|
397
|
-
} : hasCheck(schema.checks, "isFinite") ? {
|
|
398
|
-
type: "number"
|
|
399
|
-
} : {
|
|
400
|
-
"anyOf": [{
|
|
401
|
-
type: "number"
|
|
402
|
-
}, {
|
|
403
|
-
type: "string",
|
|
404
|
-
enum: ["NaN"]
|
|
405
|
-
}, {
|
|
406
|
-
type: "string",
|
|
407
|
-
enum: ["Infinity"]
|
|
408
|
-
}, {
|
|
409
|
-
type: "string",
|
|
410
|
-
enum: ["-Infinity"]
|
|
411
|
-
}]
|
|
412
|
-
};
|
|
413
|
-
case "Boolean":
|
|
414
|
-
return {
|
|
415
|
-
type: "boolean"
|
|
416
|
-
};
|
|
417
|
-
case "Literal":
|
|
418
|
-
{
|
|
419
|
-
const literal = schema.literal;
|
|
420
|
-
if (typeof literal === "string") {
|
|
421
|
-
return {
|
|
422
|
-
type: "string",
|
|
423
|
-
enum: [literal]
|
|
424
|
-
};
|
|
425
|
-
}
|
|
426
|
-
if (typeof literal === "number") {
|
|
427
|
-
return {
|
|
428
|
-
type: "number",
|
|
429
|
-
enum: [literal]
|
|
430
|
-
};
|
|
431
|
-
}
|
|
432
|
-
if (typeof literal === "boolean") {
|
|
433
|
-
return {
|
|
434
|
-
type: "boolean",
|
|
435
|
-
enum: [literal]
|
|
436
|
-
};
|
|
437
|
-
}
|
|
438
|
-
// bigint literals are not supported
|
|
439
|
-
return {
|
|
440
|
-
type: "string",
|
|
441
|
-
enum: [String(literal)]
|
|
442
|
-
};
|
|
443
|
-
}
|
|
444
|
-
case "Enum":
|
|
445
|
-
{
|
|
446
|
-
return recur({
|
|
447
|
-
_tag: "Union",
|
|
448
|
-
types: schema.enums.map(([title, value]) => ({
|
|
449
|
-
_tag: "Literal",
|
|
450
|
-
literal: value,
|
|
451
|
-
annotations: {
|
|
452
|
-
title
|
|
453
|
-
}
|
|
454
|
-
})),
|
|
455
|
-
mode: "anyOf",
|
|
456
|
-
annotations: schema.annotations
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
|
-
case "TemplateLiteral":
|
|
460
|
-
{
|
|
461
|
-
const pattern = schema.parts.map(getPartPattern).join("");
|
|
462
|
-
return {
|
|
463
|
-
type: "string",
|
|
464
|
-
pattern: `^${pattern}$`
|
|
465
|
-
};
|
|
466
|
-
}
|
|
467
|
-
case "Arrays":
|
|
468
|
-
{
|
|
469
|
-
// ---------------------------------------------
|
|
470
|
-
// handle post rest elements
|
|
471
|
-
// ---------------------------------------------
|
|
472
|
-
if (schema.rest.length > 1) {
|
|
473
|
-
throw new globalThis.Error("Generating a JSON Schema for post-rest elements is not supported");
|
|
474
|
-
}
|
|
475
|
-
const out = {
|
|
476
|
-
type: "array"
|
|
477
|
-
};
|
|
478
|
-
let minItems = schema.elements.length;
|
|
479
|
-
const prefixItems = schema.elements.map(e => {
|
|
480
|
-
if (e.isOptional) {
|
|
481
|
-
minItems--;
|
|
482
|
-
}
|
|
483
|
-
const v = recur(e.type);
|
|
484
|
-
const a = collectJsonSchemaAnnotations(e.annotations);
|
|
485
|
-
return a ? appendJsonSchema(v, a) : v;
|
|
486
|
-
});
|
|
487
|
-
if (prefixItems.length > 0) {
|
|
488
|
-
out.prefixItems = prefixItems;
|
|
489
|
-
out.maxItems = schema.elements.length;
|
|
490
|
-
if (minItems > 0) {
|
|
491
|
-
out.minItems = minItems;
|
|
492
|
-
}
|
|
493
|
-
} else {
|
|
494
|
-
out.items = false;
|
|
495
|
-
}
|
|
496
|
-
if (schema.rest.length > 0) {
|
|
497
|
-
delete out.maxItems;
|
|
498
|
-
const rest = recur(schema.rest[0]);
|
|
499
|
-
if (Object.keys(rest).length > 0) {
|
|
500
|
-
out.items = rest;
|
|
501
|
-
} else {
|
|
502
|
-
delete out.items;
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
return out;
|
|
506
|
-
}
|
|
507
|
-
case "Objects":
|
|
508
|
-
{
|
|
509
|
-
if (schema.propertySignatures.length === 0 && schema.indexSignatures.length === 0) {
|
|
510
|
-
return {
|
|
511
|
-
anyOf: [{
|
|
512
|
-
type: "object"
|
|
513
|
-
}, {
|
|
514
|
-
type: "array"
|
|
515
|
-
}]
|
|
516
|
-
};
|
|
517
|
-
}
|
|
518
|
-
const out = {
|
|
519
|
-
type: "object"
|
|
520
|
-
};
|
|
521
|
-
const properties = {};
|
|
522
|
-
const required = [];
|
|
523
|
-
for (const ps of schema.propertySignatures) {
|
|
524
|
-
const name = ps.name;
|
|
525
|
-
if (typeof name !== "string") {
|
|
526
|
-
throw new globalThis.Error(`Unsupported property signature name: ${format(name)}`);
|
|
527
|
-
}
|
|
528
|
-
const v = recur(ps.type);
|
|
529
|
-
const a = collectJsonSchemaAnnotations(ps.annotations);
|
|
530
|
-
properties[name] = a ? appendJsonSchema(v, a) : v;
|
|
531
|
-
// Property is required only if it's not explicitly optional AND doesn't contain Undefined
|
|
532
|
-
if (!ps.isOptional) {
|
|
533
|
-
required.push(name);
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
if (Object.keys(properties).length > 0) {
|
|
537
|
-
out.properties = properties;
|
|
538
|
-
}
|
|
539
|
-
if (required.length > 0) {
|
|
540
|
-
out.required = required;
|
|
541
|
-
}
|
|
542
|
-
out.additionalProperties = additionalProperties;
|
|
543
|
-
const patternProperties = {};
|
|
544
|
-
// Handle index signatures
|
|
545
|
-
for (const is of schema.indexSignatures) {
|
|
546
|
-
let type = recur(is.type);
|
|
547
|
-
// Collapse unannotated Never ({ not: {} }) to false, but keep annotated schemas as objects.
|
|
548
|
-
if (Object.keys(type).length === 1 && "not" in type) {
|
|
549
|
-
type = false;
|
|
550
|
-
}
|
|
551
|
-
const patterns = getParameterPatterns(is.parameter);
|
|
552
|
-
if (patterns.length > 0) {
|
|
553
|
-
for (const pattern of patterns) {
|
|
554
|
-
patternProperties[pattern] = type;
|
|
555
|
-
}
|
|
556
|
-
} else {
|
|
557
|
-
out.additionalProperties = type;
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
if (Object.keys(patternProperties).length > 0) {
|
|
561
|
-
out.patternProperties = patternProperties;
|
|
562
|
-
delete out.additionalProperties;
|
|
563
|
-
}
|
|
564
|
-
if (Predicate.isObject(out.additionalProperties) && Rec.isEmptyRecord(out.additionalProperties)) {
|
|
565
|
-
delete out.additionalProperties;
|
|
566
|
-
}
|
|
567
|
-
return out;
|
|
568
|
-
}
|
|
569
|
-
case "Union":
|
|
570
|
-
{
|
|
571
|
-
const types = schema.types.map(recur);
|
|
572
|
-
if (types.length === 0) {
|
|
573
|
-
// anyOf MUST be a non-empty array
|
|
574
|
-
return {
|
|
575
|
-
not: {}
|
|
576
|
-
};
|
|
577
|
-
}
|
|
578
|
-
if (types.length > 1) {
|
|
579
|
-
const compacted = compactEnums(types);
|
|
580
|
-
if (compacted) return compacted;
|
|
581
|
-
}
|
|
582
|
-
return schema.mode === "anyOf" ? {
|
|
583
|
-
anyOf: types
|
|
584
|
-
} : {
|
|
585
|
-
oneOf: types
|
|
586
|
-
};
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
// Collapses [{type:"string",enum:["a"]},{type:"string",enum:["b"]}] into {type:"string",enum:["a","b"]}.
|
|
591
|
-
// Returns undefined if members have different types, extra keys (e.g. title), or empty enums.
|
|
592
|
-
function compactEnums(types) {
|
|
593
|
-
let sharedType;
|
|
594
|
-
const values = [];
|
|
595
|
-
for (const t of types) {
|
|
596
|
-
const keys = Object.keys(t);
|
|
597
|
-
if (keys.length !== 2 || t.type === undefined || !Array.isArray(t.enum) || t.enum.length === 0) {
|
|
598
|
-
return undefined;
|
|
599
|
-
}
|
|
600
|
-
if (sharedType === undefined) {
|
|
601
|
-
sharedType = t.type;
|
|
602
|
-
} else if (t.type !== sharedType) {
|
|
603
|
-
return undefined;
|
|
604
|
-
}
|
|
605
|
-
for (const v of t.enum) {
|
|
606
|
-
values.push(v);
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
return {
|
|
610
|
-
type: sharedType,
|
|
611
|
-
enum: values
|
|
612
|
-
};
|
|
613
|
-
}
|
|
614
|
-
function collectJsonSchemaAnnotations(annotations) {
|
|
615
|
-
if (annotations === undefined) return undefined;
|
|
616
|
-
const out = {};
|
|
617
|
-
if (typeof annotations.title === "string") out.title = annotations.title;
|
|
618
|
-
if (typeof annotations.description === "string") out.description = annotations.description;else if (generateDescriptions && typeof annotations.expected === "string") out.description = annotations.expected;
|
|
619
|
-
if (annotations.default !== undefined) out.default = annotations.default;
|
|
620
|
-
if (Array.isArray(annotations.examples)) out.examples = annotations.examples;
|
|
621
|
-
if (typeof annotations.readOnly === "boolean") out.readOnly = annotations.readOnly;
|
|
622
|
-
if (typeof annotations.writeOnly === "boolean") out.writeOnly = annotations.writeOnly;
|
|
623
|
-
if (typeof annotations.format === "string") out.format = annotations.format;
|
|
624
|
-
if (typeof annotations.contentEncoding === "string") out.contentEncoding = annotations.contentEncoding;
|
|
625
|
-
if (typeof annotations.contentMediaType === "string") out.contentMediaType = annotations.contentMediaType;
|
|
626
|
-
if (includeAnnotationKey) {
|
|
627
|
-
for (const [key, value] of Object.entries(annotations)) {
|
|
628
|
-
if (value === undefined) continue;
|
|
629
|
-
if (standardJsonSchemaAnnotationKeys.has(key)) continue;
|
|
630
|
-
if (!includeAnnotationKey(key)) continue;
|
|
631
|
-
out[key] = value;
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
if (Object.keys(out).length > 0) return out;
|
|
635
|
-
}
|
|
636
|
-
function collectJsonSchemaChecks(checks, type) {
|
|
637
|
-
return checks.map(collectJsonSchemaCheck).filter(c => c !== undefined);
|
|
638
|
-
function collectJsonSchemaCheck(check) {
|
|
639
|
-
switch (check._tag) {
|
|
640
|
-
case "Filter":
|
|
641
|
-
return filterToJsonSchema(check, type);
|
|
642
|
-
case "FilterGroup":
|
|
643
|
-
{
|
|
644
|
-
const checks = check.checks.map(collectJsonSchemaCheck).filter(c => c !== undefined);
|
|
645
|
-
if (checks.length === 0) return undefined;
|
|
646
|
-
let out = {
|
|
647
|
-
allOf: checks
|
|
648
|
-
};
|
|
649
|
-
const a = collectJsonSchemaAnnotations(check.annotations);
|
|
650
|
-
if (a) {
|
|
651
|
-
out = {
|
|
652
|
-
...out,
|
|
653
|
-
...a
|
|
654
|
-
};
|
|
655
|
-
}
|
|
656
|
-
return out;
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
function filterToJsonSchema(filter, type) {
|
|
662
|
-
const meta = filter.meta;
|
|
663
|
-
if (!meta) return undefined;
|
|
664
|
-
let out = on(meta);
|
|
665
|
-
const a = collectJsonSchemaAnnotations(filter.annotations);
|
|
666
|
-
if (a) {
|
|
667
|
-
out = {
|
|
668
|
-
...out,
|
|
669
|
-
...a
|
|
670
|
-
};
|
|
671
|
-
}
|
|
672
|
-
return out;
|
|
673
|
-
function on(meta) {
|
|
674
|
-
switch (meta._tag) {
|
|
675
|
-
case "isMinLength":
|
|
676
|
-
return type === "array" ? {
|
|
677
|
-
minItems: meta.minLength
|
|
678
|
-
} : {
|
|
679
|
-
minLength: meta.minLength
|
|
680
|
-
};
|
|
681
|
-
case "isMaxLength":
|
|
682
|
-
return type === "array" ? {
|
|
683
|
-
maxItems: meta.maxLength
|
|
684
|
-
} : {
|
|
685
|
-
maxLength: meta.maxLength
|
|
686
|
-
};
|
|
687
|
-
case "isLengthBetween":
|
|
688
|
-
return type === "array" ? {
|
|
689
|
-
allOf: [{
|
|
690
|
-
minItems: meta.minimum
|
|
691
|
-
}, {
|
|
692
|
-
maxItems: meta.maximum
|
|
693
|
-
}]
|
|
694
|
-
} : {
|
|
695
|
-
allOf: [{
|
|
696
|
-
minLength: meta.minimum
|
|
697
|
-
}, {
|
|
698
|
-
maxLength: meta.maximum
|
|
699
|
-
}]
|
|
700
|
-
};
|
|
701
|
-
case "isPattern":
|
|
702
|
-
case "isGUID":
|
|
703
|
-
case "isULID":
|
|
704
|
-
case "isBase64":
|
|
705
|
-
case "isBase64Url":
|
|
706
|
-
case "isStartsWith":
|
|
707
|
-
case "isEndsWith":
|
|
708
|
-
case "isIncludes":
|
|
709
|
-
case "isUppercased":
|
|
710
|
-
case "isLowercased":
|
|
711
|
-
case "isCapitalized":
|
|
712
|
-
case "isUncapitalized":
|
|
713
|
-
case "isTrimmed":
|
|
714
|
-
case "isStringFinite":
|
|
715
|
-
case "isStringBigInt":
|
|
716
|
-
case "isStringSymbol":
|
|
717
|
-
return {
|
|
718
|
-
pattern: meta.regExp.source
|
|
719
|
-
};
|
|
720
|
-
case "isUUID":
|
|
721
|
-
return {
|
|
722
|
-
pattern: meta.regExp.source,
|
|
723
|
-
format: "uuid"
|
|
724
|
-
};
|
|
725
|
-
case "isFinite":
|
|
726
|
-
case "isInt":
|
|
727
|
-
return undefined;
|
|
728
|
-
case "isMultipleOf":
|
|
729
|
-
return {
|
|
730
|
-
multipleOf: meta.divisor
|
|
731
|
-
};
|
|
732
|
-
case "isGreaterThanOrEqualTo":
|
|
733
|
-
return {
|
|
734
|
-
minimum: meta.minimum
|
|
735
|
-
};
|
|
736
|
-
case "isLessThanOrEqualTo":
|
|
737
|
-
return {
|
|
738
|
-
maximum: meta.maximum
|
|
739
|
-
};
|
|
740
|
-
case "isGreaterThan":
|
|
741
|
-
return {
|
|
742
|
-
exclusiveMinimum: meta.exclusiveMinimum
|
|
743
|
-
};
|
|
744
|
-
case "isLessThan":
|
|
745
|
-
return {
|
|
746
|
-
exclusiveMaximum: meta.exclusiveMaximum
|
|
747
|
-
};
|
|
748
|
-
case "isBetween":
|
|
749
|
-
{
|
|
750
|
-
return {
|
|
751
|
-
[meta.exclusiveMinimum ? "exclusiveMinimum" : "minimum"]: meta.minimum,
|
|
752
|
-
[meta.exclusiveMaximum ? "exclusiveMaximum" : "maximum"]: meta.maximum
|
|
753
|
-
};
|
|
754
|
-
}
|
|
755
|
-
case "isUnique":
|
|
756
|
-
return {
|
|
757
|
-
uniqueItems: true
|
|
758
|
-
};
|
|
759
|
-
case "isMinProperties":
|
|
760
|
-
return {
|
|
761
|
-
minProperties: meta.minProperties
|
|
762
|
-
};
|
|
763
|
-
case "isMaxProperties":
|
|
764
|
-
return {
|
|
765
|
-
maxProperties: meta.maxProperties
|
|
766
|
-
};
|
|
767
|
-
case "isPropertiesLengthBetween":
|
|
768
|
-
return {
|
|
769
|
-
minProperties: meta.minimum,
|
|
770
|
-
maxProperties: meta.maximum
|
|
771
|
-
};
|
|
772
|
-
case "isPropertyNames":
|
|
773
|
-
return {
|
|
774
|
-
propertyNames: recur(meta.propertyNames)
|
|
775
|
-
};
|
|
776
|
-
case "isDateValid":
|
|
777
|
-
return {
|
|
778
|
-
format: "date-time"
|
|
779
|
-
};
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
function getParameterPatterns(parameter) {
|
|
784
|
-
switch (parameter._tag) {
|
|
785
|
-
default:
|
|
786
|
-
throw new globalThis.Error(`Unsupported index signature parameter: ${parameter._tag}`);
|
|
787
|
-
case "Reference":
|
|
788
|
-
return getParameterPatterns(multiDocument.references[parameter.$ref]);
|
|
789
|
-
case "String":
|
|
790
|
-
return getPatterns(parameter);
|
|
791
|
-
case "TemplateLiteral":
|
|
792
|
-
return [`^${parameter.parts.map(getPartPattern).join("")}$`];
|
|
793
|
-
case "Union":
|
|
794
|
-
return parameter.types.flatMap(getParameterPatterns);
|
|
795
|
-
}
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
function getPatterns(s) {
|
|
799
|
-
return recur(s.checks);
|
|
800
|
-
function recur(checks) {
|
|
801
|
-
return checks.flatMap(c => {
|
|
802
|
-
switch (c._tag) {
|
|
803
|
-
case "Filter":
|
|
804
|
-
{
|
|
805
|
-
if ("regExp" in c.meta) {
|
|
806
|
-
return [c.meta.regExp.source];
|
|
807
|
-
}
|
|
808
|
-
return [];
|
|
809
|
-
}
|
|
810
|
-
case "FilterGroup":
|
|
811
|
-
return recur(c.checks);
|
|
812
|
-
}
|
|
813
|
-
});
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
function hasCheck(checks, tag) {
|
|
817
|
-
return checks.some(c => {
|
|
818
|
-
switch (c._tag) {
|
|
819
|
-
case "Filter":
|
|
820
|
-
return c.meta._tag === tag;
|
|
821
|
-
case "FilterGroup":
|
|
822
|
-
return hasCheck(c.checks, tag);
|
|
823
|
-
}
|
|
824
|
-
});
|
|
825
|
-
}
|
|
826
|
-
function appendJsonSchema(a, b) {
|
|
827
|
-
if (Object.keys(a).length === 0) return b;
|
|
828
|
-
const len = Object.keys(b).length;
|
|
829
|
-
if (len === 0) return a;
|
|
830
|
-
const members = Array.isArray(b.allOf) && len === 1 ? b.allOf : [b];
|
|
831
|
-
if (Array.isArray(a.allOf)) {
|
|
832
|
-
return {
|
|
833
|
-
...a,
|
|
834
|
-
allOf: [...a.allOf, ...members]
|
|
835
|
-
};
|
|
836
|
-
}
|
|
837
|
-
if (typeof a.$ref === "string") {
|
|
838
|
-
return {
|
|
839
|
-
allOf: [a, ...members]
|
|
840
|
-
};
|
|
841
|
-
}
|
|
842
|
-
return {
|
|
843
|
-
...a,
|
|
844
|
-
allOf: members
|
|
845
|
-
};
|
|
846
|
-
}
|
|
847
|
-
function getPartPattern(part) {
|
|
848
|
-
switch (part._tag) {
|
|
849
|
-
case "Literal":
|
|
850
|
-
return RegEx.escape(globalThis.String(part.literal));
|
|
851
|
-
case "String":
|
|
852
|
-
return SchemaAST.STRING_PATTERN;
|
|
853
|
-
case "Number":
|
|
854
|
-
return SchemaAST.FINITE_PATTERN;
|
|
855
|
-
case "TemplateLiteral":
|
|
856
|
-
return part.parts.map(getPartPattern).join("");
|
|
857
|
-
case "Union":
|
|
858
|
-
return part.types.map(getPartPattern).join("|");
|
|
859
|
-
default:
|
|
860
|
-
throw new globalThis.Error("Unsupported part", {
|
|
861
|
-
cause: part
|
|
862
|
-
});
|
|
863
|
-
}
|
|
864
|
-
}
|
|
865
|
-
//# sourceMappingURL=representation.js.map
|