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/dist/Schema.js
CHANGED
|
@@ -30,10 +30,11 @@ import * as HashSet_ from "./HashSet.js";
|
|
|
30
30
|
import * as core from "./internal/core.js";
|
|
31
31
|
import * as InternalRecord from "./internal/record.js";
|
|
32
32
|
import * as InternalAnnotations from "./internal/schema/annotations.js";
|
|
33
|
-
import * as InternalArbitrary from "./internal/schema/arbitrary.js";
|
|
34
|
-
import * as InternalEquivalence from "./internal/schema/equivalence.js";
|
|
35
|
-
import * as InternalStandard from "./internal/schema/representation.js";
|
|
36
33
|
import * as InternalSchema from "./internal/schema/schema.js";
|
|
34
|
+
import * as InternalArbitrary from "./internal/schema/toArbitrary.js";
|
|
35
|
+
import * as InternalEquivalence from "./internal/schema/toEquivalence.js";
|
|
36
|
+
import * as InternalToJsonSchemaDocument from "./internal/schema/toJsonSchemaDocument.js";
|
|
37
|
+
import * as InternalToRepresentation from "./internal/schema/toRepresentation.js";
|
|
37
38
|
import * as JsonPatch from "./JsonPatch.js";
|
|
38
39
|
import * as JsonSchema from "./JsonSchema.js";
|
|
39
40
|
import { remainder } from "./Number.js";
|
|
@@ -44,6 +45,7 @@ import * as Pipeable from "./Pipeable.js";
|
|
|
44
45
|
import * as Predicate from "./Predicate.js";
|
|
45
46
|
import * as Record_ from "./Record.js";
|
|
46
47
|
import * as Redacted_ from "./Redacted.js";
|
|
48
|
+
import * as RegExp_ from "./RegExp.js";
|
|
47
49
|
import * as Result_ from "./Result.js";
|
|
48
50
|
import * as Scheduler from "./Scheduler.js";
|
|
49
51
|
import * as SchemaAST from "./SchemaAST.js";
|
|
@@ -195,7 +197,7 @@ export function revealBottom(bottom) {
|
|
|
195
197
|
* ```ts
|
|
196
198
|
* import { Schema } from "effect"
|
|
197
199
|
*
|
|
198
|
-
* const Age = Schema.
|
|
200
|
+
* const Age = Schema.Natural.pipe(
|
|
199
201
|
* Schema.annotate({
|
|
200
202
|
* title: "Age",
|
|
201
203
|
* description: "A non-negative integer representing age in years"
|
|
@@ -407,7 +409,7 @@ function makeStandardResult(exit) {
|
|
|
407
409
|
* // Create a standard schema from a regular schema
|
|
408
410
|
* const PersonSchema = Schema.Struct({
|
|
409
411
|
* name: Schema.NonEmptyString,
|
|
410
|
-
* age: Schema.
|
|
412
|
+
* age: Schema.Finite.check(Schema.isBetween({ minimum: 0, maximum: 150 }))
|
|
411
413
|
* })
|
|
412
414
|
*
|
|
413
415
|
* const standardSchema = Schema.toStandardSchemaV1(PersonSchema, {
|
|
@@ -1395,32 +1397,6 @@ export const encodeSync = encodeUnknownSync;
|
|
|
1395
1397
|
* @since 3.10.0
|
|
1396
1398
|
*/
|
|
1397
1399
|
export const make = InternalSchema.make;
|
|
1398
|
-
/**
|
|
1399
|
-
* Transforms a schema into a class that can be extended with `extends`. The
|
|
1400
|
-
* resulting class inherits the full schema API (e.g. `annotate`) and can define
|
|
1401
|
-
* static methods that reference `this`.
|
|
1402
|
-
*
|
|
1403
|
-
* **Example** (Wrapping a primitive schema)
|
|
1404
|
-
*
|
|
1405
|
-
* ```ts
|
|
1406
|
-
* import { Schema } from "effect"
|
|
1407
|
-
*
|
|
1408
|
-
* class MyString extends Schema.asClass(Schema.String) {
|
|
1409
|
-
* static readonly decodeUnknownSync = Schema.decodeUnknownSync(this)
|
|
1410
|
-
* }
|
|
1411
|
-
*
|
|
1412
|
-
* console.log(MyString.decodeUnknownSync("a"))
|
|
1413
|
-
* // "a"
|
|
1414
|
-
* ```
|
|
1415
|
-
*
|
|
1416
|
-
* @category constructors
|
|
1417
|
-
* @since 4.0.0
|
|
1418
|
-
*/
|
|
1419
|
-
export function asClass(schema) {
|
|
1420
|
-
// oxlint-disable-next-line @typescript-eslint/no-extraneous-class
|
|
1421
|
-
class Class {}
|
|
1422
|
-
return Object.setPrototypeOf(Class, schema);
|
|
1423
|
-
}
|
|
1424
1400
|
/**
|
|
1425
1401
|
* Checks whether a value is a `Schema`.
|
|
1426
1402
|
*
|
|
@@ -1946,8 +1922,8 @@ const canonicalPropertyKey = key => typeof key === "symbol" ? key : globalThis.S
|
|
|
1946
1922
|
export function encodeKeys(mapping) {
|
|
1947
1923
|
return function (self) {
|
|
1948
1924
|
const fields = {};
|
|
1949
|
-
const appliedMapping =
|
|
1950
|
-
const reverseMapping =
|
|
1925
|
+
const appliedMapping = Object.create(null);
|
|
1926
|
+
const reverseMapping = Object.create(null);
|
|
1951
1927
|
const seenEncodedKeys = new Set();
|
|
1952
1928
|
for (const k of Reflect.ownKeys(self.fields)) {
|
|
1953
1929
|
const encoded = toEncoded(self.fields[k]);
|
|
@@ -1958,7 +1934,7 @@ export function encodeKeys(mapping) {
|
|
|
1958
1934
|
throw new globalThis.Error(`Duplicate encoded keys: ${formatPropertyKey(encodedKey)}`);
|
|
1959
1935
|
}
|
|
1960
1936
|
seenEncodedKeys.add(canonical);
|
|
1961
|
-
fields
|
|
1937
|
+
InternalRecord.assignProperty(fields, encodedKey, encoded);
|
|
1962
1938
|
if (hasMapping) {
|
|
1963
1939
|
appliedMapping[k] = encodedKey;
|
|
1964
1940
|
reverseMapping[encodedKey] = k;
|
|
@@ -2019,7 +1995,7 @@ derive) {
|
|
|
2019
1995
|
const f = derive[k];
|
|
2020
1996
|
const o = f(input);
|
|
2021
1997
|
if (Option_.isSome(o)) {
|
|
2022
|
-
out
|
|
1998
|
+
InternalRecord.assignProperty(out, k, o.value);
|
|
2023
1999
|
}
|
|
2024
2000
|
}
|
|
2025
2001
|
return out;
|
|
@@ -2416,7 +2392,7 @@ export function suspend(f) {
|
|
|
2416
2392
|
* ```ts
|
|
2417
2393
|
* import { Schema } from "effect"
|
|
2418
2394
|
*
|
|
2419
|
-
* const AgeSchema = Schema.
|
|
2395
|
+
* const AgeSchema = Schema.Finite.pipe(
|
|
2420
2396
|
* Schema.check(Schema.isGreaterThanOrEqualTo(0), Schema.isLessThanOrEqualTo(120))
|
|
2421
2397
|
* )
|
|
2422
2398
|
* ```
|
|
@@ -3082,8 +3058,8 @@ export function toTaggedUnion(tag) {
|
|
|
3082
3058
|
}
|
|
3083
3059
|
discriminantKeys.add(key);
|
|
3084
3060
|
discriminants.push(literal);
|
|
3085
|
-
InternalRecord.
|
|
3086
|
-
InternalRecord.
|
|
3061
|
+
InternalRecord.assignProperty(cases, literal, schema);
|
|
3062
|
+
InternalRecord.assignProperty(guards, literal, is(toType(schema)));
|
|
3087
3063
|
return;
|
|
3088
3064
|
}
|
|
3089
3065
|
}
|
|
@@ -3093,12 +3069,16 @@ export function toTaggedUnion(tag) {
|
|
|
3093
3069
|
if (arguments.length === 1) {
|
|
3094
3070
|
const cases = arguments[0];
|
|
3095
3071
|
return function (value) {
|
|
3096
|
-
|
|
3072
|
+
const key = value[tag];
|
|
3073
|
+
const handler = Object.hasOwn(cases, key) ? cases[key] : undefined;
|
|
3074
|
+
return handler(value);
|
|
3097
3075
|
};
|
|
3098
3076
|
}
|
|
3099
3077
|
const value = arguments[0];
|
|
3100
3078
|
const cases = arguments[1];
|
|
3101
|
-
|
|
3079
|
+
const key = value[tag];
|
|
3080
|
+
const handler = Object.hasOwn(cases, key) ? cases[key] : undefined;
|
|
3081
|
+
return handler(value);
|
|
3102
3082
|
}
|
|
3103
3083
|
};
|
|
3104
3084
|
}
|
|
@@ -3132,7 +3112,9 @@ export function TaggedUnion(casesByTag) {
|
|
|
3132
3112
|
const cases = {};
|
|
3133
3113
|
const members = [];
|
|
3134
3114
|
for (const key of Object.keys(casesByTag)) {
|
|
3135
|
-
|
|
3115
|
+
const member = TaggedStruct(key, casesByTag[key]);
|
|
3116
|
+
InternalRecord.assignProperty(cases, key, member);
|
|
3117
|
+
members.push(member);
|
|
3136
3118
|
}
|
|
3137
3119
|
const union = Union(members);
|
|
3138
3120
|
const {
|
|
@@ -3173,9 +3155,7 @@ export function TaggedUnion(casesByTag) {
|
|
|
3173
3155
|
*/
|
|
3174
3156
|
export function Opaque() {
|
|
3175
3157
|
return schema => {
|
|
3176
|
-
|
|
3177
|
-
class Opaque {}
|
|
3178
|
-
return Object.setPrototypeOf(Opaque, schema);
|
|
3158
|
+
return schema;
|
|
3179
3159
|
};
|
|
3180
3160
|
}
|
|
3181
3161
|
/**
|
|
@@ -3283,6 +3263,11 @@ export const makeFilter = SchemaAST.makeFilter;
|
|
|
3283
3263
|
export function makeFilterGroup(checks, annotations = undefined) {
|
|
3284
3264
|
return new SchemaAST.FilterGroup(checks, annotations);
|
|
3285
3265
|
}
|
|
3266
|
+
function makeFixedDeclarationReviver(id, schema) {
|
|
3267
|
+
return InternalSchema.makeDeclarationReviver(id, Null, ({
|
|
3268
|
+
annotations
|
|
3269
|
+
}) => annotations === undefined ? schema : schema.annotate(annotations));
|
|
3270
|
+
}
|
|
3286
3271
|
const TRIMMED_PATTERN = "^\\S[\\s\\S]*\\S$|^\\S$|^$";
|
|
3287
3272
|
/**
|
|
3288
3273
|
* Validates that a string has no leading or trailing whitespace.
|
|
@@ -3303,12 +3288,19 @@ const TRIMMED_PATTERN = "^\\S[\\s\\S]*\\S$|^\\S$|^$";
|
|
|
3303
3288
|
* @since 4.0.0
|
|
3304
3289
|
*/
|
|
3305
3290
|
export function isTrimmed(annotations) {
|
|
3291
|
+
const regExp = new globalThis.RegExp(TRIMMED_PATTERN);
|
|
3306
3292
|
return makeFilter(s => s.trim() === s, {
|
|
3307
3293
|
expected: "a string with no leading or trailing whitespace",
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3294
|
+
representation: {
|
|
3295
|
+
id: "effect/schema/isTrimmed",
|
|
3296
|
+
payload: null
|
|
3311
3297
|
},
|
|
3298
|
+
toJsonSchema: () => ({
|
|
3299
|
+
pattern: regExp.source
|
|
3300
|
+
}),
|
|
3301
|
+
toCode: () => ({
|
|
3302
|
+
runtime: "Schema.isTrimmed()"
|
|
3303
|
+
}),
|
|
3312
3304
|
arbitrary: {
|
|
3313
3305
|
constraint: {
|
|
3314
3306
|
patterns: [TRIMMED_PATTERN]
|
|
@@ -3317,6 +3309,21 @@ export function isTrimmed(annotations) {
|
|
|
3317
3309
|
...annotations
|
|
3318
3310
|
});
|
|
3319
3311
|
}
|
|
3312
|
+
/**
|
|
3313
|
+
* Reviver for persisted `isTrimmed` checks.
|
|
3314
|
+
*
|
|
3315
|
+
* **When to use**
|
|
3316
|
+
*
|
|
3317
|
+
* Use when reconstructing documents that may contain checks created by {@link isTrimmed}.
|
|
3318
|
+
*
|
|
3319
|
+
* @see {@link isTrimmed} for creating the corresponding check
|
|
3320
|
+
*
|
|
3321
|
+
* @category String checks
|
|
3322
|
+
* @since 4.0.0
|
|
3323
|
+
*/
|
|
3324
|
+
export const isTrimmedReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isTrimmed", Null, ({
|
|
3325
|
+
annotations
|
|
3326
|
+
}) => isTrimmed(annotations));
|
|
3320
3327
|
/**
|
|
3321
3328
|
* Validates that a string matches the specified regular expression pattern.
|
|
3322
3329
|
*
|
|
@@ -3334,7 +3341,44 @@ export function isTrimmed(annotations) {
|
|
|
3334
3341
|
* @category String checks
|
|
3335
3342
|
* @since 4.0.0
|
|
3336
3343
|
*/
|
|
3337
|
-
export
|
|
3344
|
+
export function isPattern(regExp, annotations) {
|
|
3345
|
+
const source = regExp.source;
|
|
3346
|
+
const flags = regExp.flags;
|
|
3347
|
+
const runtimeRegExp = flags === "" ? `new RegExp(${format(source)})` : `new RegExp(${format(source)}, ${format(flags)})`;
|
|
3348
|
+
return SchemaAST.isPattern(regExp, {
|
|
3349
|
+
toCode: () => ({
|
|
3350
|
+
runtime: `Schema.isPattern(${runtimeRegExp})`
|
|
3351
|
+
}),
|
|
3352
|
+
...annotations
|
|
3353
|
+
});
|
|
3354
|
+
}
|
|
3355
|
+
const IsPatternPayload = /*#__PURE__*/Struct({
|
|
3356
|
+
source: String,
|
|
3357
|
+
flags: String
|
|
3358
|
+
}).check(/*#__PURE__*/makeFilter(payload => {
|
|
3359
|
+
const result = Result_.try(() => new globalThis.RegExp(payload.source, payload.flags));
|
|
3360
|
+
return Result_.isSuccess(result) && result.success.source === payload.source && result.success.flags === payload.flags;
|
|
3361
|
+
}));
|
|
3362
|
+
/**
|
|
3363
|
+
* Reviver for persisted `isPattern` checks.
|
|
3364
|
+
*
|
|
3365
|
+
* **When to use**
|
|
3366
|
+
*
|
|
3367
|
+
* Use when reconstructing documents that may contain checks created by {@link isPattern}.
|
|
3368
|
+
*
|
|
3369
|
+
* @see {@link isPattern} for creating the corresponding check
|
|
3370
|
+
*
|
|
3371
|
+
* @category String checks
|
|
3372
|
+
* @since 4.0.0
|
|
3373
|
+
*/
|
|
3374
|
+
export const isPatternReviver = {
|
|
3375
|
+
id: "effect/schema/isPattern",
|
|
3376
|
+
payloadSchema: IsPatternPayload,
|
|
3377
|
+
revive: ({
|
|
3378
|
+
annotations,
|
|
3379
|
+
payload
|
|
3380
|
+
}) => isPattern(new globalThis.RegExp(payload.source, payload.flags), annotations)
|
|
3381
|
+
};
|
|
3338
3382
|
/**
|
|
3339
3383
|
* Validates that a string represents a finite number.
|
|
3340
3384
|
*
|
|
@@ -3353,7 +3397,29 @@ export const isPattern = SchemaAST.isPattern;
|
|
|
3353
3397
|
* @category String checks
|
|
3354
3398
|
* @since 4.0.0
|
|
3355
3399
|
*/
|
|
3356
|
-
export
|
|
3400
|
+
export function isStringFinite(annotations) {
|
|
3401
|
+
return SchemaAST.isStringFinite({
|
|
3402
|
+
toCode: () => ({
|
|
3403
|
+
runtime: "Schema.isStringFinite()"
|
|
3404
|
+
}),
|
|
3405
|
+
...annotations
|
|
3406
|
+
});
|
|
3407
|
+
}
|
|
3408
|
+
/**
|
|
3409
|
+
* Reviver for persisted `isStringFinite` checks.
|
|
3410
|
+
*
|
|
3411
|
+
* **When to use**
|
|
3412
|
+
*
|
|
3413
|
+
* Use when reconstructing documents that may contain checks created by {@link isStringFinite}.
|
|
3414
|
+
*
|
|
3415
|
+
* @see {@link isStringFinite} for creating the corresponding check
|
|
3416
|
+
*
|
|
3417
|
+
* @category String checks
|
|
3418
|
+
* @since 4.0.0
|
|
3419
|
+
*/
|
|
3420
|
+
export const isStringFiniteReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isStringFinite", Null, ({
|
|
3421
|
+
annotations
|
|
3422
|
+
}) => isStringFinite(annotations));
|
|
3357
3423
|
/**
|
|
3358
3424
|
* Validates that a string is a signed base-10 integer literal for Effect's
|
|
3359
3425
|
* BigInt string encoding.
|
|
@@ -3371,7 +3437,29 @@ export const isStringFinite = SchemaAST.isStringFinite;
|
|
|
3371
3437
|
* @category String checks
|
|
3372
3438
|
* @since 4.0.0
|
|
3373
3439
|
*/
|
|
3374
|
-
export
|
|
3440
|
+
export function isStringBigInt(annotations) {
|
|
3441
|
+
return SchemaAST.isStringBigInt({
|
|
3442
|
+
toCode: () => ({
|
|
3443
|
+
runtime: "Schema.isStringBigInt()"
|
|
3444
|
+
}),
|
|
3445
|
+
...annotations
|
|
3446
|
+
});
|
|
3447
|
+
}
|
|
3448
|
+
/**
|
|
3449
|
+
* Reviver for persisted `isStringBigInt` checks.
|
|
3450
|
+
*
|
|
3451
|
+
* **When to use**
|
|
3452
|
+
*
|
|
3453
|
+
* Use when reconstructing documents that may contain checks created by {@link isStringBigInt}.
|
|
3454
|
+
*
|
|
3455
|
+
* @see {@link isStringBigInt} for creating the corresponding check
|
|
3456
|
+
*
|
|
3457
|
+
* @category String checks
|
|
3458
|
+
* @since 4.0.0
|
|
3459
|
+
*/
|
|
3460
|
+
export const isStringBigIntReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isStringBigInt", Null, ({
|
|
3461
|
+
annotations
|
|
3462
|
+
}) => isStringBigInt(annotations));
|
|
3375
3463
|
/**
|
|
3376
3464
|
* Validates that a string has the `Symbol(description)` format used by Effect's
|
|
3377
3465
|
* symbol string encoding.
|
|
@@ -3384,7 +3472,29 @@ export const isStringBigInt = SchemaAST.isStringBigInt;
|
|
|
3384
3472
|
* @category String checks
|
|
3385
3473
|
* @since 4.0.0
|
|
3386
3474
|
*/
|
|
3387
|
-
export
|
|
3475
|
+
export function isStringSymbol(annotations) {
|
|
3476
|
+
return SchemaAST.isStringSymbol({
|
|
3477
|
+
toCode: () => ({
|
|
3478
|
+
runtime: "Schema.isStringSymbol()"
|
|
3479
|
+
}),
|
|
3480
|
+
...annotations
|
|
3481
|
+
});
|
|
3482
|
+
}
|
|
3483
|
+
/**
|
|
3484
|
+
* Reviver for persisted `isStringSymbol` checks.
|
|
3485
|
+
*
|
|
3486
|
+
* **When to use**
|
|
3487
|
+
*
|
|
3488
|
+
* Use when reconstructing documents that may contain checks created by {@link isStringSymbol}.
|
|
3489
|
+
*
|
|
3490
|
+
* @see {@link isStringSymbol} for creating the corresponding check
|
|
3491
|
+
*
|
|
3492
|
+
* @category String checks
|
|
3493
|
+
* @since 4.0.0
|
|
3494
|
+
*/
|
|
3495
|
+
export const isStringSymbolReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isStringSymbol", Null, ({
|
|
3496
|
+
annotations
|
|
3497
|
+
}) => isStringSymbol(annotations));
|
|
3388
3498
|
/**
|
|
3389
3499
|
* Returns a RegExp for validating an RFC 9562 / RFC 4122 UUID.
|
|
3390
3500
|
*
|
|
@@ -3430,14 +3540,40 @@ export function isUUID(version, annotations) {
|
|
|
3430
3540
|
const regExp = getUUIDRegExp(version);
|
|
3431
3541
|
return isPattern(regExp, {
|
|
3432
3542
|
expected: version ? `a UUID v${version}` : "a UUID",
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3543
|
+
representation: {
|
|
3544
|
+
id: "effect/schema/isUUID",
|
|
3545
|
+
payload: {
|
|
3546
|
+
version: version ?? null
|
|
3547
|
+
}
|
|
3437
3548
|
},
|
|
3549
|
+
toJsonSchema: () => ({
|
|
3550
|
+
pattern: regExp.source,
|
|
3551
|
+
format: "uuid"
|
|
3552
|
+
}),
|
|
3553
|
+
toCode: () => ({
|
|
3554
|
+
runtime: version === undefined ? "Schema.isUUID()" : `Schema.isUUID(${version})`
|
|
3555
|
+
}),
|
|
3438
3556
|
...annotations
|
|
3439
3557
|
});
|
|
3440
3558
|
}
|
|
3559
|
+
/**
|
|
3560
|
+
* Reviver for persisted `isUUID` checks.
|
|
3561
|
+
*
|
|
3562
|
+
* **When to use**
|
|
3563
|
+
*
|
|
3564
|
+
* Use when reconstructing documents that may contain checks created by {@link isUUID}.
|
|
3565
|
+
*
|
|
3566
|
+
* @see {@link isUUID} for creating the corresponding check
|
|
3567
|
+
*
|
|
3568
|
+
* @category String checks
|
|
3569
|
+
* @since 4.0.0
|
|
3570
|
+
*/
|
|
3571
|
+
export const isUUIDReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isUUID", /*#__PURE__*/Struct({
|
|
3572
|
+
version: /*#__PURE__*/Union([/*#__PURE__*/Literals([1, 2, 3, 4, 5, 6, 7, 8]), Null])
|
|
3573
|
+
}), ({
|
|
3574
|
+
annotations,
|
|
3575
|
+
payload
|
|
3576
|
+
}) => isUUID(payload.version ?? undefined, annotations));
|
|
3441
3577
|
const GUID_REGEXP = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
|
|
3442
3578
|
/**
|
|
3443
3579
|
* Validates that a string has the GUID / UUID textual shape.
|
|
@@ -3466,13 +3602,34 @@ const GUID_REGEXP = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{
|
|
|
3466
3602
|
export function isGUID(annotations) {
|
|
3467
3603
|
return isPattern(GUID_REGEXP, {
|
|
3468
3604
|
expected: "a GUID",
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3605
|
+
representation: {
|
|
3606
|
+
id: "effect/schema/isGUID",
|
|
3607
|
+
payload: null
|
|
3472
3608
|
},
|
|
3609
|
+
toJsonSchema: () => ({
|
|
3610
|
+
pattern: GUID_REGEXP.source
|
|
3611
|
+
}),
|
|
3612
|
+
toCode: () => ({
|
|
3613
|
+
runtime: "Schema.isGUID()"
|
|
3614
|
+
}),
|
|
3473
3615
|
...annotations
|
|
3474
3616
|
});
|
|
3475
3617
|
}
|
|
3618
|
+
/**
|
|
3619
|
+
* Reviver for persisted `isGUID` checks.
|
|
3620
|
+
*
|
|
3621
|
+
* **When to use**
|
|
3622
|
+
*
|
|
3623
|
+
* Use when reconstructing documents that may contain checks created by {@link isGUID}.
|
|
3624
|
+
*
|
|
3625
|
+
* @see {@link isGUID} for creating the corresponding check
|
|
3626
|
+
*
|
|
3627
|
+
* @category String checks
|
|
3628
|
+
* @since 4.0.0
|
|
3629
|
+
*/
|
|
3630
|
+
export const isGUIDReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isGUID", Null, ({
|
|
3631
|
+
annotations
|
|
3632
|
+
}) => isGUID(annotations));
|
|
3476
3633
|
/**
|
|
3477
3634
|
* Validates that a string is a valid ULID (Universally Unique Lexicographically
|
|
3478
3635
|
* Sortable Identifier).
|
|
@@ -3495,13 +3652,34 @@ export function isGUID(annotations) {
|
|
|
3495
3652
|
export function isULID(annotations) {
|
|
3496
3653
|
const regExp = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
|
|
3497
3654
|
return isPattern(regExp, {
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3655
|
+
representation: {
|
|
3656
|
+
id: "effect/schema/isULID",
|
|
3657
|
+
payload: null
|
|
3501
3658
|
},
|
|
3659
|
+
toJsonSchema: () => ({
|
|
3660
|
+
pattern: regExp.source
|
|
3661
|
+
}),
|
|
3662
|
+
toCode: () => ({
|
|
3663
|
+
runtime: "Schema.isULID()"
|
|
3664
|
+
}),
|
|
3502
3665
|
...annotations
|
|
3503
3666
|
});
|
|
3504
3667
|
}
|
|
3668
|
+
/**
|
|
3669
|
+
* Reviver for persisted `isULID` checks.
|
|
3670
|
+
*
|
|
3671
|
+
* **When to use**
|
|
3672
|
+
*
|
|
3673
|
+
* Use when reconstructing documents that may contain checks created by {@link isULID}.
|
|
3674
|
+
*
|
|
3675
|
+
* @see {@link isULID} for creating the corresponding check
|
|
3676
|
+
*
|
|
3677
|
+
* @category String checks
|
|
3678
|
+
* @since 4.0.0
|
|
3679
|
+
*/
|
|
3680
|
+
export const isULIDReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isULID", Null, ({
|
|
3681
|
+
annotations
|
|
3682
|
+
}) => isULID(annotations));
|
|
3505
3683
|
/**
|
|
3506
3684
|
* Validates that a string is valid Base64 encoded data.
|
|
3507
3685
|
*
|
|
@@ -3524,13 +3702,34 @@ export function isBase64(annotations) {
|
|
|
3524
3702
|
const regExp = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
|
3525
3703
|
return isPattern(regExp, {
|
|
3526
3704
|
expected: "a base64 encoded string",
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3705
|
+
representation: {
|
|
3706
|
+
id: "effect/schema/isBase64",
|
|
3707
|
+
payload: null
|
|
3530
3708
|
},
|
|
3709
|
+
toJsonSchema: () => ({
|
|
3710
|
+
pattern: regExp.source
|
|
3711
|
+
}),
|
|
3712
|
+
toCode: () => ({
|
|
3713
|
+
runtime: "Schema.isBase64()"
|
|
3714
|
+
}),
|
|
3531
3715
|
...annotations
|
|
3532
3716
|
});
|
|
3533
3717
|
}
|
|
3718
|
+
/**
|
|
3719
|
+
* Reviver for persisted `isBase64` checks.
|
|
3720
|
+
*
|
|
3721
|
+
* **When to use**
|
|
3722
|
+
*
|
|
3723
|
+
* Use when reconstructing documents that may contain checks created by {@link isBase64}.
|
|
3724
|
+
*
|
|
3725
|
+
* @see {@link isBase64} for creating the corresponding check
|
|
3726
|
+
*
|
|
3727
|
+
* @category String checks
|
|
3728
|
+
* @since 4.0.0
|
|
3729
|
+
*/
|
|
3730
|
+
export const isBase64Reviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isBase64", Null, ({
|
|
3731
|
+
annotations
|
|
3732
|
+
}) => isBase64(annotations));
|
|
3534
3733
|
/**
|
|
3535
3734
|
* Validates that a string is valid Base64URL encoded data (Base64 with URL-safe
|
|
3536
3735
|
* characters).
|
|
@@ -3554,103 +3753,197 @@ export function isBase64Url(annotations) {
|
|
|
3554
3753
|
const regExp = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
|
|
3555
3754
|
return isPattern(regExp, {
|
|
3556
3755
|
expected: "a base64url encoded string",
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3756
|
+
representation: {
|
|
3757
|
+
id: "effect/schema/isBase64Url",
|
|
3758
|
+
payload: null
|
|
3560
3759
|
},
|
|
3760
|
+
toJsonSchema: () => ({
|
|
3761
|
+
pattern: regExp.source
|
|
3762
|
+
}),
|
|
3763
|
+
toCode: () => ({
|
|
3764
|
+
runtime: "Schema.isBase64Url()"
|
|
3765
|
+
}),
|
|
3561
3766
|
...annotations
|
|
3562
3767
|
});
|
|
3563
3768
|
}
|
|
3769
|
+
/**
|
|
3770
|
+
* Reviver for persisted `isBase64Url` checks.
|
|
3771
|
+
*
|
|
3772
|
+
* **When to use**
|
|
3773
|
+
*
|
|
3774
|
+
* Use when reconstructing documents that may contain checks created by {@link isBase64Url}.
|
|
3775
|
+
*
|
|
3776
|
+
* @see {@link isBase64Url} for creating the corresponding check
|
|
3777
|
+
*
|
|
3778
|
+
* @category String checks
|
|
3779
|
+
* @since 4.0.0
|
|
3780
|
+
*/
|
|
3781
|
+
export const isBase64UrlReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isBase64Url", Null, ({
|
|
3782
|
+
annotations
|
|
3783
|
+
}) => isBase64Url(annotations));
|
|
3564
3784
|
/**
|
|
3565
3785
|
* Validates at runtime that a string starts with the specified literal prefix.
|
|
3566
3786
|
*
|
|
3567
3787
|
* **Details**
|
|
3568
3788
|
*
|
|
3569
|
-
*
|
|
3570
|
-
*
|
|
3571
|
-
* escaping regexp metacharacters. If the prefix contains regexp syntax, generated
|
|
3572
|
-
* patterns may not be equivalent to the runtime `startsWith` check.
|
|
3789
|
+
* RegExp metacharacters in the prefix are escaped in JSON Schema and arbitrary
|
|
3790
|
+
* metadata so that the generated patterns retain literal `startsWith` semantics.
|
|
3573
3791
|
*
|
|
3574
3792
|
* @category String checks
|
|
3575
3793
|
* @since 4.0.0
|
|
3576
3794
|
*/
|
|
3577
3795
|
export function isStartsWith(startsWith, annotations) {
|
|
3578
3796
|
const formatted = JSON.stringify(startsWith);
|
|
3797
|
+
const regExp = new globalThis.RegExp(`^${RegExp_.escape(startsWith)}`);
|
|
3579
3798
|
return makeFilter(s => s.startsWith(startsWith), {
|
|
3580
3799
|
expected: `a string starting with ${formatted}`,
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3800
|
+
representation: {
|
|
3801
|
+
id: "effect/schema/isStartsWith",
|
|
3802
|
+
payload: {
|
|
3803
|
+
startsWith
|
|
3804
|
+
}
|
|
3585
3805
|
},
|
|
3806
|
+
toJsonSchema: () => ({
|
|
3807
|
+
pattern: regExp.source
|
|
3808
|
+
}),
|
|
3809
|
+
toCode: () => ({
|
|
3810
|
+
runtime: `Schema.isStartsWith(${format(startsWith)})`
|
|
3811
|
+
}),
|
|
3586
3812
|
arbitrary: {
|
|
3587
3813
|
constraint: {
|
|
3588
|
-
patterns: [
|
|
3814
|
+
patterns: [regExp.source]
|
|
3589
3815
|
}
|
|
3590
3816
|
},
|
|
3591
3817
|
...annotations
|
|
3592
3818
|
});
|
|
3593
3819
|
}
|
|
3820
|
+
/**
|
|
3821
|
+
* Reviver for persisted `isStartsWith` checks.
|
|
3822
|
+
*
|
|
3823
|
+
* **When to use**
|
|
3824
|
+
*
|
|
3825
|
+
* Use when reconstructing documents that may contain checks created by {@link isStartsWith}.
|
|
3826
|
+
*
|
|
3827
|
+
* @see {@link isStartsWith} for creating the corresponding check
|
|
3828
|
+
*
|
|
3829
|
+
* @category String checks
|
|
3830
|
+
* @since 4.0.0
|
|
3831
|
+
*/
|
|
3832
|
+
export const isStartsWithReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isStartsWith", /*#__PURE__*/Struct({
|
|
3833
|
+
startsWith: String
|
|
3834
|
+
}), ({
|
|
3835
|
+
annotations,
|
|
3836
|
+
payload
|
|
3837
|
+
}) => isStartsWith(payload.startsWith, annotations));
|
|
3594
3838
|
/**
|
|
3595
3839
|
* Validates at runtime that a string ends with the specified literal suffix.
|
|
3596
3840
|
*
|
|
3597
3841
|
* **Details**
|
|
3598
3842
|
*
|
|
3599
|
-
*
|
|
3600
|
-
*
|
|
3601
|
-
* escaping regexp metacharacters. If the suffix contains regexp syntax, generated
|
|
3602
|
-
* patterns may not be equivalent to the runtime `endsWith` check.
|
|
3843
|
+
* RegExp metacharacters in the suffix are escaped in JSON Schema and arbitrary
|
|
3844
|
+
* metadata so that the generated patterns retain literal `endsWith` semantics.
|
|
3603
3845
|
*
|
|
3604
3846
|
* @category String checks
|
|
3605
3847
|
* @since 4.0.0
|
|
3606
3848
|
*/
|
|
3607
3849
|
export function isEndsWith(endsWith, annotations) {
|
|
3608
3850
|
const formatted = JSON.stringify(endsWith);
|
|
3851
|
+
const regExp = new globalThis.RegExp(`${RegExp_.escape(endsWith)}$`);
|
|
3609
3852
|
return makeFilter(s => s.endsWith(endsWith), {
|
|
3610
3853
|
expected: `a string ending with ${formatted}`,
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3854
|
+
representation: {
|
|
3855
|
+
id: "effect/schema/isEndsWith",
|
|
3856
|
+
payload: {
|
|
3857
|
+
endsWith
|
|
3858
|
+
}
|
|
3615
3859
|
},
|
|
3860
|
+
toJsonSchema: () => ({
|
|
3861
|
+
pattern: regExp.source
|
|
3862
|
+
}),
|
|
3863
|
+
toCode: () => ({
|
|
3864
|
+
runtime: `Schema.isEndsWith(${format(endsWith)})`
|
|
3865
|
+
}),
|
|
3616
3866
|
arbitrary: {
|
|
3617
3867
|
constraint: {
|
|
3618
|
-
patterns: [
|
|
3868
|
+
patterns: [regExp.source]
|
|
3619
3869
|
}
|
|
3620
3870
|
},
|
|
3621
3871
|
...annotations
|
|
3622
3872
|
});
|
|
3623
3873
|
}
|
|
3874
|
+
/**
|
|
3875
|
+
* Reviver for persisted `isEndsWith` checks.
|
|
3876
|
+
*
|
|
3877
|
+
* **When to use**
|
|
3878
|
+
*
|
|
3879
|
+
* Use when reconstructing documents that may contain checks created by {@link isEndsWith}.
|
|
3880
|
+
*
|
|
3881
|
+
* @see {@link isEndsWith} for creating the corresponding check
|
|
3882
|
+
*
|
|
3883
|
+
* @category String checks
|
|
3884
|
+
* @since 4.0.0
|
|
3885
|
+
*/
|
|
3886
|
+
export const isEndsWithReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isEndsWith", /*#__PURE__*/Struct({
|
|
3887
|
+
endsWith: String
|
|
3888
|
+
}), ({
|
|
3889
|
+
annotations,
|
|
3890
|
+
payload
|
|
3891
|
+
}) => isEndsWith(payload.endsWith, annotations));
|
|
3624
3892
|
/**
|
|
3625
3893
|
* Validates at runtime that a string contains the specified literal substring.
|
|
3626
3894
|
*
|
|
3627
3895
|
* **Details**
|
|
3628
3896
|
*
|
|
3629
|
-
*
|
|
3630
|
-
*
|
|
3631
|
-
*
|
|
3632
|
-
* equivalent to the runtime `includes` check.
|
|
3897
|
+
* RegExp metacharacters in the substring are escaped in JSON Schema and
|
|
3898
|
+
* arbitrary metadata so that the generated patterns retain literal `includes`
|
|
3899
|
+
* semantics.
|
|
3633
3900
|
*
|
|
3634
3901
|
* @category String checks
|
|
3635
3902
|
* @since 4.0.0
|
|
3636
3903
|
*/
|
|
3637
3904
|
export function isIncludes(includes, annotations) {
|
|
3638
3905
|
const formatted = JSON.stringify(includes);
|
|
3906
|
+
const regExp = new globalThis.RegExp(RegExp_.escape(includes));
|
|
3639
3907
|
return makeFilter(s => s.includes(includes), {
|
|
3640
3908
|
expected: `a string including ${formatted}`,
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3909
|
+
representation: {
|
|
3910
|
+
id: "effect/schema/isIncludes",
|
|
3911
|
+
payload: {
|
|
3912
|
+
includes
|
|
3913
|
+
}
|
|
3645
3914
|
},
|
|
3915
|
+
toJsonSchema: () => ({
|
|
3916
|
+
pattern: regExp.source
|
|
3917
|
+
}),
|
|
3918
|
+
toCode: () => ({
|
|
3919
|
+
runtime: `Schema.isIncludes(${format(includes)})`
|
|
3920
|
+
}),
|
|
3646
3921
|
arbitrary: {
|
|
3647
3922
|
constraint: {
|
|
3648
|
-
patterns: [
|
|
3923
|
+
patterns: [regExp.source]
|
|
3649
3924
|
}
|
|
3650
3925
|
},
|
|
3651
3926
|
...annotations
|
|
3652
3927
|
});
|
|
3653
3928
|
}
|
|
3929
|
+
/**
|
|
3930
|
+
* Reviver for persisted `isIncludes` checks.
|
|
3931
|
+
*
|
|
3932
|
+
* **When to use**
|
|
3933
|
+
*
|
|
3934
|
+
* Use when reconstructing documents that may contain checks created by {@link isIncludes}.
|
|
3935
|
+
*
|
|
3936
|
+
* @see {@link isIncludes} for creating the corresponding check
|
|
3937
|
+
*
|
|
3938
|
+
* @category String checks
|
|
3939
|
+
* @since 4.0.0
|
|
3940
|
+
*/
|
|
3941
|
+
export const isIncludesReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isIncludes", /*#__PURE__*/Struct({
|
|
3942
|
+
includes: String
|
|
3943
|
+
}), ({
|
|
3944
|
+
annotations,
|
|
3945
|
+
payload
|
|
3946
|
+
}) => isIncludes(payload.includes, annotations));
|
|
3654
3947
|
const UPPERCASED_PATTERN = "^[^a-z]*$";
|
|
3655
3948
|
/**
|
|
3656
3949
|
* Validates that a string is unchanged by JavaScript's `toUpperCase()`.
|
|
@@ -3665,12 +3958,19 @@ const UPPERCASED_PATTERN = "^[^a-z]*$";
|
|
|
3665
3958
|
* @since 4.0.0
|
|
3666
3959
|
*/
|
|
3667
3960
|
export function isUppercased(annotations) {
|
|
3961
|
+
const regExp = new globalThis.RegExp(UPPERCASED_PATTERN);
|
|
3668
3962
|
return makeFilter(s => s.toUpperCase() === s, {
|
|
3669
3963
|
expected: "a string with all characters in uppercase",
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3964
|
+
representation: {
|
|
3965
|
+
id: "effect/schema/isUppercased",
|
|
3966
|
+
payload: null
|
|
3673
3967
|
},
|
|
3968
|
+
toJsonSchema: () => ({
|
|
3969
|
+
pattern: regExp.source
|
|
3970
|
+
}),
|
|
3971
|
+
toCode: () => ({
|
|
3972
|
+
runtime: "Schema.isUppercased()"
|
|
3973
|
+
}),
|
|
3674
3974
|
arbitrary: {
|
|
3675
3975
|
constraint: {
|
|
3676
3976
|
patterns: [UPPERCASED_PATTERN]
|
|
@@ -3679,6 +3979,21 @@ export function isUppercased(annotations) {
|
|
|
3679
3979
|
...annotations
|
|
3680
3980
|
});
|
|
3681
3981
|
}
|
|
3982
|
+
/**
|
|
3983
|
+
* Reviver for persisted `isUppercased` checks.
|
|
3984
|
+
*
|
|
3985
|
+
* **When to use**
|
|
3986
|
+
*
|
|
3987
|
+
* Use when reconstructing documents that may contain checks created by {@link isUppercased}.
|
|
3988
|
+
*
|
|
3989
|
+
* @see {@link isUppercased} for creating the corresponding check
|
|
3990
|
+
*
|
|
3991
|
+
* @category String checks
|
|
3992
|
+
* @since 4.0.0
|
|
3993
|
+
*/
|
|
3994
|
+
export const isUppercasedReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isUppercased", Null, ({
|
|
3995
|
+
annotations
|
|
3996
|
+
}) => isUppercased(annotations));
|
|
3682
3997
|
const LOWERCASED_PATTERN = "^[^A-Z]*$";
|
|
3683
3998
|
/**
|
|
3684
3999
|
* Validates that a string is unchanged by JavaScript's `toLowerCase()`.
|
|
@@ -3693,12 +4008,19 @@ const LOWERCASED_PATTERN = "^[^A-Z]*$";
|
|
|
3693
4008
|
* @since 4.0.0
|
|
3694
4009
|
*/
|
|
3695
4010
|
export function isLowercased(annotations) {
|
|
4011
|
+
const regExp = new globalThis.RegExp(LOWERCASED_PATTERN);
|
|
3696
4012
|
return makeFilter(s => s.toLowerCase() === s, {
|
|
3697
4013
|
expected: "a string with all characters in lowercase",
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
4014
|
+
representation: {
|
|
4015
|
+
id: "effect/schema/isLowercased",
|
|
4016
|
+
payload: null
|
|
3701
4017
|
},
|
|
4018
|
+
toJsonSchema: () => ({
|
|
4019
|
+
pattern: regExp.source
|
|
4020
|
+
}),
|
|
4021
|
+
toCode: () => ({
|
|
4022
|
+
runtime: "Schema.isLowercased()"
|
|
4023
|
+
}),
|
|
3702
4024
|
arbitrary: {
|
|
3703
4025
|
constraint: {
|
|
3704
4026
|
patterns: [LOWERCASED_PATTERN]
|
|
@@ -3707,6 +4029,21 @@ export function isLowercased(annotations) {
|
|
|
3707
4029
|
...annotations
|
|
3708
4030
|
});
|
|
3709
4031
|
}
|
|
4032
|
+
/**
|
|
4033
|
+
* Reviver for persisted `isLowercased` checks.
|
|
4034
|
+
*
|
|
4035
|
+
* **When to use**
|
|
4036
|
+
*
|
|
4037
|
+
* Use when reconstructing documents that may contain checks created by {@link isLowercased}.
|
|
4038
|
+
*
|
|
4039
|
+
* @see {@link isLowercased} for creating the corresponding check
|
|
4040
|
+
*
|
|
4041
|
+
* @category String checks
|
|
4042
|
+
* @since 4.0.0
|
|
4043
|
+
*/
|
|
4044
|
+
export const isLowercasedReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isLowercased", Null, ({
|
|
4045
|
+
annotations
|
|
4046
|
+
}) => isLowercased(annotations));
|
|
3710
4047
|
const CAPITALIZED_PATTERN = "^[^a-z]?.*$";
|
|
3711
4048
|
/**
|
|
3712
4049
|
* Validates that the first character of a string is unchanged by
|
|
@@ -3721,12 +4058,19 @@ const CAPITALIZED_PATTERN = "^[^a-z]?.*$";
|
|
|
3721
4058
|
* @since 4.0.0
|
|
3722
4059
|
*/
|
|
3723
4060
|
export function isCapitalized(annotations) {
|
|
4061
|
+
const regExp = new globalThis.RegExp(CAPITALIZED_PATTERN);
|
|
3724
4062
|
return makeFilter(s => s.charAt(0).toUpperCase() === s.charAt(0), {
|
|
3725
4063
|
expected: "a string with the first character in uppercase",
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
4064
|
+
representation: {
|
|
4065
|
+
id: "effect/schema/isCapitalized",
|
|
4066
|
+
payload: null
|
|
3729
4067
|
},
|
|
4068
|
+
toJsonSchema: () => ({
|
|
4069
|
+
pattern: regExp.source
|
|
4070
|
+
}),
|
|
4071
|
+
toCode: () => ({
|
|
4072
|
+
runtime: "Schema.isCapitalized()"
|
|
4073
|
+
}),
|
|
3730
4074
|
arbitrary: {
|
|
3731
4075
|
constraint: {
|
|
3732
4076
|
patterns: [CAPITALIZED_PATTERN]
|
|
@@ -3735,6 +4079,21 @@ export function isCapitalized(annotations) {
|
|
|
3735
4079
|
...annotations
|
|
3736
4080
|
});
|
|
3737
4081
|
}
|
|
4082
|
+
/**
|
|
4083
|
+
* Reviver for persisted `isCapitalized` checks.
|
|
4084
|
+
*
|
|
4085
|
+
* **When to use**
|
|
4086
|
+
*
|
|
4087
|
+
* Use when reconstructing documents that may contain checks created by {@link isCapitalized}.
|
|
4088
|
+
*
|
|
4089
|
+
* @see {@link isCapitalized} for creating the corresponding check
|
|
4090
|
+
*
|
|
4091
|
+
* @category String checks
|
|
4092
|
+
* @since 4.0.0
|
|
4093
|
+
*/
|
|
4094
|
+
export const isCapitalizedReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isCapitalized", Null, ({
|
|
4095
|
+
annotations
|
|
4096
|
+
}) => isCapitalized(annotations));
|
|
3738
4097
|
const UNCAPITALIZED_PATTERN = "^[^A-Z]?.*$";
|
|
3739
4098
|
/**
|
|
3740
4099
|
* Validates that the first character of a string is unchanged by
|
|
@@ -3749,12 +4108,19 @@ const UNCAPITALIZED_PATTERN = "^[^A-Z]?.*$";
|
|
|
3749
4108
|
* @since 4.0.0
|
|
3750
4109
|
*/
|
|
3751
4110
|
export function isUncapitalized(annotations) {
|
|
4111
|
+
const regExp = new globalThis.RegExp(UNCAPITALIZED_PATTERN);
|
|
3752
4112
|
return makeFilter(s => s.charAt(0).toLowerCase() === s.charAt(0), {
|
|
3753
4113
|
expected: "a string with the first character in lowercase",
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
4114
|
+
representation: {
|
|
4115
|
+
id: "effect/schema/isUncapitalized",
|
|
4116
|
+
payload: null
|
|
3757
4117
|
},
|
|
4118
|
+
toJsonSchema: () => ({
|
|
4119
|
+
pattern: regExp.source
|
|
4120
|
+
}),
|
|
4121
|
+
toCode: () => ({
|
|
4122
|
+
runtime: "Schema.isUncapitalized()"
|
|
4123
|
+
}),
|
|
3758
4124
|
arbitrary: {
|
|
3759
4125
|
constraint: {
|
|
3760
4126
|
patterns: [UNCAPITALIZED_PATTERN]
|
|
@@ -3763,6 +4129,28 @@ export function isUncapitalized(annotations) {
|
|
|
3763
4129
|
...annotations
|
|
3764
4130
|
});
|
|
3765
4131
|
}
|
|
4132
|
+
/**
|
|
4133
|
+
* Reviver for persisted `isUncapitalized` checks.
|
|
4134
|
+
*
|
|
4135
|
+
* **When to use**
|
|
4136
|
+
*
|
|
4137
|
+
* Use when reconstructing documents that may contain checks created by {@link isUncapitalized}.
|
|
4138
|
+
*
|
|
4139
|
+
* @see {@link isUncapitalized} for creating the corresponding check
|
|
4140
|
+
*
|
|
4141
|
+
* @category String checks
|
|
4142
|
+
* @since 4.0.0
|
|
4143
|
+
*/
|
|
4144
|
+
export const isUncapitalizedReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isUncapitalized", Null, ({
|
|
4145
|
+
annotations
|
|
4146
|
+
}) => isUncapitalized(annotations));
|
|
4147
|
+
/**
|
|
4148
|
+
* Schema for finite numbers, rejecting `NaN`, `Infinity`, and `-Infinity`.
|
|
4149
|
+
*
|
|
4150
|
+
* @category Number
|
|
4151
|
+
* @since 3.10.0
|
|
4152
|
+
*/
|
|
4153
|
+
export const Finite = /*#__PURE__*/make(SchemaAST.finite);
|
|
3766
4154
|
/**
|
|
3767
4155
|
* Validates that a number is finite (not `Infinity`, `-Infinity`, or `NaN`).
|
|
3768
4156
|
*
|
|
@@ -3781,21 +4169,22 @@ export function isUncapitalized(annotations) {
|
|
|
3781
4169
|
* @category Number checks
|
|
3782
4170
|
* @since 4.0.0
|
|
3783
4171
|
*/
|
|
3784
|
-
export
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
4172
|
+
export const isFinite = SchemaAST.isFinite;
|
|
4173
|
+
/**
|
|
4174
|
+
* Reviver for persisted `isFinite` checks.
|
|
4175
|
+
*
|
|
4176
|
+
* **When to use**
|
|
4177
|
+
*
|
|
4178
|
+
* Use when reconstructing documents that may contain checks created by {@link isFinite}.
|
|
4179
|
+
*
|
|
4180
|
+
* @see {@link isFinite} for creating the corresponding check
|
|
4181
|
+
*
|
|
4182
|
+
* @category Number checks
|
|
4183
|
+
* @since 4.0.0
|
|
4184
|
+
*/
|
|
4185
|
+
export const isFiniteReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isFinite", Null, ({
|
|
4186
|
+
annotations
|
|
4187
|
+
}) => isFinite(annotations));
|
|
3799
4188
|
/**
|
|
3800
4189
|
* Creates a greater-than (`>`) check for any ordered type from an
|
|
3801
4190
|
* `Order.Order` instance.
|
|
@@ -3957,6 +4346,12 @@ export function makeIsMultipleOf(options) {
|
|
|
3957
4346
|
});
|
|
3958
4347
|
};
|
|
3959
4348
|
}
|
|
4349
|
+
function encodeNumberPayload(number) {
|
|
4350
|
+
if (!globalThis.Number.isFinite(number)) {
|
|
4351
|
+
throw new globalThis.RangeError(`Expected a finite number, got ${format(number)}`);
|
|
4352
|
+
}
|
|
4353
|
+
return number;
|
|
4354
|
+
}
|
|
3960
4355
|
/**
|
|
3961
4356
|
* Validates that a number is greater than the specified value (exclusive).
|
|
3962
4357
|
*
|
|
@@ -3978,12 +4373,38 @@ export function makeIsMultipleOf(options) {
|
|
|
3978
4373
|
export const isGreaterThan = /*#__PURE__*/makeIsGreaterThan({
|
|
3979
4374
|
order: Order.Number,
|
|
3980
4375
|
annotate: exclusiveMinimum => ({
|
|
3981
|
-
|
|
3982
|
-
|
|
4376
|
+
representation: {
|
|
4377
|
+
id: "effect/schema/isGreaterThan",
|
|
4378
|
+
payload: {
|
|
4379
|
+
exclusiveMinimum: encodeNumberPayload(exclusiveMinimum)
|
|
4380
|
+
}
|
|
4381
|
+
},
|
|
4382
|
+
toJsonSchema: () => ({
|
|
3983
4383
|
exclusiveMinimum
|
|
3984
|
-
}
|
|
4384
|
+
}),
|
|
4385
|
+
toCode: () => ({
|
|
4386
|
+
runtime: `Schema.isGreaterThan(${format(exclusiveMinimum)})`
|
|
4387
|
+
})
|
|
3985
4388
|
})
|
|
3986
4389
|
});
|
|
4390
|
+
/**
|
|
4391
|
+
* Reviver for persisted `isGreaterThan` checks.
|
|
4392
|
+
*
|
|
4393
|
+
* **When to use**
|
|
4394
|
+
*
|
|
4395
|
+
* Use when reconstructing documents that may contain checks created by {@link isGreaterThan}.
|
|
4396
|
+
*
|
|
4397
|
+
* @see {@link isGreaterThan} for creating the corresponding check
|
|
4398
|
+
*
|
|
4399
|
+
* @category Number checks
|
|
4400
|
+
* @since 4.0.0
|
|
4401
|
+
*/
|
|
4402
|
+
export const isGreaterThanReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isGreaterThan", /*#__PURE__*/Struct({
|
|
4403
|
+
exclusiveMinimum: Finite
|
|
4404
|
+
}), ({
|
|
4405
|
+
annotations,
|
|
4406
|
+
payload
|
|
4407
|
+
}) => isGreaterThan(payload.exclusiveMinimum, annotations));
|
|
3987
4408
|
/**
|
|
3988
4409
|
* Validates that a number is greater than or equal to the specified value
|
|
3989
4410
|
* (inclusive).
|
|
@@ -4005,12 +4426,38 @@ export const isGreaterThan = /*#__PURE__*/makeIsGreaterThan({
|
|
|
4005
4426
|
export const isGreaterThanOrEqualTo = /*#__PURE__*/makeIsGreaterThanOrEqualTo({
|
|
4006
4427
|
order: Order.Number,
|
|
4007
4428
|
annotate: minimum => ({
|
|
4008
|
-
|
|
4009
|
-
|
|
4429
|
+
representation: {
|
|
4430
|
+
id: "effect/schema/isGreaterThanOrEqualTo",
|
|
4431
|
+
payload: {
|
|
4432
|
+
minimum: encodeNumberPayload(minimum)
|
|
4433
|
+
}
|
|
4434
|
+
},
|
|
4435
|
+
toJsonSchema: () => ({
|
|
4010
4436
|
minimum
|
|
4011
|
-
}
|
|
4437
|
+
}),
|
|
4438
|
+
toCode: () => ({
|
|
4439
|
+
runtime: `Schema.isGreaterThanOrEqualTo(${format(minimum)})`
|
|
4440
|
+
})
|
|
4012
4441
|
})
|
|
4013
4442
|
});
|
|
4443
|
+
/**
|
|
4444
|
+
* Reviver for persisted `isGreaterThanOrEqualTo` checks.
|
|
4445
|
+
*
|
|
4446
|
+
* **When to use**
|
|
4447
|
+
*
|
|
4448
|
+
* Use when reconstructing documents that may contain checks created by {@link isGreaterThanOrEqualTo}.
|
|
4449
|
+
*
|
|
4450
|
+
* @see {@link isGreaterThanOrEqualTo} for creating the corresponding check
|
|
4451
|
+
*
|
|
4452
|
+
* @category Number checks
|
|
4453
|
+
* @since 4.0.0
|
|
4454
|
+
*/
|
|
4455
|
+
export const isGreaterThanOrEqualToReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isGreaterThanOrEqualTo", /*#__PURE__*/Struct({
|
|
4456
|
+
minimum: Finite
|
|
4457
|
+
}), ({
|
|
4458
|
+
annotations,
|
|
4459
|
+
payload
|
|
4460
|
+
}) => isGreaterThanOrEqualTo(payload.minimum, annotations));
|
|
4014
4461
|
/**
|
|
4015
4462
|
* Validates that a number is less than the specified value (exclusive).
|
|
4016
4463
|
*
|
|
@@ -4032,12 +4479,38 @@ export const isGreaterThanOrEqualTo = /*#__PURE__*/makeIsGreaterThanOrEqualTo({
|
|
|
4032
4479
|
export const isLessThan = /*#__PURE__*/makeIsLessThan({
|
|
4033
4480
|
order: Order.Number,
|
|
4034
4481
|
annotate: exclusiveMaximum => ({
|
|
4035
|
-
|
|
4036
|
-
|
|
4482
|
+
representation: {
|
|
4483
|
+
id: "effect/schema/isLessThan",
|
|
4484
|
+
payload: {
|
|
4485
|
+
exclusiveMaximum: encodeNumberPayload(exclusiveMaximum)
|
|
4486
|
+
}
|
|
4487
|
+
},
|
|
4488
|
+
toJsonSchema: () => ({
|
|
4037
4489
|
exclusiveMaximum
|
|
4038
|
-
}
|
|
4490
|
+
}),
|
|
4491
|
+
toCode: () => ({
|
|
4492
|
+
runtime: `Schema.isLessThan(${format(exclusiveMaximum)})`
|
|
4493
|
+
})
|
|
4039
4494
|
})
|
|
4040
4495
|
});
|
|
4496
|
+
/**
|
|
4497
|
+
* Reviver for persisted `isLessThan` checks.
|
|
4498
|
+
*
|
|
4499
|
+
* **When to use**
|
|
4500
|
+
*
|
|
4501
|
+
* Use when reconstructing documents that may contain checks created by {@link isLessThan}.
|
|
4502
|
+
*
|
|
4503
|
+
* @see {@link isLessThan} for creating the corresponding check
|
|
4504
|
+
*
|
|
4505
|
+
* @category Number checks
|
|
4506
|
+
* @since 4.0.0
|
|
4507
|
+
*/
|
|
4508
|
+
export const isLessThanReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isLessThan", /*#__PURE__*/Struct({
|
|
4509
|
+
exclusiveMaximum: Finite
|
|
4510
|
+
}), ({
|
|
4511
|
+
annotations,
|
|
4512
|
+
payload
|
|
4513
|
+
}) => isLessThan(payload.exclusiveMaximum, annotations));
|
|
4041
4514
|
/**
|
|
4042
4515
|
* Validates that a number is less than or equal to the specified value
|
|
4043
4516
|
* (inclusive).
|
|
@@ -4059,12 +4532,38 @@ export const isLessThan = /*#__PURE__*/makeIsLessThan({
|
|
|
4059
4532
|
export const isLessThanOrEqualTo = /*#__PURE__*/makeIsLessThanOrEqualTo({
|
|
4060
4533
|
order: Order.Number,
|
|
4061
4534
|
annotate: maximum => ({
|
|
4062
|
-
|
|
4063
|
-
|
|
4535
|
+
representation: {
|
|
4536
|
+
id: "effect/schema/isLessThanOrEqualTo",
|
|
4537
|
+
payload: {
|
|
4538
|
+
maximum: encodeNumberPayload(maximum)
|
|
4539
|
+
}
|
|
4540
|
+
},
|
|
4541
|
+
toJsonSchema: () => ({
|
|
4064
4542
|
maximum
|
|
4065
|
-
}
|
|
4543
|
+
}),
|
|
4544
|
+
toCode: () => ({
|
|
4545
|
+
runtime: `Schema.isLessThanOrEqualTo(${format(maximum)})`
|
|
4546
|
+
})
|
|
4066
4547
|
})
|
|
4067
4548
|
});
|
|
4549
|
+
/**
|
|
4550
|
+
* Reviver for persisted `isLessThanOrEqualTo` checks.
|
|
4551
|
+
*
|
|
4552
|
+
* **When to use**
|
|
4553
|
+
*
|
|
4554
|
+
* Use when reconstructing documents that may contain checks created by {@link isLessThanOrEqualTo}.
|
|
4555
|
+
*
|
|
4556
|
+
* @see {@link isLessThanOrEqualTo} for creating the corresponding check
|
|
4557
|
+
*
|
|
4558
|
+
* @category Number checks
|
|
4559
|
+
* @since 4.0.0
|
|
4560
|
+
*/
|
|
4561
|
+
export const isLessThanOrEqualToReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isLessThanOrEqualTo", /*#__PURE__*/Struct({
|
|
4562
|
+
maximum: Finite
|
|
4563
|
+
}), ({
|
|
4564
|
+
annotations,
|
|
4565
|
+
payload
|
|
4566
|
+
}) => isLessThanOrEqualTo(payload.maximum, annotations));
|
|
4068
4567
|
/**
|
|
4069
4568
|
* Validates that a number is within a specified range. The range boundaries can
|
|
4070
4569
|
* be inclusive or exclusive based on the provided options.
|
|
@@ -4089,14 +4588,54 @@ export const isLessThanOrEqualTo = /*#__PURE__*/makeIsLessThanOrEqualTo({
|
|
|
4089
4588
|
export const isBetween = /*#__PURE__*/makeIsBetween({
|
|
4090
4589
|
order: Order.Number,
|
|
4091
4590
|
annotate: options => {
|
|
4591
|
+
const exclusiveMinimum = options.exclusiveMinimum ? true : undefined;
|
|
4592
|
+
const exclusiveMaximum = options.exclusiveMaximum ? true : undefined;
|
|
4593
|
+
const payload = {
|
|
4594
|
+
minimum: encodeNumberPayload(options.minimum),
|
|
4595
|
+
maximum: encodeNumberPayload(options.maximum),
|
|
4596
|
+
...(exclusiveMinimum && {
|
|
4597
|
+
exclusiveMinimum
|
|
4598
|
+
}),
|
|
4599
|
+
...(exclusiveMaximum && {
|
|
4600
|
+
exclusiveMaximum
|
|
4601
|
+
})
|
|
4602
|
+
};
|
|
4092
4603
|
return {
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
}
|
|
4604
|
+
representation: {
|
|
4605
|
+
id: "effect/schema/isBetween",
|
|
4606
|
+
payload
|
|
4607
|
+
},
|
|
4608
|
+
toJsonSchema: () => ({
|
|
4609
|
+
[exclusiveMinimum ? "exclusiveMinimum" : "minimum"]: options.minimum,
|
|
4610
|
+
[exclusiveMaximum ? "exclusiveMaximum" : "maximum"]: options.maximum
|
|
4611
|
+
}),
|
|
4612
|
+
toCode: () => ({
|
|
4613
|
+
runtime: `Schema.isBetween({ minimum: ${format(options.minimum)}, maximum: ${format(options.maximum)}, exclusiveMinimum: ${format(exclusiveMinimum)}, exclusiveMaximum: ${format(exclusiveMaximum)} })`
|
|
4614
|
+
})
|
|
4097
4615
|
};
|
|
4098
4616
|
}
|
|
4099
4617
|
});
|
|
4618
|
+
/**
|
|
4619
|
+
* Reviver for persisted `isBetween` checks.
|
|
4620
|
+
*
|
|
4621
|
+
* **When to use**
|
|
4622
|
+
*
|
|
4623
|
+
* Use when reconstructing documents that may contain checks created by {@link isBetween}.
|
|
4624
|
+
*
|
|
4625
|
+
* @see {@link isBetween} for creating the corresponding check
|
|
4626
|
+
*
|
|
4627
|
+
* @category Number checks
|
|
4628
|
+
* @since 4.0.0
|
|
4629
|
+
*/
|
|
4630
|
+
export const isBetweenReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isBetween", /*#__PURE__*/Struct({
|
|
4631
|
+
minimum: Finite,
|
|
4632
|
+
maximum: Finite,
|
|
4633
|
+
exclusiveMinimum: /*#__PURE__*/optional(/*#__PURE__*/Literal(true)),
|
|
4634
|
+
exclusiveMaximum: /*#__PURE__*/optional(/*#__PURE__*/Literal(true))
|
|
4635
|
+
}), ({
|
|
4636
|
+
annotations,
|
|
4637
|
+
payload
|
|
4638
|
+
}) => isBetween(payload, annotations));
|
|
4100
4639
|
/**
|
|
4101
4640
|
* Validates that a number is a multiple of the specified divisor.
|
|
4102
4641
|
*
|
|
@@ -4119,12 +4658,38 @@ export const isMultipleOf = /*#__PURE__*/makeIsMultipleOf({
|
|
|
4119
4658
|
zero: 0,
|
|
4120
4659
|
annotate: divisor => ({
|
|
4121
4660
|
expected: `a value that is a multiple of ${divisor}`,
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4661
|
+
representation: {
|
|
4662
|
+
id: "effect/schema/isMultipleOf",
|
|
4663
|
+
payload: {
|
|
4664
|
+
divisor
|
|
4665
|
+
}
|
|
4666
|
+
},
|
|
4667
|
+
toJsonSchema: () => ({
|
|
4668
|
+
multipleOf: divisor
|
|
4669
|
+
}),
|
|
4670
|
+
toCode: () => ({
|
|
4671
|
+
runtime: `Schema.isMultipleOf(${format(divisor)})`
|
|
4672
|
+
})
|
|
4126
4673
|
})
|
|
4127
4674
|
});
|
|
4675
|
+
/**
|
|
4676
|
+
* Reviver for persisted `isMultipleOf` checks.
|
|
4677
|
+
*
|
|
4678
|
+
* **When to use**
|
|
4679
|
+
*
|
|
4680
|
+
* Use when reconstructing documents that may contain checks created by {@link isMultipleOf}.
|
|
4681
|
+
*
|
|
4682
|
+
* @see {@link isMultipleOf} for creating the corresponding check
|
|
4683
|
+
*
|
|
4684
|
+
* @category Number checks
|
|
4685
|
+
* @since 4.0.0
|
|
4686
|
+
*/
|
|
4687
|
+
export const isMultipleOfReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isMultipleOf", /*#__PURE__*/Struct({
|
|
4688
|
+
divisor: Finite
|
|
4689
|
+
}), ({
|
|
4690
|
+
annotations,
|
|
4691
|
+
payload
|
|
4692
|
+
}) => isMultipleOf(payload.divisor, annotations));
|
|
4128
4693
|
/**
|
|
4129
4694
|
* Validates that a number is a safe integer (within the safe integer range
|
|
4130
4695
|
* that can be exactly represented in JavaScript).
|
|
@@ -4146,9 +4711,16 @@ export const isMultipleOf = /*#__PURE__*/makeIsMultipleOf({
|
|
|
4146
4711
|
export function isInt(annotations) {
|
|
4147
4712
|
return makeFilter(n => globalThis.Number.isSafeInteger(n), {
|
|
4148
4713
|
expected: "an integer",
|
|
4149
|
-
|
|
4150
|
-
|
|
4714
|
+
representation: {
|
|
4715
|
+
id: "effect/schema/isInt",
|
|
4716
|
+
payload: null
|
|
4151
4717
|
},
|
|
4718
|
+
toJsonSchema: () => ({
|
|
4719
|
+
type: "integer"
|
|
4720
|
+
}),
|
|
4721
|
+
toCode: () => ({
|
|
4722
|
+
runtime: "Schema.isInt()"
|
|
4723
|
+
}),
|
|
4152
4724
|
arbitrary: {
|
|
4153
4725
|
constraint: {
|
|
4154
4726
|
integer: true
|
|
@@ -4157,6 +4729,41 @@ export function isInt(annotations) {
|
|
|
4157
4729
|
...annotations
|
|
4158
4730
|
});
|
|
4159
4731
|
}
|
|
4732
|
+
/**
|
|
4733
|
+
* Reviver for persisted `isInt` checks.
|
|
4734
|
+
*
|
|
4735
|
+
* **When to use**
|
|
4736
|
+
*
|
|
4737
|
+
* Use when reconstructing documents that may contain checks created by {@link isInt}.
|
|
4738
|
+
*
|
|
4739
|
+
* @see {@link isInt} for creating the corresponding check
|
|
4740
|
+
*
|
|
4741
|
+
* @category Integer checks
|
|
4742
|
+
* @since 4.0.0
|
|
4743
|
+
*/
|
|
4744
|
+
export const isIntReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isInt", Null, ({
|
|
4745
|
+
annotations
|
|
4746
|
+
}) => isInt(annotations));
|
|
4747
|
+
/**
|
|
4748
|
+
* Schema for integers, rejecting `NaN`, `Infinity`, and `-Infinity`.
|
|
4749
|
+
*
|
|
4750
|
+
* @category Number
|
|
4751
|
+
* @since 3.10.0
|
|
4752
|
+
*/
|
|
4753
|
+
export const Int = /*#__PURE__*/Number.check(/*#__PURE__*/isInt());
|
|
4754
|
+
/**
|
|
4755
|
+
* Schema for non-negative safe integers, including zero.
|
|
4756
|
+
*
|
|
4757
|
+
* **When to use**
|
|
4758
|
+
*
|
|
4759
|
+
* Use when you need a count, index, or size that cannot be negative.
|
|
4760
|
+
*
|
|
4761
|
+
* @see {@link Int} for safe integers that may be negative
|
|
4762
|
+
*
|
|
4763
|
+
* @category Number
|
|
4764
|
+
* @since 4.0.0
|
|
4765
|
+
*/
|
|
4766
|
+
export const Natural = /*#__PURE__*/Int.check(/*#__PURE__*/isGreaterThanOrEqualTo(0));
|
|
4160
4767
|
/**
|
|
4161
4768
|
* Validates that a number is a 32-bit signed integer (range: -2,147,483,648 to
|
|
4162
4769
|
* 2,147,483,647).
|
|
@@ -4213,38 +4820,14 @@ export function isUint32(annotations) {
|
|
|
4213
4820
|
...annotations
|
|
4214
4821
|
});
|
|
4215
4822
|
}
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
* This check does not have a direct JSON Schema equivalent, as JSON Schema
|
|
4225
|
-
* validates date strings, not Date objects.
|
|
4226
|
-
*
|
|
4227
|
-
* Arbitrary:
|
|
4228
|
-
*
|
|
4229
|
-
* When generating test data with fast-check, this applies a `valid: true`
|
|
4230
|
-
* constraint to ensure generated Date objects are valid.
|
|
4231
|
-
*
|
|
4232
|
-
* @category Date checks
|
|
4233
|
-
* @since 4.0.0
|
|
4234
|
-
*/
|
|
4235
|
-
export function isDateValid(annotations) {
|
|
4236
|
-
return makeFilter(date => !isNaN(date.getTime()), {
|
|
4237
|
-
expected: "a valid date",
|
|
4238
|
-
meta: {
|
|
4239
|
-
_tag: "isDateValid"
|
|
4240
|
-
},
|
|
4241
|
-
arbitrary: {
|
|
4242
|
-
constraint: {
|
|
4243
|
-
valid: true
|
|
4244
|
-
}
|
|
4245
|
-
},
|
|
4246
|
-
...annotations
|
|
4247
|
-
});
|
|
4823
|
+
function encodeDatePayload(date) {
|
|
4824
|
+
if (globalThis.Number.isNaN(date.getTime())) {
|
|
4825
|
+
throw new globalThis.RangeError(`Expected a valid Date, got ${format(date)}`);
|
|
4826
|
+
}
|
|
4827
|
+
return date.toISOString();
|
|
4828
|
+
}
|
|
4829
|
+
function formatDateRuntime(date) {
|
|
4830
|
+
return `new Date(${format(date.getTime())})`;
|
|
4248
4831
|
}
|
|
4249
4832
|
/**
|
|
4250
4833
|
* Validates that a Date is greater than the specified value (exclusive).
|
|
@@ -4262,12 +4845,21 @@ export function isDateValid(annotations) {
|
|
|
4262
4845
|
*/
|
|
4263
4846
|
export const isGreaterThanDate = /*#__PURE__*/makeIsGreaterThan({
|
|
4264
4847
|
order: Order.Date,
|
|
4265
|
-
annotate: exclusiveMinimum =>
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4848
|
+
annotate: exclusiveMinimum => {
|
|
4849
|
+
const encoded = encodeDatePayload(exclusiveMinimum);
|
|
4850
|
+
return {
|
|
4851
|
+
representation: {
|
|
4852
|
+
id: "effect/schema/isGreaterThanDate",
|
|
4853
|
+
payload: {
|
|
4854
|
+
exclusiveMinimum: encoded
|
|
4855
|
+
}
|
|
4856
|
+
},
|
|
4857
|
+
toJsonSchema: () => ({}),
|
|
4858
|
+
toCode: () => ({
|
|
4859
|
+
runtime: `Schema.isGreaterThanDate(${formatDateRuntime(exclusiveMinimum)})`
|
|
4860
|
+
})
|
|
4861
|
+
};
|
|
4862
|
+
}
|
|
4271
4863
|
});
|
|
4272
4864
|
/**
|
|
4273
4865
|
* Validates that a Date is greater than or equal to the specified date
|
|
@@ -4291,12 +4883,21 @@ export const isGreaterThanDate = /*#__PURE__*/makeIsGreaterThan({
|
|
|
4291
4883
|
*/
|
|
4292
4884
|
export const isGreaterThanOrEqualToDate = /*#__PURE__*/makeIsGreaterThanOrEqualTo({
|
|
4293
4885
|
order: Order.Date,
|
|
4294
|
-
annotate: minimum =>
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4886
|
+
annotate: minimum => {
|
|
4887
|
+
const encoded = encodeDatePayload(minimum);
|
|
4888
|
+
return {
|
|
4889
|
+
representation: {
|
|
4890
|
+
id: "effect/schema/isGreaterThanOrEqualToDate",
|
|
4891
|
+
payload: {
|
|
4892
|
+
minimum: encoded
|
|
4893
|
+
}
|
|
4894
|
+
},
|
|
4895
|
+
toJsonSchema: () => ({}),
|
|
4896
|
+
toCode: () => ({
|
|
4897
|
+
runtime: `Schema.isGreaterThanOrEqualToDate(${formatDateRuntime(minimum)})`
|
|
4898
|
+
})
|
|
4899
|
+
};
|
|
4900
|
+
}
|
|
4300
4901
|
});
|
|
4301
4902
|
/**
|
|
4302
4903
|
* Validates that a Date is less than the specified value (exclusive).
|
|
@@ -4314,12 +4915,21 @@ export const isGreaterThanOrEqualToDate = /*#__PURE__*/makeIsGreaterThanOrEqualT
|
|
|
4314
4915
|
*/
|
|
4315
4916
|
export const isLessThanDate = /*#__PURE__*/makeIsLessThan({
|
|
4316
4917
|
order: Order.Date,
|
|
4317
|
-
annotate: exclusiveMaximum =>
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4918
|
+
annotate: exclusiveMaximum => {
|
|
4919
|
+
const encoded = encodeDatePayload(exclusiveMaximum);
|
|
4920
|
+
return {
|
|
4921
|
+
representation: {
|
|
4922
|
+
id: "effect/schema/isLessThanDate",
|
|
4923
|
+
payload: {
|
|
4924
|
+
exclusiveMaximum: encoded
|
|
4925
|
+
}
|
|
4926
|
+
},
|
|
4927
|
+
toJsonSchema: () => ({}),
|
|
4928
|
+
toCode: () => ({
|
|
4929
|
+
runtime: `Schema.isLessThanDate(${formatDateRuntime(exclusiveMaximum)})`
|
|
4930
|
+
})
|
|
4931
|
+
};
|
|
4932
|
+
}
|
|
4323
4933
|
});
|
|
4324
4934
|
/**
|
|
4325
4935
|
* Validates that a Date is less than or equal to the specified date
|
|
@@ -4343,12 +4953,21 @@ export const isLessThanDate = /*#__PURE__*/makeIsLessThan({
|
|
|
4343
4953
|
*/
|
|
4344
4954
|
export const isLessThanOrEqualToDate = /*#__PURE__*/makeIsLessThanOrEqualTo({
|
|
4345
4955
|
order: Order.Date,
|
|
4346
|
-
annotate: maximum =>
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4956
|
+
annotate: maximum => {
|
|
4957
|
+
const encoded = encodeDatePayload(maximum);
|
|
4958
|
+
return {
|
|
4959
|
+
representation: {
|
|
4960
|
+
id: "effect/schema/isLessThanOrEqualToDate",
|
|
4961
|
+
payload: {
|
|
4962
|
+
maximum: encoded
|
|
4963
|
+
}
|
|
4964
|
+
},
|
|
4965
|
+
toJsonSchema: () => ({}),
|
|
4966
|
+
toCode: () => ({
|
|
4967
|
+
runtime: `Schema.isLessThanOrEqualToDate(${formatDateRuntime(maximum)})`
|
|
4968
|
+
})
|
|
4969
|
+
};
|
|
4970
|
+
}
|
|
4352
4971
|
});
|
|
4353
4972
|
/**
|
|
4354
4973
|
* Validates that a Date is within a specified range. The range boundaries can
|
|
@@ -4372,12 +4991,30 @@ export const isLessThanOrEqualToDate = /*#__PURE__*/makeIsLessThanOrEqualTo({
|
|
|
4372
4991
|
*/
|
|
4373
4992
|
export const isBetweenDate = /*#__PURE__*/makeIsBetween({
|
|
4374
4993
|
order: Order.Date,
|
|
4375
|
-
annotate: options =>
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4994
|
+
annotate: options => {
|
|
4995
|
+
const exclusiveMinimum = options.exclusiveMinimum ? true : undefined;
|
|
4996
|
+
const exclusiveMaximum = options.exclusiveMaximum ? true : undefined;
|
|
4997
|
+
const payload = {
|
|
4998
|
+
minimum: encodeDatePayload(options.minimum),
|
|
4999
|
+
maximum: encodeDatePayload(options.maximum),
|
|
5000
|
+
...(exclusiveMinimum && {
|
|
5001
|
+
exclusiveMinimum
|
|
5002
|
+
}),
|
|
5003
|
+
...(exclusiveMaximum && {
|
|
5004
|
+
exclusiveMaximum
|
|
5005
|
+
})
|
|
5006
|
+
};
|
|
5007
|
+
return {
|
|
5008
|
+
representation: {
|
|
5009
|
+
id: "effect/schema/isBetweenDate",
|
|
5010
|
+
payload
|
|
5011
|
+
},
|
|
5012
|
+
toJsonSchema: () => ({}),
|
|
5013
|
+
toCode: () => ({
|
|
5014
|
+
runtime: `Schema.isBetweenDate({ minimum: ${formatDateRuntime(options.minimum)}, maximum: ${formatDateRuntime(options.maximum)}, exclusiveMinimum: ${format(exclusiveMinimum)}, exclusiveMaximum: ${format(exclusiveMaximum)} })`
|
|
5015
|
+
})
|
|
5016
|
+
};
|
|
5017
|
+
}
|
|
4381
5018
|
});
|
|
4382
5019
|
/**
|
|
4383
5020
|
* Validates that a BigInt is greater than the specified value (exclusive).
|
|
@@ -4395,12 +5032,21 @@ export const isBetweenDate = /*#__PURE__*/makeIsBetween({
|
|
|
4395
5032
|
*/
|
|
4396
5033
|
export const isGreaterThanBigInt = /*#__PURE__*/makeIsGreaterThan({
|
|
4397
5034
|
order: Order.BigInt,
|
|
4398
|
-
annotate: exclusiveMinimum =>
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
5035
|
+
annotate: exclusiveMinimum => {
|
|
5036
|
+
const encoded = exclusiveMinimum.toString(10);
|
|
5037
|
+
return {
|
|
5038
|
+
representation: {
|
|
5039
|
+
id: "effect/schema/isGreaterThanBigInt",
|
|
5040
|
+
payload: {
|
|
5041
|
+
exclusiveMinimum: encoded
|
|
5042
|
+
}
|
|
5043
|
+
},
|
|
5044
|
+
toJsonSchema: () => ({}),
|
|
5045
|
+
toCode: () => ({
|
|
5046
|
+
runtime: `Schema.isGreaterThanBigInt(${format(exclusiveMinimum)})`
|
|
5047
|
+
})
|
|
5048
|
+
};
|
|
5049
|
+
}
|
|
4404
5050
|
});
|
|
4405
5051
|
/**
|
|
4406
5052
|
* Validates that a BigInt is greater than or equal to the specified value
|
|
@@ -4419,12 +5065,21 @@ export const isGreaterThanBigInt = /*#__PURE__*/makeIsGreaterThan({
|
|
|
4419
5065
|
*/
|
|
4420
5066
|
export const isGreaterThanOrEqualToBigInt = /*#__PURE__*/makeIsGreaterThanOrEqualTo({
|
|
4421
5067
|
order: Order.BigInt,
|
|
4422
|
-
annotate: minimum =>
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
5068
|
+
annotate: minimum => {
|
|
5069
|
+
const encoded = minimum.toString(10);
|
|
5070
|
+
return {
|
|
5071
|
+
representation: {
|
|
5072
|
+
id: "effect/schema/isGreaterThanOrEqualToBigInt",
|
|
5073
|
+
payload: {
|
|
5074
|
+
minimum: encoded
|
|
5075
|
+
}
|
|
5076
|
+
},
|
|
5077
|
+
toJsonSchema: () => ({}),
|
|
5078
|
+
toCode: () => ({
|
|
5079
|
+
runtime: `Schema.isGreaterThanOrEqualToBigInt(${format(minimum)})`
|
|
5080
|
+
})
|
|
5081
|
+
};
|
|
5082
|
+
}
|
|
4428
5083
|
});
|
|
4429
5084
|
/**
|
|
4430
5085
|
* Validates that a BigInt is less than the specified value (exclusive).
|
|
@@ -4442,12 +5097,21 @@ export const isGreaterThanOrEqualToBigInt = /*#__PURE__*/makeIsGreaterThanOrEqua
|
|
|
4442
5097
|
*/
|
|
4443
5098
|
export const isLessThanBigInt = /*#__PURE__*/makeIsLessThan({
|
|
4444
5099
|
order: Order.BigInt,
|
|
4445
|
-
annotate: exclusiveMaximum =>
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
5100
|
+
annotate: exclusiveMaximum => {
|
|
5101
|
+
const encoded = exclusiveMaximum.toString(10);
|
|
5102
|
+
return {
|
|
5103
|
+
representation: {
|
|
5104
|
+
id: "effect/schema/isLessThanBigInt",
|
|
5105
|
+
payload: {
|
|
5106
|
+
exclusiveMaximum: encoded
|
|
5107
|
+
}
|
|
5108
|
+
},
|
|
5109
|
+
toJsonSchema: () => ({}),
|
|
5110
|
+
toCode: () => ({
|
|
5111
|
+
runtime: `Schema.isLessThanBigInt(${format(exclusiveMaximum)})`
|
|
5112
|
+
})
|
|
5113
|
+
};
|
|
5114
|
+
}
|
|
4451
5115
|
});
|
|
4452
5116
|
/**
|
|
4453
5117
|
* Validates that a BigInt is less than or equal to the specified value
|
|
@@ -4466,12 +5130,21 @@ export const isLessThanBigInt = /*#__PURE__*/makeIsLessThan({
|
|
|
4466
5130
|
*/
|
|
4467
5131
|
export const isLessThanOrEqualToBigInt = /*#__PURE__*/makeIsLessThanOrEqualTo({
|
|
4468
5132
|
order: Order.BigInt,
|
|
4469
|
-
annotate: maximum =>
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
5133
|
+
annotate: maximum => {
|
|
5134
|
+
const encoded = maximum.toString(10);
|
|
5135
|
+
return {
|
|
5136
|
+
representation: {
|
|
5137
|
+
id: "effect/schema/isLessThanOrEqualToBigInt",
|
|
5138
|
+
payload: {
|
|
5139
|
+
maximum: encoded
|
|
5140
|
+
}
|
|
5141
|
+
},
|
|
5142
|
+
toJsonSchema: () => ({}),
|
|
5143
|
+
toCode: () => ({
|
|
5144
|
+
runtime: `Schema.isLessThanOrEqualToBigInt(${format(maximum)})`
|
|
5145
|
+
})
|
|
5146
|
+
};
|
|
5147
|
+
}
|
|
4475
5148
|
});
|
|
4476
5149
|
/**
|
|
4477
5150
|
* Validates that a BigInt is within a specified range. The range boundaries can
|
|
@@ -4490,12 +5163,30 @@ export const isLessThanOrEqualToBigInt = /*#__PURE__*/makeIsLessThanOrEqualTo({
|
|
|
4490
5163
|
*/
|
|
4491
5164
|
export const isBetweenBigInt = /*#__PURE__*/makeIsBetween({
|
|
4492
5165
|
order: Order.BigInt,
|
|
4493
|
-
annotate: options =>
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
5166
|
+
annotate: options => {
|
|
5167
|
+
const exclusiveMinimum = options.exclusiveMinimum ? true : undefined;
|
|
5168
|
+
const exclusiveMaximum = options.exclusiveMaximum ? true : undefined;
|
|
5169
|
+
const payload = {
|
|
5170
|
+
minimum: options.minimum.toString(10),
|
|
5171
|
+
maximum: options.maximum.toString(10),
|
|
5172
|
+
...(exclusiveMinimum && {
|
|
5173
|
+
exclusiveMinimum
|
|
5174
|
+
}),
|
|
5175
|
+
...(exclusiveMaximum && {
|
|
5176
|
+
exclusiveMaximum
|
|
5177
|
+
})
|
|
5178
|
+
};
|
|
5179
|
+
return {
|
|
5180
|
+
representation: {
|
|
5181
|
+
id: "effect/schema/isBetweenBigInt",
|
|
5182
|
+
payload
|
|
5183
|
+
},
|
|
5184
|
+
toJsonSchema: () => ({}),
|
|
5185
|
+
toCode: () => ({
|
|
5186
|
+
runtime: `Schema.isBetweenBigInt({ minimum: ${format(options.minimum)}, maximum: ${format(options.maximum)}, exclusiveMinimum: ${format(exclusiveMinimum)}, exclusiveMaximum: ${format(exclusiveMaximum)} })`
|
|
5187
|
+
})
|
|
5188
|
+
};
|
|
5189
|
+
}
|
|
4499
5190
|
});
|
|
4500
5191
|
/**
|
|
4501
5192
|
* Validates that a BigDecimal is greater than the specified value (exclusive).
|
|
@@ -4587,11 +5278,23 @@ export function isMinLength(minLength, annotations) {
|
|
|
4587
5278
|
minLength = Math.max(0, Math.floor(minLength));
|
|
4588
5279
|
return makeFilter(input => input.length >= minLength, {
|
|
4589
5280
|
expected: `a value with a length of at least ${minLength}`,
|
|
4590
|
-
|
|
4591
|
-
|
|
5281
|
+
representation: {
|
|
5282
|
+
id: "effect/schema/isMinLength",
|
|
5283
|
+
payload: {
|
|
5284
|
+
minLength
|
|
5285
|
+
}
|
|
5286
|
+
},
|
|
5287
|
+
toJsonSchema: ({
|
|
5288
|
+
type
|
|
5289
|
+
}) => type === "array" ? {
|
|
5290
|
+
minItems: minLength
|
|
5291
|
+
} : {
|
|
4592
5292
|
minLength
|
|
4593
5293
|
},
|
|
4594
|
-
|
|
5294
|
+
toCode: () => ({
|
|
5295
|
+
runtime: `Schema.isMinLength(${minLength})`
|
|
5296
|
+
}),
|
|
5297
|
+
[InternalAnnotations.STRUCTURAL_ANNOTATION_KEY]: true,
|
|
4595
5298
|
arbitrary: {
|
|
4596
5299
|
constraint: {
|
|
4597
5300
|
minLength
|
|
@@ -4600,6 +5303,24 @@ export function isMinLength(minLength, annotations) {
|
|
|
4600
5303
|
...annotations
|
|
4601
5304
|
});
|
|
4602
5305
|
}
|
|
5306
|
+
/**
|
|
5307
|
+
* Reviver for persisted `isMinLength` checks.
|
|
5308
|
+
*
|
|
5309
|
+
* **When to use**
|
|
5310
|
+
*
|
|
5311
|
+
* Use when reconstructing documents that may contain checks created by {@link isMinLength}.
|
|
5312
|
+
*
|
|
5313
|
+
* @see {@link isMinLength} for creating the corresponding check
|
|
5314
|
+
*
|
|
5315
|
+
* @category Length checks
|
|
5316
|
+
* @since 4.0.0
|
|
5317
|
+
*/
|
|
5318
|
+
export const isMinLengthReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isMinLength", /*#__PURE__*/Struct({
|
|
5319
|
+
minLength: Natural
|
|
5320
|
+
}), ({
|
|
5321
|
+
annotations,
|
|
5322
|
+
payload
|
|
5323
|
+
}) => isMinLength(payload.minLength, annotations));
|
|
4603
5324
|
/**
|
|
4604
5325
|
* Validates that a value has at least one element. Works with strings and arrays.
|
|
4605
5326
|
* This is equivalent to `isMinLength(1)`.
|
|
@@ -4646,11 +5367,23 @@ export function isMaxLength(maxLength, annotations) {
|
|
|
4646
5367
|
maxLength = Math.max(0, Math.floor(maxLength));
|
|
4647
5368
|
return makeFilter(input => input.length <= maxLength, {
|
|
4648
5369
|
expected: `a value with a length of at most ${maxLength}`,
|
|
4649
|
-
|
|
4650
|
-
|
|
5370
|
+
representation: {
|
|
5371
|
+
id: "effect/schema/isMaxLength",
|
|
5372
|
+
payload: {
|
|
5373
|
+
maxLength
|
|
5374
|
+
}
|
|
5375
|
+
},
|
|
5376
|
+
toJsonSchema: ({
|
|
5377
|
+
type
|
|
5378
|
+
}) => type === "array" ? {
|
|
5379
|
+
maxItems: maxLength
|
|
5380
|
+
} : {
|
|
4651
5381
|
maxLength
|
|
4652
5382
|
},
|
|
4653
|
-
|
|
5383
|
+
toCode: () => ({
|
|
5384
|
+
runtime: `Schema.isMaxLength(${maxLength})`
|
|
5385
|
+
}),
|
|
5386
|
+
[InternalAnnotations.STRUCTURAL_ANNOTATION_KEY]: true,
|
|
4654
5387
|
arbitrary: {
|
|
4655
5388
|
constraint: {
|
|
4656
5389
|
maxLength
|
|
@@ -4659,6 +5392,24 @@ export function isMaxLength(maxLength, annotations) {
|
|
|
4659
5392
|
...annotations
|
|
4660
5393
|
});
|
|
4661
5394
|
}
|
|
5395
|
+
/**
|
|
5396
|
+
* Reviver for persisted `isMaxLength` checks.
|
|
5397
|
+
*
|
|
5398
|
+
* **When to use**
|
|
5399
|
+
*
|
|
5400
|
+
* Use when reconstructing documents that may contain checks created by {@link isMaxLength}.
|
|
5401
|
+
*
|
|
5402
|
+
* @see {@link isMaxLength} for creating the corresponding check
|
|
5403
|
+
*
|
|
5404
|
+
* @category Length checks
|
|
5405
|
+
* @since 4.0.0
|
|
5406
|
+
*/
|
|
5407
|
+
export const isMaxLengthReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isMaxLength", /*#__PURE__*/Struct({
|
|
5408
|
+
maxLength: Natural
|
|
5409
|
+
}), ({
|
|
5410
|
+
annotations,
|
|
5411
|
+
payload
|
|
5412
|
+
}) => isMaxLength(payload.maxLength, annotations));
|
|
4662
5413
|
/**
|
|
4663
5414
|
* Validates that a value's length is within the specified range. Works with
|
|
4664
5415
|
* strings and arrays.
|
|
@@ -4684,12 +5435,32 @@ export function isLengthBetween(minimum, maximum, annotations) {
|
|
|
4684
5435
|
maximum = Math.max(0, Math.floor(maximum));
|
|
4685
5436
|
return makeFilter(input => input.length >= minimum && input.length <= maximum, {
|
|
4686
5437
|
expected: minimum === maximum ? `a value with a length of ${minimum}` : `a value with a length between ${minimum} and ${maximum}`,
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
5438
|
+
representation: {
|
|
5439
|
+
id: "effect/schema/isLengthBetween",
|
|
5440
|
+
payload: {
|
|
5441
|
+
minimum,
|
|
5442
|
+
maximum
|
|
5443
|
+
}
|
|
5444
|
+
},
|
|
5445
|
+
toJsonSchema: ({
|
|
5446
|
+
type
|
|
5447
|
+
}) => type === "array" ? {
|
|
5448
|
+
allOf: [{
|
|
5449
|
+
minItems: minimum
|
|
5450
|
+
}, {
|
|
5451
|
+
maxItems: maximum
|
|
5452
|
+
}]
|
|
5453
|
+
} : {
|
|
5454
|
+
allOf: [{
|
|
5455
|
+
minLength: minimum
|
|
5456
|
+
}, {
|
|
5457
|
+
maxLength: maximum
|
|
5458
|
+
}]
|
|
4691
5459
|
},
|
|
4692
|
-
|
|
5460
|
+
toCode: () => ({
|
|
5461
|
+
runtime: `Schema.isLengthBetween(${minimum}, ${maximum})`
|
|
5462
|
+
}),
|
|
5463
|
+
[InternalAnnotations.STRUCTURAL_ANNOTATION_KEY]: true,
|
|
4693
5464
|
arbitrary: {
|
|
4694
5465
|
constraint: {
|
|
4695
5466
|
minLength: minimum,
|
|
@@ -4699,6 +5470,25 @@ export function isLengthBetween(minimum, maximum, annotations) {
|
|
|
4699
5470
|
...annotations
|
|
4700
5471
|
});
|
|
4701
5472
|
}
|
|
5473
|
+
/**
|
|
5474
|
+
* Reviver for persisted `isLengthBetween` checks.
|
|
5475
|
+
*
|
|
5476
|
+
* **When to use**
|
|
5477
|
+
*
|
|
5478
|
+
* Use when reconstructing documents that may contain checks created by {@link isLengthBetween}.
|
|
5479
|
+
*
|
|
5480
|
+
* @see {@link isLengthBetween} for creating the corresponding check
|
|
5481
|
+
*
|
|
5482
|
+
* @category Length checks
|
|
5483
|
+
* @since 4.0.0
|
|
5484
|
+
*/
|
|
5485
|
+
export const isLengthBetweenReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isLengthBetween", /*#__PURE__*/Struct({
|
|
5486
|
+
minimum: Natural,
|
|
5487
|
+
maximum: Natural
|
|
5488
|
+
}), ({
|
|
5489
|
+
annotations,
|
|
5490
|
+
payload
|
|
5491
|
+
}) => isLengthBetween(payload.minimum, payload.maximum, annotations));
|
|
4702
5492
|
/**
|
|
4703
5493
|
* Validates that a value has at least the specified size. Works with values
|
|
4704
5494
|
* that have a `size` property, such as `Set` or `Map`.
|
|
@@ -4723,11 +5513,17 @@ export function isMinSize(minSize, annotations) {
|
|
|
4723
5513
|
minSize = Math.max(0, Math.floor(minSize));
|
|
4724
5514
|
return makeFilter(input => input.size >= minSize, {
|
|
4725
5515
|
expected: `a value with a size of at least ${minSize}`,
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
5516
|
+
representation: {
|
|
5517
|
+
id: "effect/schema/isMinSize",
|
|
5518
|
+
payload: {
|
|
5519
|
+
minSize
|
|
5520
|
+
}
|
|
4729
5521
|
},
|
|
4730
|
-
|
|
5522
|
+
toJsonSchema: () => ({}),
|
|
5523
|
+
toCode: () => ({
|
|
5524
|
+
runtime: `Schema.isMinSize(${minSize})`
|
|
5525
|
+
}),
|
|
5526
|
+
[InternalAnnotations.STRUCTURAL_ANNOTATION_KEY]: true,
|
|
4731
5527
|
arbitrary: {
|
|
4732
5528
|
constraint: {
|
|
4733
5529
|
minLength: minSize
|
|
@@ -4736,6 +5532,24 @@ export function isMinSize(minSize, annotations) {
|
|
|
4736
5532
|
...annotations
|
|
4737
5533
|
});
|
|
4738
5534
|
}
|
|
5535
|
+
/**
|
|
5536
|
+
* Reviver for persisted `isMinSize` checks.
|
|
5537
|
+
*
|
|
5538
|
+
* **When to use**
|
|
5539
|
+
*
|
|
5540
|
+
* Use when reconstructing documents that may contain checks created by {@link isMinSize}.
|
|
5541
|
+
*
|
|
5542
|
+
* @see {@link isMinSize} for creating the corresponding check
|
|
5543
|
+
*
|
|
5544
|
+
* @category Size checks
|
|
5545
|
+
* @since 4.0.0
|
|
5546
|
+
*/
|
|
5547
|
+
export const isMinSizeReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isMinSize", /*#__PURE__*/Struct({
|
|
5548
|
+
minSize: Natural
|
|
5549
|
+
}), ({
|
|
5550
|
+
annotations,
|
|
5551
|
+
payload
|
|
5552
|
+
}) => isMinSize(payload.minSize, annotations));
|
|
4739
5553
|
/**
|
|
4740
5554
|
* Validates that a value has at most the specified size. Works with values
|
|
4741
5555
|
* that have a `size` property, such as `Set` or `Map`.
|
|
@@ -4760,11 +5574,17 @@ export function isMaxSize(maxSize, annotations) {
|
|
|
4760
5574
|
maxSize = Math.max(0, Math.floor(maxSize));
|
|
4761
5575
|
return makeFilter(input => input.size <= maxSize, {
|
|
4762
5576
|
expected: `a value with a size of at most ${maxSize}`,
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
5577
|
+
representation: {
|
|
5578
|
+
id: "effect/schema/isMaxSize",
|
|
5579
|
+
payload: {
|
|
5580
|
+
maxSize
|
|
5581
|
+
}
|
|
4766
5582
|
},
|
|
4767
|
-
|
|
5583
|
+
toJsonSchema: () => ({}),
|
|
5584
|
+
toCode: () => ({
|
|
5585
|
+
runtime: `Schema.isMaxSize(${maxSize})`
|
|
5586
|
+
}),
|
|
5587
|
+
[InternalAnnotations.STRUCTURAL_ANNOTATION_KEY]: true,
|
|
4768
5588
|
arbitrary: {
|
|
4769
5589
|
constraint: {
|
|
4770
5590
|
maxLength: maxSize
|
|
@@ -4773,6 +5593,24 @@ export function isMaxSize(maxSize, annotations) {
|
|
|
4773
5593
|
...annotations
|
|
4774
5594
|
});
|
|
4775
5595
|
}
|
|
5596
|
+
/**
|
|
5597
|
+
* Reviver for persisted `isMaxSize` checks.
|
|
5598
|
+
*
|
|
5599
|
+
* **When to use**
|
|
5600
|
+
*
|
|
5601
|
+
* Use when reconstructing documents that may contain checks created by {@link isMaxSize}.
|
|
5602
|
+
*
|
|
5603
|
+
* @see {@link isMaxSize} for creating the corresponding check
|
|
5604
|
+
*
|
|
5605
|
+
* @category Size checks
|
|
5606
|
+
* @since 4.0.0
|
|
5607
|
+
*/
|
|
5608
|
+
export const isMaxSizeReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isMaxSize", /*#__PURE__*/Struct({
|
|
5609
|
+
maxSize: Natural
|
|
5610
|
+
}), ({
|
|
5611
|
+
annotations,
|
|
5612
|
+
payload
|
|
5613
|
+
}) => isMaxSize(payload.maxSize, annotations));
|
|
4776
5614
|
/**
|
|
4777
5615
|
* Validates that a value's size is within the specified range. Works with
|
|
4778
5616
|
* values that have a `size` property, such as `Set` or `Map`.
|
|
@@ -4798,12 +5636,18 @@ export function isSizeBetween(minimum, maximum, annotations) {
|
|
|
4798
5636
|
maximum = Math.max(0, Math.floor(maximum));
|
|
4799
5637
|
return makeFilter(input => input.size >= minimum && input.size <= maximum, {
|
|
4800
5638
|
expected: minimum === maximum ? `a value with a size of ${minimum}` : `a value with a size between ${minimum} and ${maximum}`,
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
5639
|
+
representation: {
|
|
5640
|
+
id: "effect/schema/isSizeBetween",
|
|
5641
|
+
payload: {
|
|
5642
|
+
minimum,
|
|
5643
|
+
maximum
|
|
5644
|
+
}
|
|
4805
5645
|
},
|
|
4806
|
-
|
|
5646
|
+
toJsonSchema: () => ({}),
|
|
5647
|
+
toCode: () => ({
|
|
5648
|
+
runtime: `Schema.isSizeBetween(${minimum}, ${maximum})`
|
|
5649
|
+
}),
|
|
5650
|
+
[InternalAnnotations.STRUCTURAL_ANNOTATION_KEY]: true,
|
|
4807
5651
|
arbitrary: {
|
|
4808
5652
|
constraint: {
|
|
4809
5653
|
minLength: minimum,
|
|
@@ -4813,6 +5657,25 @@ export function isSizeBetween(minimum, maximum, annotations) {
|
|
|
4813
5657
|
...annotations
|
|
4814
5658
|
});
|
|
4815
5659
|
}
|
|
5660
|
+
/**
|
|
5661
|
+
* Reviver for persisted `isSizeBetween` checks.
|
|
5662
|
+
*
|
|
5663
|
+
* **When to use**
|
|
5664
|
+
*
|
|
5665
|
+
* Use when reconstructing documents that may contain checks created by {@link isSizeBetween}.
|
|
5666
|
+
*
|
|
5667
|
+
* @see {@link isSizeBetween} for creating the corresponding check
|
|
5668
|
+
*
|
|
5669
|
+
* @category Size checks
|
|
5670
|
+
* @since 4.0.0
|
|
5671
|
+
*/
|
|
5672
|
+
export const isSizeBetweenReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isSizeBetween", /*#__PURE__*/Struct({
|
|
5673
|
+
minimum: Natural,
|
|
5674
|
+
maximum: Natural
|
|
5675
|
+
}), ({
|
|
5676
|
+
annotations,
|
|
5677
|
+
payload
|
|
5678
|
+
}) => isSizeBetween(payload.minimum, payload.maximum, annotations));
|
|
4816
5679
|
/**
|
|
4817
5680
|
* Validates that an object contains at least the specified number of
|
|
4818
5681
|
* properties. This includes both string and symbol keys when counting
|
|
@@ -4837,11 +5700,19 @@ export function isMinProperties(minProperties, annotations) {
|
|
|
4837
5700
|
minProperties = Math.max(0, Math.floor(minProperties));
|
|
4838
5701
|
return makeFilter(input => Reflect.ownKeys(input).length >= minProperties, {
|
|
4839
5702
|
expected: `a value with at least ${minProperties === 1 ? "1 entry" : `${minProperties} entries`}`,
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
5703
|
+
representation: {
|
|
5704
|
+
id: "effect/schema/isMinProperties",
|
|
5705
|
+
payload: {
|
|
5706
|
+
minProperties
|
|
5707
|
+
}
|
|
4843
5708
|
},
|
|
4844
|
-
|
|
5709
|
+
toJsonSchema: () => ({
|
|
5710
|
+
minProperties
|
|
5711
|
+
}),
|
|
5712
|
+
toCode: () => ({
|
|
5713
|
+
runtime: `Schema.isMinProperties(${minProperties})`
|
|
5714
|
+
}),
|
|
5715
|
+
[InternalAnnotations.STRUCTURAL_ANNOTATION_KEY]: true,
|
|
4845
5716
|
arbitrary: {
|
|
4846
5717
|
constraint: {
|
|
4847
5718
|
minLength: minProperties
|
|
@@ -4850,6 +5721,24 @@ export function isMinProperties(minProperties, annotations) {
|
|
|
4850
5721
|
...annotations
|
|
4851
5722
|
});
|
|
4852
5723
|
}
|
|
5724
|
+
/**
|
|
5725
|
+
* Reviver for persisted `isMinProperties` checks.
|
|
5726
|
+
*
|
|
5727
|
+
* **When to use**
|
|
5728
|
+
*
|
|
5729
|
+
* Use when reconstructing documents that may contain checks created by {@link isMinProperties}.
|
|
5730
|
+
*
|
|
5731
|
+
* @see {@link isMinProperties} for creating the corresponding check
|
|
5732
|
+
*
|
|
5733
|
+
* @category Object checks
|
|
5734
|
+
* @since 4.0.0
|
|
5735
|
+
*/
|
|
5736
|
+
export const isMinPropertiesReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isMinProperties", /*#__PURE__*/Struct({
|
|
5737
|
+
minProperties: Natural
|
|
5738
|
+
}), ({
|
|
5739
|
+
annotations,
|
|
5740
|
+
payload
|
|
5741
|
+
}) => isMinProperties(payload.minProperties, annotations));
|
|
4853
5742
|
/**
|
|
4854
5743
|
* Validates that an object contains at most the specified number of properties.
|
|
4855
5744
|
* This includes both string and symbol keys when counting properties.
|
|
@@ -4873,11 +5762,19 @@ export function isMaxProperties(maxProperties, annotations) {
|
|
|
4873
5762
|
maxProperties = Math.max(0, Math.floor(maxProperties));
|
|
4874
5763
|
return makeFilter(input => Reflect.ownKeys(input).length <= maxProperties, {
|
|
4875
5764
|
expected: `a value with at most ${maxProperties === 1 ? "1 entry" : `${maxProperties} entries`}`,
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
5765
|
+
representation: {
|
|
5766
|
+
id: "effect/schema/isMaxProperties",
|
|
5767
|
+
payload: {
|
|
5768
|
+
maxProperties
|
|
5769
|
+
}
|
|
4879
5770
|
},
|
|
4880
|
-
|
|
5771
|
+
toJsonSchema: () => ({
|
|
5772
|
+
maxProperties
|
|
5773
|
+
}),
|
|
5774
|
+
toCode: () => ({
|
|
5775
|
+
runtime: `Schema.isMaxProperties(${maxProperties})`
|
|
5776
|
+
}),
|
|
5777
|
+
[InternalAnnotations.STRUCTURAL_ANNOTATION_KEY]: true,
|
|
4881
5778
|
arbitrary: {
|
|
4882
5779
|
constraint: {
|
|
4883
5780
|
maxLength: maxProperties
|
|
@@ -4886,6 +5783,24 @@ export function isMaxProperties(maxProperties, annotations) {
|
|
|
4886
5783
|
...annotations
|
|
4887
5784
|
});
|
|
4888
5785
|
}
|
|
5786
|
+
/**
|
|
5787
|
+
* Reviver for persisted `isMaxProperties` checks.
|
|
5788
|
+
*
|
|
5789
|
+
* **When to use**
|
|
5790
|
+
*
|
|
5791
|
+
* Use when reconstructing documents that may contain checks created by {@link isMaxProperties}.
|
|
5792
|
+
*
|
|
5793
|
+
* @see {@link isMaxProperties} for creating the corresponding check
|
|
5794
|
+
*
|
|
5795
|
+
* @category Object checks
|
|
5796
|
+
* @since 4.0.0
|
|
5797
|
+
*/
|
|
5798
|
+
export const isMaxPropertiesReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isMaxProperties", /*#__PURE__*/Struct({
|
|
5799
|
+
maxProperties: Natural
|
|
5800
|
+
}), ({
|
|
5801
|
+
annotations,
|
|
5802
|
+
payload
|
|
5803
|
+
}) => isMaxProperties(payload.maxProperties, annotations));
|
|
4889
5804
|
/**
|
|
4890
5805
|
* Validates that an object contains between `minimum` and `maximum` properties (inclusive).
|
|
4891
5806
|
* This includes both string and symbol keys when counting properties.
|
|
@@ -4911,12 +5826,21 @@ export function isPropertiesLengthBetween(minimum, maximum, annotations) {
|
|
|
4911
5826
|
maximum = Math.max(0, Math.floor(maximum));
|
|
4912
5827
|
return makeFilter(input => Reflect.ownKeys(input).length >= minimum && Reflect.ownKeys(input).length <= maximum, {
|
|
4913
5828
|
expected: minimum === maximum ? `a value with exactly ${minimum === 1 ? "1 entry" : `${minimum} entries`}` : `a value with between ${minimum} and ${maximum} entries`,
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
5829
|
+
representation: {
|
|
5830
|
+
id: "effect/schema/isPropertiesLengthBetween",
|
|
5831
|
+
payload: {
|
|
5832
|
+
minimum,
|
|
5833
|
+
maximum
|
|
5834
|
+
}
|
|
4918
5835
|
},
|
|
4919
|
-
|
|
5836
|
+
toJsonSchema: () => ({
|
|
5837
|
+
minProperties: minimum,
|
|
5838
|
+
maxProperties: maximum
|
|
5839
|
+
}),
|
|
5840
|
+
toCode: () => ({
|
|
5841
|
+
runtime: `Schema.isPropertiesLengthBetween(${minimum}, ${maximum})`
|
|
5842
|
+
}),
|
|
5843
|
+
[InternalAnnotations.STRUCTURAL_ANNOTATION_KEY]: true,
|
|
4920
5844
|
arbitrary: {
|
|
4921
5845
|
constraint: {
|
|
4922
5846
|
minLength: minimum,
|
|
@@ -4926,6 +5850,25 @@ export function isPropertiesLengthBetween(minimum, maximum, annotations) {
|
|
|
4926
5850
|
...annotations
|
|
4927
5851
|
});
|
|
4928
5852
|
}
|
|
5853
|
+
/**
|
|
5854
|
+
* Reviver for persisted `isPropertiesLengthBetween` checks.
|
|
5855
|
+
*
|
|
5856
|
+
* **When to use**
|
|
5857
|
+
*
|
|
5858
|
+
* Use when reconstructing documents that may contain checks created by {@link isPropertiesLengthBetween}.
|
|
5859
|
+
*
|
|
5860
|
+
* @see {@link isPropertiesLengthBetween} for creating the corresponding check
|
|
5861
|
+
*
|
|
5862
|
+
* @category Object checks
|
|
5863
|
+
* @since 4.0.0
|
|
5864
|
+
*/
|
|
5865
|
+
export const isPropertiesLengthBetweenReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isPropertiesLengthBetween", /*#__PURE__*/Struct({
|
|
5866
|
+
minimum: Natural,
|
|
5867
|
+
maximum: Natural
|
|
5868
|
+
}), ({
|
|
5869
|
+
annotations,
|
|
5870
|
+
payload
|
|
5871
|
+
}) => isPropertiesLengthBetween(payload.minimum, payload.maximum, annotations));
|
|
4929
5872
|
/**
|
|
4930
5873
|
* Validates that every own property key of an object satisfies the encoded side
|
|
4931
5874
|
* of the provided key schema.
|
|
@@ -4961,14 +5904,41 @@ export function isPropertyNames(keySchema, annotations) {
|
|
|
4961
5904
|
return true;
|
|
4962
5905
|
}, {
|
|
4963
5906
|
expected: "an object with property names matching the schema",
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
5907
|
+
representation: {
|
|
5908
|
+
id: "effect/schema/isPropertyNames",
|
|
5909
|
+
payload: null,
|
|
5910
|
+
schemas: [propertyNames.ast]
|
|
4967
5911
|
},
|
|
4968
|
-
|
|
5912
|
+
toJsonSchema: ({
|
|
5913
|
+
schemas
|
|
5914
|
+
}) => ({
|
|
5915
|
+
propertyNames: schemas[0]
|
|
5916
|
+
}),
|
|
5917
|
+
toCode: ({
|
|
5918
|
+
schemas
|
|
5919
|
+
}) => ({
|
|
5920
|
+
runtime: `Schema.isPropertyNames(${schemas[0].runtime})`
|
|
5921
|
+
}),
|
|
5922
|
+
[InternalAnnotations.STRUCTURAL_ANNOTATION_KEY]: true,
|
|
4969
5923
|
...annotations
|
|
4970
5924
|
});
|
|
4971
5925
|
}
|
|
5926
|
+
/**
|
|
5927
|
+
* Reviver for persisted `isPropertyNames` checks.
|
|
5928
|
+
*
|
|
5929
|
+
* **When to use**
|
|
5930
|
+
*
|
|
5931
|
+
* Use when reconstructing documents that may contain checks created by {@link isPropertyNames}.
|
|
5932
|
+
*
|
|
5933
|
+
* @see {@link isPropertyNames} for creating the corresponding check
|
|
5934
|
+
*
|
|
5935
|
+
* @category Object checks
|
|
5936
|
+
* @since 4.0.0
|
|
5937
|
+
*/
|
|
5938
|
+
export const isPropertyNamesReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isPropertyNames", Null, ({
|
|
5939
|
+
annotations,
|
|
5940
|
+
schemas
|
|
5941
|
+
}) => isPropertyNames(schemas[0], annotations));
|
|
4972
5942
|
/**
|
|
4973
5943
|
* Validates that all items in an array are unique according to Effect equality.
|
|
4974
5944
|
*
|
|
@@ -4986,12 +5956,18 @@ export function isPropertyNames(keySchema, annotations) {
|
|
|
4986
5956
|
* @since 4.0.0
|
|
4987
5957
|
*/
|
|
4988
5958
|
export function isUnique(annotations) {
|
|
4989
|
-
|
|
4990
|
-
return makeFilter(input => Arr.dedupeWith(input, equivalence).length === input.length, {
|
|
5959
|
+
return makeFilter(input => Arr.dedupe(input).length === input.length, {
|
|
4991
5960
|
expected: "an array with unique items",
|
|
4992
|
-
|
|
4993
|
-
|
|
5961
|
+
representation: {
|
|
5962
|
+
id: "effect/schema/isUnique",
|
|
5963
|
+
payload: null
|
|
4994
5964
|
},
|
|
5965
|
+
toJsonSchema: () => ({
|
|
5966
|
+
uniqueItems: true
|
|
5967
|
+
}),
|
|
5968
|
+
toCode: () => ({
|
|
5969
|
+
runtime: "Schema.isUnique()"
|
|
5970
|
+
}),
|
|
4995
5971
|
arbitrary: {
|
|
4996
5972
|
constraint: {
|
|
4997
5973
|
unique: true
|
|
@@ -5000,6 +5976,21 @@ export function isUnique(annotations) {
|
|
|
5000
5976
|
...annotations
|
|
5001
5977
|
});
|
|
5002
5978
|
}
|
|
5979
|
+
/**
|
|
5980
|
+
* Reviver for persisted `isUnique` checks.
|
|
5981
|
+
*
|
|
5982
|
+
* **When to use**
|
|
5983
|
+
*
|
|
5984
|
+
* Use when reconstructing documents that may contain checks created by {@link isUnique}.
|
|
5985
|
+
*
|
|
5986
|
+
* @see {@link isUnique} for creating the corresponding check
|
|
5987
|
+
*
|
|
5988
|
+
* @category Array checks
|
|
5989
|
+
* @since 4.0.0
|
|
5990
|
+
*/
|
|
5991
|
+
export const isUniqueReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isUnique", Null, ({
|
|
5992
|
+
annotations
|
|
5993
|
+
}) => isUnique(annotations));
|
|
5003
5994
|
/**
|
|
5004
5995
|
* Schema for non-empty strings. Validates that a string has at least one
|
|
5005
5996
|
* character.
|
|
@@ -5047,14 +6038,17 @@ export function Option(value) {
|
|
|
5047
6038
|
}
|
|
5048
6039
|
return Effect.fail(new SchemaIssue.InvalidType(ast, Option_.some(input)));
|
|
5049
6040
|
}, {
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
generation: {
|
|
5054
|
-
runtime: `Schema.Option(?)`,
|
|
5055
|
-
Type: `Option.Option<?>`,
|
|
5056
|
-
importDeclaration: `import * as Option from "effect/Option"`
|
|
6041
|
+
representation: {
|
|
6042
|
+
id: "effect/schema/Option",
|
|
6043
|
+
payload: null
|
|
5057
6044
|
},
|
|
6045
|
+
toCode: ({
|
|
6046
|
+
typeParameters
|
|
6047
|
+
}) => ({
|
|
6048
|
+
runtime: `Schema.Option(${typeParameters[0].runtime})`,
|
|
6049
|
+
Type: `Option.Option<${typeParameters[0].Type}>`,
|
|
6050
|
+
importDeclarations: [`import * as Option from "effect/Option"`]
|
|
6051
|
+
}),
|
|
5058
6052
|
expected: "Option",
|
|
5059
6053
|
toCodec: ([value]) => link()(Union([Struct({
|
|
5060
6054
|
_tag: Literal("Some"),
|
|
@@ -5085,6 +6079,25 @@ export function Option(value) {
|
|
|
5085
6079
|
value
|
|
5086
6080
|
});
|
|
5087
6081
|
}
|
|
6082
|
+
/**
|
|
6083
|
+
* Reviver for persisted `Option` declarations.
|
|
6084
|
+
*
|
|
6085
|
+
* **When to use**
|
|
6086
|
+
*
|
|
6087
|
+
* Use when reconstructing documents that may contain schemas created by {@link Option}.
|
|
6088
|
+
*
|
|
6089
|
+
* @see {@link Option} for creating the corresponding schema
|
|
6090
|
+
*
|
|
6091
|
+
* @category Option
|
|
6092
|
+
* @since 4.0.0
|
|
6093
|
+
*/
|
|
6094
|
+
export const OptionReviver = /*#__PURE__*/InternalSchema.makeDeclarationReviver("effect/schema/Option", Null, ({
|
|
6095
|
+
annotations,
|
|
6096
|
+
typeParameters
|
|
6097
|
+
}) => {
|
|
6098
|
+
const schema = Option(typeParameters[0]);
|
|
6099
|
+
return annotations === undefined ? schema : schema.annotate(annotations);
|
|
6100
|
+
});
|
|
5088
6101
|
/**
|
|
5089
6102
|
* Decodes a nullable, required value `T` to a required `Option<T>` value.
|
|
5090
6103
|
*
|
|
@@ -5206,14 +6219,17 @@ export function Result(success, failure) {
|
|
|
5206
6219
|
});
|
|
5207
6220
|
}
|
|
5208
6221
|
}, {
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
generation: {
|
|
5213
|
-
runtime: `Schema.Result(?, ?)`,
|
|
5214
|
-
Type: `Result.Result<?, ?>`,
|
|
5215
|
-
importDeclaration: `import * as Result from "effect/Result"`
|
|
6222
|
+
representation: {
|
|
6223
|
+
id: "effect/schema/Result",
|
|
6224
|
+
payload: null
|
|
5216
6225
|
},
|
|
6226
|
+
toCode: ({
|
|
6227
|
+
typeParameters
|
|
6228
|
+
}) => ({
|
|
6229
|
+
runtime: `Schema.Result(${typeParameters[0].runtime}, ${typeParameters[1].runtime})`,
|
|
6230
|
+
Type: `Result.Result<${typeParameters[0].Type}, ${typeParameters[1].Type}>`,
|
|
6231
|
+
importDeclarations: [`import * as Result from "effect/Result"`]
|
|
6232
|
+
}),
|
|
5217
6233
|
expected: "Result",
|
|
5218
6234
|
toCodec: ([success, failure]) => link()(Union([Struct({
|
|
5219
6235
|
_tag: Literal("Success"),
|
|
@@ -5247,6 +6263,42 @@ export function Result(success, failure) {
|
|
|
5247
6263
|
failure
|
|
5248
6264
|
});
|
|
5249
6265
|
}
|
|
6266
|
+
/**
|
|
6267
|
+
* Reviver for persisted {@link Result} declarations.
|
|
6268
|
+
*
|
|
6269
|
+
* **When to use**
|
|
6270
|
+
*
|
|
6271
|
+
* Use when reconstructing documents that may contain schemas created by {@link Result}.
|
|
6272
|
+
*
|
|
6273
|
+
* @see {@link Result} for creating the corresponding schema
|
|
6274
|
+
*
|
|
6275
|
+
* @category schemas
|
|
6276
|
+
* @since 4.0.0
|
|
6277
|
+
*/
|
|
6278
|
+
export const ResultReviver = /*#__PURE__*/InternalSchema.makeDeclarationReviver("effect/schema/Result", Null, ({
|
|
6279
|
+
annotations,
|
|
6280
|
+
typeParameters
|
|
6281
|
+
}) => {
|
|
6282
|
+
const schema = Result(typeParameters[0], typeParameters[1]);
|
|
6283
|
+
return annotations === undefined ? schema : schema.annotate(annotations);
|
|
6284
|
+
});
|
|
6285
|
+
const RedactedOptionsPayload = /*#__PURE__*/declare(input => {
|
|
6286
|
+
if (!Predicate.isObject(input)) {
|
|
6287
|
+
return false;
|
|
6288
|
+
}
|
|
6289
|
+
const keys = globalThis.Object.keys(input);
|
|
6290
|
+
return keys.length > 0 && keys.every(key => {
|
|
6291
|
+
switch (key) {
|
|
6292
|
+
case "label":
|
|
6293
|
+
return typeof input[key] === "string";
|
|
6294
|
+
case "disallowJsonEncode":
|
|
6295
|
+
return input[key] === true;
|
|
6296
|
+
default:
|
|
6297
|
+
return false;
|
|
6298
|
+
}
|
|
6299
|
+
});
|
|
6300
|
+
});
|
|
6301
|
+
const RedactedRepresentationPayload = /*#__PURE__*/Union([Null, RedactedOptionsPayload]);
|
|
5250
6302
|
/**
|
|
5251
6303
|
* Schema for values that hide sensitive information from error output and
|
|
5252
6304
|
* inspection.
|
|
@@ -5272,7 +6324,17 @@ export function Result(success, failure) {
|
|
|
5272
6324
|
* @since 3.10.0
|
|
5273
6325
|
*/
|
|
5274
6326
|
export function Redacted(value, options) {
|
|
5275
|
-
const
|
|
6327
|
+
const label = typeof options?.label === "string" ? options.label : undefined;
|
|
6328
|
+
const disallowJsonEncode = options?.disallowJsonEncode === true;
|
|
6329
|
+
const normalizedOptions = label !== undefined ? disallowJsonEncode ? {
|
|
6330
|
+
label,
|
|
6331
|
+
disallowJsonEncode: true
|
|
6332
|
+
} : {
|
|
6333
|
+
label
|
|
6334
|
+
} : disallowJsonEncode ? {
|
|
6335
|
+
disallowJsonEncode: true
|
|
6336
|
+
} : undefined;
|
|
6337
|
+
const decodeLabel = label !== undefined ? SchemaParser.decodeUnknownEffect(Literal(label)) : undefined;
|
|
5276
6338
|
const schema = declareConstructor()([value], ([value]) => (input, ast, poptions) => {
|
|
5277
6339
|
if (Redacted_.isRedacted(input)) {
|
|
5278
6340
|
const label = decodeLabel !== undefined ? Effect.mapErrorEager(decodeLabel(input.label, poptions), issue => new SchemaIssue.Pointer(["label"], issue)) : Effect.void;
|
|
@@ -5287,28 +6349,30 @@ export function Redacted(value, options) {
|
|
|
5287
6349
|
}
|
|
5288
6350
|
return Effect.fail(new SchemaIssue.InvalidType(ast, Option_.some(input)));
|
|
5289
6351
|
}, {
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
},
|
|
5294
|
-
generation: {
|
|
5295
|
-
runtime: options !== undefined ? `Schema.Redacted(?, ${format(options)})` : `Schema.Redacted(?)`,
|
|
5296
|
-
Type: `Redacted.Redacted<?>`,
|
|
5297
|
-
importDeclaration: `import * as Redacted from "effect/Redacted"`
|
|
6352
|
+
representation: {
|
|
6353
|
+
id: "effect/schema/Redacted",
|
|
6354
|
+
payload: normalizedOptions ?? null
|
|
5298
6355
|
},
|
|
6356
|
+
toCode: ({
|
|
6357
|
+
typeParameters
|
|
6358
|
+
}) => ({
|
|
6359
|
+
runtime: normalizedOptions !== undefined ? `Schema.Redacted(${typeParameters[0].runtime}, ${format(normalizedOptions)})` : `Schema.Redacted(${typeParameters[0].runtime})`,
|
|
6360
|
+
Type: `Redacted.Redacted<${typeParameters[0].Type}>`,
|
|
6361
|
+
importDeclarations: [`import * as Redacted from "effect/Redacted"`]
|
|
6362
|
+
}),
|
|
5299
6363
|
expected: "Redacted",
|
|
5300
6364
|
toCodecJson: ([value]) => link()(redact(value), {
|
|
5301
6365
|
decode: SchemaGetter.transform(e => Redacted_.make(e, {
|
|
5302
|
-
label
|
|
6366
|
+
label
|
|
5303
6367
|
})),
|
|
5304
|
-
encode:
|
|
6368
|
+
encode: disallowJsonEncode ? SchemaGetter.forbidden(oe => "Cannot serialize Redacted" + (Option_.isSome(oe) && typeof oe.value.label === "string" ? ` with label: "${oe.value.label}"` : "")) : SchemaGetter.transform(Redacted_.value)
|
|
5305
6369
|
}),
|
|
5306
6370
|
toArbitrary: ([value]) => () => ({
|
|
5307
6371
|
arbitrary: value.arbitrary.map(a => Redacted_.make(a, {
|
|
5308
|
-
label
|
|
6372
|
+
label
|
|
5309
6373
|
})),
|
|
5310
6374
|
terminal: value.terminal?.map(a => Redacted_.make(a, {
|
|
5311
|
-
label
|
|
6375
|
+
label
|
|
5312
6376
|
}))
|
|
5313
6377
|
}),
|
|
5314
6378
|
toFormatter: () => globalThis.String,
|
|
@@ -5318,6 +6382,26 @@ export function Redacted(value, options) {
|
|
|
5318
6382
|
value
|
|
5319
6383
|
});
|
|
5320
6384
|
}
|
|
6385
|
+
/**
|
|
6386
|
+
* Reviver for persisted {@link Redacted} declarations.
|
|
6387
|
+
*
|
|
6388
|
+
* **When to use**
|
|
6389
|
+
*
|
|
6390
|
+
* Use when reconstructing documents that may contain schemas created by {@link Redacted}.
|
|
6391
|
+
*
|
|
6392
|
+
* @see {@link Redacted} for creating the corresponding schema
|
|
6393
|
+
*
|
|
6394
|
+
* @category Redacted
|
|
6395
|
+
* @since 4.0.0
|
|
6396
|
+
*/
|
|
6397
|
+
export const RedactedReviver = /*#__PURE__*/InternalSchema.makeDeclarationReviver("effect/schema/Redacted", RedactedRepresentationPayload, ({
|
|
6398
|
+
annotations,
|
|
6399
|
+
payload,
|
|
6400
|
+
typeParameters
|
|
6401
|
+
}) => {
|
|
6402
|
+
const schema = Redacted(typeParameters[0], payload ?? undefined);
|
|
6403
|
+
return annotations === undefined ? schema : schema.annotate(annotations);
|
|
6404
|
+
});
|
|
5321
6405
|
/**
|
|
5322
6406
|
* Middleware that wraps decoded errors in `Redacted`, preventing sensitive
|
|
5323
6407
|
* schema details from leaking in error messages.
|
|
@@ -5388,14 +6472,17 @@ export function CauseReason(error, defect) {
|
|
|
5388
6472
|
return Effect.succeed(input);
|
|
5389
6473
|
}
|
|
5390
6474
|
}, {
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
generation: {
|
|
5395
|
-
runtime: `Schema.CauseReason(?, ?)`,
|
|
5396
|
-
Type: `Cause.Failure<?, ?>`,
|
|
5397
|
-
importDeclaration: `import * as Cause from "effect/Cause"`
|
|
6475
|
+
representation: {
|
|
6476
|
+
id: "effect/schema/CauseReason",
|
|
6477
|
+
payload: null
|
|
5398
6478
|
},
|
|
6479
|
+
toCode: ({
|
|
6480
|
+
typeParameters
|
|
6481
|
+
}) => ({
|
|
6482
|
+
runtime: `Schema.CauseReason(${typeParameters[0].runtime}, ${typeParameters[1].runtime})`,
|
|
6483
|
+
Type: `Cause.Failure<${typeParameters[0].Type}, ${typeParameters[1].Type}>`,
|
|
6484
|
+
importDeclarations: [`import * as Cause from "effect/Cause"`]
|
|
6485
|
+
}),
|
|
5399
6486
|
expected: "Cause.Failure",
|
|
5400
6487
|
toCodec: ([error, defect]) => link()(Union([Struct({
|
|
5401
6488
|
_tag: Literal("Fail"),
|
|
@@ -5428,6 +6515,25 @@ export function CauseReason(error, defect) {
|
|
|
5428
6515
|
defect
|
|
5429
6516
|
});
|
|
5430
6517
|
}
|
|
6518
|
+
/**
|
|
6519
|
+
* Reviver for persisted `CauseReason` declarations.
|
|
6520
|
+
*
|
|
6521
|
+
* **When to use**
|
|
6522
|
+
*
|
|
6523
|
+
* Use when reconstructing documents that may contain schemas created by {@link CauseReason}.
|
|
6524
|
+
*
|
|
6525
|
+
* @see {@link CauseReason} for creating the corresponding schema
|
|
6526
|
+
*
|
|
6527
|
+
* @category CauseReason
|
|
6528
|
+
* @since 4.0.0
|
|
6529
|
+
*/
|
|
6530
|
+
export const CauseReasonReviver = /*#__PURE__*/InternalSchema.makeDeclarationReviver("effect/schema/CauseReason", Null, ({
|
|
6531
|
+
annotations,
|
|
6532
|
+
typeParameters
|
|
6533
|
+
}) => {
|
|
6534
|
+
const schema = CauseReason(typeParameters[0], typeParameters[1]);
|
|
6535
|
+
return annotations === undefined ? schema : schema.annotate(annotations);
|
|
6536
|
+
});
|
|
5431
6537
|
function causeReasonToArbitrary(error, defect) {
|
|
5432
6538
|
return (fc, ctx) => {
|
|
5433
6539
|
const terminal = fc.constant(Cause_.makeInterruptReason());
|
|
@@ -5496,14 +6602,17 @@ export function Cause(error, defect) {
|
|
|
5496
6602
|
});
|
|
5497
6603
|
};
|
|
5498
6604
|
}, {
|
|
5499
|
-
|
|
5500
|
-
|
|
5501
|
-
|
|
5502
|
-
generation: {
|
|
5503
|
-
runtime: `Schema.Cause(?, ?)`,
|
|
5504
|
-
Type: `Cause.Cause<?, ?>`,
|
|
5505
|
-
importDeclaration: `import * as Cause from "effect/Cause"`
|
|
6605
|
+
representation: {
|
|
6606
|
+
id: "effect/schema/Cause",
|
|
6607
|
+
payload: null
|
|
5506
6608
|
},
|
|
6609
|
+
toCode: ({
|
|
6610
|
+
typeParameters
|
|
6611
|
+
}) => ({
|
|
6612
|
+
runtime: `Schema.Cause(${typeParameters[0].runtime}, ${typeParameters[1].runtime})`,
|
|
6613
|
+
Type: `Cause.Cause<${typeParameters[0].Type}, ${typeParameters[1].Type}>`,
|
|
6614
|
+
importDeclarations: [`import * as Cause from "effect/Cause"`]
|
|
6615
|
+
}),
|
|
5507
6616
|
expected: "Cause",
|
|
5508
6617
|
toCodec: ([error, defect]) => link()(ArraySchema(CauseReason(error, defect)), SchemaTransformation.transform({
|
|
5509
6618
|
decode: Cause_.fromReasons,
|
|
@@ -5520,6 +6629,25 @@ export function Cause(error, defect) {
|
|
|
5520
6629
|
defect
|
|
5521
6630
|
});
|
|
5522
6631
|
}
|
|
6632
|
+
/**
|
|
6633
|
+
* Reviver for persisted `Cause` declarations.
|
|
6634
|
+
*
|
|
6635
|
+
* **When to use**
|
|
6636
|
+
*
|
|
6637
|
+
* Use when reconstructing documents that may contain schemas created by {@link Cause}.
|
|
6638
|
+
*
|
|
6639
|
+
* @see {@link Cause} for creating the corresponding schema
|
|
6640
|
+
*
|
|
6641
|
+
* @category Cause
|
|
6642
|
+
* @since 4.0.0
|
|
6643
|
+
*/
|
|
6644
|
+
export const CauseReviver = /*#__PURE__*/InternalSchema.makeDeclarationReviver("effect/schema/Cause", Null, ({
|
|
6645
|
+
annotations,
|
|
6646
|
+
typeParameters
|
|
6647
|
+
}) => {
|
|
6648
|
+
const schema = Cause(typeParameters[0], typeParameters[1]);
|
|
6649
|
+
return annotations === undefined ? schema : schema.annotate(annotations);
|
|
6650
|
+
});
|
|
5523
6651
|
function causeToArbitrary(error, defect) {
|
|
5524
6652
|
return (fc, ctx) => {
|
|
5525
6653
|
const reason = causeReasonToArbitrary(error, defect)(fc, ctx);
|
|
@@ -5536,6 +6664,14 @@ function causeToFormatter(error, defect) {
|
|
|
5536
6664
|
const causeReason = causeReasonToFormatter(error, defect);
|
|
5537
6665
|
return t => `Cause([${t.reasons.map(causeReason).join(", ")}])`;
|
|
5538
6666
|
}
|
|
6667
|
+
const ErrorOptionsPayload = /*#__PURE__*/declare(input => {
|
|
6668
|
+
if (!Predicate.isObject(input)) {
|
|
6669
|
+
return false;
|
|
6670
|
+
}
|
|
6671
|
+
const keys = globalThis.Object.keys(input);
|
|
6672
|
+
return keys.length > 0 && keys.every(key => (key === "includeStack" || key === "excludeCause") && input[key] === true);
|
|
6673
|
+
});
|
|
6674
|
+
const ErrorRepresentationPayload = /*#__PURE__*/Union([Null, ErrorOptionsPayload]);
|
|
5539
6675
|
const getErrorOptionsKey = options => (options?.includeStack === true ? 1 : 0) | (options?.excludeCause === true ? 2 : 0);
|
|
5540
6676
|
const getErrorOptions = key => {
|
|
5541
6677
|
switch (key) {
|
|
@@ -5580,16 +6716,14 @@ export function Error(options) {
|
|
|
5580
6716
|
}
|
|
5581
6717
|
const normalizedOptions = getErrorOptions(key);
|
|
5582
6718
|
const schema = instanceOf(globalThis.Error, {
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
options: normalizedOptions
|
|
5587
|
-
})
|
|
6719
|
+
representation: {
|
|
6720
|
+
id: "effect/schema/Error",
|
|
6721
|
+
payload: normalizedOptions ?? null
|
|
5588
6722
|
},
|
|
5589
|
-
|
|
6723
|
+
toCode: () => ({
|
|
5590
6724
|
runtime: normalizedOptions !== undefined ? `Schema.Error(${format(normalizedOptions)})` : `Schema.Error()`,
|
|
5591
6725
|
Type: `globalThis.Error`
|
|
5592
|
-
},
|
|
6726
|
+
}),
|
|
5593
6727
|
expected: "Error",
|
|
5594
6728
|
toCodecJson: () => link()(JsonError, SchemaTransformation.errorFromJsonError(normalizedOptions)),
|
|
5595
6729
|
toArbitrary: () => fc => fc.string().map(message => new globalThis.Error(message))
|
|
@@ -5597,6 +6731,25 @@ export function Error(options) {
|
|
|
5597
6731
|
errorSchemaCache[key] = schema;
|
|
5598
6732
|
return schema;
|
|
5599
6733
|
}
|
|
6734
|
+
/**
|
|
6735
|
+
* Reviver for persisted {@link Error} declarations.
|
|
6736
|
+
*
|
|
6737
|
+
* **When to use**
|
|
6738
|
+
*
|
|
6739
|
+
* Use when reconstructing documents that may contain schemas created by {@link Error}.
|
|
6740
|
+
*
|
|
6741
|
+
* @see {@link Error} for creating the corresponding schema
|
|
6742
|
+
*
|
|
6743
|
+
* @category Error
|
|
6744
|
+
* @since 4.0.0
|
|
6745
|
+
*/
|
|
6746
|
+
export const ErrorReviver = /*#__PURE__*/InternalSchema.makeDeclarationReviver("effect/schema/Error", ErrorRepresentationPayload, ({
|
|
6747
|
+
annotations,
|
|
6748
|
+
payload
|
|
6749
|
+
}) => {
|
|
6750
|
+
const schema = Error(payload ?? undefined);
|
|
6751
|
+
return annotations === undefined ? schema : schema.annotate(annotations);
|
|
6752
|
+
});
|
|
5600
6753
|
const defectSchemaCache = [];
|
|
5601
6754
|
/**
|
|
5602
6755
|
* Schema for unexpected defect values represented as `unknown` with a JSON
|
|
@@ -5682,14 +6835,17 @@ export function Exit(value, error, defect) {
|
|
|
5682
6835
|
}
|
|
5683
6836
|
};
|
|
5684
6837
|
}, {
|
|
5685
|
-
|
|
5686
|
-
|
|
5687
|
-
|
|
5688
|
-
generation: {
|
|
5689
|
-
runtime: `Schema.Exit(?, ?, ?)`,
|
|
5690
|
-
Type: `Exit.Exit<?, ?, ?>`,
|
|
5691
|
-
importDeclaration: `import * as Exit from "effect/Exit"`
|
|
6838
|
+
representation: {
|
|
6839
|
+
id: "effect/schema/Exit",
|
|
6840
|
+
payload: null
|
|
5692
6841
|
},
|
|
6842
|
+
toCode: ({
|
|
6843
|
+
typeParameters
|
|
6844
|
+
}) => ({
|
|
6845
|
+
runtime: `Schema.Exit(${typeParameters[0].runtime}, ${typeParameters[1].runtime}, ${typeParameters[2].runtime})`,
|
|
6846
|
+
Type: `Exit.Exit<${typeParameters[0].Type}, ${typeParameters[1].Type}, ${typeParameters[2].Type}>`,
|
|
6847
|
+
importDeclarations: [`import * as Exit from "effect/Exit"`]
|
|
6848
|
+
}),
|
|
5693
6849
|
expected: "Exit",
|
|
5694
6850
|
toCodec: ([value, error, defect]) => link()(Union([Struct({
|
|
5695
6851
|
_tag: Literal("Success"),
|
|
@@ -5743,6 +6899,25 @@ export function Exit(value, error, defect) {
|
|
|
5743
6899
|
defect
|
|
5744
6900
|
});
|
|
5745
6901
|
}
|
|
6902
|
+
/**
|
|
6903
|
+
* Reviver for persisted `Exit` declarations.
|
|
6904
|
+
*
|
|
6905
|
+
* **When to use**
|
|
6906
|
+
*
|
|
6907
|
+
* Use when reconstructing documents that may contain schemas created by {@link Exit}.
|
|
6908
|
+
*
|
|
6909
|
+
* @see {@link Exit} for creating the corresponding schema
|
|
6910
|
+
*
|
|
6911
|
+
* @category Exit
|
|
6912
|
+
* @since 4.0.0
|
|
6913
|
+
*/
|
|
6914
|
+
export const ExitReviver = /*#__PURE__*/InternalSchema.makeDeclarationReviver("effect/schema/Exit", Null, ({
|
|
6915
|
+
annotations,
|
|
6916
|
+
typeParameters
|
|
6917
|
+
}) => {
|
|
6918
|
+
const schema = Exit(typeParameters[0], typeParameters[1], typeParameters[2]);
|
|
6919
|
+
return annotations === undefined ? schema : schema.annotate(annotations);
|
|
6920
|
+
});
|
|
5746
6921
|
function oneOfArbitraries(fc, a, b) {
|
|
5747
6922
|
return a === undefined ? b : b === undefined ? a : fc.oneof(a, b);
|
|
5748
6923
|
}
|
|
@@ -5805,13 +6980,16 @@ export function ReadonlyMap(key, value) {
|
|
|
5805
6980
|
return Effect.fail(new SchemaIssue.InvalidType(ast, Option_.some(input)));
|
|
5806
6981
|
};
|
|
5807
6982
|
}, {
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
generation: {
|
|
5812
|
-
runtime: `Schema.ReadonlyMap(?, ?)`,
|
|
5813
|
-
Type: `globalThis.ReadonlyMap<?, ?>`
|
|
6983
|
+
representation: {
|
|
6984
|
+
id: "effect/schema/ReadonlyMap",
|
|
6985
|
+
payload: null
|
|
5814
6986
|
},
|
|
6987
|
+
toCode: ({
|
|
6988
|
+
typeParameters
|
|
6989
|
+
}) => ({
|
|
6990
|
+
runtime: `Schema.ReadonlyMap(${typeParameters[0].runtime}, ${typeParameters[1].runtime})`,
|
|
6991
|
+
Type: `globalThis.ReadonlyMap<${typeParameters[0].Type}, ${typeParameters[1].Type}>`
|
|
6992
|
+
}),
|
|
5815
6993
|
expected: "ReadonlyMap",
|
|
5816
6994
|
toCodec: ([key, value]) => link()(ArraySchema(Tuple([key, value])), SchemaTransformation.transform({
|
|
5817
6995
|
decode: e => new globalThis.Map(e),
|
|
@@ -5833,6 +7011,25 @@ export function ReadonlyMap(key, value) {
|
|
|
5833
7011
|
value
|
|
5834
7012
|
});
|
|
5835
7013
|
}
|
|
7014
|
+
/**
|
|
7015
|
+
* Reviver for persisted {@link ReadonlyMap} declarations.
|
|
7016
|
+
*
|
|
7017
|
+
* **When to use**
|
|
7018
|
+
*
|
|
7019
|
+
* Use when reconstructing documents that may contain schemas created by {@link ReadonlyMap}.
|
|
7020
|
+
*
|
|
7021
|
+
* @see {@link ReadonlyMap} for creating the corresponding schema
|
|
7022
|
+
*
|
|
7023
|
+
* @category ReadonlyMap
|
|
7024
|
+
* @since 4.0.0
|
|
7025
|
+
*/
|
|
7026
|
+
export const ReadonlyMapReviver = /*#__PURE__*/InternalSchema.makeDeclarationReviver("effect/schema/ReadonlyMap", Null, ({
|
|
7027
|
+
annotations,
|
|
7028
|
+
typeParameters
|
|
7029
|
+
}) => {
|
|
7030
|
+
const schema = ReadonlyMap(typeParameters[0], typeParameters[1]);
|
|
7031
|
+
return annotations === undefined ? schema : schema.annotate(annotations);
|
|
7032
|
+
});
|
|
5836
7033
|
/**
|
|
5837
7034
|
* Schema for hash maps whose keys and values conform to the provided schemas.
|
|
5838
7035
|
*
|
|
@@ -5852,14 +7049,17 @@ export function HashMap(key, value) {
|
|
|
5852
7049
|
return Effect.fail(new SchemaIssue.InvalidType(ast, Option_.some(input)));
|
|
5853
7050
|
};
|
|
5854
7051
|
}, {
|
|
5855
|
-
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
generation: {
|
|
5859
|
-
runtime: `Schema.HashMap(?, ?)`,
|
|
5860
|
-
Type: `HashMap.HashMap<?, ?>`,
|
|
5861
|
-
importDeclaration: `import * as HashMap from "effect/HashMap"`
|
|
7052
|
+
representation: {
|
|
7053
|
+
id: "effect/schema/HashMap",
|
|
7054
|
+
payload: null
|
|
5862
7055
|
},
|
|
7056
|
+
toCode: ({
|
|
7057
|
+
typeParameters
|
|
7058
|
+
}) => ({
|
|
7059
|
+
runtime: `Schema.HashMap(${typeParameters[0].runtime}, ${typeParameters[1].runtime})`,
|
|
7060
|
+
Type: `HashMap.HashMap<${typeParameters[0].Type}, ${typeParameters[1].Type}>`,
|
|
7061
|
+
importDeclarations: [`import * as HashMap from "effect/HashMap"`]
|
|
7062
|
+
}),
|
|
5863
7063
|
expected: "HashMap",
|
|
5864
7064
|
toCodec: ([key, value]) => link()(ArraySchema(Tuple([key, value])), SchemaTransformation.transform({
|
|
5865
7065
|
decode: HashMap_.fromIterable,
|
|
@@ -5881,6 +7081,25 @@ export function HashMap(key, value) {
|
|
|
5881
7081
|
value
|
|
5882
7082
|
});
|
|
5883
7083
|
}
|
|
7084
|
+
/**
|
|
7085
|
+
* Reviver for persisted `HashMap` declarations.
|
|
7086
|
+
*
|
|
7087
|
+
* **When to use**
|
|
7088
|
+
*
|
|
7089
|
+
* Use when reconstructing documents that may contain schemas created by {@link HashMap}.
|
|
7090
|
+
*
|
|
7091
|
+
* @see {@link HashMap} for creating the corresponding schema
|
|
7092
|
+
*
|
|
7093
|
+
* @category HashMap
|
|
7094
|
+
* @since 4.0.0
|
|
7095
|
+
*/
|
|
7096
|
+
export const HashMapReviver = /*#__PURE__*/InternalSchema.makeDeclarationReviver("effect/schema/HashMap", Null, ({
|
|
7097
|
+
annotations,
|
|
7098
|
+
typeParameters
|
|
7099
|
+
}) => {
|
|
7100
|
+
const schema = HashMap(typeParameters[0], typeParameters[1]);
|
|
7101
|
+
return annotations === undefined ? schema : schema.annotate(annotations);
|
|
7102
|
+
});
|
|
5884
7103
|
/**
|
|
5885
7104
|
* Schema for readonly sets whose values conform to the provided element schema.
|
|
5886
7105
|
*
|
|
@@ -5900,13 +7119,16 @@ export function ReadonlySet(value) {
|
|
|
5900
7119
|
return Effect.fail(new SchemaIssue.InvalidType(ast, Option_.some(input)));
|
|
5901
7120
|
};
|
|
5902
7121
|
}, {
|
|
5903
|
-
|
|
5904
|
-
|
|
5905
|
-
|
|
5906
|
-
generation: {
|
|
5907
|
-
runtime: `Schema.ReadonlySet(?)`,
|
|
5908
|
-
Type: `globalThis.ReadonlySet<?>`
|
|
7122
|
+
representation: {
|
|
7123
|
+
id: "effect/schema/ReadonlySet",
|
|
7124
|
+
payload: null
|
|
5909
7125
|
},
|
|
7126
|
+
toCode: ({
|
|
7127
|
+
typeParameters
|
|
7128
|
+
}) => ({
|
|
7129
|
+
runtime: `Schema.ReadonlySet(${typeParameters[0].runtime})`,
|
|
7130
|
+
Type: `globalThis.ReadonlySet<${typeParameters[0].Type}>`
|
|
7131
|
+
}),
|
|
5910
7132
|
expected: "ReadonlySet",
|
|
5911
7133
|
toCodec: ([value]) => link()(ArraySchema(value), SchemaTransformation.transform({
|
|
5912
7134
|
decode: e => new globalThis.Set(e),
|
|
@@ -5927,6 +7149,25 @@ export function ReadonlySet(value) {
|
|
|
5927
7149
|
value
|
|
5928
7150
|
});
|
|
5929
7151
|
}
|
|
7152
|
+
/**
|
|
7153
|
+
* Reviver for persisted {@link ReadonlySet} declarations.
|
|
7154
|
+
*
|
|
7155
|
+
* **When to use**
|
|
7156
|
+
*
|
|
7157
|
+
* Use when reconstructing documents that may contain schemas created by {@link ReadonlySet}.
|
|
7158
|
+
*
|
|
7159
|
+
* @see {@link ReadonlySet} for creating the corresponding schema
|
|
7160
|
+
*
|
|
7161
|
+
* @category ReadonlySet
|
|
7162
|
+
* @since 4.0.0
|
|
7163
|
+
*/
|
|
7164
|
+
export const ReadonlySetReviver = /*#__PURE__*/InternalSchema.makeDeclarationReviver("effect/schema/ReadonlySet", Null, ({
|
|
7165
|
+
annotations,
|
|
7166
|
+
typeParameters
|
|
7167
|
+
}) => {
|
|
7168
|
+
const schema = ReadonlySet(typeParameters[0]);
|
|
7169
|
+
return annotations === undefined ? schema : schema.annotate(annotations);
|
|
7170
|
+
});
|
|
5930
7171
|
/**
|
|
5931
7172
|
* Schema for hash sets whose values conform to the provided element schema.
|
|
5932
7173
|
*
|
|
@@ -5946,13 +7187,16 @@ export function HashSet(value) {
|
|
|
5946
7187
|
return Effect.fail(new SchemaIssue.InvalidType(ast, Option_.some(input)));
|
|
5947
7188
|
};
|
|
5948
7189
|
}, {
|
|
5949
|
-
|
|
5950
|
-
|
|
5951
|
-
|
|
5952
|
-
generation: {
|
|
5953
|
-
runtime: `Schema.HashSet(?)`,
|
|
5954
|
-
Type: `HashSet.HashSet<?>`
|
|
7190
|
+
representation: {
|
|
7191
|
+
id: "effect/schema/HashSet",
|
|
7192
|
+
payload: null
|
|
5955
7193
|
},
|
|
7194
|
+
toCode: ({
|
|
7195
|
+
typeParameters
|
|
7196
|
+
}) => ({
|
|
7197
|
+
runtime: `Schema.HashSet(${typeParameters[0].runtime})`,
|
|
7198
|
+
Type: `HashSet.HashSet<${typeParameters[0].Type}>`
|
|
7199
|
+
}),
|
|
5956
7200
|
expected: "HashSet",
|
|
5957
7201
|
toCodec: ([value]) => link()(ArraySchema(value), SchemaTransformation.transform({
|
|
5958
7202
|
decode: HashSet_.fromIterable,
|
|
@@ -5973,6 +7217,25 @@ export function HashSet(value) {
|
|
|
5973
7217
|
value
|
|
5974
7218
|
});
|
|
5975
7219
|
}
|
|
7220
|
+
/**
|
|
7221
|
+
* Reviver for persisted `HashSet` declarations.
|
|
7222
|
+
*
|
|
7223
|
+
* **When to use**
|
|
7224
|
+
*
|
|
7225
|
+
* Use when reconstructing documents that may contain schemas created by {@link HashSet}.
|
|
7226
|
+
*
|
|
7227
|
+
* @see {@link HashSet} for creating the corresponding schema
|
|
7228
|
+
*
|
|
7229
|
+
* @category HashSet
|
|
7230
|
+
* @since 4.0.0
|
|
7231
|
+
*/
|
|
7232
|
+
export const HashSetReviver = /*#__PURE__*/InternalSchema.makeDeclarationReviver("effect/schema/HashSet", Null, ({
|
|
7233
|
+
annotations,
|
|
7234
|
+
typeParameters
|
|
7235
|
+
}) => {
|
|
7236
|
+
const schema = HashSet(typeParameters[0]);
|
|
7237
|
+
return annotations === undefined ? schema : schema.annotate(annotations);
|
|
7238
|
+
});
|
|
5976
7239
|
/**
|
|
5977
7240
|
* Schema for chunks whose values conform to the provided element schema.
|
|
5978
7241
|
*
|
|
@@ -5992,13 +7255,16 @@ export function Chunk(value) {
|
|
|
5992
7255
|
return Effect.fail(new SchemaIssue.InvalidType(ast, Option_.some(input)));
|
|
5993
7256
|
};
|
|
5994
7257
|
}, {
|
|
5995
|
-
|
|
5996
|
-
|
|
5997
|
-
|
|
5998
|
-
generation: {
|
|
5999
|
-
runtime: `Schema.Chunk(?)`,
|
|
6000
|
-
Type: `Chunk.Chunk<?>`
|
|
7258
|
+
representation: {
|
|
7259
|
+
id: "effect/schema/Chunk",
|
|
7260
|
+
payload: null
|
|
6001
7261
|
},
|
|
7262
|
+
toCode: ({
|
|
7263
|
+
typeParameters
|
|
7264
|
+
}) => ({
|
|
7265
|
+
runtime: `Schema.Chunk(${typeParameters[0].runtime})`,
|
|
7266
|
+
Type: `Chunk.Chunk<${typeParameters[0].Type}>`
|
|
7267
|
+
}),
|
|
6002
7268
|
expected: "Chunk",
|
|
6003
7269
|
toCodec: ([value]) => link()(ArraySchema(value), SchemaTransformation.transform({
|
|
6004
7270
|
decode: Chunk_.fromIterable,
|
|
@@ -6019,6 +7285,25 @@ export function Chunk(value) {
|
|
|
6019
7285
|
value
|
|
6020
7286
|
});
|
|
6021
7287
|
}
|
|
7288
|
+
/**
|
|
7289
|
+
* Reviver for persisted {@link Chunk} declarations.
|
|
7290
|
+
*
|
|
7291
|
+
* **When to use**
|
|
7292
|
+
*
|
|
7293
|
+
* Use when reconstructing documents that may contain schemas created by {@link Chunk}.
|
|
7294
|
+
*
|
|
7295
|
+
* @see {@link Chunk} for creating the corresponding schema
|
|
7296
|
+
*
|
|
7297
|
+
* @category Chunk
|
|
7298
|
+
* @since 4.0.0
|
|
7299
|
+
*/
|
|
7300
|
+
export const ChunkReviver = /*#__PURE__*/InternalSchema.makeDeclarationReviver("effect/schema/Chunk", Null, ({
|
|
7301
|
+
annotations,
|
|
7302
|
+
typeParameters
|
|
7303
|
+
}) => {
|
|
7304
|
+
const schema = Chunk(typeParameters[0]);
|
|
7305
|
+
return annotations === undefined ? schema : schema.annotate(annotations);
|
|
7306
|
+
});
|
|
6022
7307
|
/**
|
|
6023
7308
|
* Schema for JavaScript `RegExp` objects.
|
|
6024
7309
|
*
|
|
@@ -6030,13 +7315,14 @@ export function Chunk(value) {
|
|
|
6030
7315
|
* @since 4.0.0
|
|
6031
7316
|
*/
|
|
6032
7317
|
export const RegExp = /*#__PURE__*/instanceOf(globalThis.RegExp, {
|
|
6033
|
-
|
|
6034
|
-
|
|
7318
|
+
representation: {
|
|
7319
|
+
id: "effect/schema/RegExp",
|
|
7320
|
+
payload: null
|
|
6035
7321
|
},
|
|
6036
|
-
|
|
7322
|
+
toCode: () => ({
|
|
6037
7323
|
runtime: `Schema.RegExp`,
|
|
6038
7324
|
Type: `globalThis.RegExp`
|
|
6039
|
-
},
|
|
7325
|
+
}),
|
|
6040
7326
|
expected: "RegExp",
|
|
6041
7327
|
toCodecJson: () => link()(Struct({
|
|
6042
7328
|
source: String,
|
|
@@ -6060,6 +7346,19 @@ export const RegExp = /*#__PURE__*/instanceOf(globalThis.RegExp, {
|
|
|
6060
7346
|
}).map(flags => flags.join(""))).map(([source, flags]) => new globalThis.RegExp(source, flags)),
|
|
6061
7347
|
toEquivalence: () => (a, b) => a.source === b.source && a.flags === b.flags
|
|
6062
7348
|
});
|
|
7349
|
+
/**
|
|
7350
|
+
* Reviver for persisted `RegExp` declarations.
|
|
7351
|
+
*
|
|
7352
|
+
* **When to use**
|
|
7353
|
+
*
|
|
7354
|
+
* Use when reconstructing documents that may contain the {@link RegExp} schema.
|
|
7355
|
+
*
|
|
7356
|
+
* @see {@link RegExp} for the corresponding schema
|
|
7357
|
+
*
|
|
7358
|
+
* @category RegExp
|
|
7359
|
+
* @since 4.0.0
|
|
7360
|
+
*/
|
|
7361
|
+
export const RegExpReviver = /*#__PURE__*/makeFixedDeclarationReviver("effect/schema/RegExp", RegExp);
|
|
6063
7362
|
const URLString = /*#__PURE__*/String.annotate({
|
|
6064
7363
|
expected: "a string that will be decoded as a URL"
|
|
6065
7364
|
});
|
|
@@ -6076,18 +7375,32 @@ const URLString = /*#__PURE__*/String.annotate({
|
|
|
6076
7375
|
* @since 4.0.0
|
|
6077
7376
|
*/
|
|
6078
7377
|
export const URL = /*#__PURE__*/instanceOf(globalThis.URL, {
|
|
6079
|
-
|
|
6080
|
-
|
|
7378
|
+
representation: {
|
|
7379
|
+
id: "effect/schema/URL",
|
|
7380
|
+
payload: null
|
|
6081
7381
|
},
|
|
6082
|
-
|
|
7382
|
+
toCode: () => ({
|
|
6083
7383
|
runtime: `Schema.URL`,
|
|
6084
7384
|
Type: `globalThis.URL`
|
|
6085
|
-
},
|
|
7385
|
+
}),
|
|
6086
7386
|
expected: "URL",
|
|
6087
7387
|
toCodecJson: () => link()(URLString, SchemaTransformation.urlFromString),
|
|
6088
7388
|
toArbitrary: () => fc => fc.webUrl().map(s => new globalThis.URL(s)),
|
|
6089
7389
|
toEquivalence: () => (a, b) => a.toString() === b.toString()
|
|
6090
7390
|
});
|
|
7391
|
+
/**
|
|
7392
|
+
* Reviver for persisted `URL` declarations.
|
|
7393
|
+
*
|
|
7394
|
+
* **When to use**
|
|
7395
|
+
*
|
|
7396
|
+
* Use when reconstructing documents that may contain the {@link URL} schema.
|
|
7397
|
+
*
|
|
7398
|
+
* @see {@link URL} for the corresponding schema
|
|
7399
|
+
*
|
|
7400
|
+
* @category URL
|
|
7401
|
+
* @since 4.0.0
|
|
7402
|
+
*/
|
|
7403
|
+
export const URLReviver = /*#__PURE__*/makeFixedDeclarationReviver("effect/schema/URL", URL);
|
|
6091
7404
|
/**
|
|
6092
7405
|
* Schema that decodes a `string` into a `URL`.
|
|
6093
7406
|
*
|
|
@@ -6103,14 +7416,10 @@ export const URL = /*#__PURE__*/instanceOf(globalThis.URL, {
|
|
|
6103
7416
|
* @since 4.0.0
|
|
6104
7417
|
*/
|
|
6105
7418
|
export const URLFromString = /*#__PURE__*/URLString.pipe(/*#__PURE__*/decodeTo(URL, SchemaTransformation.urlFromString));
|
|
6106
|
-
function dateArbitraryConstraints(
|
|
7419
|
+
function dateArbitraryConstraints(ordered, base, toDate) {
|
|
6107
7420
|
const out = {
|
|
6108
7421
|
...base
|
|
6109
7422
|
};
|
|
6110
|
-
delete out.valid;
|
|
6111
|
-
if (base?.valid || constraint?.valid) {
|
|
6112
|
-
out.noInvalidDate = true;
|
|
6113
|
-
}
|
|
6114
7423
|
if (ordered?.minimum !== undefined) {
|
|
6115
7424
|
const minimum = toDate === undefined ? ordered.minimum : toDate(ordered.minimum);
|
|
6116
7425
|
const nextMin = ordered.exclusiveMinimum ? new globalThis.Date(minimum.getTime() + 1) : minimum;
|
|
@@ -6128,21 +7437,20 @@ function dateArbitraryConstraints(constraint, ordered, base, toDate) {
|
|
|
6128
7437
|
return out;
|
|
6129
7438
|
}
|
|
6130
7439
|
const DateString = /*#__PURE__*/String.annotate({
|
|
6131
|
-
expected: "a string
|
|
7440
|
+
expected: "a string that will be decoded as a Date"
|
|
6132
7441
|
});
|
|
6133
7442
|
/**
|
|
6134
|
-
* Schema for JavaScript `Date` objects.
|
|
7443
|
+
* Schema for valid JavaScript `Date` objects.
|
|
6135
7444
|
*
|
|
6136
7445
|
* **When to use**
|
|
6137
7446
|
*
|
|
6138
|
-
* Use to validate in-memory values that must already be JavaScript date
|
|
7447
|
+
* Use to validate in-memory values that must already be valid JavaScript date
|
|
6139
7448
|
* objects.
|
|
6140
7449
|
*
|
|
6141
7450
|
* **Details**
|
|
6142
7451
|
*
|
|
6143
|
-
* This schema accepts
|
|
6144
|
-
* JSON serializer encodes
|
|
6145
|
-
* as `"Invalid Date"`.
|
|
7452
|
+
* This schema accepts `Date` instances whose timestamp is not `NaN`. The
|
|
7453
|
+
* default JSON serializer encodes dates as ISO 8601 strings.
|
|
6146
7454
|
*
|
|
6147
7455
|
* **Example** (Defining a Date schema)
|
|
6148
7456
|
*
|
|
@@ -6153,25 +7461,40 @@ const DateString = /*#__PURE__*/String.annotate({
|
|
|
6153
7461
|
* // => Date { 2024-01-01T00:00:00.000Z }
|
|
6154
7462
|
* ```
|
|
6155
7463
|
*
|
|
6156
|
-
* @see {@link DateValid} for accepting only valid Date instances
|
|
6157
7464
|
* @see {@link DateFromString} for decoding strings into Date instances
|
|
6158
7465
|
* @see {@link DateFromMillis} for decoding epoch milliseconds into Date instances
|
|
6159
7466
|
*
|
|
6160
7467
|
* @category Date
|
|
6161
7468
|
* @since 4.0.0
|
|
6162
7469
|
*/
|
|
6163
|
-
export const Date = /*#__PURE__*/
|
|
6164
|
-
|
|
6165
|
-
|
|
7470
|
+
export const Date = /*#__PURE__*/declare(input => input instanceof globalThis.Date && !globalThis.Number.isNaN(input.getTime()), {
|
|
7471
|
+
representation: {
|
|
7472
|
+
id: "effect/schema/Date",
|
|
7473
|
+
payload: null
|
|
6166
7474
|
},
|
|
6167
|
-
|
|
7475
|
+
toCode: () => ({
|
|
6168
7476
|
runtime: `Schema.Date`,
|
|
6169
7477
|
Type: `globalThis.Date`
|
|
6170
|
-
},
|
|
6171
|
-
expected: "Date",
|
|
7478
|
+
}),
|
|
7479
|
+
expected: "a valid Date",
|
|
6172
7480
|
toCodecJson: () => link()(DateString, SchemaTransformation.dateFromString),
|
|
6173
|
-
toArbitrary: () => (fc, ctx) => fc.date(dateArbitraryConstraints(ctx?.constraint
|
|
7481
|
+
toArbitrary: () => (fc, ctx) => fc.date(dateArbitraryConstraints(ctx?.constraint?.ordered?.order === Order.Date ? ctx.constraint.ordered : undefined, {
|
|
7482
|
+
noInvalidDate: true
|
|
7483
|
+
}))
|
|
6174
7484
|
});
|
|
7485
|
+
/**
|
|
7486
|
+
* Reviver for persisted `Date` declarations.
|
|
7487
|
+
*
|
|
7488
|
+
* **When to use**
|
|
7489
|
+
*
|
|
7490
|
+
* Use when reconstructing documents that may contain the {@link Date} schema.
|
|
7491
|
+
*
|
|
7492
|
+
* @see {@link Date} for the corresponding schema
|
|
7493
|
+
*
|
|
7494
|
+
* @category Date
|
|
7495
|
+
* @since 4.0.0
|
|
7496
|
+
*/
|
|
7497
|
+
export const DateReviver = /*#__PURE__*/makeFixedDeclarationReviver("effect/schema/Date", Date);
|
|
6175
7498
|
/**
|
|
6176
7499
|
* Schema that decodes a string into a JavaScript `Date`.
|
|
6177
7500
|
*
|
|
@@ -6186,17 +7509,13 @@ export const Date = /*#__PURE__*/instanceOf(globalThis.Date, {
|
|
|
6186
7509
|
* The string is passed to JavaScript `Date` construction.
|
|
6187
7510
|
*
|
|
6188
7511
|
* Encoding:
|
|
6189
|
-
* A
|
|
6190
|
-
* `"Invalid Date"`.
|
|
6191
|
-
*
|
|
6192
|
-
* **Gotchas**
|
|
7512
|
+
* A `Date` is encoded as an ISO string.
|
|
6193
7513
|
*
|
|
6194
|
-
* Invalid date strings
|
|
7514
|
+
* Invalid date strings fail decoding.
|
|
6195
7515
|
*
|
|
6196
7516
|
* @see {@link DateFromMillis} for decoding epoch milliseconds into Date instances
|
|
6197
7517
|
* @see {@link DateTimeUtcFromString} for decoding date-time strings into UTC values
|
|
6198
7518
|
* @see {@link Date} for accepting Date instances directly
|
|
6199
|
-
* @see {@link DateValid} for rejecting invalid Date instances
|
|
6200
7519
|
*
|
|
6201
7520
|
* @category Date
|
|
6202
7521
|
* @since 3.10.0
|
|
@@ -6213,15 +7532,16 @@ export const DateFromString = /*#__PURE__*/DateString.pipe(/*#__PURE__*/decodeTo
|
|
|
6213
7532
|
* **Details**
|
|
6214
7533
|
*
|
|
6215
7534
|
* Decoding:
|
|
6216
|
-
* A number of milliseconds since the Unix epoch is decoded as a
|
|
7535
|
+
* A safe integer number of milliseconds since the Unix epoch is decoded as a
|
|
7536
|
+
* `Date`.
|
|
6217
7537
|
*
|
|
6218
7538
|
* Encoding:
|
|
6219
7539
|
* A `Date` is encoded as its millisecond timestamp.
|
|
6220
7540
|
*
|
|
6221
7541
|
* **Gotchas**
|
|
6222
7542
|
*
|
|
6223
|
-
*
|
|
6224
|
-
*
|
|
7543
|
+
* JavaScript `Date` supports a narrower range than safe integers, so integers
|
|
7544
|
+
* outside the supported `Date` range fail decoding.
|
|
6225
7545
|
*
|
|
6226
7546
|
* @see {@link DateFromString} for decoding string-encoded dates
|
|
6227
7547
|
* @see {@link DateTimeUtcFromMillis} for decoding epoch milliseconds into UTC values
|
|
@@ -6229,19 +7549,7 @@ export const DateFromString = /*#__PURE__*/DateString.pipe(/*#__PURE__*/decodeTo
|
|
|
6229
7549
|
* @category Date
|
|
6230
7550
|
* @since 4.0.0
|
|
6231
7551
|
*/
|
|
6232
|
-
export const DateFromMillis = /*#__PURE__*/
|
|
6233
|
-
/**
|
|
6234
|
-
* Schema for **valid** JavaScript `Date` objects.
|
|
6235
|
-
*
|
|
6236
|
-
* **Details**
|
|
6237
|
-
*
|
|
6238
|
-
* This schema accepts `Date` instances but rejects invalid dates (such as `new
|
|
6239
|
-
* Date("invalid")`).
|
|
6240
|
-
*
|
|
6241
|
-
* @category Date
|
|
6242
|
-
* @since 4.0.0
|
|
6243
|
-
*/
|
|
6244
|
-
export const DateValid = /*#__PURE__*/Date.check(/*#__PURE__*/isDateValid());
|
|
7552
|
+
export const DateFromMillis = /*#__PURE__*/Int.pipe(/*#__PURE__*/decodeTo(Date, SchemaTransformation.dateFromMillis));
|
|
6245
7553
|
/**
|
|
6246
7554
|
* Schema for `Duration` values.
|
|
6247
7555
|
*
|
|
@@ -6264,14 +7572,15 @@ export const DateValid = /*#__PURE__*/Date.check(/*#__PURE__*/isDateValid());
|
|
|
6264
7572
|
* @since 3.10.0
|
|
6265
7573
|
*/
|
|
6266
7574
|
export const Duration = /*#__PURE__*/declare(Duration_.isDuration, {
|
|
6267
|
-
|
|
6268
|
-
|
|
7575
|
+
representation: {
|
|
7576
|
+
id: "effect/schema/Duration",
|
|
7577
|
+
payload: null
|
|
6269
7578
|
},
|
|
6270
|
-
|
|
7579
|
+
toCode: () => ({
|
|
6271
7580
|
runtime: `Schema.Duration`,
|
|
6272
7581
|
Type: `Duration.Duration`,
|
|
6273
|
-
|
|
6274
|
-
},
|
|
7582
|
+
importDeclarations: [`import * as Duration from "effect/Duration"`]
|
|
7583
|
+
}),
|
|
6275
7584
|
expected: "Duration",
|
|
6276
7585
|
toCodecJson: () => link()(Union([Struct({
|
|
6277
7586
|
_tag: Literal("Infinity")
|
|
@@ -6323,6 +7632,19 @@ export const Duration = /*#__PURE__*/declare(Duration_.isDuration, {
|
|
|
6323
7632
|
toFormatter: () => globalThis.String,
|
|
6324
7633
|
toEquivalence: () => Duration_.Equivalence
|
|
6325
7634
|
});
|
|
7635
|
+
/**
|
|
7636
|
+
* Reviver for persisted {@link Duration} declarations.
|
|
7637
|
+
*
|
|
7638
|
+
* **When to use**
|
|
7639
|
+
*
|
|
7640
|
+
* Use when reconstructing documents that may contain the {@link Duration} schema.
|
|
7641
|
+
*
|
|
7642
|
+
* @see {@link Duration} for the corresponding schema
|
|
7643
|
+
*
|
|
7644
|
+
* @category Duration
|
|
7645
|
+
* @since 4.0.0
|
|
7646
|
+
*/
|
|
7647
|
+
export const DurationReviver = /*#__PURE__*/makeFixedDeclarationReviver("effect/schema/Duration", Duration);
|
|
6326
7648
|
const DurationString = /*#__PURE__*/String.annotate({
|
|
6327
7649
|
expected: "a string that will be decoded as a Duration"
|
|
6328
7650
|
});
|
|
@@ -6342,44 +7664,44 @@ const DurationString = /*#__PURE__*/String.annotate({
|
|
|
6342
7664
|
* @since 4.0.0
|
|
6343
7665
|
*/
|
|
6344
7666
|
export const DurationFromString = /*#__PURE__*/DurationString.pipe(/*#__PURE__*/decodeTo(Duration, SchemaTransformation.durationFromString));
|
|
6345
|
-
const bigint0 = /*#__PURE__*/globalThis.BigInt(0);
|
|
6346
7667
|
/**
|
|
6347
|
-
* Schema that decodes a
|
|
6348
|
-
*
|
|
7668
|
+
* Schema that decodes a `bigint` into a `Duration`, treating the bigint as
|
|
7669
|
+
* nanoseconds.
|
|
6349
7670
|
*
|
|
6350
7671
|
* **Details**
|
|
6351
7672
|
*
|
|
6352
7673
|
* Decoding:
|
|
6353
|
-
* A
|
|
7674
|
+
* A `bigint` representing nanoseconds is decoded as a `Duration`.
|
|
6354
7675
|
*
|
|
6355
7676
|
* Encoding:
|
|
6356
|
-
* Finite durations are encoded as a
|
|
6357
|
-
*
|
|
6358
|
-
* `Duration.infinity`.
|
|
7677
|
+
* Finite durations are encoded as a `bigint` number of nanoseconds. Encoding
|
|
7678
|
+
* fails when the duration cannot be represented as nanoseconds, such as
|
|
7679
|
+
* `Duration.infinity` or `Duration.negativeInfinity`.
|
|
6359
7680
|
*
|
|
6360
7681
|
* @category Duration
|
|
6361
7682
|
* @since 3.10.0
|
|
6362
7683
|
*/
|
|
6363
|
-
export const DurationFromNanos = /*#__PURE__*/BigInt.
|
|
7684
|
+
export const DurationFromNanos = /*#__PURE__*/BigInt.pipe(/*#__PURE__*/decodeTo(Duration, SchemaTransformation.durationFromNanos));
|
|
6364
7685
|
/**
|
|
6365
|
-
* Schema that decodes a
|
|
6366
|
-
* integer into a `Duration`, treating the integer value as the duration in
|
|
7686
|
+
* Schema that decodes a number into a `Duration`, treating the number as
|
|
6367
7687
|
* milliseconds.
|
|
6368
7688
|
*
|
|
6369
7689
|
* **Details**
|
|
6370
7690
|
*
|
|
6371
7691
|
* Decoding:
|
|
6372
|
-
* - A
|
|
6373
|
-
* decoded as a `Duration`
|
|
7692
|
+
* - A finite or infinite number is decoded as a `Duration`
|
|
6374
7693
|
*
|
|
6375
7694
|
* Encoding:
|
|
6376
|
-
* - A `Duration` is encoded to a
|
|
6377
|
-
*
|
|
7695
|
+
* - A `Duration` is encoded to a finite or infinite number of milliseconds
|
|
7696
|
+
*
|
|
7697
|
+
* **Gotchas**
|
|
7698
|
+
*
|
|
7699
|
+
* `NaN` is decoded as `Duration.zero`, matching `Duration.millis`.
|
|
6378
7700
|
*
|
|
6379
7701
|
* @category Duration
|
|
6380
7702
|
* @since 3.10.0
|
|
6381
7703
|
*/
|
|
6382
|
-
export const DurationFromMillis = /*#__PURE__*/Number.
|
|
7704
|
+
export const DurationFromMillis = /*#__PURE__*/Number.pipe(/*#__PURE__*/decodeTo(Duration, SchemaTransformation.durationFromMillis));
|
|
6383
7705
|
const BigDecimalString = /*#__PURE__*/String.annotate({
|
|
6384
7706
|
expected: "a string that will be decoded as a BigDecimal"
|
|
6385
7707
|
});
|
|
@@ -6450,14 +7772,15 @@ function bigDecimalScaleConstraints(ordered) {
|
|
|
6450
7772
|
* @since 3.10.0
|
|
6451
7773
|
*/
|
|
6452
7774
|
export const BigDecimal = /*#__PURE__*/declare(BigDecimal_.isBigDecimal, {
|
|
6453
|
-
|
|
6454
|
-
|
|
7775
|
+
representation: {
|
|
7776
|
+
id: "effect/schema/BigDecimal",
|
|
7777
|
+
payload: null
|
|
6455
7778
|
},
|
|
6456
|
-
|
|
7779
|
+
toCode: () => ({
|
|
6457
7780
|
runtime: `Schema.BigDecimal`,
|
|
6458
7781
|
Type: `BigDecimal.BigDecimal`,
|
|
6459
|
-
|
|
6460
|
-
},
|
|
7782
|
+
importDeclarations: [`import * as BigDecimal from "effect/BigDecimal"`]
|
|
7783
|
+
}),
|
|
6461
7784
|
expected: "BigDecimal",
|
|
6462
7785
|
toCodecJson: () => link()(BigDecimalString, SchemaTransformation.bigDecimalFromString),
|
|
6463
7786
|
toArbitrary: () => (fc, ctx) => {
|
|
@@ -6479,6 +7802,19 @@ export const BigDecimal = /*#__PURE__*/declare(BigDecimal_.isBigDecimal, {
|
|
|
6479
7802
|
toFormatter: () => bd => BigDecimal_.format(bd),
|
|
6480
7803
|
toEquivalence: () => BigDecimal_.Equivalence
|
|
6481
7804
|
});
|
|
7805
|
+
/**
|
|
7806
|
+
* Reviver for persisted {@link BigDecimal} declarations.
|
|
7807
|
+
*
|
|
7808
|
+
* **When to use**
|
|
7809
|
+
*
|
|
7810
|
+
* Use when reconstructing documents that may contain the {@link BigDecimal} schema.
|
|
7811
|
+
*
|
|
7812
|
+
* @see {@link BigDecimal} for the corresponding schema
|
|
7813
|
+
*
|
|
7814
|
+
* @category BigDecimal
|
|
7815
|
+
* @since 4.0.0
|
|
7816
|
+
*/
|
|
7817
|
+
export const BigDecimalReviver = /*#__PURE__*/makeFixedDeclarationReviver("effect/schema/BigDecimal", BigDecimal);
|
|
6482
7818
|
/**
|
|
6483
7819
|
* Schema that parses a string into a `BigDecimal`.
|
|
6484
7820
|
*
|
|
@@ -6507,6 +7843,10 @@ export const BigDecimal = /*#__PURE__*/declare(BigDecimal_.isBigDecimal, {
|
|
|
6507
7843
|
* @since 4.0.0
|
|
6508
7844
|
*/
|
|
6509
7845
|
export const BigDecimalFromString = /*#__PURE__*/BigDecimalString.pipe(/*#__PURE__*/decodeTo(BigDecimal, SchemaTransformation.bigDecimalFromString));
|
|
7846
|
+
const JsonString = /*#__PURE__*/String.annotate({
|
|
7847
|
+
expected: "a string that will be decoded as JSON",
|
|
7848
|
+
contentMediaType: "application/json"
|
|
7849
|
+
});
|
|
6510
7850
|
/**
|
|
6511
7851
|
* Schema that decodes a JSON-encoded string into an `unknown` value.
|
|
6512
7852
|
*
|
|
@@ -6545,12 +7885,6 @@ export const UnknownFromJsonString = /*#__PURE__*/fromJsonString(Unknown);
|
|
|
6545
7885
|
* The resulting schema first parses the input string as JSON, and then runs the
|
|
6546
7886
|
* provided schema on the parsed result.
|
|
6547
7887
|
*
|
|
6548
|
-
* JSON Schema generation:
|
|
6549
|
-
*
|
|
6550
|
-
* When using `fromJsonString` with `draft-2020-12` or `openApi3.1`, the
|
|
6551
|
-
* resulting schema will be a JSON Schema with a `contentSchema` property that
|
|
6552
|
-
* contains the JSON Schema for the given schema.
|
|
6553
|
-
*
|
|
6554
7888
|
* **Example** (Decoding JSON strings with a schema)
|
|
6555
7889
|
*
|
|
6556
7890
|
* ```ts
|
|
@@ -6563,51 +7897,11 @@ export const UnknownFromJsonString = /*#__PURE__*/fromJsonString(Unknown);
|
|
|
6563
7897
|
* // => { a: 1 }
|
|
6564
7898
|
* ```
|
|
6565
7899
|
*
|
|
6566
|
-
* **Example** (Emitting JSON Schema for a JSON string decoder)
|
|
6567
|
-
*
|
|
6568
|
-
* ```ts
|
|
6569
|
-
* import { Schema } from "effect"
|
|
6570
|
-
*
|
|
6571
|
-
* const original = Schema.Struct({ a: Schema.String })
|
|
6572
|
-
* const schema = Schema.fromJsonString(original)
|
|
6573
|
-
*
|
|
6574
|
-
* const document = Schema.toJsonSchemaDocument(schema)
|
|
6575
|
-
*
|
|
6576
|
-
* console.log(JSON.stringify(document, null, 2))
|
|
6577
|
-
* // {
|
|
6578
|
-
* // "source": "draft-2020-12",
|
|
6579
|
-
* // "schema": {
|
|
6580
|
-
* // "type": "string",
|
|
6581
|
-
* // "contentMediaType": "application/json",
|
|
6582
|
-
* // "contentSchema": {
|
|
6583
|
-
* // "type": "object",
|
|
6584
|
-
* // "properties": {
|
|
6585
|
-
* // "a": {
|
|
6586
|
-
* // "type": "string"
|
|
6587
|
-
* // }
|
|
6588
|
-
* // },
|
|
6589
|
-
* // "required": [
|
|
6590
|
-
* // "a"
|
|
6591
|
-
* // ],
|
|
6592
|
-
* // "additionalProperties": false
|
|
6593
|
-
* // }
|
|
6594
|
-
* // },
|
|
6595
|
-
* // "definitions": {}
|
|
6596
|
-
* // }
|
|
6597
|
-
* ```
|
|
6598
|
-
*
|
|
6599
7900
|
* @category constructors
|
|
6600
7901
|
* @since 4.0.0
|
|
6601
7902
|
*/
|
|
6602
7903
|
export function fromJsonString(schema) {
|
|
6603
|
-
|
|
6604
|
-
return String.annotate({
|
|
6605
|
-
// Give the transport wrapper its own name so the decoded payload keeps its identifier.
|
|
6606
|
-
identifier: identifier === undefined ? undefined : `${identifier}JsonString`,
|
|
6607
|
-
expected: "a string that will be decoded as JSON",
|
|
6608
|
-
contentMediaType: "application/json",
|
|
6609
|
-
contentSchema: SchemaAST.toEncoded(schema.ast)
|
|
6610
|
-
}).pipe(decodeTo(schema, SchemaTransformation.fromJsonString));
|
|
7904
|
+
return JsonString.pipe(decodeTo(schema, SchemaTransformation.fromJsonString));
|
|
6611
7905
|
}
|
|
6612
7906
|
/**
|
|
6613
7907
|
* Schema for JavaScript `File` objects.
|
|
@@ -6621,19 +7915,20 @@ export function fromJsonString(schema) {
|
|
|
6621
7915
|
* @since 4.0.0
|
|
6622
7916
|
*/
|
|
6623
7917
|
export const File = /*#__PURE__*/instanceOf(globalThis.File, {
|
|
6624
|
-
|
|
6625
|
-
|
|
7918
|
+
representation: {
|
|
7919
|
+
id: "effect/schema/File",
|
|
7920
|
+
payload: null
|
|
6626
7921
|
},
|
|
6627
|
-
|
|
7922
|
+
toCode: () => ({
|
|
6628
7923
|
runtime: `Schema.File`,
|
|
6629
7924
|
Type: `globalThis.File`
|
|
6630
|
-
},
|
|
7925
|
+
}),
|
|
6631
7926
|
expected: "File",
|
|
6632
7927
|
toCodecJson: () => link()(Struct({
|
|
6633
7928
|
data: String.check(isBase64()),
|
|
6634
7929
|
type: String,
|
|
6635
7930
|
name: String,
|
|
6636
|
-
lastModified:
|
|
7931
|
+
lastModified: Int
|
|
6637
7932
|
}), SchemaTransformation.transformOrFail({
|
|
6638
7933
|
decode: e => Result_.match(Encoding.decodeBase64(e.data), {
|
|
6639
7934
|
onFailure: error => Effect.fail(new SchemaIssue.InvalidValue(Option_.some(e.data), {
|
|
@@ -6663,6 +7958,19 @@ export const File = /*#__PURE__*/instanceOf(globalThis.File, {
|
|
|
6663
7958
|
})
|
|
6664
7959
|
}))
|
|
6665
7960
|
});
|
|
7961
|
+
/**
|
|
7962
|
+
* Reviver for persisted `File` declarations.
|
|
7963
|
+
*
|
|
7964
|
+
* **When to use**
|
|
7965
|
+
*
|
|
7966
|
+
* Use when reconstructing documents that may contain the {@link File} schema.
|
|
7967
|
+
*
|
|
7968
|
+
* @see {@link File} for the corresponding schema
|
|
7969
|
+
*
|
|
7970
|
+
* @category file
|
|
7971
|
+
* @since 4.0.0
|
|
7972
|
+
*/
|
|
7973
|
+
export const FileReviver = /*#__PURE__*/makeFixedDeclarationReviver("effect/schema/File", File);
|
|
6666
7974
|
/**
|
|
6667
7975
|
* Schema for JavaScript `FormData` objects.
|
|
6668
7976
|
*
|
|
@@ -6675,13 +7983,14 @@ export const File = /*#__PURE__*/instanceOf(globalThis.File, {
|
|
|
6675
7983
|
* @since 4.0.0
|
|
6676
7984
|
*/
|
|
6677
7985
|
export const FormData = /*#__PURE__*/instanceOf(globalThis.FormData, {
|
|
6678
|
-
|
|
6679
|
-
|
|
7986
|
+
representation: {
|
|
7987
|
+
id: "effect/schema/FormData",
|
|
7988
|
+
payload: null
|
|
6680
7989
|
},
|
|
6681
|
-
|
|
7990
|
+
toCode: () => ({
|
|
6682
7991
|
runtime: `Schema.FormData`,
|
|
6683
7992
|
Type: `globalThis.FormData`
|
|
6684
|
-
},
|
|
7993
|
+
}),
|
|
6685
7994
|
expected: "FormData",
|
|
6686
7995
|
toCodecJson: () => link()(ArraySchema(Tuple([String, Union([Struct({
|
|
6687
7996
|
_tag: tag("String"),
|
|
@@ -6714,6 +8023,19 @@ export const FormData = /*#__PURE__*/instanceOf(globalThis.FormData, {
|
|
|
6714
8023
|
}
|
|
6715
8024
|
}))
|
|
6716
8025
|
});
|
|
8026
|
+
/**
|
|
8027
|
+
* Reviver for persisted `FormData` declarations.
|
|
8028
|
+
*
|
|
8029
|
+
* **When to use**
|
|
8030
|
+
*
|
|
8031
|
+
* Use when reconstructing documents that may contain the {@link FormData} schema.
|
|
8032
|
+
*
|
|
8033
|
+
* @see {@link FormData} for the corresponding schema
|
|
8034
|
+
*
|
|
8035
|
+
* @category FormData
|
|
8036
|
+
* @since 4.0.0
|
|
8037
|
+
*/
|
|
8038
|
+
export const FormDataReviver = /*#__PURE__*/makeFixedDeclarationReviver("effect/schema/FormData", FormData);
|
|
6717
8039
|
/**
|
|
6718
8040
|
* Schema for decoding `FormData` through a bracket-notation tree.
|
|
6719
8041
|
*
|
|
@@ -6813,13 +8135,14 @@ export function fromFormData(schema) {
|
|
|
6813
8135
|
* @since 4.0.0
|
|
6814
8136
|
*/
|
|
6815
8137
|
export const URLSearchParams = /*#__PURE__*/instanceOf(globalThis.URLSearchParams, {
|
|
6816
|
-
|
|
6817
|
-
|
|
8138
|
+
representation: {
|
|
8139
|
+
id: "effect/schema/URLSearchParams",
|
|
8140
|
+
payload: null
|
|
6818
8141
|
},
|
|
6819
|
-
|
|
8142
|
+
toCode: () => ({
|
|
6820
8143
|
runtime: `Schema.URLSearchParams`,
|
|
6821
8144
|
Type: `globalThis.URLSearchParams`
|
|
6822
|
-
},
|
|
8145
|
+
}),
|
|
6823
8146
|
expected: "URLSearchParams",
|
|
6824
8147
|
toCodecJson: () => link()(String.annotate({
|
|
6825
8148
|
expected: "a query string that will be decoded as URLSearchParams"
|
|
@@ -6828,6 +8151,19 @@ export const URLSearchParams = /*#__PURE__*/instanceOf(globalThis.URLSearchParam
|
|
|
6828
8151
|
encode: params => params.toString()
|
|
6829
8152
|
}))
|
|
6830
8153
|
});
|
|
8154
|
+
/**
|
|
8155
|
+
* Reviver for persisted `URLSearchParams` declarations.
|
|
8156
|
+
*
|
|
8157
|
+
* **When to use**
|
|
8158
|
+
*
|
|
8159
|
+
* Use when reconstructing documents that may contain the {@link URLSearchParams} schema.
|
|
8160
|
+
*
|
|
8161
|
+
* @see {@link URLSearchParams} for the corresponding schema
|
|
8162
|
+
*
|
|
8163
|
+
* @category search params
|
|
8164
|
+
* @since 4.0.0
|
|
8165
|
+
*/
|
|
8166
|
+
export const URLSearchParamsReviver = /*#__PURE__*/makeFixedDeclarationReviver("effect/schema/URLSearchParams", URLSearchParams);
|
|
6831
8167
|
/**
|
|
6832
8168
|
* Schema for decoding `URLSearchParams` through a bracket-notation tree.
|
|
6833
8169
|
*
|
|
@@ -6911,20 +8247,6 @@ export const URLSearchParams = /*#__PURE__*/instanceOf(globalThis.URLSearchParam
|
|
|
6911
8247
|
export function fromURLSearchParams(schema) {
|
|
6912
8248
|
return URLSearchParams.pipe(decodeTo(schema, SchemaTransformation.fromURLSearchParams));
|
|
6913
8249
|
}
|
|
6914
|
-
/**
|
|
6915
|
-
* Schema for finite numbers, rejecting `NaN`, `Infinity`, and `-Infinity`.
|
|
6916
|
-
*
|
|
6917
|
-
* @category Number
|
|
6918
|
-
* @since 3.10.0
|
|
6919
|
-
*/
|
|
6920
|
-
export const Finite = /*#__PURE__*/Number.check(/*#__PURE__*/isFinite());
|
|
6921
|
-
/**
|
|
6922
|
-
* Schema for integers, rejecting `NaN`, `Infinity`, and `-Infinity`.
|
|
6923
|
-
*
|
|
6924
|
-
* @category Number
|
|
6925
|
-
* @since 3.10.0
|
|
6926
|
-
*/
|
|
6927
|
-
export const Int = /*#__PURE__*/Number.check(/*#__PURE__*/isInt());
|
|
6928
8250
|
/**
|
|
6929
8251
|
* Schema that parses a string into a `number` using JavaScript
|
|
6930
8252
|
* number coercion.
|
|
@@ -7171,17 +8493,31 @@ const Base64String = /*#__PURE__*/String.annotate({
|
|
|
7171
8493
|
* @since 4.0.0
|
|
7172
8494
|
*/
|
|
7173
8495
|
export const Uint8Array = /*#__PURE__*/instanceOf(globalThis.Uint8Array, {
|
|
7174
|
-
|
|
7175
|
-
|
|
8496
|
+
representation: {
|
|
8497
|
+
id: "effect/schema/Uint8Array",
|
|
8498
|
+
payload: null
|
|
7176
8499
|
},
|
|
7177
|
-
|
|
8500
|
+
toCode: () => ({
|
|
7178
8501
|
runtime: `Schema.Uint8Array`,
|
|
7179
8502
|
Type: `globalThis.Uint8Array`
|
|
7180
|
-
},
|
|
8503
|
+
}),
|
|
7181
8504
|
expected: "Uint8Array",
|
|
7182
8505
|
toCodecJson: () => link()(Base64String, SchemaTransformation.uint8ArrayFromBase64String),
|
|
7183
8506
|
toArbitrary: () => fc => fc.uint8Array()
|
|
7184
8507
|
});
|
|
8508
|
+
/**
|
|
8509
|
+
* Reviver for persisted `Uint8Array` declarations.
|
|
8510
|
+
*
|
|
8511
|
+
* **When to use**
|
|
8512
|
+
*
|
|
8513
|
+
* Use when reconstructing documents that may contain the {@link Uint8Array} schema.
|
|
8514
|
+
*
|
|
8515
|
+
* @see {@link Uint8Array} for the corresponding schema
|
|
8516
|
+
*
|
|
8517
|
+
* @category Uint8Array
|
|
8518
|
+
* @since 4.0.0
|
|
8519
|
+
*/
|
|
8520
|
+
export const Uint8ArrayReviver = /*#__PURE__*/makeFixedDeclarationReviver("effect/schema/Uint8Array", Uint8Array);
|
|
7185
8521
|
/**
|
|
7186
8522
|
* Schema that decodes a base64 encoded string into a
|
|
7187
8523
|
* `Uint8Array`.
|
|
@@ -7262,22 +8598,36 @@ export const Uint8ArrayFromHex = /*#__PURE__*/String.annotate({
|
|
|
7262
8598
|
* @since 3.10.0
|
|
7263
8599
|
*/
|
|
7264
8600
|
export const DateTimeUtc = /*#__PURE__*/declare(u => DateTime.isDateTime(u) && DateTime.isUtc(u), {
|
|
7265
|
-
|
|
7266
|
-
|
|
8601
|
+
representation: {
|
|
8602
|
+
id: "effect/schema/DateTimeUtc",
|
|
8603
|
+
payload: null
|
|
7267
8604
|
},
|
|
7268
|
-
|
|
8605
|
+
toCode: () => ({
|
|
7269
8606
|
runtime: `Schema.DateTimeUtc`,
|
|
7270
8607
|
Type: `DateTime.Utc`,
|
|
7271
|
-
|
|
7272
|
-
},
|
|
8608
|
+
importDeclarations: [`import * as DateTime from "effect/DateTime"`]
|
|
8609
|
+
}),
|
|
7273
8610
|
expected: "DateTime.Utc",
|
|
7274
8611
|
toCodecJson: () => link()(String, SchemaTransformation.dateTimeUtcFromString),
|
|
7275
|
-
toArbitrary: () => (fc, ctx) => fc.date(dateArbitraryConstraints(ctx?.constraint
|
|
7276
|
-
|
|
8612
|
+
toArbitrary: () => (fc, ctx) => fc.date(dateArbitraryConstraints(ctx?.constraint?.ordered?.order === DateTime.Order ? ctx.constraint.ordered : undefined, {
|
|
8613
|
+
noInvalidDate: true
|
|
7277
8614
|
}, DateTime.toDateUtc)).map(date => DateTime.fromDateUnsafe(date)),
|
|
7278
8615
|
toFormatter: () => utc => utc.toString(),
|
|
7279
8616
|
toEquivalence: () => DateTime.Equivalence
|
|
7280
8617
|
});
|
|
8618
|
+
/**
|
|
8619
|
+
* Reviver for persisted {@link DateTimeUtc} declarations.
|
|
8620
|
+
*
|
|
8621
|
+
* **When to use**
|
|
8622
|
+
*
|
|
8623
|
+
* Use when reconstructing documents that may contain the {@link DateTimeUtc} schema.
|
|
8624
|
+
*
|
|
8625
|
+
* @see {@link DateTimeUtc} for the corresponding schema
|
|
8626
|
+
*
|
|
8627
|
+
* @category DateTime
|
|
8628
|
+
* @since 4.0.0
|
|
8629
|
+
*/
|
|
8630
|
+
export const DateTimeUtcReviver = /*#__PURE__*/makeFixedDeclarationReviver("effect/schema/DateTimeUtc", DateTimeUtc);
|
|
7281
8631
|
/**
|
|
7282
8632
|
* Schema that decodes a `Date` into a `DateTime.Utc`.
|
|
7283
8633
|
*
|
|
@@ -7297,12 +8647,12 @@ export const DateTimeUtc = /*#__PURE__*/declare(u => DateTime.isDateTime(u) && D
|
|
|
7297
8647
|
* @see {@link DateTimeUtc} for validating values that are already `DateTime.Utc`
|
|
7298
8648
|
* @see {@link DateTimeUtcFromString} for decoding date-time strings into UTC values
|
|
7299
8649
|
* @see {@link DateTimeUtcFromMillis} for decoding epoch milliseconds into UTC values
|
|
7300
|
-
* @see {@link
|
|
8650
|
+
* @see {@link Date} for validating Date instances without converting them
|
|
7301
8651
|
*
|
|
7302
8652
|
* @category DateTime
|
|
7303
8653
|
* @since 3.12.0
|
|
7304
8654
|
*/
|
|
7305
|
-
export const DateTimeUtcFromDate = /*#__PURE__*/
|
|
8655
|
+
export const DateTimeUtcFromDate = /*#__PURE__*/Date.pipe(/*#__PURE__*/decodeTo(DateTimeUtc, {
|
|
7306
8656
|
decode: /*#__PURE__*/SchemaGetter.dateTimeUtcFromInput(),
|
|
7307
8657
|
encode: /*#__PURE__*/SchemaGetter.transform(DateTime.toDateUtc)
|
|
7308
8658
|
}));
|
|
@@ -7348,7 +8698,7 @@ export const DateTimeUtcFromString = /*#__PURE__*/String.annotate({
|
|
|
7348
8698
|
* @category DateTime
|
|
7349
8699
|
* @since 4.0.0
|
|
7350
8700
|
*/
|
|
7351
|
-
export const DateTimeUtcFromMillis = /*#__PURE__*/
|
|
8701
|
+
export const DateTimeUtcFromMillis = /*#__PURE__*/Int.pipe(/*#__PURE__*/decodeTo(DateTimeUtc, {
|
|
7352
8702
|
decode: /*#__PURE__*/SchemaGetter.dateTimeUtcFromInput(),
|
|
7353
8703
|
encode: /*#__PURE__*/SchemaGetter.transform(DateTime.toEpochMillis)
|
|
7354
8704
|
}));
|
|
@@ -7365,16 +8715,17 @@ export const DateTimeUtcFromMillis = /*#__PURE__*/Number.pipe(/*#__PURE__*/decod
|
|
|
7365
8715
|
* @since 3.10.0
|
|
7366
8716
|
*/
|
|
7367
8717
|
export const TimeZoneOffset = /*#__PURE__*/declare(DateTime.isTimeZoneOffset, {
|
|
7368
|
-
|
|
7369
|
-
|
|
8718
|
+
representation: {
|
|
8719
|
+
id: "effect/schema/TimeZoneOffset",
|
|
8720
|
+
payload: null
|
|
7370
8721
|
},
|
|
7371
|
-
|
|
8722
|
+
toCode: () => ({
|
|
7372
8723
|
runtime: `Schema.TimeZoneOffset`,
|
|
7373
8724
|
Type: `DateTime.TimeZone.Offset`,
|
|
7374
|
-
|
|
7375
|
-
},
|
|
8725
|
+
importDeclarations: [`import * as DateTime from "effect/DateTime"`]
|
|
8726
|
+
}),
|
|
7376
8727
|
expected: "DateTime.TimeZone.Offset",
|
|
7377
|
-
toCodecJson: () => link()(
|
|
8728
|
+
toCodecJson: () => link()(Int, SchemaTransformation.timeZoneOffsetFromNumber),
|
|
7378
8729
|
toArbitrary: () => fc => fc.integer({
|
|
7379
8730
|
min: -12 * 60 * 60 * 1000,
|
|
7380
8731
|
max: 14 * 60 * 60 * 1000
|
|
@@ -7382,6 +8733,19 @@ export const TimeZoneOffset = /*#__PURE__*/declare(DateTime.isTimeZoneOffset, {
|
|
|
7382
8733
|
toFormatter: () => tz => DateTime.zoneToString(tz),
|
|
7383
8734
|
toEquivalence: () => (a, b) => a.offset === b.offset
|
|
7384
8735
|
});
|
|
8736
|
+
/**
|
|
8737
|
+
* Reviver for persisted {@link TimeZoneOffset} declarations.
|
|
8738
|
+
*
|
|
8739
|
+
* **When to use**
|
|
8740
|
+
*
|
|
8741
|
+
* Use when reconstructing documents that may contain the {@link TimeZoneOffset} schema.
|
|
8742
|
+
*
|
|
8743
|
+
* @see {@link TimeZoneOffset} for the corresponding schema
|
|
8744
|
+
*
|
|
8745
|
+
* @category DateTime
|
|
8746
|
+
* @since 4.0.0
|
|
8747
|
+
*/
|
|
8748
|
+
export const TimeZoneOffsetReviver = /*#__PURE__*/makeFixedDeclarationReviver("effect/schema/TimeZoneOffset", TimeZoneOffset);
|
|
7385
8749
|
const TimeZoneNamedString = /*#__PURE__*/String.annotate({
|
|
7386
8750
|
expected: "an IANA time zone identifier"
|
|
7387
8751
|
});
|
|
@@ -7398,20 +8762,34 @@ const TimeZoneNamedString = /*#__PURE__*/String.annotate({
|
|
|
7398
8762
|
* @since 3.10.0
|
|
7399
8763
|
*/
|
|
7400
8764
|
export const TimeZoneNamed = /*#__PURE__*/declare(DateTime.isTimeZoneNamed, {
|
|
7401
|
-
|
|
7402
|
-
|
|
8765
|
+
representation: {
|
|
8766
|
+
id: "effect/schema/TimeZoneNamed",
|
|
8767
|
+
payload: null
|
|
7403
8768
|
},
|
|
7404
|
-
|
|
8769
|
+
toCode: () => ({
|
|
7405
8770
|
runtime: `Schema.TimeZoneNamed`,
|
|
7406
8771
|
Type: `DateTime.TimeZone.Named`,
|
|
7407
|
-
|
|
7408
|
-
},
|
|
8772
|
+
importDeclarations: [`import * as DateTime from "effect/DateTime"`]
|
|
8773
|
+
}),
|
|
7409
8774
|
expected: "DateTime.TimeZone.Named",
|
|
7410
8775
|
toCodecJson: () => link()(TimeZoneNamedString, SchemaTransformation.timeZoneNamedFromString),
|
|
7411
8776
|
toArbitrary: () => fc => fc.constantFrom(...["UTC", "Europe/London", "America/New_York", "Asia/Tokyo", "Australia/Sydney"].map(DateTime.zoneMakeNamedUnsafe)),
|
|
7412
8777
|
toFormatter: () => tz => DateTime.zoneToString(tz),
|
|
7413
8778
|
toEquivalence: () => (a, b) => a.id === b.id
|
|
7414
8779
|
});
|
|
8780
|
+
/**
|
|
8781
|
+
* Reviver for persisted {@link TimeZoneNamed} declarations.
|
|
8782
|
+
*
|
|
8783
|
+
* **When to use**
|
|
8784
|
+
*
|
|
8785
|
+
* Use when reconstructing documents that may contain the {@link TimeZoneNamed} schema.
|
|
8786
|
+
*
|
|
8787
|
+
* @see {@link TimeZoneNamed} for the corresponding schema
|
|
8788
|
+
*
|
|
8789
|
+
* @category DateTime
|
|
8790
|
+
* @since 4.0.0
|
|
8791
|
+
*/
|
|
8792
|
+
export const TimeZoneNamedReviver = /*#__PURE__*/makeFixedDeclarationReviver("effect/schema/TimeZoneNamed", TimeZoneNamed);
|
|
7415
8793
|
/**
|
|
7416
8794
|
* Schema that parses an IANA time zone identifier string into a `DateTime.TimeZone.Named`.
|
|
7417
8795
|
*
|
|
@@ -7444,14 +8822,15 @@ const TimeZoneString = /*#__PURE__*/String.annotate({
|
|
|
7444
8822
|
* @since 3.10.0
|
|
7445
8823
|
*/
|
|
7446
8824
|
export const TimeZone = /*#__PURE__*/declare(DateTime.isTimeZone, {
|
|
7447
|
-
|
|
7448
|
-
|
|
8825
|
+
representation: {
|
|
8826
|
+
id: "effect/schema/TimeZone",
|
|
8827
|
+
payload: null
|
|
7449
8828
|
},
|
|
7450
|
-
|
|
8829
|
+
toCode: () => ({
|
|
7451
8830
|
runtime: `Schema.TimeZone`,
|
|
7452
8831
|
Type: `DateTime.TimeZone`,
|
|
7453
|
-
|
|
7454
|
-
},
|
|
8832
|
+
importDeclarations: [`import * as DateTime from "effect/DateTime"`]
|
|
8833
|
+
}),
|
|
7455
8834
|
expected: "DateTime.TimeZone",
|
|
7456
8835
|
toCodecJson: () => link()(TimeZoneString, SchemaTransformation.timeZoneFromString),
|
|
7457
8836
|
toArbitrary: () => fc => fc.oneof(fc.integer({
|
|
@@ -7461,6 +8840,19 @@ export const TimeZone = /*#__PURE__*/declare(DateTime.isTimeZone, {
|
|
|
7461
8840
|
toFormatter: () => tz => DateTime.zoneToString(tz),
|
|
7462
8841
|
toEquivalence: () => (a, b) => DateTime.zoneToString(a) === DateTime.zoneToString(b)
|
|
7463
8842
|
});
|
|
8843
|
+
/**
|
|
8844
|
+
* Reviver for persisted {@link TimeZone} declarations.
|
|
8845
|
+
*
|
|
8846
|
+
* **When to use**
|
|
8847
|
+
*
|
|
8848
|
+
* Use when reconstructing documents that may contain the {@link TimeZone} schema.
|
|
8849
|
+
*
|
|
8850
|
+
* @see {@link TimeZone} for the corresponding schema
|
|
8851
|
+
*
|
|
8852
|
+
* @category DateTime
|
|
8853
|
+
* @since 4.0.0
|
|
8854
|
+
*/
|
|
8855
|
+
export const TimeZoneReviver = /*#__PURE__*/makeFixedDeclarationReviver("effect/schema/TimeZone", TimeZone);
|
|
7464
8856
|
/**
|
|
7465
8857
|
* Schema that parses a time zone string into a `DateTime.TimeZone`.
|
|
7466
8858
|
*
|
|
@@ -7495,26 +8887,40 @@ const DateTimeZonedString = /*#__PURE__*/String.annotate({
|
|
|
7495
8887
|
* @since 3.10.0
|
|
7496
8888
|
*/
|
|
7497
8889
|
export const DateTimeZoned = /*#__PURE__*/declare(u => DateTime.isDateTime(u) && DateTime.isZoned(u), {
|
|
7498
|
-
|
|
7499
|
-
|
|
8890
|
+
representation: {
|
|
8891
|
+
id: "effect/schema/DateTimeZoned",
|
|
8892
|
+
payload: null
|
|
7500
8893
|
},
|
|
7501
|
-
|
|
8894
|
+
toCode: () => ({
|
|
7502
8895
|
runtime: `Schema.DateTimeZoned`,
|
|
7503
8896
|
Type: `DateTime.Zoned`,
|
|
7504
|
-
|
|
7505
|
-
},
|
|
8897
|
+
importDeclarations: [`import * as DateTime from "effect/DateTime"`]
|
|
8898
|
+
}),
|
|
7506
8899
|
expected: "DateTime.Zoned",
|
|
7507
8900
|
toCodecJson: () => link()(DateTimeZonedString, SchemaTransformation.dateTimeZonedFromString),
|
|
7508
|
-
toArbitrary: () => (fc, ctx) => fc.tuple(fc.date(dateArbitraryConstraints(ctx?.constraint
|
|
8901
|
+
toArbitrary: () => (fc, ctx) => fc.tuple(fc.date(dateArbitraryConstraints(ctx?.constraint?.ordered?.order === DateTime.Order ? ctx.constraint.ordered : undefined, {
|
|
7509
8902
|
max: new globalThis.Date(8640000000000000 - 14 * 60 * 60 * 1000),
|
|
7510
8903
|
min: new globalThis.Date(-8640000000000000 + 14 * 60 * 60 * 1000),
|
|
7511
|
-
|
|
8904
|
+
noInvalidDate: true
|
|
7512
8905
|
}, DateTime.toDateUtc)), fc.constantFrom("UTC", "Europe/London", "America/New_York", "Asia/Tokyo", "Australia/Sydney")).map(([date, zone]) => DateTime.makeZonedUnsafe(date, {
|
|
7513
8906
|
timeZone: zone
|
|
7514
8907
|
})),
|
|
7515
8908
|
toFormatter: () => zoned => DateTime.formatIsoZoned(zoned),
|
|
7516
8909
|
toEquivalence: () => DateTime.Equivalence
|
|
7517
8910
|
});
|
|
8911
|
+
/**
|
|
8912
|
+
* Reviver for persisted {@link DateTimeZoned} declarations.
|
|
8913
|
+
*
|
|
8914
|
+
* **When to use**
|
|
8915
|
+
*
|
|
8916
|
+
* Use when reconstructing documents that may contain the {@link DateTimeZoned} schema.
|
|
8917
|
+
*
|
|
8918
|
+
* @see {@link DateTimeZoned} for the corresponding schema
|
|
8919
|
+
*
|
|
8920
|
+
* @category DateTime
|
|
8921
|
+
* @since 4.0.0
|
|
8922
|
+
*/
|
|
8923
|
+
export const DateTimeZonedReviver = /*#__PURE__*/makeFixedDeclarationReviver("effect/schema/DateTimeZoned", DateTimeZoned);
|
|
7518
8924
|
/**
|
|
7519
8925
|
* Schema that parses a zoned DateTime string into a `DateTime.Zoned`.
|
|
7520
8926
|
*
|
|
@@ -7629,7 +9035,7 @@ function getClassSchemaFactory(from, identifier, annotations) {
|
|
|
7629
9035
|
terminal: from.terminal?.map(args => new self(args))
|
|
7630
9036
|
}),
|
|
7631
9037
|
toFormatter: ([from]) => t => `${self.identifier}(${from(t)})`,
|
|
7632
|
-
|
|
9038
|
+
[InternalAnnotations.SENTINELS_ANNOTATION_KEY]: SchemaAST.collectSentinels(from.ast),
|
|
7633
9039
|
...annotations
|
|
7634
9040
|
}));
|
|
7635
9041
|
return memo = decodeTo(to, transformation)(from);
|
|
@@ -7989,14 +9395,15 @@ export function toFormatter(schema, options) {
|
|
|
7989
9395
|
}
|
|
7990
9396
|
case "Union":
|
|
7991
9397
|
{
|
|
7992
|
-
const
|
|
9398
|
+
const types = SchemaAST.toType(ast).types;
|
|
9399
|
+
const getCandidates = t => SchemaAST.getCandidates(t, types);
|
|
9400
|
+
const compiled = new Map(types.map((candidate, i) => [candidate, [SchemaParser._is(candidate), recur(ast.types[i])]]));
|
|
7993
9401
|
return t => {
|
|
7994
9402
|
const candidates = getCandidates(t);
|
|
7995
|
-
const refinements = candidates.map(SchemaParser._is);
|
|
7996
9403
|
for (let i = 0; i < candidates.length; i++) {
|
|
7997
|
-
const is =
|
|
9404
|
+
const [is, formatter] = compiled.get(candidates[i]);
|
|
7998
9405
|
if (is(t)) {
|
|
7999
|
-
return
|
|
9406
|
+
return formatter(t);
|
|
8000
9407
|
}
|
|
8001
9408
|
}
|
|
8002
9409
|
return format(t);
|
|
@@ -8056,15 +9463,18 @@ export function toEquivalence(schema) {
|
|
|
8056
9463
|
// Representation
|
|
8057
9464
|
// -----------------------------------------------------------------------------
|
|
8058
9465
|
/**
|
|
8059
|
-
* Derives an intermediate `SchemaRepresentation.Document` from
|
|
8060
|
-
*
|
|
8061
|
-
*
|
|
9466
|
+
* Derives an intermediate `SchemaRepresentation.Document` from the encoded
|
|
9467
|
+
* side of a schema.
|
|
9468
|
+
*
|
|
9469
|
+
* **Details**
|
|
9470
|
+
*
|
|
9471
|
+
* Use {@link toType} before this function to represent the type side instead.
|
|
8062
9472
|
*
|
|
8063
9473
|
* @category Representation
|
|
8064
9474
|
* @since 4.0.0
|
|
8065
9475
|
*/
|
|
8066
9476
|
export function toRepresentation(schema) {
|
|
8067
|
-
return
|
|
9477
|
+
return InternalToRepresentation.toRepresentation(schema.ast);
|
|
8068
9478
|
}
|
|
8069
9479
|
/**
|
|
8070
9480
|
* Returns a JSON Schema document using draft 2020-12.
|
|
@@ -8073,59 +9483,123 @@ export function toRepresentation(schema) {
|
|
|
8073
9483
|
*
|
|
8074
9484
|
* The `options` parameter controls generation details such as additional
|
|
8075
9485
|
* properties and synthesized check descriptions; it does not change the draft
|
|
8076
|
-
* target.
|
|
9486
|
+
* target. Declarations are lowered through their `toCodecJson` or `toCodec`
|
|
9487
|
+
* annotation when available before the representation document is compiled.
|
|
8077
9488
|
*
|
|
8078
9489
|
* **Gotchas**
|
|
8079
9490
|
*
|
|
8080
9491
|
* JSON Schema generation is best-effort. Some Effect schema semantics cannot
|
|
8081
9492
|
* be represented exactly in JSON Schema, and importing an emitted JSON Schema
|
|
8082
9493
|
* may produce an equivalent approximation rather than the original schema
|
|
8083
|
-
* shape.
|
|
9494
|
+
* shape. Opaque declarations without a structural codec are represented by an
|
|
9495
|
+
* unconstrained JSON Schema.
|
|
8084
9496
|
*
|
|
8085
9497
|
* @category converting
|
|
8086
9498
|
* @since 4.0.0
|
|
8087
9499
|
*/
|
|
8088
9500
|
export function toJsonSchemaDocument(schema, options) {
|
|
8089
|
-
const
|
|
8090
|
-
|
|
8091
|
-
return {
|
|
8092
|
-
dialect: "draft-2020-12",
|
|
8093
|
-
schema: jd.schema,
|
|
8094
|
-
definitions: jd.definitions
|
|
8095
|
-
};
|
|
9501
|
+
const document = InternalToRepresentation.toRepresentation(toCodecJsonAST(schema.ast));
|
|
9502
|
+
return InternalToJsonSchemaDocument.toJsonSchemaDocument(document, options);
|
|
8096
9503
|
}
|
|
8097
9504
|
/**
|
|
8098
9505
|
* Derives a canonical JSON codec from a schema. The encoded form is `Json`, and
|
|
8099
9506
|
* decoding produces the schema's `Type`.
|
|
8100
9507
|
*
|
|
9508
|
+
* **Gotchas**
|
|
9509
|
+
*
|
|
9510
|
+
* Declarations without a `toCodecJson` or `toCodec` annotation use `Json` as
|
|
9511
|
+
* their encoded schema. This keeps codec construction total, but encoding or
|
|
9512
|
+
* decoding can still fail when declaration values are not JSON values. A
|
|
9513
|
+
* `toCodecJson` callback can return `undefined` when the declaration is already
|
|
9514
|
+
* in canonical JSON form.
|
|
9515
|
+
*
|
|
8101
9516
|
* @category Canonical Codecs
|
|
8102
9517
|
* @since 4.0.0
|
|
8103
9518
|
*/
|
|
8104
9519
|
export function toCodecJson(schema) {
|
|
8105
|
-
return make(
|
|
9520
|
+
return make(toCodecJsonAST(schema.ast), {
|
|
8106
9521
|
schema
|
|
8107
9522
|
});
|
|
8108
9523
|
}
|
|
8109
|
-
const
|
|
8110
|
-
const out = toCodecJsonBase(ast,
|
|
8111
|
-
|
|
9524
|
+
const toCodecJsonASTBase = /*#__PURE__*/SchemaAST.applyToSelfOrLastLinkEncoding(ast => {
|
|
9525
|
+
const out = toCodecJsonBase(ast, toCodecJsonAST);
|
|
9526
|
+
const context = ast.context;
|
|
9527
|
+
if (out === ast || context === undefined) return out;
|
|
9528
|
+
return SchemaAST.replaceContextLastLink(out, withoutConstructorDefault(context));
|
|
9529
|
+
});
|
|
9530
|
+
/** @internal */
|
|
9531
|
+
export const toCodecJsonAST = /*#__PURE__*/memoize(ast => {
|
|
9532
|
+
const identifier = InternalAnnotations.resolveIdentifier(ast);
|
|
9533
|
+
const out = toCodecJsonASTBase(ast);
|
|
9534
|
+
if (identifier === undefined || out.encoding === undefined) return out;
|
|
9535
|
+
const encoded = SchemaAST.getLastEncoding(out);
|
|
9536
|
+
if (InternalAnnotations.resolveIdentifier(encoded) !== undefined || InternalAnnotations.resolveIdentifierFallback(encoded) === identifier) {
|
|
9537
|
+
return out;
|
|
9538
|
+
}
|
|
9539
|
+
const annotated = SchemaAST.annotate(encoded, {
|
|
9540
|
+
[InternalAnnotations.IDENTIFIER_FALLBACK_KEY]: identifier
|
|
9541
|
+
});
|
|
9542
|
+
return SchemaAST.applyToSelfOrLastLinkEncoding(() => annotated)(out);
|
|
9543
|
+
});
|
|
9544
|
+
function withoutConstructorDefault(context) {
|
|
9545
|
+
return context.defaultValue === undefined ? context : new SchemaAST.Context(context.isOptional, context.isMutable, undefined, context.annotations);
|
|
9546
|
+
}
|
|
9547
|
+
function validateCanonicalObjectPropertyNames(ast) {
|
|
9548
|
+
if (ast.propertySignatures.some(ps => typeof ps.name !== "string")) {
|
|
9549
|
+
throw new globalThis.Error("Objects property names must be strings", {
|
|
9550
|
+
cause: ast
|
|
9551
|
+
});
|
|
9552
|
+
}
|
|
9553
|
+
}
|
|
9554
|
+
function makeReorder(getPriority) {
|
|
9555
|
+
return types => {
|
|
9556
|
+
// Create a map of original indices for O(1) lookup
|
|
9557
|
+
const indexMap = new Map();
|
|
9558
|
+
for (let i = 0; i < types.length; i++) {
|
|
9559
|
+
indexMap.set(SchemaAST.toEncoded(types[i]), i);
|
|
9560
|
+
}
|
|
9561
|
+
// Create a sorted copy of the types array
|
|
9562
|
+
const sortedTypes = [...types].sort((a, b) => {
|
|
9563
|
+
a = SchemaAST.toEncoded(a);
|
|
9564
|
+
b = SchemaAST.toEncoded(b);
|
|
9565
|
+
const pa = getPriority(a);
|
|
9566
|
+
const pb = getPriority(b);
|
|
9567
|
+
if (pa !== pb) return pa - pb;
|
|
9568
|
+
// If priorities are equal, maintain original order (stable sort)
|
|
9569
|
+
return indexMap.get(a) - indexMap.get(b);
|
|
9570
|
+
});
|
|
9571
|
+
// Check if order changed by comparing arrays
|
|
9572
|
+
const orderChanged = sortedTypes.some((ast, index) => ast !== types[index]);
|
|
9573
|
+
if (!orderChanged) return types;
|
|
9574
|
+
return sortedTypes;
|
|
9575
|
+
};
|
|
9576
|
+
}
|
|
9577
|
+
const toCodecJsonReorder = /*#__PURE__*/makeReorder(ast => {
|
|
9578
|
+
switch (ast._tag) {
|
|
9579
|
+
case "BigInt":
|
|
9580
|
+
case "Symbol":
|
|
9581
|
+
case "UniqueSymbol":
|
|
9582
|
+
return 0;
|
|
9583
|
+
default:
|
|
9584
|
+
return 1;
|
|
9585
|
+
}
|
|
8112
9586
|
});
|
|
8113
9587
|
function toCodecJsonBase(ast, recur) {
|
|
8114
9588
|
switch (ast._tag) {
|
|
8115
9589
|
case "Declaration":
|
|
8116
9590
|
{
|
|
8117
9591
|
const getLink = ast.annotations?.toCodecJson ?? ast.annotations?.toCodec;
|
|
8118
|
-
if (Predicate.isFunction(getLink)) {
|
|
8119
|
-
|
|
8120
|
-
const link = getLink(tps);
|
|
8121
|
-
const to = recur(link.to);
|
|
8122
|
-
return SchemaAST.replaceEncoding(ast, to === link.to ? [link] : [new SchemaAST.Link(to, link.transformation)]);
|
|
9592
|
+
if (!Predicate.isFunction(getLink)) {
|
|
9593
|
+
return SchemaAST.replaceEncoding(ast, [SchemaAST.unknownToJson]);
|
|
8123
9594
|
}
|
|
8124
|
-
|
|
9595
|
+
const typeParameters = ast.typeParameters.map(tp => InternalSchema.make(SchemaAST.toEncoded(tp)));
|
|
9596
|
+
const link = getLink(typeParameters);
|
|
9597
|
+
return link === undefined ? ast : SchemaAST.replaceEncoding(ast, [SchemaAST.mapLink(link, recur)]);
|
|
8125
9598
|
}
|
|
8126
9599
|
case "Unknown":
|
|
8127
|
-
case "ObjectKeyword":
|
|
8128
9600
|
return SchemaAST.replaceEncoding(ast, [SchemaAST.unknownToJson]);
|
|
9601
|
+
case "ObjectKeyword":
|
|
9602
|
+
return SchemaAST.replaceEncoding(ast, [SchemaAST.objectKeywordToJson]);
|
|
8129
9603
|
case "Undefined":
|
|
8130
9604
|
case "Void":
|
|
8131
9605
|
case "Literal":
|
|
@@ -8137,16 +9611,12 @@ function toCodecJsonBase(ast, recur) {
|
|
|
8137
9611
|
return ast.toCodecStringTree();
|
|
8138
9612
|
case "Objects":
|
|
8139
9613
|
{
|
|
8140
|
-
|
|
8141
|
-
throw new globalThis.Error("Objects property names must be strings", {
|
|
8142
|
-
cause: ast
|
|
8143
|
-
});
|
|
8144
|
-
}
|
|
9614
|
+
validateCanonicalObjectPropertyNames(ast);
|
|
8145
9615
|
return ast.recur(recur, SchemaAST.parameterFromString);
|
|
8146
9616
|
}
|
|
8147
9617
|
case "Union":
|
|
8148
9618
|
{
|
|
8149
|
-
const sortedTypes =
|
|
9619
|
+
const sortedTypes = toCodecJsonReorder(ast.types);
|
|
8150
9620
|
if (sortedTypes !== ast.types) {
|
|
8151
9621
|
return new SchemaAST.Union(sortedTypes, ast.mode, ast.annotations, ast.checks, ast.encoding, ast.context, ast.encodingChecks).recur(recur);
|
|
8152
9622
|
}
|
|
@@ -8171,7 +9641,7 @@ export function toCodecIso(schema) {
|
|
|
8171
9641
|
}
|
|
8172
9642
|
const toCodecIsoTop = /*#__PURE__*/memoize(ast => {
|
|
8173
9643
|
const out = toCodecIsoBase(ast, toCodecIsoTop);
|
|
8174
|
-
return out !== ast &&
|
|
9644
|
+
return out !== ast && ast.context !== undefined ? SchemaAST.replaceContextLastLink(out, withoutConstructorDefault(ast.context)) : out;
|
|
8175
9645
|
});
|
|
8176
9646
|
function toCodecIsoBase(ast, recur) {
|
|
8177
9647
|
switch (ast._tag) {
|
|
@@ -8180,8 +9650,7 @@ function toCodecIsoBase(ast, recur) {
|
|
|
8180
9650
|
const getLink = ast.annotations?.toCodecIso ?? ast.annotations?.toCodec;
|
|
8181
9651
|
if (Predicate.isFunction(getLink)) {
|
|
8182
9652
|
const link = getLink(ast.typeParameters.map(tp => InternalSchema.make(tp)));
|
|
8183
|
-
|
|
8184
|
-
return SchemaAST.replaceEncoding(ast, to === link.to ? [link] : [new SchemaAST.Link(to, link.transformation)]);
|
|
9653
|
+
return SchemaAST.replaceEncoding(ast, [SchemaAST.mapLink(link, recur)]);
|
|
8185
9654
|
}
|
|
8186
9655
|
return ast;
|
|
8187
9656
|
}
|
|
@@ -8197,10 +9666,11 @@ function toCodecIsoBase(ast, recur) {
|
|
|
8197
9666
|
* Converts a schema to the StringTree canonical codec, where every leaf value
|
|
8198
9667
|
* becomes a string while preserving the original structure.
|
|
8199
9668
|
*
|
|
8200
|
-
* **
|
|
9669
|
+
* **Gotchas**
|
|
8201
9670
|
*
|
|
8202
|
-
* Declarations
|
|
8203
|
-
* `
|
|
9671
|
+
* Declarations must provide a structural `toCodecStringTree`, `toCodecJson`, or
|
|
9672
|
+
* `toCodec` encoding. A callback can return `undefined` when the declaration is
|
|
9673
|
+
* already in canonical StringTree form.
|
|
8204
9674
|
*
|
|
8205
9675
|
* @category Canonical Codecs
|
|
8206
9676
|
* @since 4.0.0
|
|
@@ -8340,7 +9810,7 @@ const xml = {
|
|
|
8340
9810
|
};
|
|
8341
9811
|
}
|
|
8342
9812
|
};
|
|
8343
|
-
|
|
9813
|
+
const toStringTreeReorder = /*#__PURE__*/makeReorder(ast => {
|
|
8344
9814
|
switch (ast._tag) {
|
|
8345
9815
|
case "Null":
|
|
8346
9816
|
case "Boolean":
|
|
@@ -8352,20 +9822,23 @@ function getStringTreePriority(ast) {
|
|
|
8352
9822
|
default:
|
|
8353
9823
|
return 1;
|
|
8354
9824
|
}
|
|
8355
|
-
}
|
|
8356
|
-
const treeReorder = /*#__PURE__*/InternalSchema.makeReorder(getStringTreePriority);
|
|
9825
|
+
});
|
|
8357
9826
|
function serializerTree(ast, recur, onMissingAnnotation) {
|
|
8358
9827
|
switch (ast._tag) {
|
|
8359
9828
|
case "Declaration":
|
|
8360
9829
|
{
|
|
8361
|
-
const
|
|
8362
|
-
|
|
8363
|
-
|
|
8364
|
-
const link =
|
|
8365
|
-
|
|
8366
|
-
return SchemaAST.replaceEncoding(ast,
|
|
9830
|
+
const typeParameters = ast.typeParameters.map(tp => make(recur(SchemaAST.toEncoded(tp))));
|
|
9831
|
+
const getStringTreeLink = ast.annotations?.toCodecStringTree;
|
|
9832
|
+
if (Predicate.isFunction(getStringTreeLink)) {
|
|
9833
|
+
const link = getStringTreeLink(typeParameters);
|
|
9834
|
+
if (link === undefined) return ast;
|
|
9835
|
+
return SchemaAST.replaceEncoding(ast, [SchemaAST.mapLink(link, recur)]);
|
|
8367
9836
|
}
|
|
8368
|
-
|
|
9837
|
+
const getJsonLink = ast.annotations?.toCodecJson;
|
|
9838
|
+
const jsonLink = Predicate.isFunction(getJsonLink) ? getJsonLink(typeParameters) : undefined;
|
|
9839
|
+
const getLink = jsonLink === undefined ? ast.annotations?.toCodec : undefined;
|
|
9840
|
+
const link = jsonLink ?? (Predicate.isFunction(getLink) ? getLink(typeParameters) : undefined);
|
|
9841
|
+
return link === undefined ? onMissingAnnotation(ast) : SchemaAST.replaceEncoding(ast, [SchemaAST.mapLink(link, recur)]);
|
|
8369
9842
|
}
|
|
8370
9843
|
case "Null":
|
|
8371
9844
|
return SchemaAST.replaceEncoding(ast, [nullToString]);
|
|
@@ -8383,16 +9856,12 @@ function serializerTree(ast, recur, onMissingAnnotation) {
|
|
|
8383
9856
|
return ast.toCodecStringTree();
|
|
8384
9857
|
case "Objects":
|
|
8385
9858
|
{
|
|
8386
|
-
|
|
8387
|
-
throw new globalThis.Error("Objects property names must be strings", {
|
|
8388
|
-
cause: ast
|
|
8389
|
-
});
|
|
8390
|
-
}
|
|
9859
|
+
validateCanonicalObjectPropertyNames(ast);
|
|
8391
9860
|
return ast.recur(recur, SchemaAST.parameterFromString);
|
|
8392
9861
|
}
|
|
8393
9862
|
case "Union":
|
|
8394
9863
|
{
|
|
8395
|
-
const sortedTypes =
|
|
9864
|
+
const sortedTypes = toStringTreeReorder(ast.types);
|
|
8396
9865
|
if (sortedTypes !== ast.types) {
|
|
8397
9866
|
return new SchemaAST.Union(sortedTypes, ast.mode, ast.annotations, ast.checks, ast.encoding, ast.context, ast.encodingChecks).recur(recur);
|
|
8398
9867
|
}
|
|
@@ -8413,13 +9882,16 @@ const serializerStringTree = /*#__PURE__*/SchemaAST.applyToSelfOrLastLinkEncodin
|
|
|
8413
9882
|
if (isSerializerArrayFromSingle(ast)) {
|
|
8414
9883
|
return ast;
|
|
8415
9884
|
}
|
|
8416
|
-
const out = serializerTree(ast, serializerStringTree, ast =>
|
|
8417
|
-
|
|
8418
|
-
|
|
9885
|
+
const out = serializerTree(ast, serializerStringTree, ast => {
|
|
9886
|
+
throw new globalThis.Error("Missing structural codec for StringTree", {
|
|
9887
|
+
cause: ast
|
|
9888
|
+
});
|
|
9889
|
+
});
|
|
9890
|
+
if (out !== ast && ast.context !== undefined) {
|
|
9891
|
+
return SchemaAST.replaceContextLastLink(out, withoutConstructorDefault(ast.context));
|
|
8419
9892
|
}
|
|
8420
9893
|
return out;
|
|
8421
9894
|
});
|
|
8422
|
-
const unknownToUndefined = /*#__PURE__*/new SchemaAST.Link(SchemaAST.undefined, /*#__PURE__*/new SchemaTransformation.Transformation(/*#__PURE__*/SchemaGetter.passthrough(), /*#__PURE__*/SchemaGetter.transform(() => undefined)));
|
|
8423
9895
|
const toArrayFromSingleInputElement = ast => SchemaAST.isOptional(ast) ? SchemaAST.optionalKey(SchemaAST.unknown) : SchemaAST.unknown;
|
|
8424
9896
|
const arrayFromSingleTransformation = /*#__PURE__*/new SchemaTransformation.Transformation(/*#__PURE__*/SchemaGetter.transform(input => typeof input === "string" ? [input] : input), /*#__PURE__*/SchemaGetter.passthrough());
|
|
8425
9897
|
const toCodecArrayFromSingleTop = /*#__PURE__*/SchemaAST.applyToSelfOrLastLinkEncoding(ast => {
|
|
@@ -8438,6 +9910,192 @@ const toCodecArrayFromSingleTop = /*#__PURE__*/SchemaAST.applyToSelfOrLastLinkEn
|
|
|
8438
9910
|
function onSerializerArrayFromSingle(ast) {
|
|
8439
9911
|
return ast._tag === "Declaration" || ast._tag === "Arrays" || ast._tag === "Objects" || ast._tag === "Union" || ast._tag === "Suspend" ? ast.recur(toCodecArrayFromSingleTop) : ast;
|
|
8440
9912
|
}
|
|
9913
|
+
/**
|
|
9914
|
+
* Reviver for persisted `isGreaterThanDate` checks.
|
|
9915
|
+
*
|
|
9916
|
+
* **When to use**
|
|
9917
|
+
*
|
|
9918
|
+
* Use when reconstructing documents that may contain checks created by {@link isGreaterThanDate}.
|
|
9919
|
+
*
|
|
9920
|
+
* @see {@link isGreaterThanDate} for creating the corresponding check
|
|
9921
|
+
*
|
|
9922
|
+
* @category Date checks
|
|
9923
|
+
* @since 4.0.0
|
|
9924
|
+
*/
|
|
9925
|
+
export const isGreaterThanDateReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isGreaterThanDate", /*#__PURE__*/Struct({
|
|
9926
|
+
exclusiveMinimum: Date
|
|
9927
|
+
}), ({
|
|
9928
|
+
annotations,
|
|
9929
|
+
payload
|
|
9930
|
+
}) => isGreaterThanDate(payload.exclusiveMinimum, annotations));
|
|
9931
|
+
/**
|
|
9932
|
+
* Reviver for persisted `isGreaterThanOrEqualToDate` checks.
|
|
9933
|
+
*
|
|
9934
|
+
* **When to use**
|
|
9935
|
+
*
|
|
9936
|
+
* Use when reconstructing documents that may contain checks created by {@link isGreaterThanOrEqualToDate}.
|
|
9937
|
+
*
|
|
9938
|
+
* @see {@link isGreaterThanOrEqualToDate} for creating the corresponding check
|
|
9939
|
+
*
|
|
9940
|
+
* @category Date checks
|
|
9941
|
+
* @since 4.0.0
|
|
9942
|
+
*/
|
|
9943
|
+
export const isGreaterThanOrEqualToDateReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isGreaterThanOrEqualToDate", /*#__PURE__*/Struct({
|
|
9944
|
+
minimum: Date
|
|
9945
|
+
}), ({
|
|
9946
|
+
annotations,
|
|
9947
|
+
payload
|
|
9948
|
+
}) => isGreaterThanOrEqualToDate(payload.minimum, annotations));
|
|
9949
|
+
/**
|
|
9950
|
+
* Reviver for persisted `isLessThanDate` checks.
|
|
9951
|
+
*
|
|
9952
|
+
* **When to use**
|
|
9953
|
+
*
|
|
9954
|
+
* Use when reconstructing documents that may contain checks created by {@link isLessThanDate}.
|
|
9955
|
+
*
|
|
9956
|
+
* @see {@link isLessThanDate} for creating the corresponding check
|
|
9957
|
+
*
|
|
9958
|
+
* @category Date checks
|
|
9959
|
+
* @since 4.0.0
|
|
9960
|
+
*/
|
|
9961
|
+
export const isLessThanDateReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isLessThanDate", /*#__PURE__*/Struct({
|
|
9962
|
+
exclusiveMaximum: Date
|
|
9963
|
+
}), ({
|
|
9964
|
+
annotations,
|
|
9965
|
+
payload
|
|
9966
|
+
}) => isLessThanDate(payload.exclusiveMaximum, annotations));
|
|
9967
|
+
/**
|
|
9968
|
+
* Reviver for persisted `isLessThanOrEqualToDate` checks.
|
|
9969
|
+
*
|
|
9970
|
+
* **When to use**
|
|
9971
|
+
*
|
|
9972
|
+
* Use when reconstructing documents that may contain checks created by {@link isLessThanOrEqualToDate}.
|
|
9973
|
+
*
|
|
9974
|
+
* @see {@link isLessThanOrEqualToDate} for creating the corresponding check
|
|
9975
|
+
*
|
|
9976
|
+
* @category Date checks
|
|
9977
|
+
* @since 4.0.0
|
|
9978
|
+
*/
|
|
9979
|
+
export const isLessThanOrEqualToDateReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isLessThanOrEqualToDate", /*#__PURE__*/Struct({
|
|
9980
|
+
maximum: Date
|
|
9981
|
+
}), ({
|
|
9982
|
+
annotations,
|
|
9983
|
+
payload
|
|
9984
|
+
}) => isLessThanOrEqualToDate(payload.maximum, annotations));
|
|
9985
|
+
/**
|
|
9986
|
+
* Reviver for persisted `isBetweenDate` checks.
|
|
9987
|
+
*
|
|
9988
|
+
* **When to use**
|
|
9989
|
+
*
|
|
9990
|
+
* Use when reconstructing documents that may contain checks created by {@link isBetweenDate}.
|
|
9991
|
+
*
|
|
9992
|
+
* @see {@link isBetweenDate} for creating the corresponding check
|
|
9993
|
+
*
|
|
9994
|
+
* @category Date checks
|
|
9995
|
+
* @since 4.0.0
|
|
9996
|
+
*/
|
|
9997
|
+
export const isBetweenDateReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isBetweenDate", /*#__PURE__*/Struct({
|
|
9998
|
+
minimum: Date,
|
|
9999
|
+
maximum: Date,
|
|
10000
|
+
exclusiveMinimum: /*#__PURE__*/optional(/*#__PURE__*/Literal(true)),
|
|
10001
|
+
exclusiveMaximum: /*#__PURE__*/optional(/*#__PURE__*/Literal(true))
|
|
10002
|
+
}), ({
|
|
10003
|
+
annotations,
|
|
10004
|
+
payload
|
|
10005
|
+
}) => isBetweenDate(payload, annotations));
|
|
10006
|
+
/**
|
|
10007
|
+
* Reviver for persisted `isGreaterThanBigInt` checks.
|
|
10008
|
+
*
|
|
10009
|
+
* **When to use**
|
|
10010
|
+
*
|
|
10011
|
+
* Use when reconstructing documents that may contain checks created by {@link isGreaterThanBigInt}.
|
|
10012
|
+
*
|
|
10013
|
+
* @see {@link isGreaterThanBigInt} for creating the corresponding check
|
|
10014
|
+
*
|
|
10015
|
+
* @category BigInt checks
|
|
10016
|
+
* @since 4.0.0
|
|
10017
|
+
*/
|
|
10018
|
+
export const isGreaterThanBigIntReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isGreaterThanBigInt", /*#__PURE__*/Struct({
|
|
10019
|
+
exclusiveMinimum: BigInt
|
|
10020
|
+
}), ({
|
|
10021
|
+
annotations,
|
|
10022
|
+
payload
|
|
10023
|
+
}) => isGreaterThanBigInt(payload.exclusiveMinimum, annotations));
|
|
10024
|
+
/**
|
|
10025
|
+
* Reviver for persisted `isGreaterThanOrEqualToBigInt` checks.
|
|
10026
|
+
*
|
|
10027
|
+
* **When to use**
|
|
10028
|
+
*
|
|
10029
|
+
* Use when reconstructing documents that may contain checks created by {@link isGreaterThanOrEqualToBigInt}.
|
|
10030
|
+
*
|
|
10031
|
+
* @see {@link isGreaterThanOrEqualToBigInt} for creating the corresponding check
|
|
10032
|
+
*
|
|
10033
|
+
* @category BigInt checks
|
|
10034
|
+
* @since 4.0.0
|
|
10035
|
+
*/
|
|
10036
|
+
export const isGreaterThanOrEqualToBigIntReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isGreaterThanOrEqualToBigInt", /*#__PURE__*/Struct({
|
|
10037
|
+
minimum: BigInt
|
|
10038
|
+
}), ({
|
|
10039
|
+
annotations,
|
|
10040
|
+
payload
|
|
10041
|
+
}) => isGreaterThanOrEqualToBigInt(payload.minimum, annotations));
|
|
10042
|
+
/**
|
|
10043
|
+
* Reviver for persisted `isLessThanBigInt` checks.
|
|
10044
|
+
*
|
|
10045
|
+
* **When to use**
|
|
10046
|
+
*
|
|
10047
|
+
* Use when reconstructing documents that may contain checks created by {@link isLessThanBigInt}.
|
|
10048
|
+
*
|
|
10049
|
+
* @see {@link isLessThanBigInt} for creating the corresponding check
|
|
10050
|
+
*
|
|
10051
|
+
* @category BigInt checks
|
|
10052
|
+
* @since 4.0.0
|
|
10053
|
+
*/
|
|
10054
|
+
export const isLessThanBigIntReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isLessThanBigInt", /*#__PURE__*/Struct({
|
|
10055
|
+
exclusiveMaximum: BigInt
|
|
10056
|
+
}), ({
|
|
10057
|
+
annotations,
|
|
10058
|
+
payload
|
|
10059
|
+
}) => isLessThanBigInt(payload.exclusiveMaximum, annotations));
|
|
10060
|
+
/**
|
|
10061
|
+
* Reviver for persisted `isLessThanOrEqualToBigInt` checks.
|
|
10062
|
+
*
|
|
10063
|
+
* **When to use**
|
|
10064
|
+
*
|
|
10065
|
+
* Use when reconstructing documents that may contain checks created by {@link isLessThanOrEqualToBigInt}.
|
|
10066
|
+
*
|
|
10067
|
+
* @see {@link isLessThanOrEqualToBigInt} for creating the corresponding check
|
|
10068
|
+
*
|
|
10069
|
+
* @category BigInt checks
|
|
10070
|
+
* @since 4.0.0
|
|
10071
|
+
*/
|
|
10072
|
+
export const isLessThanOrEqualToBigIntReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isLessThanOrEqualToBigInt", /*#__PURE__*/Struct({
|
|
10073
|
+
maximum: BigInt
|
|
10074
|
+
}), ({
|
|
10075
|
+
annotations,
|
|
10076
|
+
payload
|
|
10077
|
+
}) => isLessThanOrEqualToBigInt(payload.maximum, annotations));
|
|
10078
|
+
/**
|
|
10079
|
+
* Reviver for persisted `isBetweenBigInt` checks.
|
|
10080
|
+
*
|
|
10081
|
+
* **When to use**
|
|
10082
|
+
*
|
|
10083
|
+
* Use when reconstructing documents that may contain checks created by {@link isBetweenBigInt}.
|
|
10084
|
+
*
|
|
10085
|
+
* @see {@link isBetweenBigInt} for creating the corresponding check
|
|
10086
|
+
*
|
|
10087
|
+
* @category BigInt checks
|
|
10088
|
+
* @since 4.0.0
|
|
10089
|
+
*/
|
|
10090
|
+
export const isBetweenBigIntReviver = /*#__PURE__*/InternalSchema.makeFilterReviver("effect/schema/isBetweenBigInt", /*#__PURE__*/Struct({
|
|
10091
|
+
minimum: BigInt,
|
|
10092
|
+
maximum: BigInt,
|
|
10093
|
+
exclusiveMinimum: /*#__PURE__*/optional(/*#__PURE__*/Literal(true)),
|
|
10094
|
+
exclusiveMaximum: /*#__PURE__*/optional(/*#__PURE__*/Literal(true))
|
|
10095
|
+
}), ({
|
|
10096
|
+
annotations,
|
|
10097
|
+
payload
|
|
10098
|
+
}) => isBetweenBigInt(payload, annotations));
|
|
8441
10099
|
// -----------------------------------------------------------------------------
|
|
8442
10100
|
// Optic APIs
|
|
8443
10101
|
// -----------------------------------------------------------------------------
|
|
@@ -8550,7 +10208,25 @@ export function Tree(node) {
|
|
|
8550
10208
|
* @category schemas
|
|
8551
10209
|
* @since 4.0.0
|
|
8552
10210
|
*/
|
|
8553
|
-
export const Json = /*#__PURE__*/make(SchemaAST.Json
|
|
10211
|
+
export const Json = /*#__PURE__*/make(/*#__PURE__*/SchemaAST.annotate(SchemaAST.Json, {
|
|
10212
|
+
toCode: () => ({
|
|
10213
|
+
runtime: "Schema.Json",
|
|
10214
|
+
Type: "Schema.Json"
|
|
10215
|
+
})
|
|
10216
|
+
}));
|
|
10217
|
+
/**
|
|
10218
|
+
* Reviver for persisted `Json` declarations.
|
|
10219
|
+
*
|
|
10220
|
+
* **When to use**
|
|
10221
|
+
*
|
|
10222
|
+
* Use when reconstructing documents that may contain the {@link Json} schema.
|
|
10223
|
+
*
|
|
10224
|
+
* @see {@link Json} for the corresponding immutable JSON schema
|
|
10225
|
+
*
|
|
10226
|
+
* @category schemas
|
|
10227
|
+
* @since 4.0.0
|
|
10228
|
+
*/
|
|
10229
|
+
export const JsonReviver = /*#__PURE__*/makeFixedDeclarationReviver("effect/schema/Json", Json);
|
|
8554
10230
|
const JsonError = /*#__PURE__*/Struct({
|
|
8555
10231
|
message: String,
|
|
8556
10232
|
name: /*#__PURE__*/optionalKey(String),
|
|
@@ -8564,7 +10240,25 @@ const JsonError = /*#__PURE__*/Struct({
|
|
|
8564
10240
|
* @category schemas
|
|
8565
10241
|
* @since 4.0.0
|
|
8566
10242
|
*/
|
|
8567
|
-
export const MutableJson = /*#__PURE__*/make(SchemaAST.MutableJson
|
|
10243
|
+
export const MutableJson = /*#__PURE__*/make(/*#__PURE__*/SchemaAST.annotate(SchemaAST.MutableJson, {
|
|
10244
|
+
toCode: () => ({
|
|
10245
|
+
runtime: "Schema.MutableJson",
|
|
10246
|
+
Type: "Schema.MutableJson"
|
|
10247
|
+
})
|
|
10248
|
+
}));
|
|
10249
|
+
/**
|
|
10250
|
+
* Reviver for persisted `MutableJson` declarations.
|
|
10251
|
+
*
|
|
10252
|
+
* **When to use**
|
|
10253
|
+
*
|
|
10254
|
+
* Use when reconstructing documents that may contain the {@link MutableJson} schema.
|
|
10255
|
+
*
|
|
10256
|
+
* @see {@link MutableJson} for the corresponding mutable JSON schema
|
|
10257
|
+
*
|
|
10258
|
+
* @category schemas
|
|
10259
|
+
* @since 4.0.0
|
|
10260
|
+
*/
|
|
10261
|
+
export const MutableJsonReviver = /*#__PURE__*/makeFixedDeclarationReviver("effect/schema/MutableJson", MutableJson);
|
|
8568
10262
|
// -----------------------------------------------------------------------------
|
|
8569
10263
|
// Annotations
|
|
8570
10264
|
// -----------------------------------------------------------------------------
|