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
package/src/SchemaAST.ts
CHANGED
|
@@ -1372,14 +1372,17 @@ export class Number extends Base {
|
|
|
1372
1372
|
}
|
|
1373
1373
|
/** @internal */
|
|
1374
1374
|
toCodecJson(): AST {
|
|
1375
|
-
if (
|
|
1375
|
+
if (
|
|
1376
|
+
this.checks &&
|
|
1377
|
+
(hasCheck(this.checks, "effect/schema/isFinite") || hasCheck(this.checks, "effect/schema/isInt"))
|
|
1378
|
+
) {
|
|
1376
1379
|
return this
|
|
1377
1380
|
}
|
|
1378
|
-
return replaceEncoding(this, [numberToJson])
|
|
1381
|
+
return replaceEncoding(this, [numberToJson(this.checks)])
|
|
1379
1382
|
}
|
|
1380
1383
|
/** @internal */
|
|
1381
1384
|
toCodecStringTree(): AST {
|
|
1382
|
-
if (this.
|
|
1385
|
+
if (this.toCodecJson() === this) {
|
|
1383
1386
|
return replaceEncoding(this, [finiteToString])
|
|
1384
1387
|
}
|
|
1385
1388
|
return replaceEncoding(this, [numberToString])
|
|
@@ -1390,16 +1393,25 @@ export class Number extends Base {
|
|
|
1390
1393
|
}
|
|
1391
1394
|
}
|
|
1392
1395
|
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1396
|
+
function hasCheck(checks: ReadonlyArray<Check<unknown>>, id: string): boolean {
|
|
1397
|
+
return checks.some((check) =>
|
|
1398
|
+
check.annotations?.representation?.id === id ||
|
|
1399
|
+
(check._tag === "FilterGroup" && hasCheck(check.checks, id))
|
|
1400
|
+
)
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
function numberToJson(checks: Checks | undefined): Link {
|
|
1404
|
+
const encodedFinite = checks === undefined
|
|
1405
|
+
? finite
|
|
1406
|
+
: appendChecks(finite, checks)
|
|
1407
|
+
|
|
1408
|
+
return new Link(
|
|
1409
|
+
new Union([encodedFinite, nonFiniteLiterals], "anyOf"),
|
|
1410
|
+
new SchemaTransformation.Transformation(
|
|
1411
|
+
SchemaGetter.Number(),
|
|
1412
|
+
SchemaGetter.transform((n) => globalThis.Number.isFinite(n) ? n : globalThis.String(n))
|
|
1413
|
+
)
|
|
1414
|
+
)
|
|
1403
1415
|
}
|
|
1404
1416
|
|
|
1405
1417
|
/**
|
|
@@ -2131,9 +2143,9 @@ export class Objects extends Base {
|
|
|
2131
2143
|
const v2 = exitValue.value.value
|
|
2132
2144
|
if (is.merge && is.merge.decode && Object.hasOwn(s.out, k2)) {
|
|
2133
2145
|
const [k, v] = is.merge.decode.combine([k2, s.out[k2]], [k2, v2])
|
|
2134
|
-
InternalRecord.
|
|
2146
|
+
InternalRecord.assignProperty(s.out, k, v)
|
|
2135
2147
|
} else {
|
|
2136
|
-
InternalRecord.
|
|
2148
|
+
InternalRecord.assignProperty(s.out, k2, v2)
|
|
2137
2149
|
}
|
|
2138
2150
|
}
|
|
2139
2151
|
}),
|
|
@@ -2189,7 +2201,7 @@ export class Objects extends Base {
|
|
|
2189
2201
|
}
|
|
2190
2202
|
} else {
|
|
2191
2203
|
// preserve key
|
|
2192
|
-
InternalRecord.
|
|
2204
|
+
InternalRecord.assignProperty(out, key, input[key])
|
|
2193
2205
|
}
|
|
2194
2206
|
}
|
|
2195
2207
|
}
|
|
@@ -2229,7 +2241,7 @@ export class Objects extends Base {
|
|
|
2229
2241
|
const preserved: Record<PropertyKey, unknown> = {}
|
|
2230
2242
|
for (const key of keys) {
|
|
2231
2243
|
if (Object.hasOwn(out, key)) {
|
|
2232
|
-
InternalRecord.
|
|
2244
|
+
InternalRecord.assignProperty(preserved, key, out[key])
|
|
2233
2245
|
}
|
|
2234
2246
|
}
|
|
2235
2247
|
return Option.some(preserved)
|
|
@@ -2320,7 +2332,7 @@ const parseProperties = iterateEager<{
|
|
|
2320
2332
|
if (exit._tag === "Failure") {
|
|
2321
2333
|
return wrapPropertyKeyIssue(s, s.ast, p.name, exit)
|
|
2322
2334
|
} else if (exit.value._tag === "Some") {
|
|
2323
|
-
InternalRecord.
|
|
2335
|
+
InternalRecord.assignProperty(s.out, p.name, exit.value.value)
|
|
2324
2336
|
} else if (!isOptional(p.type)) {
|
|
2325
2337
|
const issue = new SchemaIssue.Pointer([p.name], new SchemaIssue.MissingKey(p.type.context?.annotations))
|
|
2326
2338
|
if (s.options.errors === "all") {
|
|
@@ -2447,7 +2459,7 @@ function getCandidateTypes(ast: AST): ReadonlyArray<Type> {
|
|
|
2447
2459
|
case "Objects":
|
|
2448
2460
|
return ast.propertySignatures.length || ast.indexSignatures.length
|
|
2449
2461
|
? ["object"]
|
|
2450
|
-
: ["object", "array"]
|
|
2462
|
+
: ["string", "number", "boolean", "symbol", "bigint", "object", "array", "function"]
|
|
2451
2463
|
case "Enum":
|
|
2452
2464
|
return Array.from(new Set(ast.enums.map(([, v]) => typeof v)))
|
|
2453
2465
|
case "Literal":
|
|
@@ -2476,7 +2488,7 @@ export function collectSentinels(ast: AST): Array<Sentinel> {
|
|
|
2476
2488
|
default:
|
|
2477
2489
|
return []
|
|
2478
2490
|
case "Declaration": {
|
|
2479
|
-
const s = ast.annotations?.[
|
|
2491
|
+
const s = ast.annotations?.[InternalAnnotations.SENTINELS_ANNOTATION_KEY]
|
|
2480
2492
|
return Array.isArray(s) ? s : []
|
|
2481
2493
|
}
|
|
2482
2494
|
case "Objects":
|
|
@@ -2780,14 +2792,6 @@ const nonFiniteLiterals = new Union([
|
|
|
2780
2792
|
new Literal("NaN")
|
|
2781
2793
|
], "anyOf")
|
|
2782
2794
|
|
|
2783
|
-
const numberToJson = new Link(
|
|
2784
|
-
new Union([number, nonFiniteLiterals], "anyOf"),
|
|
2785
|
-
new SchemaTransformation.Transformation(
|
|
2786
|
-
SchemaGetter.Number(),
|
|
2787
|
-
SchemaGetter.transform((n) => globalThis.Number.isFinite(n) ? n : globalThis.String(n))
|
|
2788
|
-
)
|
|
2789
|
-
)
|
|
2790
|
-
|
|
2791
2795
|
function formatIsMutable(isMutable: boolean | undefined): string {
|
|
2792
2796
|
return isMutable ? "" : "readonly "
|
|
2793
2797
|
}
|
|
@@ -2889,8 +2893,8 @@ export class Suspend extends Base {
|
|
|
2889
2893
|
*
|
|
2890
2894
|
* - `run` — the validation function. Returns `undefined` on success, or an
|
|
2891
2895
|
* `Issue` on failure.
|
|
2892
|
-
* - `annotations` — optional filter-level
|
|
2893
|
-
*
|
|
2896
|
+
* - `annotations` — optional filter-level annotations (expected message,
|
|
2897
|
+
* representation, arbitrary constraint hints).
|
|
2894
2898
|
* - `aborted` — when `true`, parsing stops immediately after this filter
|
|
2895
2899
|
* fails (no further checks run).
|
|
2896
2900
|
*
|
|
@@ -3013,6 +3017,32 @@ export function makeFilterByGuard<T extends E, E>(
|
|
|
3013
3017
|
)
|
|
3014
3018
|
}
|
|
3015
3019
|
|
|
3020
|
+
/** @internal */
|
|
3021
|
+
export function isFinite(annotations?: Schema.Annotations.Filter) {
|
|
3022
|
+
return makeFilter(
|
|
3023
|
+
(n: number) => globalThis.Number.isFinite(n),
|
|
3024
|
+
{
|
|
3025
|
+
expected: "a finite number",
|
|
3026
|
+
representation: {
|
|
3027
|
+
id: "effect/schema/isFinite",
|
|
3028
|
+
payload: null
|
|
3029
|
+
},
|
|
3030
|
+
toJsonSchema: () => ({ type: "number" }),
|
|
3031
|
+
toCode: () => ({ runtime: "Schema.isFinite()" }),
|
|
3032
|
+
arbitrary: {
|
|
3033
|
+
constraint: {
|
|
3034
|
+
noInfinity: true,
|
|
3035
|
+
noNaN: true
|
|
3036
|
+
}
|
|
3037
|
+
},
|
|
3038
|
+
...annotations
|
|
3039
|
+
}
|
|
3040
|
+
)
|
|
3041
|
+
}
|
|
3042
|
+
|
|
3043
|
+
/** @internal */
|
|
3044
|
+
export const finite = appendChecks(number, [isFinite()])
|
|
3045
|
+
|
|
3016
3046
|
/**
|
|
3017
3047
|
* Creates a {@link Filter} that validates strings by running `RegExp.test`.
|
|
3018
3048
|
*
|
|
@@ -3051,10 +3081,11 @@ export function isPattern(regExp: globalThis.RegExp, annotations?: Schema.Annota
|
|
|
3051
3081
|
(s: string) => regExp.test(s),
|
|
3052
3082
|
{
|
|
3053
3083
|
expected: `a string matching the RegExp ${source}`,
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
regExp
|
|
3084
|
+
representation: {
|
|
3085
|
+
id: "effect/schema/isPattern",
|
|
3086
|
+
payload: { source, flags: regExp.flags }
|
|
3057
3087
|
},
|
|
3088
|
+
toJsonSchema: () => ({ pattern: source }),
|
|
3058
3089
|
arbitrary: {
|
|
3059
3090
|
constraint: {
|
|
3060
3091
|
patterns: [regExp.source]
|
|
@@ -3130,14 +3161,17 @@ export function appendChecks<A extends AST>(ast: A, checks: Checks | undefined):
|
|
|
3130
3161
|
return replaceChecks(ast, combineChecks(ast.checks, checks))
|
|
3131
3162
|
}
|
|
3132
3163
|
|
|
3164
|
+
/** @internal */
|
|
3165
|
+
export function mapLink(link: Link, f: (ast: AST) => AST): Link {
|
|
3166
|
+
const to = f(link.to)
|
|
3167
|
+
return to === link.to ? link : new Link(to, link.transformation)
|
|
3168
|
+
}
|
|
3169
|
+
|
|
3133
3170
|
function updateLastLink(encoding: Encoding, f: (ast: AST) => AST): Encoding {
|
|
3134
3171
|
const links = encoding
|
|
3135
3172
|
const last = links[links.length - 1]
|
|
3136
|
-
const
|
|
3137
|
-
|
|
3138
|
-
return Arr.append(encoding.slice(0, encoding.length - 1), new Link(to, last.transformation))
|
|
3139
|
-
}
|
|
3140
|
-
return encoding
|
|
3173
|
+
const out = mapLink(last, f)
|
|
3174
|
+
return out === last ? encoding : Arr.append(encoding.slice(0, encoding.length - 1), out)
|
|
3141
3175
|
}
|
|
3142
3176
|
|
|
3143
3177
|
/** @internal */
|
|
@@ -3145,6 +3179,11 @@ export function applyToLastLink(f: (ast: AST) => AST) {
|
|
|
3145
3179
|
return <A extends AST>(ast: A): A => ast.encoding ? replaceEncoding(ast, updateLastLink(ast.encoding, f)) : ast
|
|
3146
3180
|
}
|
|
3147
3181
|
|
|
3182
|
+
/** @internal */
|
|
3183
|
+
export function replaceContextLastLink<A extends AST>(ast: A, context: Context): A {
|
|
3184
|
+
return applyToLastLink((ast) => replaceContext(ast, context))(ast)
|
|
3185
|
+
}
|
|
3186
|
+
|
|
3148
3187
|
/** @internal */
|
|
3149
3188
|
export function applyToSelfOrLastLinkEncoding(f: (ast: AST) => AST) {
|
|
3150
3189
|
function out(ast: AST): AST {
|
|
@@ -3220,8 +3259,7 @@ export function annotateKey<A extends AST>(ast: A, annotations: Schema.Annotatio
|
|
|
3220
3259
|
return replaceContext(ast, context)
|
|
3221
3260
|
}
|
|
3222
3261
|
|
|
3223
|
-
|
|
3224
|
-
export const optionalKeyLastLink = applyToLastLink(optionalKey)
|
|
3262
|
+
const optionalKeyLastLink = applyToLastLink(optionalKey)
|
|
3225
3263
|
|
|
3226
3264
|
/**
|
|
3227
3265
|
* Marks an AST node's property key as optional by setting
|
|
@@ -3366,6 +3404,20 @@ export function isMutable(ast: AST): boolean {
|
|
|
3366
3404
|
return ast.context?.isMutable ?? false
|
|
3367
3405
|
}
|
|
3368
3406
|
|
|
3407
|
+
function isStructuralCheck(check: Check<any>): boolean {
|
|
3408
|
+
return check.annotations?.[InternalAnnotations.STRUCTURAL_ANNOTATION_KEY] === true ||
|
|
3409
|
+
check._tag === "FilterGroup" && check.checks.every(isStructuralCheck)
|
|
3410
|
+
}
|
|
3411
|
+
|
|
3412
|
+
function extractStructuralChecks(checks: Checks): Checks | undefined {
|
|
3413
|
+
function extract(check: Check<any>): Array<Check<any>> {
|
|
3414
|
+
if (isStructuralCheck(check)) return [check]
|
|
3415
|
+
return check._tag === "FilterGroup" ? check.checks.flatMap(extract) : []
|
|
3416
|
+
}
|
|
3417
|
+
const out = checks.flatMap(extract)
|
|
3418
|
+
return Arr.isArrayNonEmpty(out) ? out : undefined
|
|
3419
|
+
}
|
|
3420
|
+
|
|
3369
3421
|
/**
|
|
3370
3422
|
* Strips all encoding transformations from an AST, returning the decoded
|
|
3371
3423
|
* (type-level) representation.
|
|
@@ -3397,13 +3449,16 @@ export const toType = memoize(<A extends AST>(ast: A): A => {
|
|
|
3397
3449
|
}
|
|
3398
3450
|
const out: any = ast
|
|
3399
3451
|
const type = out.recur?.(toType) ?? out
|
|
3400
|
-
const encodingChecks = type.encodingChecks
|
|
3452
|
+
const encodingChecks: Checks | undefined = type.encodingChecks
|
|
3401
3453
|
if (encodingChecks) {
|
|
3454
|
+
const checks = type === ast
|
|
3455
|
+
? encodingChecks
|
|
3456
|
+
: isArrays(type) || isObjects(type) || isDeclaration(type) && type.typeParameters.length > 0
|
|
3457
|
+
? extractStructuralChecks(encodingChecks)
|
|
3458
|
+
: undefined
|
|
3402
3459
|
return modifyOwnPropertyDescriptors(type, (d) => {
|
|
3403
3460
|
d.encodingChecks.value = undefined
|
|
3404
|
-
|
|
3405
|
-
d.checks.value = combineChecks(type.checks, encodingChecks)
|
|
3406
|
-
}
|
|
3461
|
+
d.checks.value = combineChecks(type.checks, checks)
|
|
3407
3462
|
})
|
|
3408
3463
|
}
|
|
3409
3464
|
return type
|
|
@@ -3540,12 +3595,21 @@ function segmentTemplateLiteralParts(
|
|
|
3540
3595
|
input: string,
|
|
3541
3596
|
options: ParseOptions
|
|
3542
3597
|
): Array<string> | undefined {
|
|
3598
|
+
const literals = parts.map((part) => part._tag === "Literal" ? globalThis.String(part.literal) : undefined)
|
|
3599
|
+
if (literals.some((literal) => literal !== undefined && !input.includes(literal))) return undefined
|
|
3600
|
+
|
|
3601
|
+
const minimumLengths = new Array<number>(parts.length + 1)
|
|
3602
|
+
minimumLengths[parts.length] = 0
|
|
3603
|
+
for (let i = parts.length - 1; i >= 0; i--) {
|
|
3604
|
+
minimumLengths[i] = minimumLengths[i + 1] + (literals[i]?.length ?? 0)
|
|
3605
|
+
}
|
|
3606
|
+
if (minimumLengths[0] > input.length) return undefined
|
|
3607
|
+
|
|
3543
3608
|
const out = new Array<string>(parts.length)
|
|
3544
|
-
const failures = new Set<
|
|
3609
|
+
const failures = parts.map(() => new Set<number>())
|
|
3545
3610
|
function go(i: number, pos: number): boolean {
|
|
3546
3611
|
if (i === parts.length) return pos === input.length
|
|
3547
|
-
|
|
3548
|
-
if (failures.has(key)) return false
|
|
3612
|
+
if (failures[i].has(pos)) return false
|
|
3549
3613
|
const part = parts[i]
|
|
3550
3614
|
if (i === parts.length - 1) {
|
|
3551
3615
|
const s = input.slice(pos)
|
|
@@ -3554,21 +3618,27 @@ function segmentTemplateLiteralParts(
|
|
|
3554
3618
|
return true
|
|
3555
3619
|
}
|
|
3556
3620
|
} else if (part._tag === "Literal") {
|
|
3557
|
-
const s =
|
|
3621
|
+
const s = literals[i]!
|
|
3558
3622
|
if (input.startsWith(s, pos) && go(i + 1, pos + s.length)) {
|
|
3559
3623
|
out[i] = s
|
|
3560
3624
|
return true
|
|
3561
3625
|
}
|
|
3562
3626
|
} else {
|
|
3563
|
-
|
|
3627
|
+
const maximumEnd = input.length - minimumLengths[i + 1]
|
|
3628
|
+
// Splits preceding a literal only need to consider occurrences of that literal.
|
|
3629
|
+
const anchor = literals[i + 1]
|
|
3630
|
+
let end = anchor === undefined ? maximumEnd : input.lastIndexOf(anchor, maximumEnd)
|
|
3631
|
+
while (end >= pos) {
|
|
3564
3632
|
const s = input.slice(pos, end)
|
|
3565
3633
|
if (part.matchPart(s, options) !== undefined && go(i + 1, end)) {
|
|
3566
3634
|
out[i] = s
|
|
3567
3635
|
return true
|
|
3568
3636
|
}
|
|
3637
|
+
if (end === 0) break
|
|
3638
|
+
end = anchor === undefined ? end - 1 : input.lastIndexOf(anchor, end - 1)
|
|
3569
3639
|
}
|
|
3570
3640
|
}
|
|
3571
|
-
failures.add(
|
|
3641
|
+
failures[i].add(pos)
|
|
3572
3642
|
return false
|
|
3573
3643
|
}
|
|
3574
3644
|
return go(0, 0) ? out : undefined
|
|
@@ -3627,7 +3697,7 @@ export const STRING_PATTERN = "[\\s\\S]*?"
|
|
|
3627
3697
|
|
|
3628
3698
|
const isStringFiniteRegExp = new globalThis.RegExp(`^${FINITE_PATTERN}$`)
|
|
3629
3699
|
|
|
3630
|
-
const isStringNumberRegExp = new globalThis.RegExp(
|
|
3700
|
+
const isStringNumberRegExp = new globalThis.RegExp(`^(?:${FINITE_PATTERN}|Infinity|-Infinity|NaN)$`)
|
|
3631
3701
|
|
|
3632
3702
|
/** @internal */
|
|
3633
3703
|
export function isStringFinite(annotations?: Schema.Annotations.Filter) {
|
|
@@ -3635,10 +3705,11 @@ export function isStringFinite(annotations?: Schema.Annotations.Filter) {
|
|
|
3635
3705
|
isStringFiniteRegExp,
|
|
3636
3706
|
{
|
|
3637
3707
|
expected: "a string representing a finite number",
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3708
|
+
representation: {
|
|
3709
|
+
id: "effect/schema/isStringFinite",
|
|
3710
|
+
payload: null
|
|
3641
3711
|
},
|
|
3712
|
+
toJsonSchema: () => ({ pattern: isStringFiniteRegExp.source }),
|
|
3642
3713
|
...annotations
|
|
3643
3714
|
}
|
|
3644
3715
|
)
|
|
@@ -3669,10 +3740,11 @@ export function isStringBigInt(annotations?: Schema.Annotations.Filter) {
|
|
|
3669
3740
|
isStringBigIntRegExp,
|
|
3670
3741
|
{
|
|
3671
3742
|
expected: "a string representing a bigint",
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3743
|
+
representation: {
|
|
3744
|
+
id: "effect/schema/isStringBigInt",
|
|
3745
|
+
payload: null
|
|
3675
3746
|
},
|
|
3747
|
+
toJsonSchema: () => ({ pattern: isStringBigIntRegExp.source }),
|
|
3676
3748
|
...annotations
|
|
3677
3749
|
}
|
|
3678
3750
|
)
|
|
@@ -3720,10 +3792,11 @@ export function isStringSymbol(annotations?: Schema.Annotations.Filter) {
|
|
|
3720
3792
|
isStringSymbolRegExp,
|
|
3721
3793
|
{
|
|
3722
3794
|
expected: "a string representing a symbol",
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3795
|
+
representation: {
|
|
3796
|
+
id: "effect/schema/isStringSymbol",
|
|
3797
|
+
payload: null
|
|
3726
3798
|
},
|
|
3799
|
+
toJsonSchema: () => ({ pattern: isStringSymbolRegExp.source }),
|
|
3727
3800
|
...annotations
|
|
3728
3801
|
}
|
|
3729
3802
|
)
|
|
@@ -3770,9 +3843,6 @@ export function runChecks<T>(
|
|
|
3770
3843
|
/** @internal */
|
|
3771
3844
|
export const ClassTypeId = "~effect/Schema/Class"
|
|
3772
3845
|
|
|
3773
|
-
/** @internal */
|
|
3774
|
-
export const STRUCTURAL_ANNOTATION_KEY = "~structural"
|
|
3775
|
-
|
|
3776
3846
|
/**
|
|
3777
3847
|
* Returns all annotations from the AST node.
|
|
3778
3848
|
*
|
|
@@ -3854,6 +3924,82 @@ export const resolveTitle: (ast: AST) => string | undefined = InternalAnnotation
|
|
|
3854
3924
|
*/
|
|
3855
3925
|
export const resolveDescription: (ast: AST) => string | undefined = InternalAnnotations.resolveDescription
|
|
3856
3926
|
|
|
3927
|
+
type TreeFrame = {
|
|
3928
|
+
readonly value: object
|
|
3929
|
+
// Object keys or an array length snapshot.
|
|
3930
|
+
readonly keys: ReadonlyArray<string> | number
|
|
3931
|
+
index: number
|
|
3932
|
+
}
|
|
3933
|
+
|
|
3934
|
+
function isJsonLeaf(u: unknown): boolean {
|
|
3935
|
+
return u === null || typeof u === "string" || typeof u === "boolean" ||
|
|
3936
|
+
typeof u === "number" && globalThis.Number.isFinite(u)
|
|
3937
|
+
}
|
|
3938
|
+
|
|
3939
|
+
function isStringTreeLeaf(u: unknown): boolean {
|
|
3940
|
+
return u === undefined || typeof u === "string"
|
|
3941
|
+
}
|
|
3942
|
+
|
|
3943
|
+
function isTree(u: unknown, isLeaf: (u: unknown) => boolean): boolean {
|
|
3944
|
+
const cache = new WeakMap<object, boolean>()
|
|
3945
|
+
const stack: Array<TreeFrame> = []
|
|
3946
|
+
outer: while (true) {
|
|
3947
|
+
if (typeof u !== "object" || u === null) {
|
|
3948
|
+
if (!isLeaf(u)) {
|
|
3949
|
+
return false
|
|
3950
|
+
}
|
|
3951
|
+
} else {
|
|
3952
|
+
const value = u
|
|
3953
|
+
const cached = cache.get(value)
|
|
3954
|
+
// `false` marks a node on the current path, while `true` marks a fully
|
|
3955
|
+
// validated node that can be safely reused by a DAG.
|
|
3956
|
+
if (cached === false) {
|
|
3957
|
+
return false
|
|
3958
|
+
}
|
|
3959
|
+
if (cached === undefined) {
|
|
3960
|
+
const isArray = Array.isArray(value)
|
|
3961
|
+
if (!isArray) {
|
|
3962
|
+
const prototype = Object.getPrototypeOf(value)
|
|
3963
|
+
// A plain object from another realm has a different Object.prototype,
|
|
3964
|
+
// but that prototype still has a null prototype.
|
|
3965
|
+
if (
|
|
3966
|
+
prototype !== null &&
|
|
3967
|
+
prototype !== Object.prototype &&
|
|
3968
|
+
Object.getPrototypeOf(prototype) !== null
|
|
3969
|
+
) {
|
|
3970
|
+
return false
|
|
3971
|
+
}
|
|
3972
|
+
}
|
|
3973
|
+
cache.set(value, false)
|
|
3974
|
+
stack.push({
|
|
3975
|
+
value,
|
|
3976
|
+
keys: isArray ? value.length : Object.keys(value),
|
|
3977
|
+
index: 0
|
|
3978
|
+
})
|
|
3979
|
+
}
|
|
3980
|
+
}
|
|
3981
|
+
|
|
3982
|
+
while (stack.length > 0) {
|
|
3983
|
+
const frame = stack[stack.length - 1]
|
|
3984
|
+
const keys = frame.keys
|
|
3985
|
+
if (typeof keys === "number") {
|
|
3986
|
+
if (frame.index < keys) {
|
|
3987
|
+
// A sparse slot is read as `undefined`; the leaf predicate determines
|
|
3988
|
+
// whether that is valid for the current tree.
|
|
3989
|
+
u = (frame.value as ReadonlyArray<unknown>)[frame.index++]
|
|
3990
|
+
continue outer
|
|
3991
|
+
}
|
|
3992
|
+
} else if (frame.index < keys.length) {
|
|
3993
|
+
u = (frame.value as Record<string, unknown>)[keys[frame.index++]]
|
|
3994
|
+
continue outer
|
|
3995
|
+
}
|
|
3996
|
+
cache.set(frame.value, true)
|
|
3997
|
+
stack.pop()
|
|
3998
|
+
}
|
|
3999
|
+
return true
|
|
4000
|
+
}
|
|
4001
|
+
}
|
|
4002
|
+
|
|
3857
4003
|
/**
|
|
3858
4004
|
* Returns true if the value is a JSON value.
|
|
3859
4005
|
*
|
|
@@ -3862,51 +4008,7 @@ export const resolveDescription: (ast: AST) => string | undefined = InternalAnno
|
|
|
3862
4008
|
* @internal
|
|
3863
4009
|
*/
|
|
3864
4010
|
export function isJson(u: unknown): u is Schema.Json {
|
|
3865
|
-
|
|
3866
|
-
// one being visited. A hit here means we looped back to an ancestor — a
|
|
3867
|
-
// real cycle, not a DAG — so the value is not JSON.
|
|
3868
|
-
const onPath = new Set<unknown>()
|
|
3869
|
-
// `validated` memoizes subtrees we've already fully checked. Without it, a
|
|
3870
|
-
// diamond-shaped DAG (same node reached through multiple parents) would be
|
|
3871
|
-
// re-traversed once per parent, which is exponential in the nesting depth.
|
|
3872
|
-
const validated = new Set<unknown>()
|
|
3873
|
-
return recur(u)
|
|
3874
|
-
|
|
3875
|
-
function recur(u: unknown): boolean {
|
|
3876
|
-
if (u === null || typeof u === "string" || typeof u === "boolean") {
|
|
3877
|
-
return true
|
|
3878
|
-
}
|
|
3879
|
-
if (typeof u === "number") {
|
|
3880
|
-
return globalThis.Number.isFinite(u)
|
|
3881
|
-
}
|
|
3882
|
-
if (typeof u !== "object" || u === undefined) {
|
|
3883
|
-
return false
|
|
3884
|
-
}
|
|
3885
|
-
if (onPath.has(u)) {
|
|
3886
|
-
return false
|
|
3887
|
-
}
|
|
3888
|
-
if (validated.has(u)) {
|
|
3889
|
-
return true
|
|
3890
|
-
}
|
|
3891
|
-
const isArray = Array.isArray(u)
|
|
3892
|
-
if (!isArray) {
|
|
3893
|
-
const prototype = Object.getPrototypeOf(u)
|
|
3894
|
-
if (prototype !== null && Object.getPrototypeOf(prototype) !== null) {
|
|
3895
|
-
return false
|
|
3896
|
-
}
|
|
3897
|
-
}
|
|
3898
|
-
onPath.add(u)
|
|
3899
|
-
const ok = isArray
|
|
3900
|
-
? u.every(recur)
|
|
3901
|
-
: Object.keys(u).every((key) => recur((u as Record<string, unknown>)[key]))
|
|
3902
|
-
// Pop on exit so siblings reaching the same node via a different path
|
|
3903
|
-
// don't see it as an ancestor (that would reject valid DAGs).
|
|
3904
|
-
onPath.delete(u)
|
|
3905
|
-
if (ok) {
|
|
3906
|
-
validated.add(u)
|
|
3907
|
-
}
|
|
3908
|
-
return ok
|
|
3909
|
-
}
|
|
4011
|
+
return isTree(u, isJsonLeaf)
|
|
3910
4012
|
}
|
|
3911
4013
|
|
|
3912
4014
|
/** @internal */
|
|
@@ -3917,42 +4019,37 @@ export const Json = new Declaration(
|
|
|
3917
4019
|
Effect.succeed(input) :
|
|
3918
4020
|
Effect.fail(new SchemaIssue.InvalidType(ast, Option.some(input))),
|
|
3919
4021
|
{
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
generation: {
|
|
3924
|
-
runtime: `Schema.Json`,
|
|
3925
|
-
Type: `Schema.Json`
|
|
4022
|
+
representation: {
|
|
4023
|
+
id: "effect/schema/Json",
|
|
4024
|
+
payload: null
|
|
3926
4025
|
},
|
|
3927
4026
|
expected: "JSON value",
|
|
3928
|
-
toCodecJson: () =>
|
|
4027
|
+
toCodecJson: () => undefined,
|
|
4028
|
+
toCodecStringTree: () => unknownToStringTree,
|
|
3929
4029
|
toArbitrary: () => (fc: typeof FastCheck) => fc.jsonValue()
|
|
3930
4030
|
}
|
|
3931
4031
|
)
|
|
3932
4032
|
|
|
3933
4033
|
/** @internal */
|
|
3934
4034
|
export const MutableJson = annotate(Json, {
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
generation: {
|
|
3939
|
-
runtime: `Schema.MutableJson`,
|
|
3940
|
-
Type: `Schema.MutableJson`
|
|
4035
|
+
representation: {
|
|
4036
|
+
id: "effect/schema/MutableJson",
|
|
4037
|
+
payload: null
|
|
3941
4038
|
}
|
|
3942
4039
|
})
|
|
3943
4040
|
|
|
3944
4041
|
/** @internal */
|
|
3945
|
-
export const
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
SchemaGetter.passthrough(),
|
|
3949
|
-
SchemaGetter.transform(() => null)
|
|
3950
|
-
)
|
|
4042
|
+
export const unknownToJson = new Link(
|
|
4043
|
+
Json,
|
|
4044
|
+
SchemaTransformation.passthrough()
|
|
3951
4045
|
)
|
|
3952
4046
|
|
|
3953
4047
|
/** @internal */
|
|
3954
|
-
export const
|
|
3955
|
-
|
|
4048
|
+
export const objectKeywordToJson = new Link(
|
|
4049
|
+
new Union([
|
|
4050
|
+
new Arrays(false, [], [Json]),
|
|
4051
|
+
new Objects([], [new IndexSignature(string, Json, undefined)])
|
|
4052
|
+
], "anyOf"),
|
|
3956
4053
|
SchemaTransformation.passthrough()
|
|
3957
4054
|
)
|
|
3958
4055
|
|
|
@@ -3964,25 +4061,7 @@ export const unknownToJson = new Link(
|
|
|
3964
4061
|
* @internal
|
|
3965
4062
|
*/
|
|
3966
4063
|
export function isStringTree(u: unknown): u is Schema.StringTree {
|
|
3967
|
-
|
|
3968
|
-
return recur(u)
|
|
3969
|
-
|
|
3970
|
-
function recur(u: unknown): boolean {
|
|
3971
|
-
if (u === undefined || typeof u === "string") {
|
|
3972
|
-
return true
|
|
3973
|
-
}
|
|
3974
|
-
if (typeof u !== "object" || u === null) {
|
|
3975
|
-
return false
|
|
3976
|
-
}
|
|
3977
|
-
if (seen.has(u)) {
|
|
3978
|
-
return false
|
|
3979
|
-
}
|
|
3980
|
-
seen.add(u)
|
|
3981
|
-
if (Array.isArray(u)) {
|
|
3982
|
-
return u.every(recur)
|
|
3983
|
-
}
|
|
3984
|
-
return Object.keys(u).every((key) => recur((u as Record<string, unknown>)[key]))
|
|
3985
|
-
}
|
|
4064
|
+
return isTree(u, isStringTreeLeaf)
|
|
3986
4065
|
}
|
|
3987
4066
|
|
|
3988
4067
|
const StringTree = new Declaration(
|
|
@@ -3991,7 +4070,7 @@ const StringTree = new Declaration(
|
|
|
3991
4070
|
isStringTree(input) ?
|
|
3992
4071
|
Effect.succeed(input) :
|
|
3993
4072
|
Effect.fail(new SchemaIssue.InvalidType(ast, Option.some(input))),
|
|
3994
|
-
{ expected: "StringTree" }
|
|
4073
|
+
{ expected: "StringTree", toCodecStringTree: () => undefined }
|
|
3995
4074
|
)
|
|
3996
4075
|
|
|
3997
4076
|
/** @internal */
|
package/src/SchemaError.ts
CHANGED
|
@@ -60,5 +60,5 @@ export class SchemaError extends Data.TaggedError("SchemaError")<{
|
|
|
60
60
|
* @since 4.0.0
|
|
61
61
|
*/
|
|
62
62
|
export function isSchemaError(u: unknown): u is SchemaError {
|
|
63
|
-
return Predicate.hasProperty(u, TypeId)
|
|
63
|
+
return Predicate.hasProperty(u, TypeId) && u[TypeId] === TypeId
|
|
64
64
|
}
|