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
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import type { Config, MultipartError, PartInfo } from "../../MultipartParser.ts"
|
|
2
|
+
import * as CT from "./contentType.ts"
|
|
3
|
+
import * as HP from "./headers.ts"
|
|
4
|
+
import * as Search from "./search.ts"
|
|
5
|
+
|
|
6
|
+
const State = {
|
|
7
|
+
headers: 0,
|
|
8
|
+
body: 1
|
|
9
|
+
} as const
|
|
10
|
+
type State = (typeof State)[keyof typeof State]
|
|
11
|
+
|
|
12
|
+
const errInvalidDisposition: MultipartError = { _tag: "InvalidDisposition" }
|
|
13
|
+
const errEndNotReached: MultipartError = { _tag: "EndNotReached" }
|
|
14
|
+
const errMaxParts: MultipartError = { _tag: "ReachedLimit", limit: "MaxParts" }
|
|
15
|
+
const errMaxTotalSize: MultipartError = {
|
|
16
|
+
_tag: "ReachedLimit",
|
|
17
|
+
limit: "MaxTotalSize"
|
|
18
|
+
}
|
|
19
|
+
const errMaxPartSize: MultipartError = {
|
|
20
|
+
_tag: "ReachedLimit",
|
|
21
|
+
limit: "MaxPartSize"
|
|
22
|
+
}
|
|
23
|
+
const errMaxFieldSize: MultipartError = {
|
|
24
|
+
_tag: "ReachedLimit",
|
|
25
|
+
limit: "MaxFieldSize"
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const constCR = new TextEncoder().encode("\r\n")
|
|
29
|
+
|
|
30
|
+
export function defaultIsFile(info: PartInfo) {
|
|
31
|
+
return (
|
|
32
|
+
info.filename !== undefined ||
|
|
33
|
+
info.contentType === "application/octet-stream"
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function parseBoundary(headers: Record<string, string>) {
|
|
38
|
+
const contentType = CT.parse(headers["content-type"])
|
|
39
|
+
return contentType.parameters.boundary
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function noopOnChunk(_chunk: Uint8Array | null) {}
|
|
43
|
+
|
|
44
|
+
export function make({
|
|
45
|
+
headers,
|
|
46
|
+
onFile: onPart,
|
|
47
|
+
onField,
|
|
48
|
+
onError,
|
|
49
|
+
onDone,
|
|
50
|
+
isFile = defaultIsFile,
|
|
51
|
+
maxParts = Infinity,
|
|
52
|
+
maxTotalSize = Infinity,
|
|
53
|
+
maxPartSize = Infinity,
|
|
54
|
+
maxFieldSize = 1024 * 1024
|
|
55
|
+
}: Config) {
|
|
56
|
+
const boundary = parseBoundary(headers)
|
|
57
|
+
if (boundary === undefined) {
|
|
58
|
+
onError({ _tag: "InvalidBoundary" })
|
|
59
|
+
return {
|
|
60
|
+
write: noopOnChunk,
|
|
61
|
+
end() {}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const state = {
|
|
66
|
+
state: State.headers as State,
|
|
67
|
+
index: 0,
|
|
68
|
+
parts: 0,
|
|
69
|
+
onChunk: noopOnChunk,
|
|
70
|
+
info: undefined as any as PartInfo,
|
|
71
|
+
headerSkip: 0,
|
|
72
|
+
partSize: 0,
|
|
73
|
+
totalSize: 0,
|
|
74
|
+
isFile: false,
|
|
75
|
+
fieldChunks: [] as Array<Uint8Array>,
|
|
76
|
+
fieldSize: 0,
|
|
77
|
+
done: false
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function skipBody() {
|
|
81
|
+
state.state = State.body
|
|
82
|
+
state.isFile = true
|
|
83
|
+
state.onChunk = noopOnChunk
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const headerParser = HP.make()
|
|
87
|
+
|
|
88
|
+
const split = Search.make(
|
|
89
|
+
`\r\n--${boundary}`,
|
|
90
|
+
function(index, chunk) {
|
|
91
|
+
if (index === 0) {
|
|
92
|
+
// data before the first boundary
|
|
93
|
+
skipBody()
|
|
94
|
+
return
|
|
95
|
+
} else if (index !== state.index) {
|
|
96
|
+
if (state.index > 0) {
|
|
97
|
+
if (state.isFile) {
|
|
98
|
+
state.onChunk(null)
|
|
99
|
+
} else {
|
|
100
|
+
if (state.fieldChunks.length === 1) {
|
|
101
|
+
onField(state.info, state.fieldChunks[0])
|
|
102
|
+
} else {
|
|
103
|
+
const buf = new Uint8Array(state.fieldSize)
|
|
104
|
+
let offset = 0
|
|
105
|
+
for (let i = 0; i < state.fieldChunks.length; i++) {
|
|
106
|
+
const chunk = state.fieldChunks[i]
|
|
107
|
+
buf.set(chunk, offset)
|
|
108
|
+
offset += chunk.length
|
|
109
|
+
}
|
|
110
|
+
onField(state.info, buf)
|
|
111
|
+
}
|
|
112
|
+
state.fieldSize = 0
|
|
113
|
+
state.fieldChunks = []
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
state.partSize = 0
|
|
117
|
+
|
|
118
|
+
state.state = State.headers
|
|
119
|
+
state.index = index
|
|
120
|
+
state.headerSkip = 2 // skip the first \r\n
|
|
121
|
+
|
|
122
|
+
// trailing --
|
|
123
|
+
if (chunk[0] === 45 && chunk[1] === 45) {
|
|
124
|
+
state.done = true
|
|
125
|
+
return onDone()
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
state.parts++
|
|
129
|
+
if (state.parts > maxParts) {
|
|
130
|
+
onError(errMaxParts)
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if ((state.partSize += chunk.length) > maxPartSize) {
|
|
135
|
+
onError(errMaxPartSize)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (state.state === State.headers) {
|
|
139
|
+
const result = headerParser(chunk, state.headerSkip)
|
|
140
|
+
state.headerSkip = 0
|
|
141
|
+
|
|
142
|
+
if (result._tag === "Continue") {
|
|
143
|
+
return
|
|
144
|
+
} else if (result._tag === "Failure") {
|
|
145
|
+
skipBody()
|
|
146
|
+
return onError({ _tag: "BadHeaders", error: result })
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const contentType = CT.parse(result.headers["content-type"] as string)
|
|
150
|
+
const contentDisposition = CT.parse(
|
|
151
|
+
result.headers["content-disposition"] as string,
|
|
152
|
+
true
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
if (
|
|
156
|
+
"form-data" === contentDisposition.value &&
|
|
157
|
+
!("name" in contentDisposition.parameters)
|
|
158
|
+
) {
|
|
159
|
+
skipBody()
|
|
160
|
+
return onError(errInvalidDisposition)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
let encodedFilename: string | undefined
|
|
164
|
+
if ("filename*" in contentDisposition.parameters) {
|
|
165
|
+
const parts = contentDisposition.parameters["filename*"].split("''")
|
|
166
|
+
if (parts.length === 2) {
|
|
167
|
+
try {
|
|
168
|
+
encodedFilename = decodeURIComponent(parts[1])
|
|
169
|
+
} catch {
|
|
170
|
+
encodedFilename = parts[1]
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
state.info = {
|
|
176
|
+
name: contentDisposition.parameters.name ?? "",
|
|
177
|
+
filename: encodedFilename ?? contentDisposition.parameters.filename,
|
|
178
|
+
contentType: contentType.value === ""
|
|
179
|
+
? contentDisposition.parameters.filename !== undefined
|
|
180
|
+
? "application/octet-stream"
|
|
181
|
+
: "text/plain"
|
|
182
|
+
: contentType.value,
|
|
183
|
+
contentTypeParameters: contentType.parameters,
|
|
184
|
+
contentDisposition: contentDisposition.value,
|
|
185
|
+
contentDispositionParameters: contentDisposition.parameters as any,
|
|
186
|
+
headers: result.headers
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
state.state = State.body
|
|
190
|
+
state.isFile = isFile(state.info)
|
|
191
|
+
|
|
192
|
+
if (state.isFile) {
|
|
193
|
+
state.onChunk = onPart(state.info)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (result.endPosition < chunk.length) {
|
|
197
|
+
if (state.isFile) {
|
|
198
|
+
state.onChunk(chunk.subarray(result.endPosition))
|
|
199
|
+
} else {
|
|
200
|
+
const buf = chunk.subarray(result.endPosition)
|
|
201
|
+
if ((state.fieldSize += buf.length) > maxFieldSize) {
|
|
202
|
+
onError(errMaxFieldSize)
|
|
203
|
+
}
|
|
204
|
+
state.fieldChunks.push(buf)
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
} else if (state.isFile) {
|
|
208
|
+
state.onChunk(chunk)
|
|
209
|
+
} else {
|
|
210
|
+
if ((state.fieldSize += chunk.length) > maxFieldSize) {
|
|
211
|
+
onError(errMaxFieldSize)
|
|
212
|
+
}
|
|
213
|
+
state.fieldChunks.push(chunk)
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
constCR,
|
|
217
|
+
2
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
return {
|
|
221
|
+
write(chunk: Uint8Array) {
|
|
222
|
+
if ((state.totalSize += chunk.length) > maxTotalSize) {
|
|
223
|
+
return onError(errMaxTotalSize)
|
|
224
|
+
}
|
|
225
|
+
return split.write(chunk)
|
|
226
|
+
},
|
|
227
|
+
end() {
|
|
228
|
+
split.end()
|
|
229
|
+
if (!state.done) {
|
|
230
|
+
onError(errEndNotReached)
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
state.state = State.headers
|
|
234
|
+
state.index = 0
|
|
235
|
+
state.parts = 0
|
|
236
|
+
state.onChunk = noopOnChunk
|
|
237
|
+
state.info = undefined as any as PartInfo
|
|
238
|
+
state.totalSize = 0
|
|
239
|
+
state.partSize = 0
|
|
240
|
+
state.fieldChunks = []
|
|
241
|
+
state.fieldSize = 0
|
|
242
|
+
state.done = false
|
|
243
|
+
}
|
|
244
|
+
} as const
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const utf8Decoder = new TextDecoder("utf-8")
|
|
248
|
+
function getDecoder(charset: string) {
|
|
249
|
+
if (charset === "utf-8" || charset === "utf8" || charset === "") {
|
|
250
|
+
return utf8Decoder
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
try {
|
|
254
|
+
return new TextDecoder(charset)
|
|
255
|
+
} catch (error) {
|
|
256
|
+
return utf8Decoder
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export function decodeField(info: PartInfo, value: Uint8Array): string {
|
|
261
|
+
return getDecoder(info.contentTypeParameters.charset ?? "utf-8").decode(value)
|
|
262
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
interface SearchState {
|
|
2
|
+
readonly needle: Uint8Array
|
|
3
|
+
readonly needleLength: number
|
|
4
|
+
readonly indexes: Record<number, ReadonlyArray<number>>
|
|
5
|
+
readonly firstByte: number
|
|
6
|
+
|
|
7
|
+
previousChunk: Uint8Array | undefined
|
|
8
|
+
previousChunkLength: number
|
|
9
|
+
matchIndex: number
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function makeState(needle_: string): SearchState {
|
|
13
|
+
const needle = new TextEncoder().encode(needle_)
|
|
14
|
+
const needleLength = needle.length
|
|
15
|
+
|
|
16
|
+
const indexes: Record<number, Array<number>> = {}
|
|
17
|
+
for (let i = 0; i < needleLength; i++) {
|
|
18
|
+
const b = needle[i]
|
|
19
|
+
if (indexes[b] === undefined) indexes[b] = []
|
|
20
|
+
indexes[b].push(i)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
needle,
|
|
25
|
+
needleLength,
|
|
26
|
+
indexes,
|
|
27
|
+
firstByte: needle[0],
|
|
28
|
+
previousChunk: undefined,
|
|
29
|
+
previousChunkLength: 0,
|
|
30
|
+
matchIndex: 0
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function make(
|
|
35
|
+
needle: string,
|
|
36
|
+
callback: (index: number, chunk: Uint8Array) => void,
|
|
37
|
+
seed?: Uint8Array,
|
|
38
|
+
minimumChunkLength?: number
|
|
39
|
+
) {
|
|
40
|
+
const state = makeState(needle)
|
|
41
|
+
const minChunkLength = minimumChunkLength ?? state.needleLength
|
|
42
|
+
if (seed !== undefined) {
|
|
43
|
+
state.previousChunk = seed
|
|
44
|
+
state.previousChunkLength = seed.length
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function makeIndexOf(): (
|
|
48
|
+
chunk: Uint8Array,
|
|
49
|
+
needle: Uint8Array,
|
|
50
|
+
fromIndex: number
|
|
51
|
+
) => number {
|
|
52
|
+
// on node.js use the Buffer api
|
|
53
|
+
if (
|
|
54
|
+
"Buffer" in globalThis &&
|
|
55
|
+
!("Bun" in globalThis || "Deno" in globalThis)
|
|
56
|
+
) {
|
|
57
|
+
return function(chunk, needle, fromIndex) {
|
|
58
|
+
return Buffer.prototype.indexOf.call(chunk, needle, fromIndex)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const skipTable = new Uint8Array(256).fill(state.needle.length)
|
|
63
|
+
for (let i = 0, lastIndex = state.needle.length - 1; i < lastIndex; ++i) {
|
|
64
|
+
skipTable[state.needle[i]] = lastIndex - i
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return function(chunk, needle, fromIndex) {
|
|
68
|
+
const lengthTotal = chunk.length
|
|
69
|
+
let i = fromIndex + state.needleLength - 1
|
|
70
|
+
|
|
71
|
+
while (i < lengthTotal) {
|
|
72
|
+
for (
|
|
73
|
+
let j = state.needleLength - 1, k = i;
|
|
74
|
+
j >= 0 && chunk[k] === needle[j];
|
|
75
|
+
j--, k--
|
|
76
|
+
) {
|
|
77
|
+
if (j === 0) return k
|
|
78
|
+
}
|
|
79
|
+
i += skipTable[chunk[i]]
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return -1
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const indexOf = makeIndexOf()
|
|
87
|
+
|
|
88
|
+
function write(chunk: Uint8Array): void {
|
|
89
|
+
let chunkLength = chunk.length
|
|
90
|
+
|
|
91
|
+
if (state.previousChunk !== undefined) {
|
|
92
|
+
const newChunk = new Uint8Array(state.previousChunkLength + chunkLength)
|
|
93
|
+
newChunk.set(state.previousChunk)
|
|
94
|
+
newChunk.set(chunk, state.previousChunkLength)
|
|
95
|
+
chunk = newChunk
|
|
96
|
+
chunkLength = state.previousChunkLength + chunkLength
|
|
97
|
+
state.previousChunk = undefined
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
let pos = 0
|
|
101
|
+
while (pos < chunkLength) {
|
|
102
|
+
const remaining = chunkLength - pos
|
|
103
|
+
if (remaining < minChunkLength) {
|
|
104
|
+
state.previousChunk = chunk.subarray(pos)
|
|
105
|
+
state.previousChunkLength = remaining
|
|
106
|
+
return
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const match = indexOf(chunk, state.needle, pos)
|
|
110
|
+
|
|
111
|
+
if (match > -1) {
|
|
112
|
+
if (match > pos) {
|
|
113
|
+
callback(state.matchIndex, chunk.subarray(pos, match))
|
|
114
|
+
}
|
|
115
|
+
state.matchIndex += 1
|
|
116
|
+
pos = match + state.needleLength
|
|
117
|
+
continue
|
|
118
|
+
} else if (chunk[chunkLength - 1] in state.indexes) {
|
|
119
|
+
const indexes = state.indexes[chunk[chunkLength - 1]]
|
|
120
|
+
let earliestIndex = -1
|
|
121
|
+
for (let i = 0, len = indexes.length; i < len; i++) {
|
|
122
|
+
const index = indexes[i]
|
|
123
|
+
if (
|
|
124
|
+
chunk[chunkLength - 1 - index] === state.firstByte &&
|
|
125
|
+
i > earliestIndex
|
|
126
|
+
) {
|
|
127
|
+
earliestIndex = index
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (earliestIndex === -1) {
|
|
131
|
+
if (pos === 0) {
|
|
132
|
+
callback(state.matchIndex, chunk)
|
|
133
|
+
} else {
|
|
134
|
+
callback(state.matchIndex, chunk.subarray(pos))
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
if (chunkLength - 1 - earliestIndex > pos) {
|
|
138
|
+
callback(
|
|
139
|
+
state.matchIndex,
|
|
140
|
+
chunk.subarray(pos, chunkLength - 1 - earliestIndex)
|
|
141
|
+
)
|
|
142
|
+
}
|
|
143
|
+
state.previousChunk = chunk.subarray(chunkLength - 1 - earliestIndex)
|
|
144
|
+
state.previousChunkLength = earliestIndex + 1
|
|
145
|
+
}
|
|
146
|
+
} else if (pos === 0) {
|
|
147
|
+
callback(state.matchIndex, chunk)
|
|
148
|
+
} else {
|
|
149
|
+
callback(state.matchIndex, chunk.subarray(pos))
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
break
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function end(): void {
|
|
157
|
+
if (state.previousChunk !== undefined && state.previousChunk !== seed) {
|
|
158
|
+
callback(state.matchIndex, state.previousChunk)
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
state.previousChunk = seed
|
|
162
|
+
state.previousChunkLength = seed?.length ?? 0
|
|
163
|
+
state.matchIndex = 0
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return { write, end } as const
|
|
167
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Low-level parser for HTTP `multipart/form-data` bodies.
|
|
3
|
+
*
|
|
4
|
+
* @since 4.0.0
|
|
5
|
+
*/
|
|
6
|
+
import type * as HeadersParser from "./MultipartParser/HeadersParser.ts"
|
|
7
|
+
import * as internal from "./MultipartParser/internal/multipart.ts"
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Metadata describing a multipart form part.
|
|
11
|
+
*
|
|
12
|
+
* @category models
|
|
13
|
+
* @since 4.0.0
|
|
14
|
+
*/
|
|
15
|
+
export interface PartInfo {
|
|
16
|
+
readonly name: string
|
|
17
|
+
readonly filename?: string | undefined
|
|
18
|
+
readonly contentType: string
|
|
19
|
+
readonly contentTypeParameters: Record<string, string>
|
|
20
|
+
readonly contentDisposition: string
|
|
21
|
+
readonly contentDispositionParameters: Record<string, string>
|
|
22
|
+
readonly headers: Record<string, string | Array<string>>
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* An error produced while parsing a multipart body.
|
|
27
|
+
*
|
|
28
|
+
* @category errors
|
|
29
|
+
* @since 4.0.0
|
|
30
|
+
*/
|
|
31
|
+
export type MultipartError =
|
|
32
|
+
| {
|
|
33
|
+
readonly _tag: "InvalidBoundary"
|
|
34
|
+
}
|
|
35
|
+
| {
|
|
36
|
+
readonly _tag: "BadHeaders"
|
|
37
|
+
readonly error: HeadersParser.Failure
|
|
38
|
+
}
|
|
39
|
+
| {
|
|
40
|
+
readonly _tag: "InvalidDisposition"
|
|
41
|
+
}
|
|
42
|
+
| {
|
|
43
|
+
readonly _tag: "ReachedLimit"
|
|
44
|
+
readonly limit:
|
|
45
|
+
| "MaxParts"
|
|
46
|
+
| "MaxTotalSize"
|
|
47
|
+
| "MaxPartSize"
|
|
48
|
+
| "MaxFieldSize"
|
|
49
|
+
}
|
|
50
|
+
| {
|
|
51
|
+
readonly _tag: "EndNotReached"
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Shared multipart parser configuration.
|
|
56
|
+
*
|
|
57
|
+
* @category models
|
|
58
|
+
* @since 4.0.0
|
|
59
|
+
*/
|
|
60
|
+
export type BaseConfig = {
|
|
61
|
+
readonly headers: Record<string, string>
|
|
62
|
+
readonly isFile?: ((info: PartInfo) => boolean) | undefined
|
|
63
|
+
readonly maxParts?: number | undefined
|
|
64
|
+
readonly maxTotalSize?: number | undefined
|
|
65
|
+
readonly maxPartSize?: number | undefined
|
|
66
|
+
readonly maxFieldSize?: number | undefined
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Multipart parser configuration with event callbacks.
|
|
71
|
+
*
|
|
72
|
+
* @category models
|
|
73
|
+
* @since 4.0.0
|
|
74
|
+
*/
|
|
75
|
+
export type Config = BaseConfig & {
|
|
76
|
+
readonly onField: (info: PartInfo, value: Uint8Array) => void
|
|
77
|
+
readonly onFile: (info: PartInfo) => (chunk: Uint8Array | null) => void
|
|
78
|
+
readonly onError: (error: MultipartError) => void
|
|
79
|
+
readonly onDone: () => void
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* A streaming multipart parser.
|
|
84
|
+
*
|
|
85
|
+
* @category models
|
|
86
|
+
* @since 4.0.0
|
|
87
|
+
*/
|
|
88
|
+
export interface Parser {
|
|
89
|
+
readonly write: (chunk: Uint8Array) => void
|
|
90
|
+
readonly end: () => void
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Creates a streaming multipart parser.
|
|
95
|
+
*
|
|
96
|
+
* @category constructors
|
|
97
|
+
* @since 4.0.0
|
|
98
|
+
*/
|
|
99
|
+
export const make: (options: Config) => Parser = internal.make
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Determines whether a multipart part should be treated as a file.
|
|
103
|
+
*
|
|
104
|
+
* @category utilities
|
|
105
|
+
* @since 4.0.0
|
|
106
|
+
*/
|
|
107
|
+
export const defaultIsFile: (info: PartInfo) => boolean = internal.defaultIsFile
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Decodes a multipart field using its declared character set.
|
|
111
|
+
*
|
|
112
|
+
* @category utilities
|
|
113
|
+
* @since 4.0.0
|
|
114
|
+
*/
|
|
115
|
+
export const decodeField: (info: PartInfo, value: Uint8Array) => string = internal.decodeField
|
|
@@ -215,11 +215,12 @@ export function stream<A extends ReadonlyArray<InterpolatedWithStream>>(
|
|
|
215
215
|
buffer = ""
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
return Stream.
|
|
219
|
-
Stream.
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
218
|
+
return Stream.fromIterable(chunks).pipe(
|
|
219
|
+
Stream.mapEffect(
|
|
220
|
+
(chunk) => Effect.isEffect(chunk) ? chunk : Effect.succeed(chunk),
|
|
221
|
+
{ concurrency: "unbounded" }
|
|
222
|
+
),
|
|
223
|
+
Stream.flatMap((chunk) => typeof chunk === "string" ? Stream.succeed(chunk) : chunk)
|
|
223
224
|
)
|
|
224
225
|
}
|
|
225
226
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as Headers from "../Headers.ts"
|
|
2
|
+
import type * as HttpBody from "../HttpBody.ts"
|
|
3
|
+
|
|
4
|
+
/** @internal */
|
|
5
|
+
export const updateHeaders = (headers: Headers.Headers, body: HttpBody.HttpBody): Headers.Headers => {
|
|
6
|
+
if (body._tag === "Empty" || body._tag === "FormData") {
|
|
7
|
+
return Headers.remove(Headers.remove(headers, "content-type"), "content-length")
|
|
8
|
+
}
|
|
9
|
+
headers = body.contentType === undefined
|
|
10
|
+
? Headers.remove(headers, "content-type")
|
|
11
|
+
: Headers.set(headers, "content-type", body.contentType)
|
|
12
|
+
return body.contentLength === undefined
|
|
13
|
+
? Headers.remove(headers, "content-length")
|
|
14
|
+
: Headers.set(headers, "content-length", body.contentLength.toString())
|
|
15
|
+
}
|
|
@@ -15,7 +15,6 @@ import { type Pipeable, pipeArguments } from "../../Pipeable.ts"
|
|
|
15
15
|
import * as Predicate from "../../Predicate.ts"
|
|
16
16
|
import * as Record from "../../Record.ts"
|
|
17
17
|
import type * as Schema from "../../Schema.ts"
|
|
18
|
-
import type * as SchemaAST from "../../SchemaAST.ts"
|
|
19
18
|
import type { PathInput } from "../http/HttpRouter.ts"
|
|
20
19
|
import * as HttpApiEndpoint from "./HttpApiEndpoint.ts"
|
|
21
20
|
import type * as HttpApiGroup from "./HttpApiGroup.ts"
|
|
@@ -290,11 +289,11 @@ export const reflect = <Id extends string, Groups extends HttpApiGroup.Constrain
|
|
|
290
289
|
mergedAnnotations: Context.merge(groupAnnotations, endpoint.annotations),
|
|
291
290
|
successes: extractResponseContent(
|
|
292
291
|
HttpApiEndpoint.getSuccessSchemas(endpoint),
|
|
293
|
-
HttpApiSchema.
|
|
292
|
+
HttpApiSchema.getStatusSuccessSchema
|
|
294
293
|
),
|
|
295
294
|
errors: extractResponseContent(
|
|
296
295
|
HttpApiEndpoint.getErrorSchemas(endpoint),
|
|
297
|
-
HttpApiSchema.
|
|
296
|
+
HttpApiSchema.getStatusErrorSchema
|
|
298
297
|
)
|
|
299
298
|
})
|
|
300
299
|
}
|
|
@@ -305,7 +304,7 @@ export const reflect = <Id extends string, Groups extends HttpApiGroup.Constrain
|
|
|
305
304
|
|
|
306
305
|
const extractResponseContent = (
|
|
307
306
|
schemas: Array<Schema.Top>,
|
|
308
|
-
getStatus: (
|
|
307
|
+
getStatus: (schema: Schema.Constraint) => number
|
|
309
308
|
): ReadonlyMap<number, [Schema.Top, ...Array<Schema.Top>]> => {
|
|
310
309
|
const map = new Map<number, [Schema.Top, ...Array<Schema.Top>]>()
|
|
311
310
|
|
|
@@ -314,9 +313,9 @@ const extractResponseContent = (
|
|
|
314
313
|
return map
|
|
315
314
|
|
|
316
315
|
function add(schema: Schema.Top) {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
const status = getStatus(
|
|
316
|
+
const body = HttpApiSchema.isWithHeaders(schema) ? schema.schema : schema
|
|
317
|
+
if (HttpApiSchema.isStreamSchema(body)) return
|
|
318
|
+
const status = getStatus(schema)
|
|
320
319
|
const schemas = map.get(status)
|
|
321
320
|
if (schemas === undefined) {
|
|
322
321
|
map.set(status, [schema])
|