effect 4.0.0-beta.101 → 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/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 +1268 -495
- 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 +2 -1
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/effect.js +64 -21
- 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 +4 -4
- 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/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/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 +2537 -986
- 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 +3 -2
- package/src/internal/effect.ts +67 -31
- 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/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,345 @@
|
|
|
1
|
+
import * as Arr from "../../Array.ts"
|
|
2
|
+
import * as Result from "../../Result.ts"
|
|
3
|
+
import * as Schema from "../../Schema.ts"
|
|
4
|
+
import type * as SchemaAST from "../../SchemaAST.ts"
|
|
5
|
+
import type * as SchemaRepresentation from "../../SchemaRepresentation.ts"
|
|
6
|
+
import { errorWithPath } from "../errors.ts"
|
|
7
|
+
import * as InternalRecord from "../record.ts"
|
|
8
|
+
|
|
9
|
+
type Path = ReadonlyArray<string | number>
|
|
10
|
+
|
|
11
|
+
/** @internal */
|
|
12
|
+
export function fromRepresentations(
|
|
13
|
+
document: SchemaRepresentation.MultiDocument,
|
|
14
|
+
revivers: ReadonlyArray<SchemaRepresentation.AnyReviver>
|
|
15
|
+
): SchemaRepresentation.SchemaMultiDocument {
|
|
16
|
+
return revivePersisted(document.representations, document.references, makeReviverMap(revivers), false)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
class ReferenceSlot {
|
|
20
|
+
body: Schema.Top | undefined
|
|
21
|
+
resolving = false
|
|
22
|
+
readonly wrapper: Schema.Top
|
|
23
|
+
|
|
24
|
+
constructor(key: string) {
|
|
25
|
+
this.wrapper = Schema.suspend(() => {
|
|
26
|
+
if (this.body === undefined) {
|
|
27
|
+
throw new Error(`Reference ${key} was evaluated before it was resolved`)
|
|
28
|
+
}
|
|
29
|
+
return this.body
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function makeReviverMap(
|
|
35
|
+
revivers: ReadonlyArray<SchemaRepresentation.AnyReviver>
|
|
36
|
+
): Map<string, SchemaRepresentation.AnyReviver> {
|
|
37
|
+
const out = new Map<string, SchemaRepresentation.AnyReviver>()
|
|
38
|
+
|
|
39
|
+
for (let index = 0; index < revivers.length; index++) {
|
|
40
|
+
const reviver = revivers[index]
|
|
41
|
+
if (out.has(reviver.id)) {
|
|
42
|
+
throw errorWithPath(`Duplicate reviver for ${reviver.id}`, ["revivers", index, "id"])
|
|
43
|
+
}
|
|
44
|
+
out.set(reviver.id, {
|
|
45
|
+
...reviver,
|
|
46
|
+
payloadSchema: Schema.toCodecJson(reviver.payloadSchema)
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return out
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function revivePersisted(
|
|
54
|
+
representations: readonly [
|
|
55
|
+
SchemaRepresentation.Representation,
|
|
56
|
+
...Array<SchemaRepresentation.Representation>
|
|
57
|
+
],
|
|
58
|
+
references: SchemaRepresentation.References,
|
|
59
|
+
reviverMap: ReadonlyMap<string, SchemaRepresentation.AnyReviver>,
|
|
60
|
+
singleRoot: boolean
|
|
61
|
+
): SchemaRepresentation.SchemaMultiDocument {
|
|
62
|
+
const slots = new Map<string, ReferenceSlot>()
|
|
63
|
+
const referenceKeys = Object.keys(references)
|
|
64
|
+
|
|
65
|
+
for (const key of referenceKeys) {
|
|
66
|
+
slots.set(key, new ReferenceSlot(key))
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function resolveReference(key: string, path: Path): Schema.Top {
|
|
70
|
+
const slot = slots.get(key)
|
|
71
|
+
if (slot === undefined) {
|
|
72
|
+
throw errorWithPath(`Invalid reference ${key}`, [...path, "$ref"])
|
|
73
|
+
}
|
|
74
|
+
if (slot.body !== undefined) {
|
|
75
|
+
return slot.body
|
|
76
|
+
}
|
|
77
|
+
if (slot.resolving) {
|
|
78
|
+
return slot.wrapper
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
slot.resolving = true
|
|
82
|
+
try {
|
|
83
|
+
slot.body = annotate(recur(references[key], ["references", key]), { identifier: key })
|
|
84
|
+
return slot.body
|
|
85
|
+
} finally {
|
|
86
|
+
slot.resolving = false
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function resolveReviver<R extends SchemaRepresentation.AnyReviver>(
|
|
91
|
+
representation: SchemaRepresentation.RepresentationAnnotation,
|
|
92
|
+
path: Path
|
|
93
|
+
): R {
|
|
94
|
+
const reviver = reviverMap.get(representation.id)
|
|
95
|
+
if (reviver === undefined) {
|
|
96
|
+
throw errorWithPath(`Missing reviver for ${representation.id}`, path)
|
|
97
|
+
}
|
|
98
|
+
return reviver as R
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function decodePayload(
|
|
102
|
+
representation: SchemaRepresentation.RepresentationAnnotation,
|
|
103
|
+
reviver: SchemaRepresentation.AnyReviver,
|
|
104
|
+
path: Path
|
|
105
|
+
): any {
|
|
106
|
+
const decoded = Schema.decodeUnknownResult(reviver.payloadSchema)(representation.payload)
|
|
107
|
+
if (Result.isFailure(decoded)) {
|
|
108
|
+
throw errorWithPath(`Invalid representation payload for ${representation.id}`, path)
|
|
109
|
+
}
|
|
110
|
+
return decoded.success
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function reviveSchemas(
|
|
114
|
+
representations: ReadonlyArray<SchemaRepresentation.Representation>,
|
|
115
|
+
path: Path
|
|
116
|
+
): ReadonlyArray<Schema.Top> {
|
|
117
|
+
return representations.map((representation, index) => recur(representation, [...path, index]))
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function reviveDeclaration(
|
|
121
|
+
declaration: SchemaRepresentation.Declaration,
|
|
122
|
+
path: Path
|
|
123
|
+
): Schema.Top {
|
|
124
|
+
const representationPath = [...path, "representation"]
|
|
125
|
+
const representation = declaration.representation
|
|
126
|
+
if (representation === undefined) {
|
|
127
|
+
throw errorWithPath("Missing representation annotation", representationPath)
|
|
128
|
+
}
|
|
129
|
+
const reviver = resolveReviver<SchemaRepresentation.DeclarationReviver<any>>(representation, representationPath)
|
|
130
|
+
const payload = decodePayload(representation, reviver, [...representationPath, "payload"])
|
|
131
|
+
const typeParameters = reviveSchemas(declaration.typeParameters, [...path, "typeParameters"])
|
|
132
|
+
const schema = reviver.revive({ payload, typeParameters, annotations: declaration.annotations })
|
|
133
|
+
return appendChecks(schema, declaration.checks, [...path, "checks"])
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function reviveFilter(
|
|
137
|
+
filter: SchemaRepresentation.Filter,
|
|
138
|
+
path: Path
|
|
139
|
+
): SchemaAST.Filter<any> {
|
|
140
|
+
const representationPath = [...path, "representation"]
|
|
141
|
+
const representation = filter.representation
|
|
142
|
+
if (representation === undefined) {
|
|
143
|
+
throw errorWithPath("Missing representation annotation", representationPath)
|
|
144
|
+
}
|
|
145
|
+
const reviver = resolveReviver<SchemaRepresentation.FilterReviver<any>>(representation, representationPath)
|
|
146
|
+
const payload = decodePayload(representation, reviver, [...representationPath, "payload"])
|
|
147
|
+
const schemas = reviveSchemas(representation.schemas ?? [], [...representationPath, "schemas"])
|
|
148
|
+
const check = reviver.revive({ payload, schemas, annotations: filter.annotations })
|
|
149
|
+
return filter.aborted ? check.abort() : check
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function reviveFilterGroup(
|
|
153
|
+
group: SchemaRepresentation.FilterGroup,
|
|
154
|
+
path: Path
|
|
155
|
+
): SchemaAST.FilterGroup<any> {
|
|
156
|
+
const representationPath = [...path, "representation"]
|
|
157
|
+
const representation = group.representation
|
|
158
|
+
if (representation === undefined) {
|
|
159
|
+
const checks = group.checks.map((check, index) => reviveCheck(check, [...path, "checks", index]))
|
|
160
|
+
return Schema.makeFilterGroup(
|
|
161
|
+
checks as [SchemaAST.Check<any>, ...Array<SchemaAST.Check<any>>],
|
|
162
|
+
group.annotations as Schema.Annotations.Filter | undefined
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const reviver = resolveReviver<SchemaRepresentation.FilterGroupReviver<any>>(representation, representationPath)
|
|
167
|
+
const payload = decodePayload(representation, reviver, [...representationPath, "payload"])
|
|
168
|
+
const schemas = reviveSchemas(representation.schemas ?? [], [...representationPath, "schemas"])
|
|
169
|
+
return reviver.revive({ payload, schemas, annotations: group.annotations })
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function reviveCheck(
|
|
173
|
+
check: SchemaRepresentation.Check,
|
|
174
|
+
path: Path
|
|
175
|
+
): SchemaAST.Check<any> {
|
|
176
|
+
return check._tag === "Filter"
|
|
177
|
+
? reviveFilter(check, path)
|
|
178
|
+
: reviveFilterGroup(check, path)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function appendChecks<S extends Schema.Top>(
|
|
182
|
+
schema: S,
|
|
183
|
+
checks: ReadonlyArray<SchemaRepresentation.Check>,
|
|
184
|
+
path: Path
|
|
185
|
+
): S["Rebuild"] {
|
|
186
|
+
const revived = checks.map((check, index) => reviveCheck(check, [...path, index]))
|
|
187
|
+
return Arr.isArrayNonEmpty(revived) ? schema.check(...revived) : schema as S["Rebuild"]
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function annotate(
|
|
191
|
+
schema: Schema.Top,
|
|
192
|
+
annotations: Schema.Annotations.Annotations | undefined
|
|
193
|
+
): Schema.Top {
|
|
194
|
+
return annotations === undefined ? schema : schema.annotate(annotations)
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function finishStructural(
|
|
198
|
+
schema: Schema.Top,
|
|
199
|
+
representation: Exclude<SchemaRepresentation.Representation, SchemaRepresentation.Reference>,
|
|
200
|
+
path: Path
|
|
201
|
+
): Schema.Top {
|
|
202
|
+
return appendChecks(
|
|
203
|
+
annotate(schema, representation.annotations),
|
|
204
|
+
representation.checks,
|
|
205
|
+
[...path, "checks"]
|
|
206
|
+
)
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function recur(
|
|
210
|
+
representation: SchemaRepresentation.Representation,
|
|
211
|
+
path: Path
|
|
212
|
+
): Schema.Top {
|
|
213
|
+
switch (representation._tag) {
|
|
214
|
+
case "Reference":
|
|
215
|
+
return resolveReference(representation.$ref, path)
|
|
216
|
+
case "Declaration":
|
|
217
|
+
return reviveDeclaration(representation, path)
|
|
218
|
+
case "Suspend": {
|
|
219
|
+
const thunkPath = [...path, "thunk"]
|
|
220
|
+
if (representation.thunk._tag === "Reference") {
|
|
221
|
+
const key = representation.thunk.$ref
|
|
222
|
+
resolveReference(key, thunkPath)
|
|
223
|
+
const slot = slots.get(key)!
|
|
224
|
+
return annotate(slot.wrapper, representation.annotations)
|
|
225
|
+
}
|
|
226
|
+
const thunk = recur(representation.thunk, thunkPath)
|
|
227
|
+
return annotate(Schema.suspend(() => thunk), representation.annotations)
|
|
228
|
+
}
|
|
229
|
+
case "Null":
|
|
230
|
+
return finishStructural(Schema.Null, representation, path)
|
|
231
|
+
case "Undefined":
|
|
232
|
+
return finishStructural(Schema.Undefined, representation, path)
|
|
233
|
+
case "Void":
|
|
234
|
+
return finishStructural(Schema.Void, representation, path)
|
|
235
|
+
case "Never":
|
|
236
|
+
return finishStructural(Schema.Never, representation, path)
|
|
237
|
+
case "Unknown":
|
|
238
|
+
return finishStructural(Schema.Unknown, representation, path)
|
|
239
|
+
case "Any":
|
|
240
|
+
return finishStructural(Schema.Any, representation, path)
|
|
241
|
+
case "String":
|
|
242
|
+
return finishStructural(Schema.String, representation, path)
|
|
243
|
+
case "Number":
|
|
244
|
+
return finishStructural(Schema.Number, representation, path)
|
|
245
|
+
case "Boolean":
|
|
246
|
+
return finishStructural(Schema.Boolean, representation, path)
|
|
247
|
+
case "BigInt":
|
|
248
|
+
return finishStructural(Schema.BigInt, representation, path)
|
|
249
|
+
case "Symbol":
|
|
250
|
+
return finishStructural(Schema.Symbol, representation, path)
|
|
251
|
+
case "Literal":
|
|
252
|
+
return finishStructural(Schema.Literal(representation.literal), representation, path)
|
|
253
|
+
case "UniqueSymbol":
|
|
254
|
+
return finishStructural(Schema.UniqueSymbol(representation.symbol), representation, path)
|
|
255
|
+
case "ObjectKeyword":
|
|
256
|
+
return finishStructural(Schema.ObjectKeyword, representation, path)
|
|
257
|
+
case "Enum":
|
|
258
|
+
return finishStructural(
|
|
259
|
+
Schema.Enum(Object.fromEntries(representation.enums)),
|
|
260
|
+
representation,
|
|
261
|
+
path
|
|
262
|
+
)
|
|
263
|
+
case "TemplateLiteral": {
|
|
264
|
+
const parts = representation.parts.map((part, index) => recur(part, [...path, "parts", index]))
|
|
265
|
+
return finishStructural(
|
|
266
|
+
Schema.TemplateLiteral(parts as unknown as Schema.TemplateLiteral.Parts),
|
|
267
|
+
representation,
|
|
268
|
+
path
|
|
269
|
+
)
|
|
270
|
+
}
|
|
271
|
+
case "Arrays": {
|
|
272
|
+
const elements = representation.elements.map((element, index) => {
|
|
273
|
+
let schema = recur(element.type, [...path, "elements", index, "type"])
|
|
274
|
+
if (element.annotations !== undefined) {
|
|
275
|
+
schema = schema.annotateKey(element.annotations as Schema.Annotations.Key<unknown>)
|
|
276
|
+
}
|
|
277
|
+
return element.isOptional ? Schema.optionalKey(schema) : schema
|
|
278
|
+
})
|
|
279
|
+
const rest = representation.rest.map((item, index) => recur(item, [...path, "rest", index]))
|
|
280
|
+
const schema = Arr.isArrayNonEmpty(rest)
|
|
281
|
+
? elements.length === 0 && rest.length === 1
|
|
282
|
+
? Schema.Array(rest[0])
|
|
283
|
+
: Schema.TupleWithRest(Schema.Tuple(elements), rest)
|
|
284
|
+
: Schema.Tuple(elements)
|
|
285
|
+
return finishStructural(schema, representation, path)
|
|
286
|
+
}
|
|
287
|
+
case "Objects": {
|
|
288
|
+
const fields: Record<PropertyKey, Schema.Top> = {}
|
|
289
|
+
for (let index = 0; index < representation.propertySignatures.length; index++) {
|
|
290
|
+
const property = representation.propertySignatures[index]
|
|
291
|
+
let schema = recur(property.type, [...path, "propertySignatures", index, "type"])
|
|
292
|
+
if (property.annotations !== undefined) {
|
|
293
|
+
schema = schema.annotateKey(property.annotations as Schema.Annotations.Key<unknown>)
|
|
294
|
+
}
|
|
295
|
+
if (property.isOptional) {
|
|
296
|
+
schema = Schema.optionalKey(schema)
|
|
297
|
+
}
|
|
298
|
+
if (property.isMutable) {
|
|
299
|
+
schema = Schema.mutableKey(schema)
|
|
300
|
+
}
|
|
301
|
+
InternalRecord.assignProperty(fields, property.name, schema)
|
|
302
|
+
}
|
|
303
|
+
const records = representation.indexSignatures.map((indexSignature, index) =>
|
|
304
|
+
Schema.Record(
|
|
305
|
+
recur(indexSignature.parameter, [...path, "indexSignatures", index, "parameter"]) as Schema.Record.Key,
|
|
306
|
+
recur(indexSignature.type, [...path, "indexSignatures", index, "type"])
|
|
307
|
+
)
|
|
308
|
+
)
|
|
309
|
+
const schema = Arr.isArrayNonEmpty(records)
|
|
310
|
+
? representation.propertySignatures.length === 0 && records.length === 1
|
|
311
|
+
? records[0]
|
|
312
|
+
: Schema.StructWithRest(Schema.Struct(fields), records)
|
|
313
|
+
: Schema.Struct(fields)
|
|
314
|
+
return finishStructural(schema, representation, path)
|
|
315
|
+
}
|
|
316
|
+
case "Union": {
|
|
317
|
+
const members = representation.types.map((member, index) => recur(member, [...path, "types", index]))
|
|
318
|
+
return finishStructural(Schema.Union(members, { mode: representation.mode }), representation, path)
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
const definitions: Record<string, Schema.Top> = {}
|
|
324
|
+
for (const key of referenceKeys) {
|
|
325
|
+
InternalRecord.assignProperty(definitions, key, resolveReference(key, ["references", key]))
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
const schemas = representations.map((representation, index) =>
|
|
329
|
+
recur(representation, singleRoot ? ["representation"] : ["representations", index])
|
|
330
|
+
) as [Schema.Top, ...Array<Schema.Top>]
|
|
331
|
+
return { schemas, definitions }
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/** @internal */
|
|
335
|
+
export function fromRepresentation(
|
|
336
|
+
document: SchemaRepresentation.Document,
|
|
337
|
+
revivers: ReadonlyArray<SchemaRepresentation.AnyReviver>
|
|
338
|
+
): Schema.Top {
|
|
339
|
+
return revivePersisted(
|
|
340
|
+
[document.representation],
|
|
341
|
+
document.references,
|
|
342
|
+
makeReviverMap(revivers),
|
|
343
|
+
true
|
|
344
|
+
).schemas[0]
|
|
345
|
+
}
|
|
@@ -6,10 +6,50 @@ import * as SchemaAST from "../../SchemaAST.ts"
|
|
|
6
6
|
import { SchemaError } from "../../SchemaError.ts"
|
|
7
7
|
import type { Issue } from "../../SchemaIssue.ts"
|
|
8
8
|
import * as SchemaParser from "../../SchemaParser.ts"
|
|
9
|
+
import type * as SchemaRepresentation from "../../SchemaRepresentation.ts"
|
|
9
10
|
|
|
10
11
|
/** @internal */
|
|
11
12
|
export const TypeId = "~effect/Schema/Schema"
|
|
12
13
|
|
|
14
|
+
/** @internal */
|
|
15
|
+
export function makeDeclarationReviver<P>(
|
|
16
|
+
id: string,
|
|
17
|
+
payloadSchema: Schema.Decoder<P>,
|
|
18
|
+
revive: SchemaRepresentation.DeclarationReviver<P>["revive"]
|
|
19
|
+
): SchemaRepresentation.DeclarationReviver<P> {
|
|
20
|
+
return {
|
|
21
|
+
id,
|
|
22
|
+
payloadSchema,
|
|
23
|
+
revive
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** @internal */
|
|
28
|
+
export function makeFilterReviver<P>(
|
|
29
|
+
id: string,
|
|
30
|
+
payloadSchema: Schema.Decoder<P>,
|
|
31
|
+
revive: SchemaRepresentation.FilterReviver<P>["revive"]
|
|
32
|
+
): SchemaRepresentation.FilterReviver<P> {
|
|
33
|
+
return {
|
|
34
|
+
id,
|
|
35
|
+
payloadSchema,
|
|
36
|
+
revive
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** @internal */
|
|
41
|
+
export function makeFilterGroupReviver<P>(
|
|
42
|
+
id: string,
|
|
43
|
+
payloadSchema: Schema.Decoder<P>,
|
|
44
|
+
revive: SchemaRepresentation.FilterGroupReviver<P>["revive"]
|
|
45
|
+
): SchemaRepresentation.FilterGroupReviver<P> {
|
|
46
|
+
return {
|
|
47
|
+
id,
|
|
48
|
+
payloadSchema,
|
|
49
|
+
revive
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
13
53
|
const SchemaProto = {
|
|
14
54
|
[TypeId]: TypeId,
|
|
15
55
|
pipe() {
|
|
@@ -28,10 +68,11 @@ const SchemaProto = {
|
|
|
28
68
|
|
|
29
69
|
/** @internal */
|
|
30
70
|
export function make<S extends Schema.Constraint>(ast: S["ast"], options?: object): S {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
Object.
|
|
34
|
-
|
|
71
|
+
function Schema() {}
|
|
72
|
+
const self = Object.defineProperties(
|
|
73
|
+
Object.setPrototypeOf(Schema, SchemaProto),
|
|
74
|
+
Object.getOwnPropertyDescriptors({ ...options })
|
|
75
|
+
)
|
|
35
76
|
self.ast = ast
|
|
36
77
|
self.rebuild = (ast: SchemaAST.AST) => make(ast, options)
|
|
37
78
|
const makeEffect = SchemaParser.makeEffect(self)
|
|
@@ -51,45 +92,3 @@ export function fromIssueEffect<A, R>(
|
|
|
51
92
|
(cause) => Effect.failCauseSync(() => Cause.map(cause, (issue) => new SchemaError(issue)))
|
|
52
93
|
)
|
|
53
94
|
}
|
|
54
|
-
|
|
55
|
-
/** @internal */
|
|
56
|
-
export const jsonReorder = makeReorder(getJsonPriority)
|
|
57
|
-
|
|
58
|
-
function getJsonPriority(ast: SchemaAST.AST): number {
|
|
59
|
-
switch (ast._tag) {
|
|
60
|
-
case "BigInt":
|
|
61
|
-
case "Symbol":
|
|
62
|
-
case "UniqueSymbol":
|
|
63
|
-
return 0
|
|
64
|
-
default:
|
|
65
|
-
return 1
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/** @internal */
|
|
70
|
-
export function makeReorder(getPriority: (ast: SchemaAST.AST) => number) {
|
|
71
|
-
return (types: ReadonlyArray<SchemaAST.AST>): ReadonlyArray<SchemaAST.AST> => {
|
|
72
|
-
// Create a map of original indices for O(1) lookup
|
|
73
|
-
const indexMap = new Map<SchemaAST.AST, number>()
|
|
74
|
-
for (let i = 0; i < types.length; i++) {
|
|
75
|
-
indexMap.set(SchemaAST.toEncoded(types[i]), i)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Create a sorted copy of the types array
|
|
79
|
-
const sortedTypes = [...types].sort((a, b) => {
|
|
80
|
-
a = SchemaAST.toEncoded(a)
|
|
81
|
-
b = SchemaAST.toEncoded(b)
|
|
82
|
-
const pa = getPriority(a)
|
|
83
|
-
const pb = getPriority(b)
|
|
84
|
-
if (pa !== pb) return pa - pb
|
|
85
|
-
// If priorities are equal, maintain original order (stable sort)
|
|
86
|
-
return indexMap.get(a)! - indexMap.get(b)!
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
// Check if order changed by comparing arrays
|
|
90
|
-
const orderChanged = sortedTypes.some((ast, index) => ast !== types[index])
|
|
91
|
-
|
|
92
|
-
if (!orderChanged) return types
|
|
93
|
-
return sortedTypes
|
|
94
|
-
}
|
|
95
|
-
}
|
|
@@ -13,6 +13,7 @@ import * as Struct from "../../Struct.ts"
|
|
|
13
13
|
import type * as FastCheck from "../../testing/FastCheck.ts"
|
|
14
14
|
import * as UndefinedOr from "../../UndefinedOr.ts"
|
|
15
15
|
import { errorWithPath } from "../errors.ts"
|
|
16
|
+
import * as InternalRecord from "../record.ts"
|
|
16
17
|
import * as InternalAnnotations from "./annotations.ts"
|
|
17
18
|
|
|
18
19
|
const arbitraryMemoMap = new WeakMap<SchemaAST.AST, LazyArbitraryWithContext<any>>()
|
|
@@ -131,8 +132,7 @@ const combiner: Combiner.Combiner<any> = Struct.makeCombiner({
|
|
|
131
132
|
noInfinity: or,
|
|
132
133
|
noNaN: or,
|
|
133
134
|
patterns: concat,
|
|
134
|
-
unique: or
|
|
135
|
-
valid: or
|
|
135
|
+
unique: or
|
|
136
136
|
}, {
|
|
137
137
|
omitKeyWhen: Predicate.isUndefined
|
|
138
138
|
})
|
|
@@ -288,7 +288,7 @@ function objectWithOptionalCount(
|
|
|
288
288
|
const out: Record<PropertyKey, any> = {}
|
|
289
289
|
for (const name of orderedNames) {
|
|
290
290
|
if (keep.has(name)) {
|
|
291
|
-
out
|
|
291
|
+
InternalRecord.assignProperty(out, name, base[name])
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
294
|
return out
|
|
@@ -403,10 +403,8 @@ function reportChecks(report: MutableReport, checks: SchemaAST.Checks | undefine
|
|
|
403
403
|
visit(child, nextCovered)
|
|
404
404
|
}
|
|
405
405
|
} else if (!nextCovered) {
|
|
406
|
-
const
|
|
407
|
-
|
|
408
|
-
? meta._tag
|
|
409
|
-
: check.annotations?.identifier ?? check.annotations?.expected
|
|
406
|
+
const description = check.annotations?.representation?.id ?? check.annotations?.identifier ??
|
|
407
|
+
check.annotations?.expected
|
|
410
408
|
report.warnings.push({ _tag: "OpaqueFilter", path, ...(description === undefined ? {} : { description }) })
|
|
411
409
|
}
|
|
412
410
|
}
|
|
@@ -773,7 +771,7 @@ function base(ast: SchemaAST.AST, path: ReadonlyArray<PropertyKey>): LazyArbitra
|
|
|
773
771
|
return undefined
|
|
774
772
|
}
|
|
775
773
|
requiredKeys.push(name)
|
|
776
|
-
pss
|
|
774
|
+
InternalRecord.assignProperty(pss, name, out)
|
|
777
775
|
}
|
|
778
776
|
let optionalCount = Math.max(0, (ctx.constraint?.minLength ?? 0) - requiredKeys.length)
|
|
779
777
|
for (const [name, out] of optionals) {
|
|
@@ -782,7 +780,7 @@ function base(ast: SchemaAST.AST, path: ReadonlyArray<PropertyKey>): LazyArbitra
|
|
|
782
780
|
}
|
|
783
781
|
optionalCount--
|
|
784
782
|
requiredKeys.push(name)
|
|
785
|
-
pss
|
|
783
|
+
InternalRecord.assignProperty(pss, name, out)
|
|
786
784
|
}
|
|
787
785
|
if (optionalCount > 0 && ast.indexSignatures.length === 0) {
|
|
788
786
|
return undefined
|
|
@@ -828,7 +826,7 @@ function base(ast: SchemaAST.AST, path: ReadonlyArray<PropertyKey>): LazyArbitra
|
|
|
828
826
|
} else {
|
|
829
827
|
requiredKeys.push(name)
|
|
830
828
|
}
|
|
831
|
-
pss
|
|
829
|
+
InternalRecord.assignProperty(pss, name, arbitrary(fc, reset, recursionStack))
|
|
832
830
|
}
|
|
833
831
|
// When property-count constraints must be satisfied by selecting
|
|
834
832
|
// optional keys (no index signatures are available to fill the gap),
|