effect 4.0.0-beta.103 → 4.0.0-beta.105
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/AGENTS.md +381 -0
- package/CLAUDE.md +381 -0
- package/ai-docs/README.md +44 -0
- package/ai-docs/package.json +36 -0
- package/ai-docs/src/01_effect/01_basics/01_effect-gen.ts +30 -0
- package/ai-docs/src/01_effect/01_basics/02_effect-fn.ts +39 -0
- package/ai-docs/src/01_effect/01_basics/10_creating-effects.ts +74 -0
- package/ai-docs/src/01_effect/01_basics/index.md +5 -0
- package/ai-docs/src/01_effect/02_schema/10_schema-basics.ts +43 -0
- package/ai-docs/src/01_effect/02_schema/index.md +7 -0
- package/ai-docs/src/01_effect/03_services/01_service.ts +45 -0
- package/ai-docs/src/01_effect/03_services/10_reference.ts +10 -0
- package/ai-docs/src/01_effect/03_services/20_layer-composition.ts +70 -0
- package/ai-docs/src/01_effect/03_services/20_layer-unwrap.ts +66 -0
- package/ai-docs/src/01_effect/03_services/index.md +5 -0
- package/ai-docs/src/01_effect/04_errors/01_error-handling.ts +30 -0
- package/ai-docs/src/01_effect/04_errors/10_catch-tags.ts +24 -0
- package/ai-docs/src/01_effect/04_errors/20_reason-errors.ts +64 -0
- package/ai-docs/src/01_effect/04_errors/index.md +1 -0
- package/ai-docs/src/01_effect/05_resources/10_acquire-release.ts +105 -0
- package/ai-docs/src/01_effect/05_resources/20_layer-side-effects.ts +31 -0
- package/ai-docs/src/01_effect/05_resources/30_layer-map.ts +86 -0
- package/ai-docs/src/01_effect/05_resources/index.md +3 -0
- package/ai-docs/src/01_effect/06_running/10_run-main.ts +30 -0
- package/ai-docs/src/01_effect/06_running/20_layer-launch.ts +27 -0
- package/ai-docs/src/01_effect/06_running/index.md +1 -0
- package/ai-docs/src/01_effect/07_pubsub/10_pubsub.ts +56 -0
- package/ai-docs/src/01_effect/07_pubsub/index.md +3 -0
- package/ai-docs/src/03_stream/10_creating-streams.ts +103 -0
- package/ai-docs/src/03_stream/20_consuming-streams.ts +137 -0
- package/ai-docs/src/03_stream/30_encoding.ts +165 -0
- package/ai-docs/src/03_stream/index.md +4 -0
- package/ai-docs/src/04_integration/10_managed-runtime.ts +129 -0
- package/ai-docs/src/04_integration/index.md +5 -0
- package/ai-docs/src/05_batching/10_request-resolver.ts +89 -0
- package/ai-docs/src/05_batching/index.md +3 -0
- package/ai-docs/src/06_schedule/10_schedules.ts +110 -0
- package/ai-docs/src/06_schedule/index.md +3 -0
- package/ai-docs/src/07_datetime/10_creating-and-formatting.ts +30 -0
- package/ai-docs/src/07_datetime/20_time-zones.ts +44 -0
- package/ai-docs/src/07_datetime/index.md +5 -0
- package/ai-docs/src/08_observability/10_logging.ts +66 -0
- package/ai-docs/src/08_observability/20_otlp-tracing.ts +95 -0
- package/ai-docs/src/08_observability/index.md +7 -0
- package/ai-docs/src/09_testing/10_effect-tests.ts +55 -0
- package/ai-docs/src/09_testing/20_layer-tests.ts +138 -0
- package/ai-docs/src/09_testing/index.md +1 -0
- package/ai-docs/src/10_predicate/01_basics.ts +14 -0
- package/ai-docs/src/10_predicate/index.md +9 -0
- package/ai-docs/src/50_http-client/10_basics.ts +102 -0
- package/ai-docs/src/50_http-client/index.md +3 -0
- package/ai-docs/src/51_http-server/10_basics.ts +116 -0
- package/ai-docs/src/51_http-server/fixtures/api/Api.ts +14 -0
- package/ai-docs/src/51_http-server/fixtures/api/Authorization.ts +36 -0
- package/ai-docs/src/51_http-server/fixtures/api/System.ts +10 -0
- package/ai-docs/src/51_http-server/fixtures/api/Users.ts +91 -0
- package/ai-docs/src/51_http-server/fixtures/domain/User.ts +12 -0
- package/ai-docs/src/51_http-server/fixtures/domain/UserErrors.ts +22 -0
- package/ai-docs/src/51_http-server/fixtures/server/Authorization.ts +36 -0
- package/ai-docs/src/51_http-server/fixtures/server/Users/http.ts +71 -0
- package/ai-docs/src/51_http-server/fixtures/server/Users.ts +62 -0
- package/ai-docs/src/51_http-server/index.md +3 -0
- package/ai-docs/src/60_child-process/10_working-with-child-processes.ts +117 -0
- package/ai-docs/src/60_child-process/index.md +3 -0
- package/ai-docs/src/70_cli/10_basics.ts +136 -0
- package/ai-docs/src/70_cli/index.md +5 -0
- package/ai-docs/src/71_ai/10_language-model.ts +156 -0
- package/ai-docs/src/71_ai/20_tools.ts +226 -0
- package/ai-docs/src/71_ai/30_chat.ts +158 -0
- package/ai-docs/src/71_ai/fixtures/domain/LaunchPlan.ts +9 -0
- package/ai-docs/src/71_ai/index.md +5 -0
- package/ai-docs/src/80_cluster/10_entities.ts +97 -0
- package/ai-docs/src/80_cluster/index.md +4 -0
- package/ai-docs/src/index.md +10 -0
- package/ai-docs/tsconfig.json +24 -0
- package/dist/Brand.d.ts +3 -3
- package/dist/Brand.d.ts.map +1 -1
- package/dist/Brand.js +4 -3
- package/dist/Brand.js.map +1 -1
- package/dist/Cache.js +1 -1
- package/dist/Cache.js.map +1 -1
- package/dist/Channel.d.ts +1 -1
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js.map +1 -1
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +30 -8
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.d.ts.map +1 -1
- package/dist/ConfigProvider.js +2 -1
- package/dist/ConfigProvider.js.map +1 -1
- package/dist/Context.d.ts +2 -3
- package/dist/Context.d.ts.map +1 -1
- package/dist/Context.js +1 -22
- package/dist/Context.js.map +1 -1
- package/dist/Cron.d.ts +31 -0
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +58 -2
- package/dist/Cron.js.map +1 -1
- package/dist/Crypto.d.ts.map +1 -1
- package/dist/Crypto.js +13 -5
- package/dist/Crypto.js.map +1 -1
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +12 -1
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +132 -14
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +38 -0
- package/dist/Effect.js.map +1 -1
- package/dist/Equal.d.ts.map +1 -1
- package/dist/Equal.js +10 -2
- package/dist/Equal.js.map +1 -1
- package/dist/ExecutionPlan.d.ts +73 -0
- package/dist/ExecutionPlan.d.ts.map +1 -1
- package/dist/ExecutionPlan.js +1 -1
- package/dist/ExecutionPlan.js.map +1 -1
- package/dist/FiberSet.js +1 -1
- package/dist/FileSystem.d.ts +2 -2
- package/dist/Function.d.ts +4 -3
- package/dist/Function.d.ts.map +1 -1
- package/dist/Function.js +5 -5
- package/dist/Function.js.map +1 -1
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +11 -10
- package/dist/Iterable.js.map +1 -1
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +7 -5
- package/dist/Layer.js.map +1 -1
- package/dist/Optic.d.ts +35 -21
- package/dist/Optic.d.ts.map +1 -1
- package/dist/Optic.js +33 -34
- package/dist/Optic.js.map +1 -1
- package/dist/Schedule.d.ts +8 -8
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +4 -4
- package/dist/Schedule.js.map +1 -1
- package/dist/Schema.d.ts +105 -57
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +105 -67
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +33 -3
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +87 -63
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaError.d.ts +8 -8
- package/dist/SchemaError.d.ts.map +1 -1
- package/dist/SchemaError.js +7 -6
- package/dist/SchemaError.js.map +1 -1
- package/dist/SchemaGetter.d.ts +8 -5
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +41 -37
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaIssue.d.ts +195 -38
- package/dist/SchemaIssue.d.ts.map +1 -1
- package/dist/SchemaIssue.js +243 -68
- package/dist/SchemaIssue.js.map +1 -1
- package/dist/SchemaParser.d.ts +30 -0
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +74 -62
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +2 -2
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +26 -26
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/ScopedCache.js +1 -1
- package/dist/ScopedCache.js.map +1 -1
- package/dist/Sink.d.ts +1 -1
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Stdio.d.ts +17 -4
- package/dist/Stdio.d.ts.map +1 -1
- package/dist/Stdio.js +6 -3
- package/dist/Stdio.js.map +1 -1
- package/dist/Stream.d.ts +27 -4
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +27 -2
- package/dist/Stream.js.map +1 -1
- package/dist/SynchronizedRef.js +1 -1
- package/dist/SynchronizedRef.js.map +1 -1
- package/dist/Terminal.js +1 -1
- package/dist/Terminal.js.map +1 -1
- package/dist/Tuple.d.ts +6 -4
- package/dist/Tuple.d.ts.map +1 -1
- package/dist/Tuple.js.map +1 -1
- package/dist/TxReentrantLock.d.ts +0 -56
- package/dist/TxReentrantLock.d.ts.map +1 -1
- package/dist/TxReentrantLock.js +8 -8
- package/dist/TxReentrantLock.js.map +1 -1
- package/dist/internal/dateTime.js +1 -1
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/executionPlan.js +51 -3
- package/dist/internal/executionPlan.js.map +1 -1
- package/dist/internal/hashMap.js +12 -8
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/matcher.js +1 -1
- package/dist/internal/matcher.js.map +1 -1
- package/dist/internal/schedule.js.map +1 -1
- package/dist/internal/schema/annotations.js +2 -0
- package/dist/internal/schema/annotations.js.map +1 -1
- package/dist/internal/schema/schema.js +1 -9
- package/dist/internal/schema/schema.js.map +1 -1
- package/dist/internal/schema/toArbitrary.js +1 -1
- package/dist/internal/schema/toArbitrary.js.map +1 -1
- package/dist/internal/trie.js +13 -3
- package/dist/internal/trie.js.map +1 -1
- package/dist/testing/TestClock.d.ts.map +1 -1
- package/dist/testing/TestClock.js +11 -1
- package/dist/testing/TestClock.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +2 -2
- package/dist/testing/TestSchema.d.ts.map +1 -1
- package/dist/testing/TestSchema.js +8 -7
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/unstable/ai/AiError.js +19 -19
- package/dist/unstable/ai/AiError.js.map +1 -1
- package/dist/unstable/ai/Chat.js +1 -1
- package/dist/unstable/ai/Chat.js.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +4 -2
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/ai/McpSchema.d.ts +132 -132
- package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
- package/dist/unstable/ai/McpSchema.js +8 -8
- package/dist/unstable/ai/McpSchema.js.map +1 -1
- package/dist/unstable/ai/McpServer.js +1 -1
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/ai/Prompt.d.ts +15 -3
- package/dist/unstable/ai/Prompt.d.ts.map +1 -1
- package/dist/unstable/ai/Prompt.js +10 -7
- package/dist/unstable/ai/Prompt.js.map +1 -1
- package/dist/unstable/cli/CliError.d.ts +3 -3
- package/dist/unstable/cli/CliError.js +11 -11
- package/dist/unstable/cli/CliError.js.map +1 -1
- package/dist/unstable/cli/Command.d.ts +9 -9
- package/dist/unstable/cli/Command.d.ts.map +1 -1
- package/dist/unstable/cli/Command.js +8 -6
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cli/Param.d.ts +7 -5
- package/dist/unstable/cli/Param.d.ts.map +1 -1
- package/dist/unstable/cli/Param.js +15 -11
- package/dist/unstable/cli/Param.js.map +1 -1
- package/dist/unstable/cli/Primitive.d.ts.map +1 -1
- package/dist/unstable/cli/Primitive.js +31 -24
- package/dist/unstable/cli/Primitive.js.map +1 -1
- package/dist/unstable/cli/Prompt.d.ts.map +1 -1
- package/dist/unstable/cli/Prompt.js +31 -17
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/cli/internal/ansi.js +2 -2
- package/dist/unstable/cli/internal/ansi.js.map +1 -1
- package/dist/unstable/cli/internal/command.d.ts +2 -2
- package/dist/unstable/cli/internal/command.d.ts.map +1 -1
- package/dist/unstable/cli/internal/command.js +10 -9
- package/dist/unstable/cli/internal/command.js.map +1 -1
- package/dist/unstable/cli/internal/completions/bash.js +69 -9
- package/dist/unstable/cli/internal/completions/bash.js.map +1 -1
- package/dist/unstable/cli/internal/completions/descriptor.js +24 -18
- package/dist/unstable/cli/internal/completions/descriptor.js.map +1 -1
- package/dist/unstable/cli/internal/completions/fish.js +5 -5
- package/dist/unstable/cli/internal/completions/fish.js.map +1 -1
- package/dist/unstable/cli/internal/help.d.ts.map +1 -1
- package/dist/unstable/cli/internal/help.js +4 -2
- package/dist/unstable/cli/internal/help.js.map +1 -1
- package/dist/unstable/cli/internal/parser.js +3 -3
- package/dist/unstable/cli/internal/parser.js.map +1 -1
- package/dist/unstable/cli/internal/wizard.js +2 -2
- package/dist/unstable/cli/internal/wizard.js.map +1 -1
- package/dist/unstable/cluster/ClusterError.js +7 -7
- package/dist/unstable/cluster/ClusterError.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/MessageStorage.js +8 -1
- package/dist/unstable/cluster/MessageStorage.js.map +1 -1
- package/dist/unstable/cluster/Reply.d.ts +8 -0
- package/dist/unstable/cluster/Reply.d.ts.map +1 -1
- package/dist/unstable/cluster/Reply.js +16 -4
- package/dist/unstable/cluster/Reply.js.map +1 -1
- package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerServer.js +4 -2
- package/dist/unstable/cluster/RunnerServer.js.map +1 -1
- package/dist/unstable/cluster/RunnerStorage.d.ts +1 -2
- package/dist/unstable/cluster/RunnerStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerStorage.js +7 -6
- package/dist/unstable/cluster/RunnerStorage.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +22 -4
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/internal/entityManager.js +1 -1
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/cluster/internal/resourceMap.js +2 -2
- package/dist/unstable/cluster/internal/resourceMap.js.map +1 -1
- package/dist/unstable/cluster/internal/resourceRef.js +17 -0
- package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
- package/dist/unstable/devtools/DevToolsClient.d.ts.map +1 -1
- package/dist/unstable/devtools/DevToolsClient.js +7 -2
- package/dist/unstable/devtools/DevToolsClient.js.map +1 -1
- package/dist/unstable/encoding/Ini.d.ts +20 -0
- package/dist/unstable/encoding/Ini.d.ts.map +1 -0
- package/dist/unstable/encoding/Ini.js +153 -0
- package/dist/unstable/encoding/Ini.js.map +1 -0
- package/dist/unstable/encoding/Msgpack.d.ts +2 -1
- package/dist/unstable/encoding/Msgpack.d.ts.map +1 -1
- package/dist/unstable/encoding/Msgpack.js +27 -13
- package/dist/unstable/encoding/Msgpack.js.map +1 -1
- package/dist/unstable/encoding/Ndjson.d.ts.map +1 -1
- package/dist/unstable/encoding/Ndjson.js +7 -1
- package/dist/unstable/encoding/Ndjson.js.map +1 -1
- package/dist/unstable/encoding/Sse.d.ts.map +1 -1
- package/dist/unstable/encoding/Sse.js +14 -23
- package/dist/unstable/encoding/Sse.js.map +1 -1
- package/dist/unstable/encoding/Toml.d.ts +19 -0
- package/dist/unstable/encoding/Toml.d.ts.map +1 -0
- package/dist/unstable/encoding/Toml.js +434 -0
- package/dist/unstable/encoding/Toml.js.map +1 -0
- package/dist/unstable/encoding/Yaml.d.ts +19 -0
- package/dist/unstable/encoding/Yaml.d.ts.map +1 -0
- package/dist/unstable/encoding/Yaml.js +461 -0
- package/dist/unstable/encoding/Yaml.js.map +1 -0
- package/dist/unstable/encoding/index.d.ts +12 -0
- package/dist/unstable/encoding/index.d.ts.map +1 -1
- package/dist/unstable/encoding/index.js +12 -0
- package/dist/unstable/encoding/index.js.map +1 -1
- package/dist/unstable/eventlog/EventJournal.d.ts +1 -1
- package/dist/unstable/eventlog/EventJournal.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventJournal.js +13 -5
- package/dist/unstable/eventlog/EventJournal.js.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.js +1 -1
- package/dist/unstable/eventlog/EventLogMessage.js.map +1 -1
- package/dist/unstable/eventlog/EventLogServerUnencrypted.js +1 -1
- package/dist/unstable/eventlog/EventLogServerUnencrypted.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventJournal.d.ts.map +1 -1
- package/dist/unstable/eventlog/SqlEventJournal.js +1 -4
- package/dist/unstable/eventlog/SqlEventJournal.js.map +1 -1
- package/dist/unstable/http/FindMyWay/internal/queryString.d.ts +11 -0
- package/dist/unstable/http/FindMyWay/internal/queryString.d.ts.map +1 -0
- package/dist/unstable/http/FindMyWay/internal/queryString.js +259 -0
- package/dist/unstable/http/FindMyWay/internal/queryString.js.map +1 -0
- package/dist/unstable/http/FindMyWay/internal/router.d.ts +2 -0
- package/dist/unstable/http/FindMyWay/internal/router.d.ts.map +1 -0
- package/dist/unstable/http/FindMyWay/internal/router.js +665 -0
- package/dist/unstable/http/FindMyWay/internal/router.js.map +1 -0
- package/dist/unstable/http/FindMyWay.d.ts +33 -8
- package/dist/unstable/http/FindMyWay.d.ts.map +1 -1
- package/dist/unstable/http/FindMyWay.js +4 -7
- package/dist/unstable/http/FindMyWay.js.map +1 -1
- package/dist/unstable/http/HttpClient.d.ts +59 -3
- package/dist/unstable/http/HttpClient.d.ts.map +1 -1
- package/dist/unstable/http/HttpClient.js +33 -19
- package/dist/unstable/http/HttpClient.js.map +1 -1
- package/dist/unstable/http/HttpClientError.js +1 -1
- package/dist/unstable/http/HttpClientError.js.map +1 -1
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.js +2 -14
- package/dist/unstable/http/HttpClientRequest.js.map +1 -1
- package/dist/unstable/http/HttpClientResponse.js +1 -16
- package/dist/unstable/http/HttpClientResponse.js.map +1 -1
- package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
- package/dist/unstable/http/HttpPlatform.js +21 -3
- package/dist/unstable/http/HttpPlatform.js.map +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRequest.js +7 -6
- package/dist/unstable/http/HttpServerRequest.js.map +1 -1
- package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerResponse.js +8 -6
- package/dist/unstable/http/HttpServerResponse.js.map +1 -1
- package/dist/unstable/http/Multipart.d.ts +1 -1
- package/dist/unstable/http/Multipart.d.ts.map +1 -1
- package/dist/unstable/http/Multipart.js +9 -2
- package/dist/unstable/http/Multipart.js.map +1 -1
- package/dist/unstable/http/MultipartParser/HeadersParser.d.ts +53 -0
- package/dist/unstable/http/MultipartParser/HeadersParser.d.ts.map +1 -0
- package/dist/unstable/http/MultipartParser/HeadersParser.js +14 -0
- package/dist/unstable/http/MultipartParser/HeadersParser.js.map +1 -0
- package/dist/unstable/http/MultipartParser/Search.d.ts +11 -0
- package/dist/unstable/http/MultipartParser/Search.d.ts.map +1 -0
- package/dist/unstable/http/MultipartParser/Search.js +14 -0
- package/dist/unstable/http/MultipartParser/Search.js.map +1 -0
- package/dist/unstable/http/MultipartParser/internal/contentType.d.ts +5 -0
- package/dist/unstable/http/MultipartParser/internal/contentType.d.ts.map +1 -0
- package/dist/unstable/http/MultipartParser/internal/contentType.js +82 -0
- package/dist/unstable/http/MultipartParser/internal/contentType.js.map +1 -0
- package/dist/unstable/http/MultipartParser/internal/headers.d.ts +3 -0
- package/dist/unstable/http/MultipartParser/internal/headers.d.ts.map +1 -0
- package/dist/unstable/http/MultipartParser/internal/headers.js +194 -0
- package/dist/unstable/http/MultipartParser/internal/headers.js.map +1 -0
- package/dist/unstable/http/MultipartParser/internal/multipart.d.ts +8 -0
- package/dist/unstable/http/MultipartParser/internal/multipart.d.ts.map +1 -0
- package/dist/unstable/http/MultipartParser/internal/multipart.js +226 -0
- package/dist/unstable/http/MultipartParser/internal/multipart.js.map +1 -0
- package/dist/unstable/http/MultipartParser/internal/search.d.ts +5 -0
- package/dist/unstable/http/MultipartParser/internal/search.d.ts.map +1 -0
- package/dist/unstable/http/MultipartParser/internal/search.js +120 -0
- package/dist/unstable/http/MultipartParser/internal/search.js.map +1 -0
- package/dist/unstable/http/MultipartParser.d.ts +98 -0
- package/dist/unstable/http/MultipartParser.d.ts.map +1 -0
- package/dist/unstable/http/MultipartParser.js +23 -0
- package/dist/unstable/http/MultipartParser.js.map +1 -0
- package/dist/unstable/http/Template.d.ts.map +1 -1
- package/dist/unstable/http/Template.js +2 -2
- package/dist/unstable/http/Template.js.map +1 -1
- package/dist/unstable/http/index.d.ts +1 -1
- package/dist/unstable/http/index.d.ts.map +1 -1
- package/dist/unstable/http/index.js +1 -1
- package/dist/unstable/http/index.js.map +1 -1
- package/dist/unstable/http/internal/httpBody.d.ts +2 -0
- package/dist/unstable/http/internal/httpBody.d.ts.map +1 -0
- package/dist/unstable/http/internal/httpBody.js +10 -0
- package/dist/unstable/http/internal/httpBody.js.map +1 -0
- package/dist/unstable/httpapi/HttpApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApi.js +5 -5
- package/dist/unstable/httpapi/HttpApi.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +73 -20
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.d.ts +1 -1
- package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js +74 -34
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +6 -4
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.js +73 -16
- package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.d.ts +5 -5
- package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.js +17 -17
- package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.js +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.d.ts +219 -0
- package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.js +170 -0
- package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts +8 -0
- package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/OpenApi.js +45 -18
- package/dist/unstable/httpapi/OpenApi.js.map +1 -1
- package/dist/unstable/observability/OtlpExporter.d.ts +1 -1
- package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.js +2 -1
- package/dist/unstable/observability/OtlpExporter.js.map +1 -1
- 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 +2 -2
- package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.js +28 -15
- package/dist/unstable/observability/OtlpMetrics.js.map +1 -1
- package/dist/unstable/observability/OtlpTracer.js +1 -1
- package/dist/unstable/observability/OtlpTracer.js.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.js +9 -9
- package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
- package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
- package/dist/unstable/persistence/Persistence.js +17 -7
- package/dist/unstable/persistence/Persistence.js.map +1 -1
- package/dist/unstable/persistence/RateLimiter.d.ts +22 -12
- package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
- package/dist/unstable/persistence/RateLimiter.js +15 -42
- package/dist/unstable/persistence/RateLimiter.js.map +1 -1
- package/dist/unstable/persistence/Redis.js +1 -1
- package/dist/unstable/persistence/Redis.js.map +1 -1
- package/dist/unstable/reactivity/AsyncResult.d.ts.map +1 -1
- package/dist/unstable/reactivity/AsyncResult.js +4 -4
- package/dist/unstable/reactivity/AsyncResult.js.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts +26 -11
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +9 -22
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts +14 -0
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +21 -10
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/rpc/RpcClientError.js +2 -2
- package/dist/unstable/rpc/RpcClientError.js.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.js +3 -1
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +3 -2
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/schema/Model.d.ts +1 -1
- package/dist/unstable/schema/Model.d.ts.map +1 -1
- package/dist/unstable/schema/VariantSchema.d.ts +5 -5
- package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
- package/dist/unstable/schema/VariantSchema.js +17 -9
- package/dist/unstable/schema/VariantSchema.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +28 -12
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
- package/dist/unstable/sql/SqlClient.js +7 -3
- package/dist/unstable/sql/SqlClient.js.map +1 -1
- package/dist/unstable/sql/SqlError.js +13 -13
- package/dist/unstable/sql/SqlError.js.map +1 -1
- package/dist/unstable/sql/SqlResolver.js +8 -6
- package/dist/unstable/sql/SqlResolver.js.map +1 -1
- package/dist/unstable/sql/Statement.d.ts.map +1 -1
- package/dist/unstable/sql/Statement.js +8 -6
- package/dist/unstable/sql/Statement.js.map +1 -1
- package/dist/unstable/workers/WorkerError.js +5 -5
- package/dist/unstable/workers/WorkerError.js.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
- package/dist/unstable/workflow/Workflow.js +2 -2
- package/dist/unstable/workflow/Workflow.js.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js +3 -3
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +6 -9
- package/src/Brand.ts +4 -4
- package/src/Cache.ts +1 -1
- package/src/Channel.ts +1 -1
- package/src/Config.ts +31 -8
- package/src/ConfigProvider.ts +4 -1
- package/src/Context.ts +6 -28
- package/src/Cron.ts +65 -2
- package/src/Crypto.ts +17 -8
- package/src/Duration.ts +16 -2
- package/src/Effect.ts +141 -17
- package/src/Equal.ts +10 -2
- package/src/ExecutionPlan.ts +78 -1
- package/src/FiberSet.ts +1 -1
- package/src/FileSystem.ts +2 -2
- package/src/Function.ts +6 -6
- package/src/Iterable.ts +11 -10
- package/src/Layer.ts +7 -5
- package/src/Optic.ts +59 -58
- package/src/Schedule.ts +13 -13
- package/src/Schema.ts +195 -112
- package/src/SchemaAST.ts +154 -85
- package/src/SchemaError.ts +9 -9
- package/src/SchemaGetter.ts +89 -30
- package/src/SchemaIssue.ts +285 -80
- package/src/SchemaParser.ts +126 -86
- package/src/SchemaTransformation.ts +66 -18
- package/src/ScopedCache.ts +1 -1
- package/src/Sink.ts +1 -1
- package/src/Stdio.ts +23 -4
- package/src/Stream.ts +77 -10
- package/src/SynchronizedRef.ts +1 -1
- package/src/Terminal.ts +1 -1
- package/src/Tuple.ts +7 -4
- package/src/TxReentrantLock.ts +39 -35
- package/src/internal/dateTime.ts +1 -1
- package/src/internal/executionPlan.ts +105 -10
- package/src/internal/hashMap.ts +20 -14
- package/src/internal/matcher.ts +2 -2
- package/src/internal/schedule.ts +4 -4
- package/src/internal/schema/annotations.ts +3 -0
- package/src/internal/schema/schema.ts +1 -17
- package/src/internal/schema/toArbitrary.ts +3 -1
- package/src/internal/trie.ts +12 -2
- package/src/testing/TestClock.ts +13 -1
- package/src/testing/TestSchema.ts +9 -9
- package/src/unstable/ai/AiError.ts +19 -19
- package/src/unstable/ai/Chat.ts +1 -1
- package/src/unstable/ai/LanguageModel.ts +4 -2
- package/src/unstable/ai/McpSchema.ts +17 -16
- package/src/unstable/ai/McpServer.ts +1 -1
- package/src/unstable/ai/Prompt.ts +35 -10
- package/src/unstable/cli/CliError.ts +12 -12
- package/src/unstable/cli/Command.ts +12 -10
- package/src/unstable/cli/Param.ts +41 -19
- package/src/unstable/cli/Primitive.ts +11 -5
- package/src/unstable/cli/Prompt.ts +36 -20
- package/src/unstable/cli/internal/ansi.ts +2 -2
- package/src/unstable/cli/internal/command.ts +15 -10
- package/src/unstable/cli/internal/completions/bash.ts +59 -9
- package/src/unstable/cli/internal/completions/descriptor.ts +14 -20
- package/src/unstable/cli/internal/completions/fish.ts +5 -7
- package/src/unstable/cli/internal/help.ts +4 -2
- package/src/unstable/cli/internal/parser.ts +3 -3
- package/src/unstable/cli/internal/wizard.ts +2 -2
- package/src/unstable/cluster/ClusterError.ts +7 -7
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +4 -1
- package/src/unstable/cluster/MessageStorage.ts +9 -5
- package/src/unstable/cluster/Reply.ts +25 -4
- package/src/unstable/cluster/RunnerServer.ts +4 -10
- package/src/unstable/cluster/RunnerStorage.ts +9 -7
- package/src/unstable/cluster/Sharding.ts +35 -7
- package/src/unstable/cluster/internal/entityManager.ts +1 -1
- package/src/unstable/cluster/internal/resourceMap.ts +5 -2
- package/src/unstable/cluster/internal/resourceRef.ts +27 -5
- package/src/unstable/devtools/DevToolsClient.ts +3 -2
- package/src/unstable/encoding/Ini.ts +174 -0
- package/src/unstable/encoding/Msgpack.ts +59 -36
- package/src/unstable/encoding/Ndjson.ts +9 -1
- package/src/unstable/encoding/Sse.ts +11 -21
- package/src/unstable/encoding/Toml.ts +504 -0
- package/src/unstable/encoding/Yaml.ts +541 -0
- package/src/unstable/encoding/index.ts +15 -0
- package/src/unstable/eventlog/EventJournal.ts +14 -6
- package/src/unstable/eventlog/EventLogMessage.ts +1 -1
- package/src/unstable/eventlog/EventLogServerUnencrypted.ts +1 -1
- package/src/unstable/eventlog/SqlEventJournal.ts +6 -4
- package/src/unstable/http/FindMyWay/internal/queryString.ts +420 -0
- package/src/unstable/http/FindMyWay/internal/router.ts +950 -0
- package/src/unstable/http/FindMyWay.ts +65 -6
- package/src/unstable/http/HttpClient.ts +132 -23
- package/src/unstable/http/HttpClientError.ts +1 -1
- package/src/unstable/http/HttpClientRequest.ts +2 -14
- package/src/unstable/http/HttpClientResponse.ts +1 -17
- package/src/unstable/http/HttpPlatform.ts +34 -6
- package/src/unstable/http/HttpServerRequest.ts +14 -6
- package/src/unstable/http/HttpServerResponse.ts +9 -7
- package/src/unstable/http/Multipart.ts +9 -2
- package/src/unstable/http/MultipartParser/HeadersParser.ts +68 -0
- package/src/unstable/http/MultipartParser/Search.ts +17 -0
- package/src/unstable/http/MultipartParser/internal/contentType.ts +103 -0
- package/src/unstable/http/MultipartParser/internal/headers.ts +615 -0
- package/src/unstable/http/MultipartParser/internal/multipart.ts +262 -0
- package/src/unstable/http/MultipartParser/internal/search.ts +167 -0
- package/src/unstable/http/MultipartParser.ts +115 -0
- package/src/unstable/http/Template.ts +6 -5
- package/src/unstable/http/index.ts +1 -1
- package/src/unstable/http/internal/httpBody.ts +15 -0
- package/src/unstable/httpapi/HttpApi.ts +6 -7
- package/src/unstable/httpapi/HttpApiBuilder.ts +142 -25
- package/src/unstable/httpapi/HttpApiClient.ts +130 -49
- package/src/unstable/httpapi/HttpApiEndpoint.ts +117 -29
- package/src/unstable/httpapi/HttpApiError.ts +33 -39
- package/src/unstable/httpapi/HttpApiMiddleware.ts +1 -1
- package/src/unstable/httpapi/HttpApiSchema.ts +353 -0
- package/src/unstable/httpapi/OpenApi.ts +70 -20
- package/src/unstable/observability/OtlpExporter.ts +4 -2
- package/src/unstable/observability/OtlpLogger.ts +3 -1
- package/src/unstable/observability/OtlpMetrics.ts +32 -18
- package/src/unstable/observability/OtlpTracer.ts +1 -1
- package/src/unstable/persistence/PersistedQueue.ts +12 -9
- package/src/unstable/persistence/Persistence.ts +27 -7
- package/src/unstable/persistence/RateLimiter.ts +54 -31
- package/src/unstable/persistence/Redis.ts +1 -1
- package/src/unstable/reactivity/AsyncResult.ts +11 -6
- package/src/unstable/reactivity/Atom.ts +44 -25
- package/src/unstable/rpc/RpcClient.ts +42 -13
- package/src/unstable/rpc/RpcClientError.ts +2 -2
- package/src/unstable/rpc/RpcSerialization.ts +1 -1
- package/src/unstable/rpc/RpcServer.ts +4 -2
- package/src/unstable/schema/VariantSchema.ts +36 -18
- package/src/unstable/socket/Socket.ts +24 -14
- package/src/unstable/sql/SqlClient.ts +65 -56
- package/src/unstable/sql/SqlError.ts +13 -13
- package/src/unstable/sql/SqlResolver.ts +8 -6
- package/src/unstable/sql/Statement.ts +13 -8
- package/src/unstable/workers/WorkerError.ts +5 -5
- package/src/unstable/workflow/Workflow.ts +2 -5
- package/src/unstable/workflow/WorkflowEngine.ts +8 -3
- package/dist/unstable/http/Multipasta/HeadersParser.d.ts +0 -14
- package/dist/unstable/http/Multipasta/HeadersParser.d.ts.map +0 -1
- package/dist/unstable/http/Multipasta/HeadersParser.js +0 -14
- package/dist/unstable/http/Multipasta/HeadersParser.js.map +0 -1
- package/dist/unstable/http/Multipasta/Node.d.ts +0 -14
- package/dist/unstable/http/Multipasta/Node.d.ts.map +0 -1
- package/dist/unstable/http/Multipasta/Node.js +0 -14
- package/dist/unstable/http/Multipasta/Node.js.map +0 -1
- package/dist/unstable/http/Multipasta/Search.d.ts +0 -14
- package/dist/unstable/http/Multipasta/Search.d.ts.map +0 -1
- package/dist/unstable/http/Multipasta/Search.js +0 -14
- package/dist/unstable/http/Multipasta/Search.js.map +0 -1
- package/dist/unstable/http/Multipasta/Web.d.ts +0 -14
- package/dist/unstable/http/Multipasta/Web.d.ts.map +0 -1
- package/dist/unstable/http/Multipasta/Web.js +0 -14
- package/dist/unstable/http/Multipasta/Web.js.map +0 -1
- package/dist/unstable/http/Multipasta.d.ts +0 -15
- package/dist/unstable/http/Multipasta.d.ts.map +0 -1
- package/dist/unstable/http/Multipasta.js +0 -15
- package/dist/unstable/http/Multipasta.js.map +0 -1
- package/src/unstable/http/Multipasta/HeadersParser.ts +0 -14
- package/src/unstable/http/Multipasta/Node.ts +0 -14
- package/src/unstable/http/Multipasta/Search.ts +0 -14
- package/src/unstable/http/Multipasta/Web.ts +0 -14
- package/src/unstable/http/Multipasta.ts +0 -15
package/src/SchemaAST.ts
CHANGED
|
@@ -450,6 +450,8 @@ export type Encoding = readonly [Link, ...Array<Link>]
|
|
|
450
450
|
* transformations.
|
|
451
451
|
* - `concurrency` — maximum number of async parse effects to run concurrently;
|
|
452
452
|
* defaults to `1`, or use `"unbounded"`.
|
|
453
|
+
* - `reportInput` — includes rejected input values in value-bearing schema
|
|
454
|
+
* issues.
|
|
453
455
|
*
|
|
454
456
|
* @category options
|
|
455
457
|
* @since 3.10.0
|
|
@@ -516,6 +518,35 @@ export interface ParseOptions {
|
|
|
516
518
|
* @default 1
|
|
517
519
|
*/
|
|
518
520
|
readonly concurrency?: number | "unbounded" | undefined
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* Whether schema issues should retain and report rejected input values.
|
|
524
|
+
*
|
|
525
|
+
* **Details**
|
|
526
|
+
*
|
|
527
|
+
* When enabled, value-bearing issues created by the parser expose an `input`
|
|
528
|
+
* field. Built-in formatters may include reported input in default messages.
|
|
529
|
+
* The input is retained by reference rather than copied.
|
|
530
|
+
*
|
|
531
|
+
* **Gotchas**
|
|
532
|
+
*
|
|
533
|
+
* Enabling this option can retain or disclose secrets, personally
|
|
534
|
+
* identifiable information, and large object graphs. The `input` field is
|
|
535
|
+
* enumerable and may be included by object enumeration, spread, or
|
|
536
|
+
* serialization. Disabling it on a nested schema does not redact that value
|
|
537
|
+
* from an ancestor issue whose input reporting remains enabled. Issues
|
|
538
|
+
* returned directly by user-defined declarations, checks, transformations,
|
|
539
|
+
* and middleware are not modified; their authors decide whether to retain an
|
|
540
|
+
* input. To respect this option, pass the callback's input and parse options
|
|
541
|
+
* directly to a value-bearing issue constructor. Custom messages and
|
|
542
|
+
* annotations remain the caller's responsibility regardless of this option.
|
|
543
|
+
* Formatting an issue with `SchemaIssue.makeFormatterDefault()`, reading
|
|
544
|
+
* `SchemaError.message`, or formatting a Standard Schema failure can disclose
|
|
545
|
+
* retained input.
|
|
546
|
+
*
|
|
547
|
+
* @default false
|
|
548
|
+
*/
|
|
549
|
+
readonly reportInput?: boolean | undefined
|
|
519
550
|
}
|
|
520
551
|
|
|
521
552
|
/** @internal */
|
|
@@ -532,7 +563,7 @@ export const defaultParseOptions: ParseOptions = {}
|
|
|
532
563
|
*
|
|
533
564
|
* - `isOptional` — the property key may be absent from the input.
|
|
534
565
|
* - `isMutable` — the property is `readonly` when `false`.
|
|
535
|
-
* - `
|
|
566
|
+
* - `constructorDefault` — a {@link Link} applied during construction to
|
|
536
567
|
* supply missing values.
|
|
537
568
|
* - `annotations` — key-level annotations (e.g. description of the key
|
|
538
569
|
* itself).
|
|
@@ -546,19 +577,19 @@ export class Context {
|
|
|
546
577
|
readonly isOptional: boolean
|
|
547
578
|
readonly isMutable: boolean
|
|
548
579
|
/** Used for constructor default values (e.g. `withConstructorDefault` API) */
|
|
549
|
-
readonly
|
|
580
|
+
readonly constructorDefault: Link | undefined
|
|
550
581
|
readonly annotations: Schema.Annotations.Key<unknown> | undefined
|
|
551
582
|
|
|
552
583
|
constructor(
|
|
553
584
|
isOptional: boolean,
|
|
554
585
|
isMutable: boolean,
|
|
555
586
|
/** Used for constructor default values (e.g. `withConstructorDefault` API) */
|
|
556
|
-
|
|
587
|
+
constructorDefault: Link | undefined = undefined,
|
|
557
588
|
annotations: Schema.Annotations.Key<unknown> | undefined = undefined
|
|
558
589
|
) {
|
|
559
590
|
this.isOptional = isOptional
|
|
560
591
|
this.isMutable = isMutable
|
|
561
|
-
this.
|
|
592
|
+
this.constructorDefault = constructorDefault
|
|
562
593
|
this.annotations = annotations
|
|
563
594
|
}
|
|
564
595
|
}
|
|
@@ -1141,8 +1172,8 @@ export class TemplateLiteral extends Base {
|
|
|
1141
1172
|
this.suffixLengths = suffixLengths
|
|
1142
1173
|
}
|
|
1143
1174
|
/** @internal */
|
|
1144
|
-
getParser(
|
|
1145
|
-
const parser =
|
|
1175
|
+
getParser(compile: SchemaParser.Compiler): SchemaParser.Parser {
|
|
1176
|
+
const parser = compile(this.asTemplateLiteralParser())
|
|
1146
1177
|
return (input, options) => {
|
|
1147
1178
|
if (input === InternalParser.missing) return InternalParser.missingExit
|
|
1148
1179
|
const result = parser(input, options)
|
|
@@ -1151,7 +1182,7 @@ export class TemplateLiteral extends Base {
|
|
|
1151
1182
|
}
|
|
1152
1183
|
return Effect.mapBothEager(result, {
|
|
1153
1184
|
onSuccess: () => input,
|
|
1154
|
-
onFailure: (issue) => new SchemaIssue.Composite(this, [issue])
|
|
1185
|
+
onFailure: (issue) => new SchemaIssue.Composite(this, [issue], input, options)
|
|
1155
1186
|
})
|
|
1156
1187
|
}
|
|
1157
1188
|
}
|
|
@@ -1174,9 +1205,11 @@ export class TemplateLiteral extends Base {
|
|
|
1174
1205
|
const segments = segmentTemplateLiteralParts(this, s, options)
|
|
1175
1206
|
if (segments) return Effect.succeed(segments)
|
|
1176
1207
|
return Effect.fail(
|
|
1177
|
-
new SchemaIssue.InvalidValue(
|
|
1178
|
-
|
|
1179
|
-
|
|
1208
|
+
new SchemaIssue.InvalidValue(
|
|
1209
|
+
{ expected: "a string matching template literal parts" },
|
|
1210
|
+
s,
|
|
1211
|
+
options
|
|
1212
|
+
)
|
|
1180
1213
|
)
|
|
1181
1214
|
}),
|
|
1182
1215
|
SchemaGetter.transform((parts) => parts.join(""))
|
|
@@ -1684,7 +1717,10 @@ export class Arrays extends Base {
|
|
|
1684
1717
|
}
|
|
1685
1718
|
}
|
|
1686
1719
|
/** @internal */
|
|
1687
|
-
getParser(
|
|
1720
|
+
getParser(
|
|
1721
|
+
compile: SchemaParser.Compiler,
|
|
1722
|
+
compileConstructorDefault: SchemaParser.Compiler = compile
|
|
1723
|
+
): SchemaParser.Parser {
|
|
1688
1724
|
// oxlint-disable-next-line @typescript-eslint/no-this-alias
|
|
1689
1725
|
const ast = this
|
|
1690
1726
|
type ElementParser = { readonly ast: AST; readonly parser: SchemaParser.Parser }
|
|
@@ -1712,11 +1748,11 @@ export class Arrays extends Base {
|
|
|
1712
1748
|
|
|
1713
1749
|
// If the input is not an array, return early with an error
|
|
1714
1750
|
if (!Array.isArray(input)) {
|
|
1715
|
-
return yield* Effect.fail(new SchemaIssue.InvalidType(ast))
|
|
1751
|
+
return yield* Effect.fail(new SchemaIssue.InvalidType(ast, input, options))
|
|
1716
1752
|
}
|
|
1717
1753
|
if (!elements) {
|
|
1718
|
-
elements = ast.elements.map((ast) => ({ ast, parser:
|
|
1719
|
-
rest = ast.rest.map((ast) => ({ ast, parser:
|
|
1754
|
+
elements = ast.elements.map((ast) => ({ ast, parser: compileConstructorDefault(ast) }))
|
|
1755
|
+
rest = ast.rest.map((ast) => ({ ast, parser: compileConstructorDefault(ast) }))
|
|
1720
1756
|
}
|
|
1721
1757
|
|
|
1722
1758
|
const len = input.length
|
|
@@ -1742,20 +1778,21 @@ export class Arrays extends Base {
|
|
|
1742
1778
|
// ---------------------------------------------
|
|
1743
1779
|
if (ast.rest.length === 0 && len > elementLen) {
|
|
1744
1780
|
for (let i = elementLen; i <= len - 1; i++) {
|
|
1745
|
-
const
|
|
1781
|
+
const unexpected = new SchemaIssue.UnexpectedKey(ast, input[i], options)
|
|
1782
|
+
const issue = new SchemaIssue.Pointer([i], unexpected)
|
|
1746
1783
|
if (options.errors === "all") {
|
|
1747
1784
|
if (state.issues) state.issues.push(issue)
|
|
1748
1785
|
else state.issues = [issue]
|
|
1749
1786
|
} else {
|
|
1750
1787
|
return yield* Effect.fail(
|
|
1751
|
-
new SchemaIssue.Composite(ast, [issue])
|
|
1788
|
+
new SchemaIssue.Composite(ast, [issue], input, options)
|
|
1752
1789
|
)
|
|
1753
1790
|
}
|
|
1754
1791
|
}
|
|
1755
1792
|
}
|
|
1756
1793
|
if (state.issues) {
|
|
1757
1794
|
return yield* Effect.fail(
|
|
1758
|
-
new SchemaIssue.Composite(ast, state.issues)
|
|
1795
|
+
new SchemaIssue.Composite(ast, state.issues, input, options)
|
|
1759
1796
|
)
|
|
1760
1797
|
}
|
|
1761
1798
|
return state.output
|
|
@@ -1826,7 +1863,7 @@ const parseArray = iterateEager<{
|
|
|
1826
1863
|
else s.issues = [issue]
|
|
1827
1864
|
} else {
|
|
1828
1865
|
return Exit.fail(
|
|
1829
|
-
new SchemaIssue.Composite(s.ast, [issue])
|
|
1866
|
+
new SchemaIssue.Composite(s.ast, [issue], s.input, s.options)
|
|
1830
1867
|
)
|
|
1831
1868
|
}
|
|
1832
1869
|
}
|
|
@@ -1859,7 +1896,9 @@ const wrapPropertyKeyIssue = (
|
|
|
1859
1896
|
(issue) =>
|
|
1860
1897
|
new SchemaIssue.Composite(
|
|
1861
1898
|
ast,
|
|
1862
|
-
[new SchemaIssue.Pointer([key], issue)]
|
|
1899
|
+
[new SchemaIssue.Pointer([key], issue)],
|
|
1900
|
+
s.input,
|
|
1901
|
+
s.options
|
|
1863
1902
|
)
|
|
1864
1903
|
)
|
|
1865
1904
|
)
|
|
@@ -1870,7 +1909,7 @@ const wrapPropertyKeyIssue = (
|
|
|
1870
1909
|
else s.issues = [pointer]
|
|
1871
1910
|
} else {
|
|
1872
1911
|
return Exit.fail(
|
|
1873
|
-
new SchemaIssue.Composite(ast, [pointer])
|
|
1912
|
+
new SchemaIssue.Composite(ast, [pointer], s.input, s.options)
|
|
1874
1913
|
)
|
|
1875
1914
|
}
|
|
1876
1915
|
}
|
|
@@ -2076,7 +2115,10 @@ export class Objects extends Base {
|
|
|
2076
2115
|
}
|
|
2077
2116
|
}
|
|
2078
2117
|
/** @internal */
|
|
2079
|
-
getParser(
|
|
2118
|
+
getParser(
|
|
2119
|
+
compile: SchemaParser.Compiler,
|
|
2120
|
+
compileConstructorDefault: SchemaParser.Compiler = compile
|
|
2121
|
+
): SchemaParser.Parser {
|
|
2080
2122
|
// oxlint-disable-next-line @typescript-eslint/no-this-alias
|
|
2081
2123
|
const ast = this
|
|
2082
2124
|
const expectedKeys: Array<PropertyKey> = []
|
|
@@ -2171,19 +2213,19 @@ export class Objects extends Base {
|
|
|
2171
2213
|
|
|
2172
2214
|
// If the input is not a record, return early with an error
|
|
2173
2215
|
if (!(typeof input === "object" && input !== null && !Array.isArray(input))) {
|
|
2174
|
-
return yield* Effect.fail(new SchemaIssue.InvalidType(ast))
|
|
2216
|
+
return yield* Effect.fail(new SchemaIssue.InvalidType(ast, input, options))
|
|
2175
2217
|
}
|
|
2176
2218
|
if (!properties) {
|
|
2177
2219
|
properties = ast.propertySignatures.map((ps) => ({
|
|
2178
|
-
parser:
|
|
2220
|
+
parser: compileConstructorDefault(ps.type),
|
|
2179
2221
|
name: ps.name,
|
|
2180
2222
|
type: ps.type
|
|
2181
2223
|
}))
|
|
2182
2224
|
indexes = indexCount
|
|
2183
2225
|
? ast.indexSignatures.map((is) => ({
|
|
2184
2226
|
is,
|
|
2185
|
-
parserKey:
|
|
2186
|
-
parserValue:
|
|
2227
|
+
parserKey: compile(parameterFromPropertyKey(is.parameter)),
|
|
2228
|
+
parserValue: compileConstructorDefault(is.type)
|
|
2187
2229
|
}))
|
|
2188
2230
|
: undefined
|
|
2189
2231
|
}
|
|
@@ -2213,7 +2255,8 @@ export class Objects extends Base {
|
|
|
2213
2255
|
if (!expectedKeysSet.has(key)) {
|
|
2214
2256
|
// key is unexpected
|
|
2215
2257
|
if (onExcessPropertyError) {
|
|
2216
|
-
const
|
|
2258
|
+
const unexpected = new SchemaIssue.UnexpectedKey(ast, record[key], options)
|
|
2259
|
+
const issue = new SchemaIssue.Pointer([key], unexpected)
|
|
2217
2260
|
if (errorsAllOption) {
|
|
2218
2261
|
if (state.issues) {
|
|
2219
2262
|
state.issues.push(issue)
|
|
@@ -2223,7 +2266,7 @@ export class Objects extends Base {
|
|
|
2223
2266
|
continue
|
|
2224
2267
|
} else {
|
|
2225
2268
|
return yield* Effect.fail(
|
|
2226
|
-
new SchemaIssue.Composite(ast, [issue])
|
|
2269
|
+
new SchemaIssue.Composite(ast, [issue], input, options)
|
|
2227
2270
|
)
|
|
2228
2271
|
}
|
|
2229
2272
|
} else {
|
|
@@ -2275,7 +2318,7 @@ export class Objects extends Base {
|
|
|
2275
2318
|
|
|
2276
2319
|
if (state.issues) {
|
|
2277
2320
|
return yield* Effect.fail(
|
|
2278
|
-
new SchemaIssue.Composite(ast, state.issues)
|
|
2321
|
+
new SchemaIssue.Composite(ast, state.issues, input, options)
|
|
2279
2322
|
)
|
|
2280
2323
|
}
|
|
2281
2324
|
if (options.propertyOrder === "original") {
|
|
@@ -2381,7 +2424,7 @@ const parseProperties = iterateEager<ObjectParserState, ParsedProperty>()({
|
|
|
2381
2424
|
return
|
|
2382
2425
|
} else {
|
|
2383
2426
|
return Exit.fail(
|
|
2384
|
-
new SchemaIssue.Composite(s.ast, [issue])
|
|
2427
|
+
new SchemaIssue.Composite(s.ast, [issue], s.input, s.options)
|
|
2385
2428
|
)
|
|
2386
2429
|
}
|
|
2387
2430
|
}
|
|
@@ -2577,7 +2620,7 @@ export function collectSentinels(ast: AST): Array<Sentinel> {
|
|
|
2577
2620
|
}
|
|
2578
2621
|
|
|
2579
2622
|
type CandidateIndex =
|
|
2580
|
-
| ((input: any) => ReadonlyArray<AST>)
|
|
2623
|
+
| ((input: any, isConstructor: boolean) => ReadonlyArray<AST>)
|
|
2581
2624
|
| {
|
|
2582
2625
|
bySentinel?: Map<PropertyKey, Map<LiteralValue | symbol, Array<number>>>
|
|
2583
2626
|
otherwise?: { [K in Type]?: Array<number> }
|
|
@@ -2636,10 +2679,14 @@ function getIndex(types: ReadonlyArray<AST>): CandidateIndex {
|
|
|
2636
2679
|
for (const [literal, indexes] of byValue) {
|
|
2637
2680
|
candidates.set(literal, Object.freeze(indexes.map((index) => types[index])))
|
|
2638
2681
|
}
|
|
2639
|
-
idx = (input) =>
|
|
2640
|
-
Predicate.isObjectKeyword(input)
|
|
2641
|
-
|
|
2642
|
-
|
|
2682
|
+
idx = (input, isConstructor) => {
|
|
2683
|
+
if (Predicate.isObjectKeyword(input)) {
|
|
2684
|
+
const value = Object.hasOwn(input, key) ? (input as any)[key] : undefined
|
|
2685
|
+
if (value !== undefined) return candidates.get(value) ?? emptyCandidates
|
|
2686
|
+
if (isConstructor) return types
|
|
2687
|
+
}
|
|
2688
|
+
return emptyCandidates
|
|
2689
|
+
}
|
|
2643
2690
|
}
|
|
2644
2691
|
}
|
|
2645
2692
|
|
|
@@ -2664,9 +2711,13 @@ function filterLiterals(input: any) {
|
|
|
2664
2711
|
*
|
|
2665
2712
|
* @internal
|
|
2666
2713
|
*/
|
|
2667
|
-
export function getCandidates(
|
|
2714
|
+
export function getCandidates(
|
|
2715
|
+
input: any,
|
|
2716
|
+
types: ReadonlyArray<AST>,
|
|
2717
|
+
isConstructor = false
|
|
2718
|
+
): ReadonlyArray<AST> {
|
|
2668
2719
|
const idx = getIndex(types)
|
|
2669
|
-
if (typeof idx === "function") return idx(input)
|
|
2720
|
+
if (typeof idx === "function") return idx(input, isConstructor)
|
|
2670
2721
|
|
|
2671
2722
|
const runtimeType: Type = input === null ? "null" : Array.isArray(input) ? "array" : typeof input
|
|
2672
2723
|
|
|
@@ -2676,11 +2727,16 @@ export function getCandidates(input: any, types: ReadonlyArray<AST>): ReadonlyAr
|
|
|
2676
2727
|
if (Predicate.isObjectKeyword(input)) {
|
|
2677
2728
|
const selected = new Set(base)
|
|
2678
2729
|
for (const [k, m] of idx.bySentinel) {
|
|
2679
|
-
|
|
2680
|
-
|
|
2730
|
+
const value = Object.hasOwn(input, k) ? (input as any)[k] : undefined
|
|
2731
|
+
if (value !== undefined) {
|
|
2732
|
+
const match = m.get(value)
|
|
2681
2733
|
if (match) {
|
|
2682
2734
|
for (const candidate of match) selected.add(candidate)
|
|
2683
2735
|
}
|
|
2736
|
+
} else if (isConstructor) {
|
|
2737
|
+
for (const indexes of m.values()) {
|
|
2738
|
+
for (const candidate of indexes) selected.add(candidate)
|
|
2739
|
+
}
|
|
2684
2740
|
}
|
|
2685
2741
|
}
|
|
2686
2742
|
return Array.from(selected).sort((a, b) => a - b).map((i) => types[i])
|
|
@@ -2743,7 +2799,10 @@ export class Union<A extends AST = AST> extends Base {
|
|
|
2743
2799
|
this.encodingChecks = encodingChecks
|
|
2744
2800
|
}
|
|
2745
2801
|
/** @internal */
|
|
2746
|
-
getParser(
|
|
2802
|
+
getParser(
|
|
2803
|
+
compile: SchemaParser.Compiler,
|
|
2804
|
+
compileConstructorDefault?: SchemaParser.Compiler
|
|
2805
|
+
): SchemaParser.Parser {
|
|
2747
2806
|
// oxlint-disable-next-line @typescript-eslint/no-this-alias
|
|
2748
2807
|
const ast = this
|
|
2749
2808
|
|
|
@@ -2751,19 +2810,19 @@ export class Union<A extends AST = AST> extends Base {
|
|
|
2751
2810
|
if (input === InternalParser.missing) {
|
|
2752
2811
|
return InternalParser.missingExit
|
|
2753
2812
|
}
|
|
2754
|
-
const candidates = getCandidates(input, ast.types)
|
|
2813
|
+
const candidates = getCandidates(input, ast.types, compileConstructorDefault !== undefined)
|
|
2755
2814
|
|
|
2756
2815
|
if (candidates.length === 1) {
|
|
2757
|
-
const result =
|
|
2816
|
+
const result = compile(candidates[0])(input, options)
|
|
2758
2817
|
if ((result as Exit.Exit<unknown, SchemaIssue.Issue>)._tag === "Success") return result
|
|
2759
2818
|
return effectIsExit(result)
|
|
2760
|
-
? failSingleUnionCandidate(ast, (result as Exit.Failure<unknown, SchemaIssue.Issue>).cause)
|
|
2761
|
-
: Effect.catchCause(result, (cause) => failSingleUnionCandidate(ast, cause))
|
|
2819
|
+
? failSingleUnionCandidate(ast, (result as Exit.Failure<unknown, SchemaIssue.Issue>).cause, input, options)
|
|
2820
|
+
: Effect.catchCause(result, (cause) => failSingleUnionCandidate(ast, cause, input, options))
|
|
2762
2821
|
}
|
|
2763
2822
|
|
|
2764
2823
|
const state = {
|
|
2765
2824
|
ast,
|
|
2766
|
-
|
|
2825
|
+
compile,
|
|
2767
2826
|
input,
|
|
2768
2827
|
out: undefined,
|
|
2769
2828
|
successes: ast.mode === "oneOf" ? [] : undefined,
|
|
@@ -2773,12 +2832,13 @@ export class Union<A extends AST = AST> extends Base {
|
|
|
2773
2832
|
const concurrency = resolveConcurrency(options?.concurrency)
|
|
2774
2833
|
const eff = parseUnion(state, candidates, concurrency ? { ...concurrency, orderedStep: true } : undefined)
|
|
2775
2834
|
if (!eff) {
|
|
2776
|
-
|
|
2835
|
+
if (state.out) return state.out
|
|
2836
|
+
return Effect.fail(new SchemaIssue.AnyOf(ast, state.issues ?? [], input, options))
|
|
2777
2837
|
}
|
|
2778
2838
|
return Effect.flatMapEager(eff, (_) => {
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2839
|
+
if (state.out === InternalParser.sameExit) return Effect.succeed(input)
|
|
2840
|
+
if (state.out) return state.out
|
|
2841
|
+
return Effect.fail(new SchemaIssue.AnyOf(ast, state.issues ?? [], input, options))
|
|
2782
2842
|
})
|
|
2783
2843
|
}
|
|
2784
2844
|
}
|
|
@@ -2845,16 +2905,17 @@ export class Union<A extends AST = AST> extends Base {
|
|
|
2845
2905
|
|
|
2846
2906
|
function failSingleUnionCandidate(
|
|
2847
2907
|
ast: Union,
|
|
2848
|
-
cause: Cause.Cause<SchemaIssue.Issue
|
|
2908
|
+
cause: Cause.Cause<SchemaIssue.Issue>,
|
|
2909
|
+
input: unknown,
|
|
2910
|
+
options: ParseOptions
|
|
2849
2911
|
) {
|
|
2850
2912
|
const issue = InternalSchemaCause.getSchemaIssue(cause)
|
|
2851
|
-
return
|
|
2852
|
-
|
|
2853
|
-
: Exit.failCause(cause)
|
|
2913
|
+
if (!issue) return Exit.failCause(cause)
|
|
2914
|
+
return Exit.fail(new SchemaIssue.AnyOf(ast, [issue], input, options))
|
|
2854
2915
|
}
|
|
2855
2916
|
|
|
2856
2917
|
const parseUnion = iterateEager<{
|
|
2857
|
-
readonly
|
|
2918
|
+
readonly compile: (ast: AST) => SchemaParser.Parser
|
|
2858
2919
|
readonly ast: Union
|
|
2859
2920
|
readonly input: unknown
|
|
2860
2921
|
readonly options: ParseOptions
|
|
@@ -2863,7 +2924,7 @@ const parseUnion = iterateEager<{
|
|
|
2863
2924
|
issues: Array<SchemaIssue.Issue> | undefined
|
|
2864
2925
|
}, AST>()({
|
|
2865
2926
|
onItem(s, ast) {
|
|
2866
|
-
const parser = s.
|
|
2927
|
+
const parser = s.compile(ast)
|
|
2867
2928
|
return parser(s.input, s.options)
|
|
2868
2929
|
},
|
|
2869
2930
|
step(s, candidate, exit) {
|
|
@@ -2877,7 +2938,7 @@ const parseUnion = iterateEager<{
|
|
|
2877
2938
|
} else {
|
|
2878
2939
|
if (s.out && s.successes) {
|
|
2879
2940
|
s.successes.push(candidate)
|
|
2880
|
-
return Exit.fail(new SchemaIssue.OneOf(s.ast, s.successes))
|
|
2941
|
+
return Exit.fail(new SchemaIssue.OneOf(s.ast, s.successes, s.input, s.options))
|
|
2881
2942
|
}
|
|
2882
2943
|
s.out = exit
|
|
2883
2944
|
if (s.successes) {
|
|
@@ -2966,9 +3027,9 @@ export class Suspend extends Base {
|
|
|
2966
3027
|
this.thunk = memoizeThunk(thunk)
|
|
2967
3028
|
}
|
|
2968
3029
|
/** @internal */
|
|
2969
|
-
getParser(
|
|
3030
|
+
getParser(compile: SchemaParser.Compiler): SchemaParser.Parser {
|
|
2970
3031
|
let parser: SchemaParser.Parser
|
|
2971
|
-
return (input, options) => (parser ??=
|
|
3032
|
+
return (input, options) => (parser ??= compile(this.thunk()))(input, options)
|
|
2972
3033
|
}
|
|
2973
3034
|
/** @internal */
|
|
2974
3035
|
recur(recur: (ast: AST) => AST) {
|
|
@@ -3103,7 +3164,7 @@ export function makeFilter<T>(
|
|
|
3103
3164
|
aborted: boolean = false
|
|
3104
3165
|
): Filter<T> {
|
|
3105
3166
|
return new Filter(
|
|
3106
|
-
(input, ast, options) => SchemaIssue.normalizeFilterOutput(ast, filter(input, ast, options)),
|
|
3167
|
+
(input, ast, options) => SchemaIssue.normalizeFilterOutput(ast, filter(input, ast, options), input, options),
|
|
3107
3168
|
annotations,
|
|
3108
3169
|
aborted
|
|
3109
3170
|
)
|
|
@@ -3115,7 +3176,7 @@ export function makeFilterByGuard<T extends E, E>(
|
|
|
3115
3176
|
annotations?: Schema.Annotations.Filter
|
|
3116
3177
|
): Filter<any> {
|
|
3117
3178
|
return new Filter(
|
|
3118
|
-
(input: E) => is(input) ? undefined : new SchemaIssue.InvalidValue(),
|
|
3179
|
+
(input: E, _ast, options) => is(input) ? undefined : new SchemaIssue.InvalidValue(undefined, input, options),
|
|
3119
3180
|
annotations,
|
|
3120
3181
|
true // after a guard, we always want to abort
|
|
3121
3182
|
)
|
|
@@ -3364,7 +3425,7 @@ export function annotateKey<A extends AST>(ast: A, annotations: Schema.Annotatio
|
|
|
3364
3425
|
new Context(
|
|
3365
3426
|
ast.context.isOptional,
|
|
3366
3427
|
ast.context.isMutable,
|
|
3367
|
-
ast.context.
|
|
3428
|
+
ast.context.constructorDefault,
|
|
3368
3429
|
{ ...ast.context.annotations, ...annotations }
|
|
3369
3430
|
) :
|
|
3370
3431
|
new Context(false, false, undefined, annotations)
|
|
@@ -3390,7 +3451,7 @@ const optionalKeyLastLink = applyToLastLink(optionalKey)
|
|
|
3390
3451
|
export function optionalKey<A extends AST>(ast: A): A {
|
|
3391
3452
|
const context = ast.context ?
|
|
3392
3453
|
ast.context.isOptional === false ?
|
|
3393
|
-
new Context(true, ast.context.isMutable, ast.context.
|
|
3454
|
+
new Context(true, ast.context.isMutable, ast.context.constructorDefault, ast.context.annotations) :
|
|
3394
3455
|
ast.context :
|
|
3395
3456
|
new Context(true, false)
|
|
3396
3457
|
return optionalKeyLastLink(replaceContext(ast, context))
|
|
@@ -3402,7 +3463,7 @@ const mutableKeyLastLink = applyToLastLink(mutableKey)
|
|
|
3402
3463
|
export function mutableKey<A extends AST>(ast: A): A {
|
|
3403
3464
|
const context = ast.context ?
|
|
3404
3465
|
ast.context.isMutable === false ?
|
|
3405
|
-
new Context(ast.context.isOptional, true, ast.context.
|
|
3466
|
+
new Context(ast.context.isOptional, true, ast.context.constructorDefault, ast.context.annotations) :
|
|
3406
3467
|
ast.context :
|
|
3407
3468
|
new Context(false, true)
|
|
3408
3469
|
return mutableKeyLastLink(replaceContext(ast, context))
|
|
@@ -3417,10 +3478,10 @@ export function withConstructorDefault<A extends AST>(
|
|
|
3417
3478
|
SchemaGetter.withDefault(defaultValue),
|
|
3418
3479
|
SchemaGetter.passthrough()
|
|
3419
3480
|
)
|
|
3420
|
-
const
|
|
3481
|
+
const constructorDefault = new Link(unknown, transformation)
|
|
3421
3482
|
const context = ast.context ?
|
|
3422
|
-
new Context(ast.context.isOptional, ast.context.isMutable,
|
|
3423
|
-
new Context(false, false,
|
|
3483
|
+
new Context(ast.context.isOptional, ast.context.isMutable, constructorDefault, ast.context.annotations) :
|
|
3484
|
+
new Context(false, false, constructorDefault)
|
|
3424
3485
|
return replaceContext(ast, context)
|
|
3425
3486
|
}
|
|
3426
3487
|
|
|
@@ -3666,13 +3727,10 @@ function fromConst<const T>(
|
|
|
3666
3727
|
value: T
|
|
3667
3728
|
): SchemaParser.Parser {
|
|
3668
3729
|
const succeed = InternalParser.succeed(value)
|
|
3669
|
-
return (input) => {
|
|
3730
|
+
return (input, options) => {
|
|
3670
3731
|
if (input === InternalParser.missing) return InternalParser.missingExit
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
: Effect.fail(
|
|
3674
|
-
new SchemaIssue.InvalidType(ast)
|
|
3675
|
-
)
|
|
3732
|
+
if (input === value) return succeed
|
|
3733
|
+
return Effect.fail(new SchemaIssue.InvalidType(ast, input, options))
|
|
3676
3734
|
}
|
|
3677
3735
|
}
|
|
3678
3736
|
|
|
@@ -3680,13 +3738,10 @@ function fromRefinement<T>(
|
|
|
3680
3738
|
ast: AST,
|
|
3681
3739
|
refinement: (input: unknown) => input is T
|
|
3682
3740
|
): SchemaParser.Parser {
|
|
3683
|
-
return (input) => {
|
|
3741
|
+
return (input, options) => {
|
|
3684
3742
|
if (input === InternalParser.missing) return InternalParser.missingExit
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
: Effect.fail(
|
|
3688
|
-
new SchemaIssue.InvalidType(ast)
|
|
3689
|
-
)
|
|
3743
|
+
if (refinement(input)) return InternalParser.sameExit
|
|
3744
|
+
return Effect.fail(new SchemaIssue.InvalidType(ast, input, options))
|
|
3690
3745
|
}
|
|
3691
3746
|
}
|
|
3692
3747
|
|
|
@@ -3874,13 +3929,17 @@ const symbolToString = new Link(
|
|
|
3874
3929
|
symbolString,
|
|
3875
3930
|
new SchemaTransformation.Transformation(
|
|
3876
3931
|
SchemaGetter.transform((description) => globalThis.Symbol.for(isStringSymbolRegExp.exec(description)![1])),
|
|
3877
|
-
SchemaGetter.transformOrFail((sym: symbol) => {
|
|
3932
|
+
SchemaGetter.transformOrFail((sym: symbol, options) => {
|
|
3878
3933
|
const key = globalThis.Symbol.keyFor(sym)
|
|
3879
3934
|
if (key !== undefined) {
|
|
3880
3935
|
return Effect.succeed(globalThis.String(sym))
|
|
3881
3936
|
}
|
|
3882
3937
|
return Effect.fail(
|
|
3883
|
-
new SchemaIssue.Forbidden(
|
|
3938
|
+
new SchemaIssue.Forbidden(
|
|
3939
|
+
{ message: "cannot serialize to string, Symbol is not registered" },
|
|
3940
|
+
sym,
|
|
3941
|
+
options
|
|
3942
|
+
)
|
|
3884
3943
|
)
|
|
3885
3944
|
})
|
|
3886
3945
|
)
|
|
@@ -3923,7 +3982,7 @@ export function collectIssues<T>(
|
|
|
3923
3982
|
} else {
|
|
3924
3983
|
const issue = check.run(value, ast, options)
|
|
3925
3984
|
if (issue) {
|
|
3926
|
-
const filter = new SchemaIssue.Filter(check, issue)
|
|
3985
|
+
const filter = new SchemaIssue.Filter(check, issue, value, options)
|
|
3927
3986
|
if (issues) issues.push(filter)
|
|
3928
3987
|
else issues = [filter]
|
|
3929
3988
|
if (options.errors !== "all" || check.aborted) {
|
|
@@ -3949,7 +4008,17 @@ export function runChecks<T>(
|
|
|
3949
4008
|
}
|
|
3950
4009
|
|
|
3951
4010
|
/** @internal */
|
|
3952
|
-
export
|
|
4011
|
+
export interface ConstructorDescriptor {
|
|
4012
|
+
readonly isConstructed: Predicate.Predicate<unknown>
|
|
4013
|
+
readonly link: Link
|
|
4014
|
+
}
|
|
4015
|
+
|
|
4016
|
+
/** @internal */
|
|
4017
|
+
export function getConstructorDescriptor(ast: AST): ConstructorDescriptor | undefined {
|
|
4018
|
+
if (!isDeclaration(ast)) return undefined
|
|
4019
|
+
const getDescriptor = ast.annotations?.[InternalAnnotations.CONSTRUCTOR_ANNOTATION_KEY]
|
|
4020
|
+
return Predicate.isFunction(getDescriptor) ? getDescriptor(ast.typeParameters) : undefined
|
|
4021
|
+
}
|
|
3953
4022
|
|
|
3954
4023
|
/**
|
|
3955
4024
|
* Returns all annotations from the AST node.
|
|
@@ -4122,10 +4191,10 @@ export function isJson(u: unknown): u is Schema.Json {
|
|
|
4122
4191
|
/** @internal */
|
|
4123
4192
|
export const Json = new Declaration(
|
|
4124
4193
|
[],
|
|
4125
|
-
() => (input, ast) =>
|
|
4194
|
+
() => (input, ast, options) =>
|
|
4126
4195
|
isJson(input) ?
|
|
4127
4196
|
InternalParser.sameExit :
|
|
4128
|
-
Effect.fail(new SchemaIssue.InvalidType(ast)),
|
|
4197
|
+
Effect.fail(new SchemaIssue.InvalidType(ast, input, options)),
|
|
4129
4198
|
{
|
|
4130
4199
|
representation: {
|
|
4131
4200
|
id: "effect/schema/Json",
|
|
@@ -4174,10 +4243,10 @@ export function isStringTree(u: unknown): u is Schema.StringTree {
|
|
|
4174
4243
|
|
|
4175
4244
|
const StringTree = new Declaration(
|
|
4176
4245
|
[],
|
|
4177
|
-
() => (input, ast) =>
|
|
4246
|
+
() => (input, ast, options) =>
|
|
4178
4247
|
isStringTree(input) ?
|
|
4179
4248
|
InternalParser.sameExit :
|
|
4180
|
-
Effect.fail(new SchemaIssue.InvalidType(ast)),
|
|
4249
|
+
Effect.fail(new SchemaIssue.InvalidType(ast, input, options)),
|
|
4181
4250
|
{ expected: "StringTree", toCodecStringTree: () => undefined }
|
|
4182
4251
|
)
|
|
4183
4252
|
|
package/src/SchemaError.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as Data from "./Data.ts"
|
|
5
5
|
import * as Predicate from "./Predicate.ts"
|
|
6
|
-
import
|
|
6
|
+
import * as SchemaIssue from "./SchemaIssue.ts"
|
|
7
7
|
|
|
8
8
|
const TypeId = "~effect/SchemaError/SchemaError"
|
|
9
9
|
|
|
@@ -13,12 +13,12 @@ const TypeId = "~effect/SchemaError/SchemaError"
|
|
|
13
13
|
*
|
|
14
14
|
* **Details**
|
|
15
15
|
*
|
|
16
|
-
* The `issue` field contains a structured {@link Issue} tree describing
|
|
16
|
+
* The `issue` field contains a structured {@link SchemaIssue.Issue} tree describing
|
|
17
17
|
* every validation failure, including the path to the problematic value and
|
|
18
|
-
* the expected type or constraint.
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
18
|
+
* the expected type or constraint. The `message` field renders the issue tree
|
|
19
|
+
* with the default formatter. When input reporting is enabled, the message may
|
|
20
|
+
* include reported input. Other Issue fields and custom annotations or messages
|
|
21
|
+
* are not sanitized.
|
|
22
22
|
*
|
|
23
23
|
* Use {@link isSchemaError} to narrow an unknown value to `SchemaError`.
|
|
24
24
|
*
|
|
@@ -40,14 +40,14 @@ const TypeId = "~effect/SchemaError/SchemaError"
|
|
|
40
40
|
* @since 4.0.0
|
|
41
41
|
*/
|
|
42
42
|
export class SchemaError extends Data.TaggedError("SchemaError")<{
|
|
43
|
-
readonly issue: Issue
|
|
43
|
+
readonly issue: SchemaIssue.Issue
|
|
44
44
|
}> {
|
|
45
45
|
readonly [TypeId]: typeof TypeId = TypeId
|
|
46
|
-
constructor(issue: Issue) {
|
|
46
|
+
constructor(issue: SchemaIssue.Issue) {
|
|
47
47
|
super({ issue })
|
|
48
48
|
}
|
|
49
49
|
override get message() {
|
|
50
|
-
return this.issue
|
|
50
|
+
return SchemaIssue.defaultFormatter(this.issue)
|
|
51
51
|
}
|
|
52
52
|
override toString() {
|
|
53
53
|
return `SchemaError(${this.message})`
|