effect 4.0.0-beta.103 → 4.0.0-beta.104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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 +28 -7
- 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 -2
- package/dist/Context.d.ts.map +1 -1
- package/dist/Context.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/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 +32 -32
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +23 -18
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +3 -3
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +47 -31
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +35 -53
- package/dist/SchemaParser.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/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/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 +1 -1
- package/dist/testing/TestSchema.d.ts.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 +6 -3
- 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 +12 -0
- 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 +21 -7
- 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/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 +68 -15
- 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 +65 -25
- 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/rpc/RpcClient.d.ts +14 -0
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +18 -9
- 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/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/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 +2 -8
- package/src/Cache.ts +1 -1
- package/src/Channel.ts +1 -1
- package/src/Config.ts +28 -7
- package/src/ConfigProvider.ts +4 -1
- package/src/Context.ts +5 -5
- 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/Schedule.ts +13 -13
- package/src/Schema.ts +50 -41
- package/src/SchemaAST.ts +69 -37
- package/src/SchemaParser.ts +75 -69
- package/src/ScopedCache.ts +1 -1
- package/src/Sink.ts +1 -1
- 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/toArbitrary.ts +3 -1
- package/src/internal/trie.ts +12 -2
- package/src/testing/TestClock.ts +13 -1
- package/src/testing/TestSchema.ts +1 -1
- 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 +21 -6
- 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 +21 -0
- 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 +47 -28
- 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/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 +119 -21
- package/src/unstable/httpapi/HttpApiClient.ts +104 -41
- 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/rpc/RpcClient.ts +38 -12
- package/src/unstable/rpc/RpcClientError.ts +2 -2
- package/src/unstable/rpc/RpcSerialization.ts +1 -1
- 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/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
|
|
@@ -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,
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Low-level parser for multipart header blocks.
|
|
3
|
+
*
|
|
4
|
+
* @since 4.0.0
|
|
5
|
+
*/
|
|
6
|
+
import * as internal from "./internal/headers.ts"
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The reason a multipart header block could not be parsed.
|
|
10
|
+
*
|
|
11
|
+
* @category errors
|
|
12
|
+
* @since 4.0.0
|
|
13
|
+
*/
|
|
14
|
+
export type FailureReason =
|
|
15
|
+
| "TooManyHeaders"
|
|
16
|
+
| "HeaderTooLarge"
|
|
17
|
+
| "InvalidHeaderName"
|
|
18
|
+
| "InvalidHeaderValue"
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Indicates that the parser needs more input.
|
|
22
|
+
*
|
|
23
|
+
* @category models
|
|
24
|
+
* @since 4.0.0
|
|
25
|
+
*/
|
|
26
|
+
export interface Continue {
|
|
27
|
+
readonly _tag: "Continue"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A multipart header parsing failure.
|
|
32
|
+
*
|
|
33
|
+
* @category errors
|
|
34
|
+
* @since 4.0.0
|
|
35
|
+
*/
|
|
36
|
+
export interface Failure {
|
|
37
|
+
readonly _tag: "Failure"
|
|
38
|
+
readonly reason: FailureReason
|
|
39
|
+
readonly headers: Record<string, string | Array<string>>
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* A successfully parsed multipart header block.
|
|
44
|
+
*
|
|
45
|
+
* @category models
|
|
46
|
+
* @since 4.0.0
|
|
47
|
+
*/
|
|
48
|
+
export interface Headers {
|
|
49
|
+
readonly _tag: "Headers"
|
|
50
|
+
readonly headers: Record<string, string | Array<string>>
|
|
51
|
+
readonly endPosition: number
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The result of parsing a multipart header block.
|
|
56
|
+
*
|
|
57
|
+
* @category models
|
|
58
|
+
* @since 4.0.0
|
|
59
|
+
*/
|
|
60
|
+
export type ReturnValue = Continue | Failure | Headers
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Creates an incremental multipart header parser.
|
|
64
|
+
*
|
|
65
|
+
* @category constructors
|
|
66
|
+
* @since 4.0.0
|
|
67
|
+
*/
|
|
68
|
+
export const make: () => (chunk: Uint8Array, start: number) => ReturnValue = internal.make
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Low-level byte search used by the multipart parser.
|
|
3
|
+
*
|
|
4
|
+
* @since 4.0.0
|
|
5
|
+
*/
|
|
6
|
+
import * as internal from "./internal/search.ts"
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Creates an incremental byte search for a string boundary.
|
|
10
|
+
*
|
|
11
|
+
* @category constructors
|
|
12
|
+
* @since 4.0.0
|
|
13
|
+
*/
|
|
14
|
+
export const make: (
|
|
15
|
+
needle: string,
|
|
16
|
+
callback: (index: number, chunk: Uint8Array) => void
|
|
17
|
+
) => { readonly write: (chunk: Uint8Array) => void; readonly end: () => void } = internal.make
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// taken from https://github.com/fastify/fast-content-type-parse
|
|
2
|
+
// under the MIT license
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* RegExp to match *( ";" parameter ) in RFC 7231 sec 3.1.1.1
|
|
6
|
+
*
|
|
7
|
+
* parameter = token "=" ( token / quoted-string )
|
|
8
|
+
* token = 1*tchar
|
|
9
|
+
* tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*"
|
|
10
|
+
* / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~"
|
|
11
|
+
* / DIGIT / ALPHA
|
|
12
|
+
* ; any VCHAR, except delimiters
|
|
13
|
+
* quoted-string = DQUOTE *( qdtext / quoted-pair ) DQUOTE
|
|
14
|
+
* qdtext = HTAB / SP / %x21 / %x23-5B / %x5D-7E / obs-text
|
|
15
|
+
* obs-text = %x80-FF
|
|
16
|
+
* quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text )
|
|
17
|
+
*/
|
|
18
|
+
const paramRE =
|
|
19
|
+
/; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u{10ffff}]|\\[\v\u0020-\u{10ffff}])*"|[!#$%&'*+.^\w`|~-]+) */gu
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* RegExp to match quoted-pair in RFC 7230 sec 3.2.6
|
|
23
|
+
*
|
|
24
|
+
* quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text )
|
|
25
|
+
* obs-text = %x80-FF
|
|
26
|
+
*/
|
|
27
|
+
const quotedPairRE = /\\([\v\u0020-\u{10ffff}])/gu
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* RegExp to match type in RFC 7231 sec 3.1.1.1
|
|
31
|
+
*
|
|
32
|
+
* media-type = type "/" subtype
|
|
33
|
+
* type = token
|
|
34
|
+
* subtype = token
|
|
35
|
+
*/
|
|
36
|
+
const mediaTypeRE = /^[!#$%&'*+.^\w|~-]+\/[!#$%&'*+.^\w|~-]+$/u
|
|
37
|
+
const mediaTypeRENoSlash = /^[!#$%&'*+.^\w|~-]+$/u
|
|
38
|
+
|
|
39
|
+
// default ContentType to prevent repeated object creation
|
|
40
|
+
const defaultContentType = { value: "", parameters: Object.create(null) }
|
|
41
|
+
|
|
42
|
+
export function parse(
|
|
43
|
+
header: string | undefined,
|
|
44
|
+
withoutSlash = false
|
|
45
|
+
): {
|
|
46
|
+
readonly value: string
|
|
47
|
+
readonly parameters: Record<string, string>
|
|
48
|
+
} {
|
|
49
|
+
if (typeof header !== "string") {
|
|
50
|
+
return defaultContentType
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let index = header.indexOf(";")
|
|
54
|
+
const type = index !== -1 ? header.slice(0, index).trim() : header.trim()
|
|
55
|
+
const mediaRE = withoutSlash ? mediaTypeRENoSlash : mediaTypeRE
|
|
56
|
+
|
|
57
|
+
if (mediaRE.test(type) === false) {
|
|
58
|
+
return defaultContentType
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const result = {
|
|
62
|
+
value: type.toLowerCase(),
|
|
63
|
+
parameters: Object.create(null)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// parse parameters
|
|
67
|
+
if (index === -1) {
|
|
68
|
+
return result
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
let key: string
|
|
72
|
+
let match: RegExpExecArray | null
|
|
73
|
+
let value: string
|
|
74
|
+
|
|
75
|
+
paramRE.lastIndex = index
|
|
76
|
+
|
|
77
|
+
while ((match = paramRE.exec(header))) {
|
|
78
|
+
if (match.index !== index) {
|
|
79
|
+
return defaultContentType
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
index += match[0].length
|
|
83
|
+
key = match[1].toLowerCase()
|
|
84
|
+
value = match[2]
|
|
85
|
+
|
|
86
|
+
if (value[0] === "\"") {
|
|
87
|
+
// remove quotes and escapes
|
|
88
|
+
value = value.slice(1, value.length - 1)
|
|
89
|
+
|
|
90
|
+
if (!withoutSlash && quotedPairRE.test(value)) {
|
|
91
|
+
value = value.replace(quotedPairRE, "$1")
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
result.parameters[key] = value
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (index !== header.length) {
|
|
99
|
+
return defaultContentType
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return result
|
|
103
|
+
}
|