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
|
@@ -1,15 +1,74 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* routing modules.
|
|
2
|
+
* A radix-tree HTTP router used by the unstable HTTP routing modules.
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
|
|
4
|
+
* @since 4.0.0
|
|
5
|
+
*/
|
|
6
|
+
import * as internal from "./FindMyWay/internal/router.ts"
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* MIT License
|
|
10
|
+
*
|
|
11
|
+
* Copyright (c) 2017-2019 Tomas Della Vedova
|
|
12
|
+
*
|
|
13
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
* in the Software without restriction, including without limitation the rights
|
|
16
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
* furnished to do so, subject to the following conditions:
|
|
19
|
+
*
|
|
20
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
* copies or substantial portions of the Software.
|
|
7
22
|
*
|
|
23
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
* SOFTWARE.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @since 4.0.0
|
|
34
|
+
* @category models
|
|
35
|
+
*/
|
|
36
|
+
export interface RouterConfig {
|
|
37
|
+
readonly ignoreTrailingSlash: boolean
|
|
38
|
+
readonly ignoreDuplicateSlashes: boolean
|
|
39
|
+
readonly caseSensitive: boolean
|
|
40
|
+
readonly maxParamLength: number
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @since 4.0.0
|
|
45
|
+
* @category models
|
|
46
|
+
*/
|
|
47
|
+
export type PathInput = `/${string}` | "*"
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @since 4.0.0
|
|
51
|
+
* @category models
|
|
52
|
+
*/
|
|
53
|
+
export interface Router<A> {
|
|
54
|
+
readonly on: (method: string | Iterable<string>, path: PathInput, handler: A) => void
|
|
55
|
+
readonly all: (path: PathInput, handler: A) => void
|
|
56
|
+
readonly find: (method: string, url: string) => FindResult<A> | undefined
|
|
57
|
+
readonly has: (method: string, url: string) => boolean
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
8
61
|
* @since 4.0.0
|
|
62
|
+
* @category models
|
|
9
63
|
*/
|
|
64
|
+
export interface FindResult<A> {
|
|
65
|
+
readonly handler: A
|
|
66
|
+
readonly params: Record<string, string | undefined>
|
|
67
|
+
readonly searchParams: Record<string, string | Array<string>>
|
|
68
|
+
}
|
|
10
69
|
|
|
11
70
|
/**
|
|
12
|
-
* @category re-exports
|
|
13
71
|
* @since 4.0.0
|
|
72
|
+
* @category constructors
|
|
14
73
|
*/
|
|
15
|
-
export
|
|
74
|
+
export const make: <A>(options?: Partial<RouterConfig>) => Router<A> = internal.make
|
|
@@ -1267,7 +1267,8 @@ export declare namespace WithRateLimiter {
|
|
|
1267
1267
|
*
|
|
1268
1268
|
* **Details**
|
|
1269
1269
|
*
|
|
1270
|
-
* They define the backing limiter, initial limit window, keying strategy,
|
|
1270
|
+
* They define the backing limiter, initial limit window, keying strategy,
|
|
1271
|
+
* algorithm, token cost, retry count, and response header inspection.
|
|
1271
1272
|
*
|
|
1272
1273
|
* @category rate limiting
|
|
1273
1274
|
* @since 4.0.0
|
|
@@ -1300,11 +1301,48 @@ export declare namespace WithRateLimiter {
|
|
|
1300
1301
|
*/
|
|
1301
1302
|
readonly tokens?: number | ((request: HttpClientRequest.HttpClientRequest) => number) | undefined
|
|
1302
1303
|
/**
|
|
1303
|
-
*
|
|
1304
|
+
* The maximum number of automatic retries after an HTTP `429` response.
|
|
1305
|
+
* Use a non-negative integer. Defaults to an unlimited number of retries.
|
|
1306
|
+
* Set to `0` to disable automatic retries.
|
|
1307
|
+
*/
|
|
1308
|
+
readonly times?: number | undefined
|
|
1309
|
+
/**
|
|
1310
|
+
* Overrides the response header names used for rate limit inspection.
|
|
1311
|
+
* Header names are matched case-insensitively. An omitted field continues
|
|
1312
|
+
* using the built-in names, while a configured field replaces them for
|
|
1313
|
+
* that value. Header value formats are unchanged.
|
|
1314
|
+
*/
|
|
1315
|
+
readonly responseHeaders?: {
|
|
1316
|
+
/**
|
|
1317
|
+
* Header containing the maximum number of requests in a window.
|
|
1318
|
+
*/
|
|
1319
|
+
readonly limit?: string | undefined
|
|
1320
|
+
/**
|
|
1321
|
+
* Header containing the number of requests remaining in a window.
|
|
1322
|
+
*/
|
|
1323
|
+
readonly remaining?: string | undefined
|
|
1324
|
+
/**
|
|
1325
|
+
* Header containing the rate limit reset time.
|
|
1326
|
+
*/
|
|
1327
|
+
readonly reset?: string | undefined
|
|
1328
|
+
/**
|
|
1329
|
+
* Header containing the number of seconds until the rate limit resets.
|
|
1330
|
+
*/
|
|
1331
|
+
readonly resetAfter?: string | undefined
|
|
1332
|
+
/**
|
|
1333
|
+
* Header containing the retry delay for an HTTP `429` response.
|
|
1334
|
+
*/
|
|
1335
|
+
readonly retryAfter?: string | undefined
|
|
1336
|
+
} | undefined
|
|
1337
|
+
/**
|
|
1338
|
+
* Disables automatic limit updates, `Retry-After` delays, and adaptive
|
|
1339
|
+
* feedback from response headers. This does not disable automatic HTTP
|
|
1340
|
+
* `429` retries. Set `times` to `0` to disable them.
|
|
1304
1341
|
*/
|
|
1305
1342
|
readonly disableResponseInspection?: boolean | undefined
|
|
1306
1343
|
/**
|
|
1307
|
-
*
|
|
1344
|
+
* Disables adaptive learning from `Retry-After` responses. Response
|
|
1345
|
+
* inspection and direct `Retry-After` delays remain enabled.
|
|
1308
1346
|
*/
|
|
1309
1347
|
readonly disableAdaptiveLearning?: boolean | undefined
|
|
1310
1348
|
}
|
|
@@ -1319,6 +1357,12 @@ export declare namespace WithRateLimiter {
|
|
|
1319
1357
|
* automatically retries HTTP `429` responses (or `HttpClientError` values
|
|
1320
1358
|
* wrapping a `429` response) by forcing the retry back through the limiter.
|
|
1321
1359
|
*
|
|
1360
|
+
* **Gotchas**
|
|
1361
|
+
*
|
|
1362
|
+
* Automatic HTTP `429` retries are unlimited unless `times` is specified.
|
|
1363
|
+
* Disabling response inspection does not disable retries; set `times` to `0`
|
|
1364
|
+
* to return or fail with the first `429`.
|
|
1365
|
+
*
|
|
1322
1366
|
* @category rate limiting
|
|
1323
1367
|
* @since 4.0.0
|
|
1324
1368
|
*/
|
|
@@ -1332,6 +1376,12 @@ export const withRateLimiter: {
|
|
|
1332
1376
|
* automatically retries HTTP `429` responses (or `HttpClientError` values
|
|
1333
1377
|
* wrapping a `429` response) by forcing the retry back through the limiter.
|
|
1334
1378
|
*
|
|
1379
|
+
* **Gotchas**
|
|
1380
|
+
*
|
|
1381
|
+
* Automatic HTTP `429` retries are unlimited unless `times` is specified.
|
|
1382
|
+
* Disabling response inspection does not disable retries; set `times` to `0`
|
|
1383
|
+
* to return or fail with the first `429`.
|
|
1384
|
+
*
|
|
1335
1385
|
* @category rate limiting
|
|
1336
1386
|
* @since 4.0.0
|
|
1337
1387
|
*/
|
|
@@ -1347,6 +1397,12 @@ export const withRateLimiter: {
|
|
|
1347
1397
|
* automatically retries HTTP `429` responses (or `HttpClientError` values
|
|
1348
1398
|
* wrapping a `429` response) by forcing the retry back through the limiter.
|
|
1349
1399
|
*
|
|
1400
|
+
* **Gotchas**
|
|
1401
|
+
*
|
|
1402
|
+
* Automatic HTTP `429` retries are unlimited unless `times` is specified.
|
|
1403
|
+
* Disabling response inspection does not disable retries; set `times` to `0`
|
|
1404
|
+
* to return or fail with the first `429`.
|
|
1405
|
+
*
|
|
1350
1406
|
* @category rate limiting
|
|
1351
1407
|
* @since 4.0.0
|
|
1352
1408
|
*/
|
|
@@ -1371,6 +1427,7 @@ export const withRateLimiter: {
|
|
|
1371
1427
|
? tokensOption
|
|
1372
1428
|
: constant(tokensOption ?? 1)
|
|
1373
1429
|
const adaptiveLearningEnabled = !options.disableAdaptiveLearning
|
|
1430
|
+
const headerNames = resolveRateLimiterHeaderNames(options.responseHeaders)
|
|
1374
1431
|
|
|
1375
1432
|
const getState = (key: string): RateLimiterState => {
|
|
1376
1433
|
const current = states.get(key)
|
|
@@ -1385,13 +1442,13 @@ export const withRateLimiter: {
|
|
|
1385
1442
|
? undefined
|
|
1386
1443
|
: (clock: Clock, key: string, headers: Headers.Headers, tokens: number) => {
|
|
1387
1444
|
const current = getState(key)
|
|
1388
|
-
const next = parseRateLimiterState(current, clock, headers, tokens)
|
|
1445
|
+
const next = parseRateLimiterState(current, clock, headers, tokens, headerNames)
|
|
1389
1446
|
if (next.limit !== current.limit || !Duration.equals(next.window, current.window)) {
|
|
1390
1447
|
states.set(key, next)
|
|
1391
1448
|
}
|
|
1392
1449
|
}
|
|
1393
1450
|
|
|
1394
|
-
return transform(self, function loop(effect, request): Effect.Effect<
|
|
1451
|
+
return transform(self, function loop(effect, request, retries = 0): Effect.Effect<
|
|
1395
1452
|
HttpClientResponse.HttpClientResponse,
|
|
1396
1453
|
E | RateLimiter.RateLimiterError,
|
|
1397
1454
|
R
|
|
@@ -1401,11 +1458,11 @@ export const withRateLimiter: {
|
|
|
1401
1458
|
const key = resolveKey(request)
|
|
1402
1459
|
const tokens = Math.max(resolveTokens(request), 1)
|
|
1403
1460
|
const current = getState(key)
|
|
1461
|
+
const canRetry = options.times === undefined || retries < options.times
|
|
1404
1462
|
function retry(retryAfter: Duration.Duration | undefined) {
|
|
1405
|
-
if (options.disableResponseInspection) return loop(effect, request)
|
|
1406
1463
|
return retryAfter
|
|
1407
|
-
? Effect.flatMap(Effect.sleep(retryAfter), () => loop(effect, request))
|
|
1408
|
-
: loop(effect, request)
|
|
1464
|
+
? Effect.flatMap(Effect.sleep(retryAfter), () => loop(effect, request, retries + 1))
|
|
1465
|
+
: loop(effect, request, retries + 1)
|
|
1409
1466
|
}
|
|
1410
1467
|
const inspectResponse = (
|
|
1411
1468
|
response: HttpClientResponse.HttpClientResponse,
|
|
@@ -1422,12 +1479,18 @@ export const withRateLimiter: {
|
|
|
1422
1479
|
* automatically retries HTTP `429` responses (or `HttpClientError` values
|
|
1423
1480
|
* wrapping a `429` response) by forcing the retry back through the limiter.
|
|
1424
1481
|
*
|
|
1482
|
+
* **Gotchas**
|
|
1483
|
+
*
|
|
1484
|
+
* Automatic HTTP `429` retries are unlimited unless `times` is specified.
|
|
1485
|
+
* Disabling response inspection does not disable retries; set `times` to `0`
|
|
1486
|
+
* to return or fail with the first `429`.
|
|
1487
|
+
*
|
|
1425
1488
|
* @category rate limiting
|
|
1426
1489
|
* @since 4.0.0
|
|
1427
1490
|
*/
|
|
1428
1491
|
Duration.Duration | undefined>(undefined);
|
|
1429
1492
|
}
|
|
1430
|
-
const retryAfter = parseRetryAfter(clock, getHeader(response.headers,
|
|
1493
|
+
const retryAfter = parseRetryAfter(clock, getHeader(response.headers, ...headerNames.retryAfter))
|
|
1431
1494
|
if (retryAfter === undefined) {
|
|
1432
1495
|
return Effect.succeed</**
|
|
1433
1496
|
* Applies request rate limiting using the `RateLimiter` service.
|
|
@@ -1438,12 +1501,18 @@ export const withRateLimiter: {
|
|
|
1438
1501
|
* automatically retries HTTP `429` responses (or `HttpClientError` values
|
|
1439
1502
|
* wrapping a `429` response) by forcing the retry back through the limiter.
|
|
1440
1503
|
*
|
|
1504
|
+
* **Gotchas**
|
|
1505
|
+
*
|
|
1506
|
+
* Automatic HTTP `429` retries are unlimited unless `times` is specified.
|
|
1507
|
+
* Disabling response inspection does not disable retries; set `times` to `0`
|
|
1508
|
+
* to return or fail with the first `429`.
|
|
1509
|
+
*
|
|
1441
1510
|
* @category rate limiting
|
|
1442
1511
|
* @since 4.0.0
|
|
1443
1512
|
*/
|
|
1444
1513
|
Duration.Duration | undefined>(undefined);
|
|
1445
1514
|
}
|
|
1446
|
-
const delay = parseRateLimitWindow(clock, response.headers) ?? retryAfter
|
|
1515
|
+
const delay = parseRateLimitWindow(clock, response.headers, headerNames) ?? retryAfter
|
|
1447
1516
|
if (adaptive === undefined) {
|
|
1448
1517
|
return Effect.succeed</**
|
|
1449
1518
|
* Applies request rate limiting using the `RateLimiter` service.
|
|
@@ -1454,6 +1523,12 @@ export const withRateLimiter: {
|
|
|
1454
1523
|
* automatically retries HTTP `429` responses (or `HttpClientError` values
|
|
1455
1524
|
* wrapping a `429` response) by forcing the retry back through the limiter.
|
|
1456
1525
|
*
|
|
1526
|
+
* **Gotchas**
|
|
1527
|
+
*
|
|
1528
|
+
* Automatic HTTP `429` retries are unlimited unless `times` is specified.
|
|
1529
|
+
* Disabling response inspection does not disable retries; set `times` to `0`
|
|
1530
|
+
* to return or fail with the first `429`.
|
|
1531
|
+
*
|
|
1457
1532
|
* @category rate limiting
|
|
1458
1533
|
* @since 4.0.0
|
|
1459
1534
|
*/
|
|
@@ -1489,7 +1564,7 @@ export const withRateLimiter: {
|
|
|
1489
1564
|
const request = Effect.matchEffect(effect, {
|
|
1490
1565
|
onSuccess(response) {
|
|
1491
1566
|
return Effect.flatMap(inspectResponse(response, adaptive), (retryAfter) => {
|
|
1492
|
-
if (response.status !== 429) return Effect.succeed(response)
|
|
1567
|
+
if (response.status !== 429 || !canRetry) return Effect.succeed(response)
|
|
1493
1568
|
return retry(retryAfter)
|
|
1494
1569
|
})
|
|
1495
1570
|
},
|
|
@@ -1497,7 +1572,7 @@ export const withRateLimiter: {
|
|
|
1497
1572
|
if (isTooManyRequestsHttpClientError(error)) {
|
|
1498
1573
|
return Effect.flatMap(
|
|
1499
1574
|
inspectResponse(error.reason.response, adaptive),
|
|
1500
|
-
(retryAfter) => retry(retryAfter)
|
|
1575
|
+
(retryAfter) => canRetry ? retry(retryAfter) : Effect.fail(error)
|
|
1501
1576
|
)
|
|
1502
1577
|
}
|
|
1503
1578
|
return Effect.fail(error)
|
|
@@ -1531,6 +1606,34 @@ export const withRateLimiter: {
|
|
|
1531
1606
|
});
|
|
1532
1607
|
})
|
|
1533
1608
|
|
|
1609
|
+
interface RateLimiterHeaderNames {
|
|
1610
|
+
readonly limit: ReadonlyArray<string>
|
|
1611
|
+
readonly remaining: ReadonlyArray<string>
|
|
1612
|
+
readonly reset: ReadonlyArray<string>
|
|
1613
|
+
readonly resetAfter: ReadonlyArray<string>
|
|
1614
|
+
readonly retryAfter: ReadonlyArray<string>
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
const resolveRateLimiterHeaderNames = (
|
|
1618
|
+
responseHeaders: WithRateLimiter.Options["responseHeaders"]
|
|
1619
|
+
): RateLimiterHeaderNames => ({
|
|
1620
|
+
limit: responseHeaders?.limit === undefined
|
|
1621
|
+
? ["ratelimit-limit", "x-ratelimit-limit"]
|
|
1622
|
+
: [responseHeaders.limit.toLowerCase()],
|
|
1623
|
+
remaining: responseHeaders?.remaining === undefined
|
|
1624
|
+
? ["ratelimit-remaining", "x-ratelimit-remaining"]
|
|
1625
|
+
: [responseHeaders.remaining.toLowerCase()],
|
|
1626
|
+
reset: responseHeaders?.reset === undefined
|
|
1627
|
+
? ["ratelimit-reset", "x-ratelimit-reset"]
|
|
1628
|
+
: [responseHeaders.reset.toLowerCase()],
|
|
1629
|
+
resetAfter: responseHeaders?.resetAfter === undefined
|
|
1630
|
+
? ["ratelimit-reset-after", "x-ratelimit-reset-after"]
|
|
1631
|
+
: [responseHeaders.resetAfter.toLowerCase()],
|
|
1632
|
+
retryAfter: responseHeaders?.retryAfter === undefined
|
|
1633
|
+
? ["retry-after"]
|
|
1634
|
+
: [responseHeaders.retryAfter.toLowerCase()]
|
|
1635
|
+
})
|
|
1636
|
+
|
|
1534
1637
|
interface RateLimiterState {
|
|
1535
1638
|
readonly limit: number
|
|
1536
1639
|
readonly window: Duration.Duration
|
|
@@ -1541,10 +1644,11 @@ const parseRateLimiterState = (
|
|
|
1541
1644
|
state: RateLimiterState,
|
|
1542
1645
|
clock: Clock,
|
|
1543
1646
|
headers: Headers.Headers,
|
|
1544
|
-
tokens: number
|
|
1647
|
+
tokens: number,
|
|
1648
|
+
headerNames: RateLimiterHeaderNames
|
|
1545
1649
|
): RateLimiterState => {
|
|
1546
|
-
const limit = parseRateLimitLimit(state, headers, tokens) ?? state.limit
|
|
1547
|
-
const window = parseRateLimitWindow(clock, headers) ?? state.window
|
|
1650
|
+
const limit = parseRateLimitLimit(state, headers, tokens, headerNames) ?? state.limit
|
|
1651
|
+
const window = parseRateLimitWindow(clock, headers, headerNames) ?? state.window
|
|
1548
1652
|
if (limit === state.limit && Duration.equals(window, state.window)) {
|
|
1549
1653
|
return state
|
|
1550
1654
|
}
|
|
@@ -1554,35 +1658,40 @@ const parseRateLimiterState = (
|
|
|
1554
1658
|
const parseRateLimitLimit = (
|
|
1555
1659
|
state: RateLimiterState,
|
|
1556
1660
|
headers: Headers.Headers,
|
|
1557
|
-
tokens: number
|
|
1661
|
+
tokens: number,
|
|
1662
|
+
headerNames: RateLimiterHeaderNames
|
|
1558
1663
|
): number | undefined => {
|
|
1559
|
-
const raw = getHeader(headers,
|
|
1664
|
+
const raw = getHeader(headers, ...headerNames.limit)
|
|
1560
1665
|
const value = parseNumberHeader(raw)
|
|
1561
1666
|
if (value !== undefined && value > 0) {
|
|
1562
1667
|
return value
|
|
1563
1668
|
}
|
|
1564
|
-
const remaining = parseRateLimitRemaining(headers)
|
|
1669
|
+
const remaining = parseRateLimitRemaining(headers, headerNames)
|
|
1565
1670
|
if (remaining === undefined) {
|
|
1566
1671
|
return undefined
|
|
1567
1672
|
}
|
|
1568
1673
|
return state.initial ? remaining + tokens : Math.max(remaining + tokens, state.limit)
|
|
1569
1674
|
}
|
|
1570
1675
|
|
|
1571
|
-
const parseRateLimitRemaining = (
|
|
1572
|
-
|
|
1676
|
+
const parseRateLimitRemaining = (
|
|
1677
|
+
headers: Headers.Headers,
|
|
1678
|
+
headerNames: RateLimiterHeaderNames
|
|
1679
|
+
): number | undefined => {
|
|
1680
|
+
const raw = getHeader(headers, ...headerNames.remaining)
|
|
1573
1681
|
const value = parseNumberHeader(raw)
|
|
1574
1682
|
return value !== undefined && value >= 0 ? value : undefined
|
|
1575
1683
|
}
|
|
1576
1684
|
|
|
1577
1685
|
const parseRateLimitWindow = (
|
|
1578
1686
|
clock: Clock,
|
|
1579
|
-
headers: Headers.Headers
|
|
1687
|
+
headers: Headers.Headers,
|
|
1688
|
+
headerNames: RateLimiterHeaderNames
|
|
1580
1689
|
): Duration.Duration | undefined => {
|
|
1581
|
-
const resetAfter = parseResetAfter(getHeader(headers,
|
|
1690
|
+
const resetAfter = parseResetAfter(getHeader(headers, ...headerNames.resetAfter))
|
|
1582
1691
|
if (resetAfter !== undefined) {
|
|
1583
1692
|
return resetAfter
|
|
1584
1693
|
}
|
|
1585
|
-
return parseResetHeader(clock, getHeader(headers,
|
|
1694
|
+
return parseResetHeader(clock, getHeader(headers, ...headerNames.reset))
|
|
1586
1695
|
}
|
|
1587
1696
|
|
|
1588
1697
|
const parseRetryAfter = (
|
|
@@ -299,7 +299,7 @@ export type HttpClientErrorReason = RequestError | ResponseError
|
|
|
299
299
|
* @category schemas
|
|
300
300
|
* @since 4.0.0
|
|
301
301
|
*/
|
|
302
|
-
export class HttpClientErrorSchema extends Schema.
|
|
302
|
+
export class HttpClientErrorSchema extends Schema.Error<HttpClientErrorSchema>(TypeId)({
|
|
303
303
|
_tag: Schema.tag("HttpError"),
|
|
304
304
|
kind: Schema.Literals(
|
|
305
305
|
[
|
|
@@ -28,6 +28,7 @@ import * as Stream from "../../Stream.ts"
|
|
|
28
28
|
import * as Headers from "./Headers.ts"
|
|
29
29
|
import * as HttpBody from "./HttpBody.ts"
|
|
30
30
|
import { hasBody, type HttpMethod } from "./HttpMethod.ts"
|
|
31
|
+
import * as bodyInternal from "./internal/httpBody.ts"
|
|
31
32
|
import * as Url from "./Url.ts"
|
|
32
33
|
import * as UrlParams from "./UrlParams.ts"
|
|
33
34
|
|
|
@@ -874,25 +875,12 @@ export const setBody: {
|
|
|
874
875
|
*/
|
|
875
876
|
(self: HttpClientRequest, body: HttpBody.HttpBody): HttpClientRequest
|
|
876
877
|
} = dual(2, (self: HttpClientRequest, body: HttpBody.HttpBody): HttpClientRequest => {
|
|
877
|
-
let headers = self.headers
|
|
878
|
-
if (body._tag === "Empty" || body._tag === "FormData") {
|
|
879
|
-
headers = Headers.remove(Headers.remove(headers, "Content-Type"), "Content-length")
|
|
880
|
-
} else {
|
|
881
|
-
if (body.contentType) {
|
|
882
|
-
headers = Headers.set(headers, "content-type", body.contentType)
|
|
883
|
-
}
|
|
884
|
-
if (body.contentLength !== undefined) {
|
|
885
|
-
headers = Headers.set(headers, "content-length", body.contentLength.toString())
|
|
886
|
-
} else {
|
|
887
|
-
headers = Headers.remove(headers, "content-length")
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
878
|
return makeWith(
|
|
891
879
|
self.method,
|
|
892
880
|
self.url,
|
|
893
881
|
self.urlParams,
|
|
894
882
|
self.hash,
|
|
895
|
-
headers,
|
|
883
|
+
bodyInternal.updateHeaders(self.headers, body),
|
|
896
884
|
body
|
|
897
885
|
)
|
|
898
886
|
})
|
|
@@ -355,22 +355,7 @@ class WebHttpClientResponse extends Inspectable.Class implements HttpClientRespo
|
|
|
355
355
|
|
|
356
356
|
private textBody?: Effect.Effect<string, Error.HttpClientError>
|
|
357
357
|
get text(): Effect.Effect<string, Error.HttpClientError> {
|
|
358
|
-
|
|
359
|
-
return this.textBody
|
|
360
|
-
}
|
|
361
|
-
this.textBody = Effect.tryPromise({
|
|
362
|
-
try: () => this.source.text(),
|
|
363
|
-
catch: (cause) =>
|
|
364
|
-
new Error.HttpClientError({
|
|
365
|
-
reason: new Error.DecodeError({
|
|
366
|
-
request: this.request,
|
|
367
|
-
response: this,
|
|
368
|
-
cause
|
|
369
|
-
})
|
|
370
|
-
})
|
|
371
|
-
}).pipe(Effect.cached, Effect.runSync)
|
|
372
|
-
this.arrayBufferBody = Effect.map(this.textBody, (_) => new TextEncoder().encode(_).buffer)
|
|
373
|
-
return this.textBody
|
|
358
|
+
return this.textBody ??= Effect.map(this.arrayBuffer, (_) => new TextDecoder().decode(_))
|
|
374
359
|
}
|
|
375
360
|
|
|
376
361
|
get urlParamsBody(): Effect.Effect<UrlParams.UrlParams, Error.HttpClientError> {
|
|
@@ -419,7 +404,6 @@ class WebHttpClientResponse extends Inspectable.Class implements HttpClientRespo
|
|
|
419
404
|
})
|
|
420
405
|
})
|
|
421
406
|
}).pipe(Effect.cached, Effect.runSync)
|
|
422
|
-
this.textBody = Effect.map(this.arrayBufferBody, (_) => new TextDecoder().decode(_))
|
|
423
407
|
return this.arrayBufferBody
|
|
424
408
|
}
|
|
425
409
|
|
|
@@ -161,14 +161,42 @@ export const layer = Layer.effect(HttpPlatform)(
|
|
|
161
161
|
{ contentLength, headers, status, statusText }
|
|
162
162
|
)
|
|
163
163
|
},
|
|
164
|
-
fileWebResponse(file, status, statusText, headers,
|
|
165
|
-
|
|
166
|
-
|
|
164
|
+
fileWebResponse(file, status, statusText, headers, options) {
|
|
165
|
+
const offset = Number(options?.offset ?? 0)
|
|
166
|
+
const bytesToRead = options?.bytesToRead !== undefined ? Number(options.bytesToRead) : undefined
|
|
167
|
+
const chunkSize = options?.chunkSize !== undefined ? Math.max(1, Number(options.chunkSize)) : Infinity
|
|
168
|
+
const end = offset + (bytesToRead ?? Infinity)
|
|
169
|
+
const stream = end <= offset
|
|
170
|
+
? Stream.empty
|
|
171
|
+
: Stream.fromReadableStream({
|
|
167
172
|
evaluate: () => file.stream() as ReadableStream<Uint8Array>,
|
|
168
173
|
onError: identity
|
|
169
|
-
})
|
|
170
|
-
|
|
171
|
-
|
|
174
|
+
}).pipe(
|
|
175
|
+
Stream.mapAccum(
|
|
176
|
+
() => 0,
|
|
177
|
+
(position, bytes) => {
|
|
178
|
+
const next = position + bytes.length
|
|
179
|
+
const start = Math.min(Math.max(offset - position, 0), bytes.length)
|
|
180
|
+
const stop = Math.min(Math.max(end - position, 0), bytes.length)
|
|
181
|
+
const chunks: Array<{ readonly bytes: Uint8Array; readonly done: boolean }> = []
|
|
182
|
+
for (let index = start; index < stop; index += chunkSize) {
|
|
183
|
+
chunks.push({
|
|
184
|
+
bytes: bytes.subarray(index, Math.min(index + chunkSize, stop)),
|
|
185
|
+
done: next >= end && index + chunkSize >= stop
|
|
186
|
+
})
|
|
187
|
+
}
|
|
188
|
+
return [next, chunks]
|
|
189
|
+
}
|
|
190
|
+
),
|
|
191
|
+
Stream.takeUntil((chunk) => chunk.done),
|
|
192
|
+
Stream.map((chunk) => chunk.bytes)
|
|
193
|
+
)
|
|
194
|
+
return Response.stream(stream, {
|
|
195
|
+
contentLength: bytesToRead ?? file.size - offset,
|
|
196
|
+
headers,
|
|
197
|
+
status,
|
|
198
|
+
statusText
|
|
199
|
+
})
|
|
172
200
|
}
|
|
173
201
|
}))
|
|
174
202
|
).pipe(Layer.provide(Etag.layerWeak))
|
|
@@ -863,25 +863,25 @@ const rawBodyStream = (request: HttpServerRequest, body: unknown): Stream.Stream
|
|
|
863
863
|
if (body instanceof Request) {
|
|
864
864
|
return streamFromReadable(request, body.body)
|
|
865
865
|
}
|
|
866
|
-
if (isFormData(body)) {
|
|
867
|
-
return streamFromReadable(request, new Response(body).body)
|
|
868
|
-
}
|
|
869
866
|
if (isReadableStream(body)) {
|
|
870
867
|
return streamFromReadable(request, body)
|
|
871
868
|
}
|
|
869
|
+
if (isBodyInit(body)) {
|
|
870
|
+
return streamFromReadable(request, new Response(body).body)
|
|
871
|
+
}
|
|
872
872
|
return Stream.fail(requestParseError(request, "Unsupported body type"))
|
|
873
873
|
}
|
|
874
874
|
|
|
875
875
|
const rawBodyBytes = (request: HttpServerRequest, body: unknown): Effect.Effect<Uint8Array, HttpServerError> => {
|
|
876
|
-
if (body instanceof Blob) {
|
|
877
|
-
return bytesFromBodyInit(request, body)
|
|
878
|
-
}
|
|
879
876
|
if (body instanceof Request) {
|
|
880
877
|
return Effect.tryPromise({
|
|
881
878
|
try: () => body.arrayBuffer().then((buffer) => new Uint8Array(buffer)),
|
|
882
879
|
catch: (cause) => requestParseError(request, undefined, cause)
|
|
883
880
|
})
|
|
884
881
|
}
|
|
882
|
+
if (isBodyInit(body)) {
|
|
883
|
+
return bytesFromBodyInit(request, body)
|
|
884
|
+
}
|
|
885
885
|
return Effect.fail(requestParseError(request, "Unsupported body type"))
|
|
886
886
|
}
|
|
887
887
|
|
|
@@ -995,6 +995,14 @@ const isReadableStream = (u: unknown): u is ReadableStream<Uint8Array> =>
|
|
|
995
995
|
|
|
996
996
|
const isFormData = (u: unknown): u is FormData => typeof FormData !== "undefined" && u instanceof FormData
|
|
997
997
|
|
|
998
|
+
const isBodyInit = (u: unknown): u is BodyInit =>
|
|
999
|
+
typeof u === "string" ||
|
|
1000
|
+
(typeof ArrayBuffer !== "undefined" && (u instanceof ArrayBuffer || ArrayBuffer.isView(u))) ||
|
|
1001
|
+
(typeof Blob !== "undefined" && u instanceof Blob) ||
|
|
1002
|
+
isFormData(u) ||
|
|
1003
|
+
(typeof URLSearchParams !== "undefined" && u instanceof URLSearchParams) ||
|
|
1004
|
+
isReadableStream(u)
|
|
1005
|
+
|
|
998
1006
|
const textDecoder = new TextDecoder()
|
|
999
1007
|
|
|
1000
1008
|
/**
|
|
@@ -34,6 +34,7 @@ import * as HttpClientRequest from "./HttpClientRequest.ts"
|
|
|
34
34
|
import * as HttpClientResponse from "./HttpClientResponse.ts"
|
|
35
35
|
import * as HttpIncomingMessage from "./HttpIncomingMessage.ts"
|
|
36
36
|
import type { HttpPlatform } from "./HttpPlatform.ts"
|
|
37
|
+
import * as bodyInternal from "./internal/httpBody.ts"
|
|
37
38
|
import * as Template from "./Template.ts"
|
|
38
39
|
import * as UrlParams from "./UrlParams.ts"
|
|
39
40
|
|
|
@@ -563,7 +564,7 @@ export const setHeader: {
|
|
|
563
564
|
makeResponse({
|
|
564
565
|
...self,
|
|
565
566
|
headers: Headers.set(self.headers, key, value)
|
|
566
|
-
})
|
|
567
|
+
}, true)
|
|
567
568
|
)
|
|
568
569
|
|
|
569
570
|
/**
|
|
@@ -623,7 +624,7 @@ export const setHeaders: {
|
|
|
623
624
|
makeResponse({
|
|
624
625
|
...self,
|
|
625
626
|
headers: Headers.setAll(self.headers, input)
|
|
626
|
-
})
|
|
627
|
+
}, true)
|
|
627
628
|
)
|
|
628
629
|
|
|
629
630
|
/**
|
|
@@ -1204,7 +1205,8 @@ export const setBody: {
|
|
|
1204
1205
|
(self: HttpServerResponse, body: Body.HttpBody): HttpServerResponse
|
|
1205
1206
|
} = dual(
|
|
1206
1207
|
2,
|
|
1207
|
-
(self: HttpServerResponse, body: Body.HttpBody): HttpServerResponse =>
|
|
1208
|
+
(self: HttpServerResponse, body: Body.HttpBody): HttpServerResponse =>
|
|
1209
|
+
makeResponse({ ...self, headers: bodyInternal.updateHeaders(self.headers, body), body })
|
|
1208
1210
|
)
|
|
1209
1211
|
|
|
1210
1212
|
/**
|
|
@@ -1623,7 +1625,7 @@ const makeResponse = (options: {
|
|
|
1623
1625
|
readonly headers?: Headers.Headers | undefined
|
|
1624
1626
|
readonly cookies?: Cookies.Cookies | undefined
|
|
1625
1627
|
readonly body?: Body.HttpBody | undefined
|
|
1626
|
-
}) => {
|
|
1628
|
+
}, preferHeaders = false) => {
|
|
1627
1629
|
const self = Object.create(Proto) as Mutable<HttpServerResponse>
|
|
1628
1630
|
self.status = options.status
|
|
1629
1631
|
self.statusText = options.statusText
|
|
@@ -1631,13 +1633,13 @@ const makeResponse = (options: {
|
|
|
1631
1633
|
self.body = options.body ?? Body.empty
|
|
1632
1634
|
if (
|
|
1633
1635
|
self.body._tag !== "Empty" &&
|
|
1634
|
-
(self.body.contentType || self.body.contentLength)
|
|
1636
|
+
(self.body.contentType || self.body.contentLength !== undefined)
|
|
1635
1637
|
) {
|
|
1636
1638
|
const newHeaders = Headers.fromRecordUnsafe({ ...options.headers }) as any
|
|
1637
|
-
if (self.body.contentType) {
|
|
1639
|
+
if (self.body.contentType && (!preferHeaders || newHeaders["content-type"] === undefined)) {
|
|
1638
1640
|
newHeaders["content-type"] = self.body.contentType
|
|
1639
1641
|
}
|
|
1640
|
-
if (self.body.contentLength) {
|
|
1642
|
+
if (self.body.contentLength !== undefined && (!preferHeaders || newHeaders["content-length"] === undefined)) {
|
|
1641
1643
|
newHeaders["content-length"] = self.body.contentLength.toString()
|
|
1642
1644
|
}
|
|
1643
1645
|
self.headers = newHeaders
|
|
@@ -34,7 +34,7 @@ import * as UndefinedOr from "../../UndefinedOr.ts"
|
|
|
34
34
|
import * as IncomingMessage from "./HttpIncomingMessage.ts"
|
|
35
35
|
import * as HttpServerRespondable from "./HttpServerRespondable.ts"
|
|
36
36
|
import * as HttpServerResponse from "./HttpServerResponse.ts"
|
|
37
|
-
import * as MP from "./
|
|
37
|
+
import * as MP from "./MultipartParser.ts"
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* Type identifier used to brand multipart part values.
|
|
@@ -678,6 +678,8 @@ export const toPersisted = (
|
|
|
678
678
|
const path_ = yield* Path.Path
|
|
679
679
|
const dir = yield* fs.makeTempDirectoryScoped()
|
|
680
680
|
const persisted: Record<string, Array<PersistedFile> | Array<string> | string> = Object.create(null)
|
|
681
|
+
const usedPaths = new Set<string>()
|
|
682
|
+
let fileIndex = 0
|
|
681
683
|
yield* Stream.runForEach(stream, (part) => {
|
|
682
684
|
if (part._tag === "Field") {
|
|
683
685
|
if (!(part.key in persisted)) {
|
|
@@ -692,7 +694,12 @@ export const toPersisted = (
|
|
|
692
694
|
return Effect.void
|
|
693
695
|
}
|
|
694
696
|
const file = part
|
|
695
|
-
const
|
|
697
|
+
const fileName = path_.basename(file.name).slice(-128)
|
|
698
|
+
let path = path_.join(dir, fileName)
|
|
699
|
+
while (usedPaths.has(path)) {
|
|
700
|
+
path = path_.join(dir, `${fileIndex++}-${fileName}`)
|
|
701
|
+
}
|
|
702
|
+
usedPaths.add(path)
|
|
696
703
|
const filePart = new PersistedFileImpl(
|
|
697
704
|
file.key,
|
|
698
705
|
file.name,
|