effect 4.0.0-beta.30 → 4.0.0-beta.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Array.d.ts +87 -86
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +47 -40
- package/dist/Array.js.map +1 -1
- package/dist/BigDecimal.d.ts +46 -45
- package/dist/BigDecimal.d.ts.map +1 -1
- package/dist/BigDecimal.js +35 -38
- package/dist/BigDecimal.js.map +1 -1
- package/dist/BigInt.d.ts +39 -32
- package/dist/BigInt.d.ts.map +1 -1
- package/dist/BigInt.js +32 -29
- package/dist/BigInt.js.map +1 -1
- package/dist/Channel.d.ts +2 -2
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js.map +1 -1
- package/dist/Chunk.d.ts +58 -57
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +20 -21
- package/dist/Chunk.js.map +1 -1
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +4 -1
- package/dist/Config.js.map +1 -1
- package/dist/Cron.d.ts +3 -6
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +11 -18
- package/dist/Cron.js.map +1 -1
- package/dist/DateTime.d.ts +49 -92
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/DateTime.js +9 -9
- package/dist/DateTime.js.map +1 -1
- package/dist/Deferred.d.ts +7 -5
- package/dist/Deferred.d.ts.map +1 -1
- package/dist/Deferred.js +7 -5
- package/dist/Deferred.js.map +1 -1
- package/dist/Duration.d.ts +55 -25
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +100 -70
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +3 -4
- package/dist/Effect.js.map +1 -1
- package/dist/Fiber.d.ts +2 -1
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/Fiber.js.map +1 -1
- package/dist/FiberHandle.d.ts +9 -8
- package/dist/FiberHandle.d.ts.map +1 -1
- package/dist/FiberHandle.js +8 -7
- package/dist/FiberHandle.js.map +1 -1
- package/dist/FiberMap.d.ts +20 -19
- package/dist/FiberMap.d.ts.map +1 -1
- package/dist/FiberMap.js +6 -6
- package/dist/FiberMap.js.map +1 -1
- package/dist/FileSystem.d.ts +17 -16
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js +10 -7
- package/dist/FileSystem.js.map +1 -1
- package/dist/Graph.d.ts +64 -64
- package/dist/Graph.d.ts.map +1 -1
- package/dist/Graph.js +53 -53
- package/dist/Graph.js.map +1 -1
- package/dist/HashMap.d.ts +11 -5
- package/dist/HashMap.d.ts.map +1 -1
- package/dist/HashMap.js +3 -1
- package/dist/HashMap.js.map +1 -1
- package/dist/Iterable.d.ts +11 -11
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +12 -12
- package/dist/Iterable.js.map +1 -1
- package/dist/Latch.d.ts +69 -3
- package/dist/Latch.d.ts.map +1 -1
- package/dist/Latch.js +58 -0
- package/dist/Latch.js.map +1 -1
- package/dist/Layer.d.ts +181 -2
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +35 -2
- package/dist/Layer.js.map +1 -1
- package/dist/Number.d.ts +74 -18
- package/dist/Number.d.ts.map +1 -1
- package/dist/Number.js +34 -15
- package/dist/Number.js.map +1 -1
- package/dist/Option.d.ts +2 -0
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js.map +1 -1
- package/dist/PartitionedSemaphore.d.ts +183 -0
- package/dist/PartitionedSemaphore.d.ts.map +1 -0
- package/dist/PartitionedSemaphore.js +231 -0
- package/dist/PartitionedSemaphore.js.map +1 -0
- package/dist/PubSub.d.ts +5 -4
- package/dist/PubSub.d.ts.map +1 -1
- package/dist/PubSub.js +6 -5
- package/dist/PubSub.js.map +1 -1
- package/dist/Queue.d.ts +3 -3
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Queue.js +2 -2
- package/dist/Queue.js.map +1 -1
- package/dist/Record.d.ts +40 -40
- package/dist/Record.d.ts.map +1 -1
- package/dist/Record.js +16 -15
- package/dist/Record.js.map +1 -1
- package/dist/Scheduler.d.ts +25 -123
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +20 -123
- package/dist/Scheduler.js.map +1 -1
- package/dist/Schema.d.ts +2346 -114
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +1359 -68
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +2 -2
- package/dist/SchemaAST.js +2 -2
- package/dist/SchemaGetter.js +6 -4
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +2 -2
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +32 -27
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/Semaphore.d.ts +149 -53
- package/dist/Semaphore.d.ts.map +1 -1
- package/dist/Semaphore.js +137 -117
- package/dist/Semaphore.js.map +1 -1
- package/dist/ServiceMap.d.ts +26 -0
- package/dist/ServiceMap.d.ts.map +1 -1
- package/dist/ServiceMap.js +36 -21
- package/dist/ServiceMap.js.map +1 -1
- package/dist/Stream.js +1 -1
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +114 -47
- package/dist/String.d.ts.map +1 -1
- package/dist/String.js +29 -47
- package/dist/String.js.map +1 -1
- package/dist/SubscriptionRef.d.ts +1 -2
- package/dist/SubscriptionRef.d.ts.map +1 -1
- package/dist/SubscriptionRef.js +81 -115
- package/dist/SubscriptionRef.js.map +1 -1
- package/dist/Terminal.d.ts +2 -1
- package/dist/Terminal.d.ts.map +1 -1
- package/dist/Terminal.js.map +1 -1
- package/dist/Tracer.d.ts +5 -4
- package/dist/Tracer.d.ts.map +1 -1
- package/dist/Tracer.js +2 -1
- package/dist/Tracer.js.map +1 -1
- package/dist/Trie.d.ts +26 -14
- package/dist/Trie.d.ts.map +1 -1
- package/dist/Trie.js +8 -4
- package/dist/Trie.js.map +1 -1
- package/dist/TxHashMap.d.ts +77 -59
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashMap.js +25 -19
- package/dist/TxHashMap.js.map +1 -1
- package/dist/TxSemaphore.d.ts +162 -2
- package/dist/TxSemaphore.d.ts.map +1 -1
- package/dist/TxSemaphore.js +16 -2
- package/dist/TxSemaphore.js.map +1 -1
- package/dist/index.d.ts +88 -32
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +88 -32
- package/dist/index.js.map +1 -1
- package/dist/internal/dateTime.js +66 -59
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +21 -90
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/hashMap.js +2 -1
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/option.js +6 -0
- package/dist/internal/option.js.map +1 -1
- package/dist/internal/trie.js +3 -3
- package/dist/internal/trie.js.map +1 -1
- package/dist/unstable/ai/AiError.js +1 -1
- package/dist/unstable/ai/AiError.js.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.js +4 -0
- package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Chat.d.ts +3 -4
- package/dist/unstable/ai/Chat.d.ts.map +1 -1
- package/dist/unstable/ai/Chat.js +2 -2
- package/dist/unstable/ai/Chat.js.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts +30 -16
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +10 -87
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js +4 -0
- package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Tool.d.ts +14 -0
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +13 -0
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/cli/Argument.d.ts +2 -4
- package/dist/unstable/cli/Argument.d.ts.map +1 -1
- package/dist/unstable/cli/Argument.js +1 -3
- package/dist/unstable/cli/Argument.js.map +1 -1
- package/dist/unstable/cli/CliOutput.d.ts +3 -2
- package/dist/unstable/cli/CliOutput.d.ts.map +1 -1
- package/dist/unstable/cli/CliOutput.js +4 -3
- package/dist/unstable/cli/CliOutput.js.map +1 -1
- package/dist/unstable/cli/Command.d.ts +3 -2
- package/dist/unstable/cli/Command.d.ts.map +1 -1
- package/dist/unstable/cli/Command.js +3 -3
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cli/Completions.d.ts +16 -0
- package/dist/unstable/cli/Completions.d.ts.map +1 -0
- package/dist/unstable/cli/Completions.js +23 -0
- package/dist/unstable/cli/Completions.js.map +1 -0
- package/dist/unstable/cli/Flag.d.ts +2 -2
- package/dist/unstable/cli/Flag.d.ts.map +1 -1
- package/dist/unstable/cli/Flag.js +1 -1
- package/dist/unstable/cli/Flag.js.map +1 -1
- package/dist/unstable/cli/GlobalFlag.d.ts.map +1 -1
- package/dist/unstable/cli/GlobalFlag.js +4 -4
- package/dist/unstable/cli/GlobalFlag.js.map +1 -1
- package/dist/unstable/cli/HelpDoc.d.ts +14 -12
- package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
- package/dist/unstable/cli/Param.d.ts +4 -4
- package/dist/unstable/cli/Param.d.ts.map +1 -1
- package/dist/unstable/cli/Param.js +7 -7
- package/dist/unstable/cli/Param.js.map +1 -1
- package/dist/unstable/cli/Primitive.d.ts +1 -1
- package/dist/unstable/cli/Primitive.d.ts.map +1 -1
- package/dist/unstable/cli/Primitive.js.map +1 -1
- package/dist/unstable/cli/Prompt.js +71 -67
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/cli/index.d.ts +4 -0
- package/dist/unstable/cli/index.d.ts.map +1 -1
- package/dist/unstable/cli/index.js +4 -0
- package/dist/unstable/cli/index.js.map +1 -1
- package/dist/unstable/cli/internal/completions/CommandDescriptor.js +9 -2
- package/dist/unstable/cli/internal/completions/CommandDescriptor.js.map +1 -1
- package/dist/unstable/cli/internal/parser.js +8 -3
- package/dist/unstable/cli/internal/parser.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts +3 -2
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +25 -23
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/DeliverAt.js +1 -1
- package/dist/unstable/cluster/DeliverAt.js.map +1 -1
- package/dist/unstable/cluster/Entity.d.ts +3 -2
- package/dist/unstable/cluster/Entity.d.ts.map +1 -1
- package/dist/unstable/cluster/Entity.js +7 -7
- package/dist/unstable/cluster/Entity.js.map +1 -1
- package/dist/unstable/cluster/Message.d.ts +4 -3
- package/dist/unstable/cluster/Message.d.ts.map +1 -1
- package/dist/unstable/cluster/Message.js +3 -2
- package/dist/unstable/cluster/Message.js.map +1 -1
- package/dist/unstable/cluster/MessageStorage.d.ts +10 -10
- package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/MessageStorage.js +12 -12
- package/dist/unstable/cluster/MessageStorage.js.map +1 -1
- package/dist/unstable/cluster/Reply.d.ts +2 -1
- package/dist/unstable/cluster/Reply.d.ts.map +1 -1
- package/dist/unstable/cluster/Reply.js +4 -3
- 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 +9 -8
- package/dist/unstable/cluster/RunnerServer.js.map +1 -1
- package/dist/unstable/cluster/Runners.d.ts +2 -1
- package/dist/unstable/cluster/Runners.d.ts.map +1 -1
- package/dist/unstable/cluster/Runners.js +7 -6
- package/dist/unstable/cluster/Runners.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +19 -13
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.d.ts +5 -4
- package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.js +4 -4
- package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js +19 -18
- package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/unstable/cluster/internal/entityManager.js +9 -10
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.d.ts +2 -1
- package/dist/unstable/devtools/DevToolsSchema.d.ts.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.js +1 -4
- package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
- package/dist/unstable/encoding/Ndjson.d.ts +8 -8
- package/dist/unstable/encoding/Ndjson.d.ts.map +1 -1
- package/dist/unstable/encoding/Ndjson.js.map +1 -1
- package/dist/unstable/http/Cookies.d.ts +5 -4
- package/dist/unstable/http/Cookies.d.ts.map +1 -1
- package/dist/unstable/http/Cookies.js +3 -4
- package/dist/unstable/http/Cookies.js.map +1 -1
- package/dist/unstable/http/Etag.d.ts.map +1 -1
- package/dist/unstable/http/Etag.js +5 -1
- package/dist/unstable/http/Etag.js.map +1 -1
- package/dist/unstable/http/Headers.d.ts +3 -2
- package/dist/unstable/http/Headers.d.ts.map +1 -1
- package/dist/unstable/http/Headers.js +2 -1
- package/dist/unstable/http/Headers.js.map +1 -1
- package/dist/unstable/http/HttpClient.d.ts.map +1 -1
- package/dist/unstable/http/HttpClient.js +2 -1
- package/dist/unstable/http/HttpClient.js.map +1 -1
- package/dist/unstable/http/HttpClientRequest.d.ts +4 -3
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.js +8 -6
- package/dist/unstable/http/HttpClientRequest.js.map +1 -1
- package/dist/unstable/http/HttpClientResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientResponse.js +2 -1
- package/dist/unstable/http/HttpClientResponse.js.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.d.ts +3 -2
- package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/unstable/http/HttpMiddleware.js +16 -15
- package/dist/unstable/http/HttpMiddleware.js.map +1 -1
- package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
- package/dist/unstable/http/HttpPlatform.js +3 -2
- package/dist/unstable/http/HttpPlatform.js.map +1 -1
- package/dist/unstable/http/HttpRouter.d.ts +2 -1
- package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
- package/dist/unstable/http/HttpRouter.js +7 -7
- package/dist/unstable/http/HttpRouter.js.map +1 -1
- package/dist/unstable/http/HttpServer.d.ts.map +1 -1
- package/dist/unstable/http/HttpServer.js +2 -2
- package/dist/unstable/http/HttpServer.js.map +1 -1
- package/dist/unstable/http/HttpServerError.d.ts +2 -1
- package/dist/unstable/http/HttpServerError.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerError.js +2 -1
- package/dist/unstable/http/HttpServerError.js.map +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts +3 -2
- package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRequest.js +14 -10
- 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 +4 -3
- package/dist/unstable/http/HttpServerResponse.js.map +1 -1
- package/dist/unstable/http/HttpTraceContext.d.ts +3 -2
- package/dist/unstable/http/HttpTraceContext.d.ts.map +1 -1
- package/dist/unstable/http/HttpTraceContext.js +27 -15
- package/dist/unstable/http/HttpTraceContext.js.map +1 -1
- package/dist/unstable/http/UrlParams.d.ts +5 -4
- package/dist/unstable/http/UrlParams.d.ts.map +1 -1
- package/dist/unstable/http/UrlParams.js +5 -6
- package/dist/unstable/http/UrlParams.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts +2 -2
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +4 -2
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.d.ts +15 -0
- package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.js +81 -3
- package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
- package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.js +2 -2
- package/dist/unstable/observability/OtlpExporter.js.map +1 -1
- package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpTracer.js +7 -3
- package/dist/unstable/observability/OtlpTracer.js.map +1 -1
- package/dist/unstable/persistence/Persistable.js +1 -1
- package/dist/unstable/persistence/Persistable.js.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +1 -5
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js +4 -2
- package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
- package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.js +4 -3
- package/dist/unstable/rpc/Rpc.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +4 -4
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/rpc/RpcGroup.d.ts +1 -3
- package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSchema.js +3 -2
- package/dist/unstable/rpc/RpcSchema.js.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.js +4 -1
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +3 -2
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +2 -1
- 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 +1 -1
- package/dist/unstable/sql/SqlClient.js.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.js +6 -6
- package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts +2 -1
- package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts +5 -4
- package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js +19 -14
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +1 -1
- package/src/Array.ts +112 -105
- package/src/BigDecimal.ts +63 -66
- package/src/BigInt.ts +49 -41
- package/src/Channel.ts +3 -3
- package/src/Chunk.ts +68 -63
- package/src/Config.ts +4 -1
- package/src/Cron.ts +13 -18
- package/src/DateTime.ts +51 -92
- package/src/Deferred.ts +8 -6
- package/src/Duration.ts +112 -56
- package/src/Effect.ts +3 -4
- package/src/Fiber.ts +2 -1
- package/src/FiberHandle.ts +10 -9
- package/src/FiberMap.ts +22 -22
- package/src/FileSystem.ts +25 -22
- package/src/Graph.ts +105 -105
- package/src/HashMap.ts +11 -5
- package/src/Iterable.ts +13 -13
- package/src/Latch.ts +85 -3
- package/src/Layer.ts +244 -19
- package/src/Number.ts +85 -26
- package/src/Option.ts +2 -0
- package/src/PartitionedSemaphore.ts +414 -0
- package/src/PubSub.ts +7 -6
- package/src/Queue.ts +5 -5
- package/src/Record.ts +52 -47
- package/src/Scheduler.ts +37 -126
- package/src/Schema.ts +2366 -116
- package/src/SchemaAST.ts +2 -2
- package/src/SchemaGetter.ts +4 -4
- package/src/SchemaRepresentation.ts +2 -2
- package/src/SchemaTransformation.ts +27 -27
- package/src/Semaphore.ts +271 -183
- package/src/ServiceMap.ts +83 -31
- package/src/Stream.ts +1 -1
- package/src/String.ts +122 -69
- package/src/SubscriptionRef.ts +96 -117
- package/src/Terminal.ts +2 -1
- package/src/Tracer.ts +6 -5
- package/src/Trie.ts +26 -14
- package/src/TxHashMap.ts +78 -60
- package/src/TxSemaphore.ts +186 -11
- package/src/index.ts +89 -33
- package/src/internal/dateTime.ts +74 -65
- package/src/internal/effect.ts +30 -122
- package/src/internal/hashMap.ts +4 -3
- package/src/internal/option.ts +7 -0
- package/src/internal/trie.ts +6 -6
- package/src/unstable/ai/AiError.ts +1 -1
- package/src/unstable/ai/AnthropicStructuredOutput.ts +4 -0
- package/src/unstable/ai/Chat.ts +17 -15
- package/src/unstable/ai/LanguageModel.ts +148 -97
- package/src/unstable/ai/OpenAiStructuredOutput.ts +4 -0
- package/src/unstable/ai/Tool.ts +20 -0
- package/src/unstable/cli/Argument.ts +2 -4
- package/src/unstable/cli/CliOutput.ts +7 -5
- package/src/unstable/cli/Command.ts +5 -5
- package/src/unstable/cli/Completions.ts +36 -0
- package/src/unstable/cli/Flag.ts +2 -2
- package/src/unstable/cli/GlobalFlag.ts +4 -5
- package/src/unstable/cli/HelpDoc.ts +14 -12
- package/src/unstable/cli/Param.ts +15 -11
- package/src/unstable/cli/Primitive.ts +1 -1
- package/src/unstable/cli/Prompt.ts +81 -83
- package/src/unstable/cli/index.ts +5 -0
- package/src/unstable/cli/internal/completions/CommandDescriptor.ts +3 -2
- package/src/unstable/cli/internal/parser.ts +7 -4
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +35 -30
- package/src/unstable/cluster/DeliverAt.ts +1 -1
- package/src/unstable/cluster/Entity.ts +13 -12
- package/src/unstable/cluster/Message.ts +6 -5
- package/src/unstable/cluster/MessageStorage.ts +26 -25
- package/src/unstable/cluster/Reply.ts +7 -4
- package/src/unstable/cluster/RunnerServer.ts +10 -13
- package/src/unstable/cluster/Runners.ts +8 -7
- package/src/unstable/cluster/Sharding.ts +24 -17
- package/src/unstable/cluster/ShardingConfig.ts +6 -6
- package/src/unstable/cluster/SqlMessageStorage.ts +21 -18
- package/src/unstable/cluster/internal/entityManager.ts +27 -21
- package/src/unstable/devtools/DevToolsSchema.ts +3 -2
- package/src/unstable/encoding/Ndjson.ts +17 -17
- package/src/unstable/http/Cookies.ts +7 -8
- package/src/unstable/http/Etag.ts +5 -3
- package/src/unstable/http/Headers.ts +6 -5
- package/src/unstable/http/HttpClient.ts +2 -1
- package/src/unstable/http/HttpClientRequest.ts +11 -9
- package/src/unstable/http/HttpClientResponse.ts +5 -4
- package/src/unstable/http/HttpIncomingMessage.ts +3 -2
- package/src/unstable/http/HttpMiddleware.ts +16 -15
- package/src/unstable/http/HttpPlatform.ts +3 -2
- package/src/unstable/http/HttpRouter.ts +9 -9
- package/src/unstable/http/HttpServer.ts +3 -9
- package/src/unstable/http/HttpServerError.ts +3 -2
- package/src/unstable/http/HttpServerRequest.ts +29 -25
- package/src/unstable/http/HttpServerResponse.ts +7 -6
- package/src/unstable/http/HttpTraceContext.ts +31 -17
- package/src/unstable/http/UrlParams.ts +11 -14
- package/src/unstable/httpapi/HttpApiBuilder.ts +13 -7
- package/src/unstable/httpapi/HttpApiError.ts +67 -12
- package/src/unstable/observability/OtlpExporter.ts +5 -2
- package/src/unstable/observability/OtlpTracer.ts +8 -4
- package/src/unstable/persistence/Persistable.ts +1 -1
- package/src/unstable/reactivity/Atom.ts +1 -4
- package/src/unstable/reactivity/AtomRegistry.ts +5 -3
- package/src/unstable/rpc/Rpc.ts +4 -3
- package/src/unstable/rpc/RpcClient.ts +10 -9
- package/src/unstable/rpc/RpcGroup.ts +3 -3
- package/src/unstable/rpc/RpcSchema.ts +6 -5
- package/src/unstable/rpc/RpcSerialization.ts +4 -1
- package/src/unstable/rpc/RpcServer.ts +3 -3
- package/src/unstable/socket/Socket.ts +2 -1
- package/src/unstable/sql/SqlClient.ts +5 -3
- package/src/unstable/workflow/DurableDeferred.ts +6 -6
- package/src/unstable/workflow/Workflow.ts +1 -1
- package/src/unstable/workflow/WorkflowEngine.ts +29 -20
- package/dist/NullOr.d.ts +0 -149
- package/dist/NullOr.d.ts.map +0 -1
- package/dist/NullOr.js +0 -152
- package/dist/NullOr.js.map +0 -1
- package/dist/unstable/cli/internal/completions/Completions.d.ts +0 -2
- package/dist/unstable/cli/internal/completions/Completions.d.ts.map +0 -1
- package/dist/unstable/cli/internal/completions/Completions.js +0 -23
- package/dist/unstable/cli/internal/completions/Completions.js.map +0 -1
- package/src/NullOr.ts +0 -204
- package/src/unstable/cli/internal/completions/Completions.ts +0 -31
|
@@ -6,6 +6,7 @@ import type * as FileSystem from "../../FileSystem.ts"
|
|
|
6
6
|
import { dual } from "../../Function.ts"
|
|
7
7
|
import * as Inspectable from "../../Inspectable.ts"
|
|
8
8
|
import { stringOrRedacted } from "../../internal/redacted.ts"
|
|
9
|
+
import * as Option from "../../Option.ts"
|
|
9
10
|
import { type Pipeable, pipeArguments } from "../../Pipeable.ts"
|
|
10
11
|
import type * as PlatformError from "../../PlatformError.ts"
|
|
11
12
|
import { hasProperty } from "../../Predicate.ts"
|
|
@@ -37,7 +38,7 @@ export interface HttpClientRequest extends Inspectable.Inspectable, Pipeable {
|
|
|
37
38
|
readonly method: HttpMethod
|
|
38
39
|
readonly url: string
|
|
39
40
|
readonly urlParams: UrlParams.UrlParams
|
|
40
|
-
readonly hash: string
|
|
41
|
+
readonly hash: Option.Option<string>
|
|
41
42
|
readonly headers: Headers.Headers
|
|
42
43
|
readonly body: HttpBody.HttpBody
|
|
43
44
|
}
|
|
@@ -95,7 +96,7 @@ export function makeWith(
|
|
|
95
96
|
method: HttpMethod,
|
|
96
97
|
url: string,
|
|
97
98
|
urlParams: UrlParams.UrlParams,
|
|
98
|
-
hash: string
|
|
99
|
+
hash: Option.Option<string>,
|
|
99
100
|
headers: Headers.Headers,
|
|
100
101
|
body: HttpBody.HttpBody
|
|
101
102
|
): HttpClientRequest {
|
|
@@ -117,7 +118,7 @@ export const empty: HttpClientRequest = makeWith(
|
|
|
117
118
|
"GET",
|
|
118
119
|
"",
|
|
119
120
|
UrlParams.empty,
|
|
120
|
-
|
|
121
|
+
Option.none(),
|
|
121
122
|
Headers.empty,
|
|
122
123
|
HttpBody.empty
|
|
123
124
|
)
|
|
@@ -409,7 +410,7 @@ export const setUrl: {
|
|
|
409
410
|
}
|
|
410
411
|
const clone = new URL(url.toString())
|
|
411
412
|
const urlParams = UrlParams.fromInput(clone.searchParams)
|
|
412
|
-
const hash = clone.hash ? clone.hash.slice(1)
|
|
413
|
+
const hash = Option.fromNullishOr(clone.hash === "" ? undefined : clone.hash.slice(1))
|
|
413
414
|
clone.search = ""
|
|
414
415
|
clone.hash = ""
|
|
415
416
|
return makeWith(
|
|
@@ -633,7 +634,7 @@ export const setHash: {
|
|
|
633
634
|
self.method,
|
|
634
635
|
self.url,
|
|
635
636
|
self.urlParams,
|
|
636
|
-
hash,
|
|
637
|
+
Option.some(hash),
|
|
637
638
|
self.headers,
|
|
638
639
|
self.body
|
|
639
640
|
))
|
|
@@ -647,7 +648,7 @@ export const removeHash = (self: HttpClientRequest): HttpClientRequest =>
|
|
|
647
648
|
self.method,
|
|
648
649
|
self.url,
|
|
649
650
|
self.urlParams,
|
|
650
|
-
|
|
651
|
+
Option.none(),
|
|
651
652
|
self.headers,
|
|
652
653
|
self.body
|
|
653
654
|
)
|
|
@@ -946,9 +947,10 @@ export const bodyFile: {
|
|
|
946
947
|
* @since 4.0.0
|
|
947
948
|
* @category combinators
|
|
948
949
|
*/
|
|
949
|
-
export function toUrl(self: HttpClientRequest): URL
|
|
950
|
-
const r = UrlParams.makeUrl(self.url, self.urlParams, self.hash)
|
|
950
|
+
export function toUrl(self: HttpClientRequest): Option.Option<URL> {
|
|
951
|
+
const r = UrlParams.makeUrl(self.url, self.urlParams, Option.getOrUndefined(self.hash))
|
|
951
952
|
if (Result.isSuccess(r)) {
|
|
952
|
-
return r.success
|
|
953
|
+
return Option.some(r.success)
|
|
953
954
|
}
|
|
955
|
+
return Option.none()
|
|
954
956
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import * as Effect from "../../Effect.ts"
|
|
5
5
|
import { dual } from "../../Function.ts"
|
|
6
6
|
import * as Inspectable from "../../Inspectable.ts"
|
|
7
|
+
import * as Option from "../../Option.ts"
|
|
7
8
|
import { type Pipeable, pipeArguments } from "../../Pipeable.ts"
|
|
8
9
|
import * as Schema from "../../Schema.ts"
|
|
9
10
|
import type { ParseOptions } from "../../SchemaAST.ts"
|
|
@@ -270,8 +271,8 @@ class WebHttpClientResponse extends Inspectable.Class implements HttpClientRespo
|
|
|
270
271
|
return this.cachedCookies = Cookies.fromSetCookie(this.source.headers.getSetCookie())
|
|
271
272
|
}
|
|
272
273
|
|
|
273
|
-
get remoteAddress(): string
|
|
274
|
-
return
|
|
274
|
+
get remoteAddress(): Option.Option<string> {
|
|
275
|
+
return Option.none()
|
|
275
276
|
}
|
|
276
277
|
|
|
277
278
|
get stream(): Stream.Stream<Uint8Array, Error.HttpClientError> {
|
|
@@ -298,10 +299,10 @@ class WebHttpClientResponse extends Inspectable.Class implements HttpClientRespo
|
|
|
298
299
|
)
|
|
299
300
|
}
|
|
300
301
|
|
|
301
|
-
get json(): Effect.Effect<
|
|
302
|
+
get json(): Effect.Effect<Schema.Json, Error.HttpClientError> {
|
|
302
303
|
return Effect.flatMap(this.text, (text) =>
|
|
303
304
|
Effect.try({
|
|
304
|
-
try: () => text === "" ? null : JSON.parse(text)
|
|
305
|
+
try: () => text === "" ? null : JSON.parse(text),
|
|
305
306
|
catch: (cause) =>
|
|
306
307
|
new Error.HttpClientError({
|
|
307
308
|
reason: new Error.DecodeError({
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import * as Effect from "../../Effect.ts"
|
|
5
5
|
import type * as FileSystem from "../../FileSystem.ts"
|
|
6
6
|
import type * as Inspectable from "../../Inspectable.ts"
|
|
7
|
+
import type * as Option from "../../Option.ts"
|
|
7
8
|
import { hasProperty } from "../../Predicate.ts"
|
|
8
9
|
import { redact } from "../../Redactable.ts"
|
|
9
10
|
import * as Schema from "../../Schema.ts"
|
|
@@ -32,8 +33,8 @@ export const isHttpIncomingMessage = (u: unknown): u is HttpIncomingMessage => h
|
|
|
32
33
|
export interface HttpIncomingMessage<E = unknown> extends Inspectable.Inspectable {
|
|
33
34
|
readonly [TypeId]: typeof TypeId
|
|
34
35
|
readonly headers: Headers.Headers
|
|
35
|
-
readonly remoteAddress: string
|
|
36
|
-
readonly json: Effect.Effect<
|
|
36
|
+
readonly remoteAddress: Option.Option<string>
|
|
37
|
+
readonly json: Effect.Effect<Schema.Json, E>
|
|
37
38
|
readonly text: Effect.Effect<string, E>
|
|
38
39
|
readonly urlParamsBody: Effect.Effect<UrlParams.UrlParams, E>
|
|
39
40
|
readonly arrayBuffer: Effect.Effect<ArrayBuffer, E>
|
|
@@ -6,6 +6,7 @@ import * as Effect from "../../Effect.ts"
|
|
|
6
6
|
import { constant, constFalse } from "../../Function.ts"
|
|
7
7
|
import * as internalEffect from "../../internal/effect.ts"
|
|
8
8
|
import * as Layer from "../../Layer.ts"
|
|
9
|
+
import * as Option from "../../Option.ts"
|
|
9
10
|
import type { Predicate } from "../../Predicate.ts"
|
|
10
11
|
import type { ReadonlyRecord } from "../../Record.ts"
|
|
11
12
|
import { TracerEnabled } from "../../References.ts"
|
|
@@ -102,7 +103,7 @@ export const logger: <E, R>(
|
|
|
102
103
|
} else if (exit._tag === "Failure") {
|
|
103
104
|
const [response, cause] = causeResponseStripped(exit.cause)
|
|
104
105
|
return Effect.andThen(
|
|
105
|
-
Effect.annotateLogs(Effect.log(cause
|
|
106
|
+
Effect.annotateLogs(Effect.log(Option.getOrElse(cause, () => "Sent HTTP Response")), {
|
|
106
107
|
"http.method": request.method,
|
|
107
108
|
"http.url": request.url,
|
|
108
109
|
"http.status": response.status
|
|
@@ -139,7 +140,7 @@ export const tracer: <E, R>(
|
|
|
139
140
|
}
|
|
140
141
|
const nameGenerator = fiber.getRef(SpanNameGenerator)
|
|
141
142
|
const span = internalEffect.makeSpanUnsafe(fiber, nameGenerator(request), {
|
|
142
|
-
parent: TraceContext.fromHeaders(request.headers),
|
|
143
|
+
parent: Option.getOrUndefined(TraceContext.fromHeaders(request.headers)),
|
|
143
144
|
kind: "server"
|
|
144
145
|
})
|
|
145
146
|
const prevServices = fiber.services
|
|
@@ -147,23 +148,23 @@ export const tracer: <E, R>(
|
|
|
147
148
|
return Effect.onExitPrimitive(httpApp, (exit) => {
|
|
148
149
|
fiber.setServices(prevServices)
|
|
149
150
|
const endTime = fiber.getRef(Clock).currentTimeNanosUnsafe()
|
|
150
|
-
fiber.
|
|
151
|
+
fiber.currentDispatcher.scheduleTask(() => {
|
|
151
152
|
const url = Request.toURL(request)
|
|
152
|
-
if (url
|
|
153
|
-
url.username = "REDACTED"
|
|
154
|
-
url.password = "REDACTED"
|
|
153
|
+
if (Option.isSome(url) && (url.value.username !== "" || url.value.password !== "")) {
|
|
154
|
+
url.value.username = "REDACTED"
|
|
155
|
+
url.value.password = "REDACTED"
|
|
155
156
|
}
|
|
156
157
|
const redactedHeaderNames = fiber.getRef(Headers.CurrentRedactedNames)
|
|
157
158
|
const requestHeaders = Headers.redact(request.headers, redactedHeaderNames)
|
|
158
159
|
span.attribute("http.request.method", request.method)
|
|
159
|
-
if (url
|
|
160
|
-
span.attribute("url.full", url.toString())
|
|
161
|
-
span.attribute("url.path", url.pathname)
|
|
162
|
-
const query = url.search.slice(1)
|
|
160
|
+
if (Option.isSome(url)) {
|
|
161
|
+
span.attribute("url.full", url.value.toString())
|
|
162
|
+
span.attribute("url.path", url.value.pathname)
|
|
163
|
+
const query = url.value.search.slice(1)
|
|
163
164
|
if (query !== "") {
|
|
164
|
-
span.attribute("url.query", url.search.slice(1))
|
|
165
|
+
span.attribute("url.query", url.value.search.slice(1))
|
|
165
166
|
}
|
|
166
|
-
span.attribute("url.scheme", url.protocol.slice(0, -1))
|
|
167
|
+
span.attribute("url.scheme", url.value.protocol.slice(0, -1))
|
|
167
168
|
}
|
|
168
169
|
if (request.headers["user-agent"] !== undefined) {
|
|
169
170
|
span.attribute("user_agent.original", request.headers["user-agent"])
|
|
@@ -171,8 +172,8 @@ export const tracer: <E, R>(
|
|
|
171
172
|
for (const name in requestHeaders) {
|
|
172
173
|
span.attribute(`http.request.header.${name}`, String(requestHeaders[name]))
|
|
173
174
|
}
|
|
174
|
-
if (request.remoteAddress
|
|
175
|
-
span.attribute("client.address", request.remoteAddress)
|
|
175
|
+
if (Option.isSome(request.remoteAddress)) {
|
|
176
|
+
span.attribute("client.address", request.remoteAddress.value)
|
|
176
177
|
}
|
|
177
178
|
const response = exitResponse(exit)
|
|
178
179
|
span.attribute("http.response.status_code", response.status)
|
|
@@ -200,7 +201,7 @@ export const xForwardedHeaders = make((httpApp) =>
|
|
|
200
201
|
"host",
|
|
201
202
|
request.headers["x-forwarded-host"]
|
|
202
203
|
),
|
|
203
|
-
remoteAddress: request.headers["x-forwarded-for"]?.split(",")[0].trim()
|
|
204
|
+
remoteAddress: Option.fromNullishOr(request.headers["x-forwarded-for"]?.split(",")[0].trim())
|
|
204
205
|
})
|
|
205
206
|
: request)
|
|
206
207
|
)
|
|
@@ -5,6 +5,7 @@ import * as Effect from "../../Effect.ts"
|
|
|
5
5
|
import * as FileSystem from "../../FileSystem.ts"
|
|
6
6
|
import { identity } from "../../Function.ts"
|
|
7
7
|
import * as Layer from "../../Layer.ts"
|
|
8
|
+
import * as Option from "../../Option.ts"
|
|
8
9
|
import type { PlatformError } from "../../PlatformError.ts"
|
|
9
10
|
import * as ServiceMap from "../../ServiceMap.ts"
|
|
10
11
|
import * as Stream from "../../Stream.ts"
|
|
@@ -80,8 +81,8 @@ export const make: (impl: {
|
|
|
80
81
|
"etag",
|
|
81
82
|
Etag.toString(etag)
|
|
82
83
|
)
|
|
83
|
-
if (info.mtime) {
|
|
84
|
-
;(headers as any)["last-modified"] = info.mtime.toUTCString()
|
|
84
|
+
if (Option.isSome(info.mtime)) {
|
|
85
|
+
;(headers as any)["last-modified"] = info.mtime.value.toUTCString()
|
|
85
86
|
}
|
|
86
87
|
const contentLength = end !== undefined ? end - start : Number(info.size) - start
|
|
87
88
|
return impl.fileResponse(
|
|
@@ -5,6 +5,7 @@ import * as Arr from "../../Array.ts"
|
|
|
5
5
|
import * as Effect from "../../Effect.ts"
|
|
6
6
|
import { compose, dual, identity } from "../../Function.ts"
|
|
7
7
|
import * as Layer from "../../Layer.ts"
|
|
8
|
+
import * as Option from "../../Option.ts"
|
|
8
9
|
import type { ReadonlyRecord } from "../../Record.ts"
|
|
9
10
|
import * as Schema from "../../Schema.ts"
|
|
10
11
|
import type { ParseOptions } from "../../SchemaAST.ts"
|
|
@@ -12,7 +13,6 @@ import * as Scope from "../../Scope.ts"
|
|
|
12
13
|
import * as ServiceMap from "../../ServiceMap.ts"
|
|
13
14
|
import * as Tracer from "../../Tracer.ts"
|
|
14
15
|
import type * as Types from "../../Types.ts"
|
|
15
|
-
import * as UndefinedOr from "../../UndefinedOr.ts"
|
|
16
16
|
import * as FindMyWay from "./FindMyWay.ts"
|
|
17
17
|
import * as HttpEffect from "./HttpEffect.ts"
|
|
18
18
|
import type * as HttpMethod from "./HttpMethod.ts"
|
|
@@ -177,8 +177,8 @@ export const make = Effect.gen(function*() {
|
|
|
177
177
|
)
|
|
178
178
|
}
|
|
179
179
|
const route = result.handler
|
|
180
|
-
if (route.prefix
|
|
181
|
-
contextMap.set(HttpServerRequest.HttpServerRequest.key, sliceRequestUrl(request, route.prefix))
|
|
180
|
+
if (Option.isSome(route.prefix)) {
|
|
181
|
+
contextMap.set(HttpServerRequest.HttpServerRequest.key, sliceRequestUrl(request, route.prefix.value))
|
|
182
182
|
}
|
|
183
183
|
contextMap.set(HttpServerRequest.ParsedSearchParams.key, result.searchParams)
|
|
184
184
|
contextMap.set(RouteContext.key, {
|
|
@@ -501,7 +501,7 @@ export interface Route<E = never, R = never> {
|
|
|
501
501
|
readonly path: PathInput
|
|
502
502
|
readonly handler: Effect.Effect<HttpServerResponse.HttpServerResponse, E, R>
|
|
503
503
|
readonly uninterruptible: boolean
|
|
504
|
-
readonly prefix: string
|
|
504
|
+
readonly prefix: Option.Option<string>
|
|
505
505
|
}
|
|
506
506
|
|
|
507
507
|
/**
|
|
@@ -527,12 +527,12 @@ const makeRoute = <E, R>(options: {
|
|
|
527
527
|
readonly path: PathInput
|
|
528
528
|
readonly handler: Effect.Effect<HttpServerResponse.HttpServerResponse, E, R>
|
|
529
529
|
readonly uninterruptible?: boolean | undefined
|
|
530
|
-
readonly prefix?: string | undefined
|
|
530
|
+
readonly prefix?: Option.Option<string> | string | undefined
|
|
531
531
|
}): Route<E, Exclude<R, Provided>> =>
|
|
532
532
|
(({
|
|
533
533
|
...options,
|
|
534
534
|
uninterruptible: options.uninterruptible ?? false,
|
|
535
|
-
prefix: options.prefix,
|
|
535
|
+
prefix: typeof options.prefix === "string" ? Option.some(options.prefix) : options.prefix ?? Option.none(),
|
|
536
536
|
[RouteTypeId]: RouteTypeId
|
|
537
537
|
}) as Route<E, Exclude<R, Provided>>)
|
|
538
538
|
|
|
@@ -614,9 +614,9 @@ export const prefixRoute: {
|
|
|
614
614
|
makeRoute({
|
|
615
615
|
...self,
|
|
616
616
|
path: prefixPath(self.path, prefix) as PathInput,
|
|
617
|
-
prefix:
|
|
618
|
-
|
|
619
|
-
|
|
617
|
+
prefix: Option.match(self.prefix, {
|
|
618
|
+
onNone: () => prefix as string,
|
|
619
|
+
onSome: (existingPrefix) => prefixPath(existingPrefix, prefix) as string
|
|
620
620
|
})
|
|
621
621
|
}))
|
|
622
622
|
|
|
@@ -36,6 +36,7 @@ export class HttpServer extends ServiceMap.Service<HttpServer, {
|
|
|
36
36
|
Exclude<R, HttpServerRequest> | Scope.Scope
|
|
37
37
|
>
|
|
38
38
|
}
|
|
39
|
+
|
|
39
40
|
readonly address: Address
|
|
40
41
|
}>()("effect/http/HttpServer") {}
|
|
41
42
|
|
|
@@ -127,10 +128,7 @@ export const serve: {
|
|
|
127
128
|
HttpServer | Exclude<Effect.Services<App>, HttpServerRequest | Scope.Scope>
|
|
128
129
|
> =>
|
|
129
130
|
Layer.effectDiscard(
|
|
130
|
-
|
|
131
|
-
HttpServer.asEffect(),
|
|
132
|
-
(server) => server.serve(effect, middleware!)
|
|
133
|
-
)
|
|
131
|
+
HttpServer.use((server) => server.serve(effect, middleware!))
|
|
134
132
|
) as any)
|
|
135
133
|
|
|
136
134
|
/**
|
|
@@ -180,11 +178,7 @@ export const serveEffect: {
|
|
|
180
178
|
void,
|
|
181
179
|
never,
|
|
182
180
|
Scope.Scope | HttpServer | Exclude<Effect.Services<App>, HttpServerRequest>
|
|
183
|
-
> =>
|
|
184
|
-
Effect.flatMap(
|
|
185
|
-
HttpServer.asEffect(),
|
|
186
|
-
(server) => server.serve(effect, middleware!)
|
|
187
|
-
) as any)
|
|
181
|
+
> => HttpServer.use((server) => server.serve(effect, middleware!)) as any)
|
|
188
182
|
|
|
189
183
|
/**
|
|
190
184
|
* @since 4.0.0
|
|
@@ -7,6 +7,7 @@ import * as Effect from "../../Effect.ts"
|
|
|
7
7
|
import * as ErrorReporter from "../../ErrorReporter.ts"
|
|
8
8
|
import type * as Exit from "../../Exit.ts"
|
|
9
9
|
import { constUndefined } from "../../Function.ts"
|
|
10
|
+
import * as Option from "../../Option.ts"
|
|
10
11
|
import { hasProperty } from "../../Predicate.ts"
|
|
11
12
|
import * as ServiceMap from "../../ServiceMap.ts"
|
|
12
13
|
import type * as Request from "./HttpServerRequest.ts"
|
|
@@ -256,7 +257,7 @@ export const causeResponse = <E>(
|
|
|
256
257
|
*/
|
|
257
258
|
export const causeResponseStripped = <E>(
|
|
258
259
|
cause: Cause.Cause<E>
|
|
259
|
-
): readonly [response: Response.HttpServerResponse, cause: Cause.Cause<E
|
|
260
|
+
): readonly [response: Response.HttpServerResponse, cause: Option.Option<Cause.Cause<E>>] => {
|
|
260
261
|
let response: Response.HttpServerResponse | undefined
|
|
261
262
|
const failures = cause.reasons.filter((f) => {
|
|
262
263
|
if (f._tag === "Die" && Response.isHttpServerResponse(f.defect)) {
|
|
@@ -267,7 +268,7 @@ export const causeResponseStripped = <E>(
|
|
|
267
268
|
})
|
|
268
269
|
return [
|
|
269
270
|
response ?? internalServerError,
|
|
270
|
-
failures.length > 0 ? Cause.fromReasons(failures) :
|
|
271
|
+
failures.length > 0 ? Option.some(Cause.fromReasons(failures)) : Option.none()
|
|
271
272
|
]
|
|
272
273
|
}
|
|
273
274
|
|
|
@@ -6,6 +6,7 @@ import * as Channel from "../../Channel.ts"
|
|
|
6
6
|
import * as Effect from "../../Effect.ts"
|
|
7
7
|
import type * as FileSystem from "../../FileSystem.ts"
|
|
8
8
|
import * as Inspectable from "../../Inspectable.ts"
|
|
9
|
+
import * as Option from "../../Option.ts"
|
|
9
10
|
import type * as Path from "../../Path.ts"
|
|
10
11
|
import type { ReadonlyRecord } from "../../Record.ts"
|
|
11
12
|
import * as Result from "../../Result.ts"
|
|
@@ -64,7 +65,7 @@ export interface HttpServerRequest extends HttpIncomingMessage.HttpIncomingMessa
|
|
|
64
65
|
options: {
|
|
65
66
|
readonly url?: string
|
|
66
67
|
readonly headers?: Headers.Headers
|
|
67
|
-
readonly remoteAddress?: string
|
|
68
|
+
readonly remoteAddress?: Option.Option<string>
|
|
68
69
|
}
|
|
69
70
|
) => HttpServerRequest
|
|
70
71
|
}
|
|
@@ -284,7 +285,10 @@ export const schemaBodyFormJson = <A, I, RD, RE>(
|
|
|
284
285
|
* @category conversions
|
|
285
286
|
*/
|
|
286
287
|
export const fromClientRequest = (request: HttpClientRequest.HttpClientRequest): HttpServerRequest => {
|
|
287
|
-
const url = HttpClientRequest.toUrl(request)
|
|
288
|
+
const url = Option.match(HttpClientRequest.toUrl(request), {
|
|
289
|
+
onNone: () => request.url,
|
|
290
|
+
onSome: (url) => url.toString()
|
|
291
|
+
})
|
|
288
292
|
return new ClientRequestImpl(request, url)
|
|
289
293
|
}
|
|
290
294
|
|
|
@@ -305,11 +309,11 @@ export const toClientRequest = (request: HttpServerRequest): HttpClientRequest.H
|
|
|
305
309
|
request.method,
|
|
306
310
|
"",
|
|
307
311
|
UrlParams.empty,
|
|
308
|
-
|
|
312
|
+
Option.none(),
|
|
309
313
|
request.headers,
|
|
310
314
|
toClientBody(request)
|
|
311
315
|
),
|
|
312
|
-
toURL(request)
|
|
316
|
+
Option.getOrElse(toURL(request), () => request.url)
|
|
313
317
|
)
|
|
314
318
|
|
|
315
319
|
const toClientBody = (request: HttpServerRequest): HttpBody.HttpBody =>
|
|
@@ -343,13 +347,13 @@ class ServerRequestImpl extends Inspectable.Class implements HttpServerRequest {
|
|
|
343
347
|
readonly source: Request
|
|
344
348
|
readonly url: string
|
|
345
349
|
public headersOverride?: Headers.Headers | undefined
|
|
346
|
-
private remoteAddressOverride?: string | undefined
|
|
350
|
+
private remoteAddressOverride?: Option.Option<string> | undefined
|
|
347
351
|
|
|
348
352
|
constructor(
|
|
349
353
|
source: Request,
|
|
350
354
|
url: string,
|
|
351
355
|
headersOverride?: Headers.Headers,
|
|
352
|
-
remoteAddressOverride?: string
|
|
356
|
+
remoteAddressOverride?: Option.Option<string>
|
|
353
357
|
) {
|
|
354
358
|
super()
|
|
355
359
|
this[TypeId] = TypeId
|
|
@@ -370,14 +374,14 @@ class ServerRequestImpl extends Inspectable.Class implements HttpServerRequest {
|
|
|
370
374
|
options: {
|
|
371
375
|
readonly url?: string | undefined
|
|
372
376
|
readonly headers?: Headers.Headers | undefined
|
|
373
|
-
readonly remoteAddress?: string | undefined
|
|
377
|
+
readonly remoteAddress?: Option.Option<string> | undefined
|
|
374
378
|
}
|
|
375
379
|
) {
|
|
376
380
|
return new ServerRequestImpl(
|
|
377
381
|
this.source,
|
|
378
382
|
options.url ?? this.url,
|
|
379
383
|
options.headers ?? this.headersOverride,
|
|
380
|
-
options.remoteAddress
|
|
384
|
+
"remoteAddress" in options ? options.remoteAddress : this.remoteAddressOverride
|
|
381
385
|
)
|
|
382
386
|
}
|
|
383
387
|
get method(): HttpMethod {
|
|
@@ -386,8 +390,8 @@ class ServerRequestImpl extends Inspectable.Class implements HttpServerRequest {
|
|
|
386
390
|
get originalUrl() {
|
|
387
391
|
return this.source.url
|
|
388
392
|
}
|
|
389
|
-
get remoteAddress(): string
|
|
390
|
-
return this.remoteAddressOverride
|
|
393
|
+
get remoteAddress(): Option.Option<string> {
|
|
394
|
+
return this.remoteAddressOverride ?? Option.none()
|
|
391
395
|
}
|
|
392
396
|
get headers(): Headers.Headers {
|
|
393
397
|
this.headersOverride ??= Headers.fromInput(this.source.headers as any)
|
|
@@ -444,10 +448,10 @@ class ServerRequestImpl extends Inspectable.Class implements HttpServerRequest {
|
|
|
444
448
|
return this.textEffect
|
|
445
449
|
}
|
|
446
450
|
|
|
447
|
-
get json(): Effect.Effect<
|
|
451
|
+
get json(): Effect.Effect<Schema.Json, HttpServerError> {
|
|
448
452
|
return Effect.flatMap(this.text, (text) =>
|
|
449
453
|
Effect.try({
|
|
450
|
-
try: () => JSON.parse(text) as
|
|
454
|
+
try: () => JSON.parse(text) as Schema.Json,
|
|
451
455
|
catch: (cause) =>
|
|
452
456
|
new HttpServerError({
|
|
453
457
|
reason: new RequestParseError({
|
|
@@ -538,7 +542,7 @@ class ClientRequestImpl extends Inspectable.Class implements HttpServerRequest {
|
|
|
538
542
|
readonly source: HttpClientRequest.HttpClientRequest
|
|
539
543
|
public originalUrl: string
|
|
540
544
|
public headersOverride?: Headers.Headers | undefined
|
|
541
|
-
private remoteAddressOverride?: string | undefined
|
|
545
|
+
private remoteAddressOverride?: Option.Option<string> | undefined
|
|
542
546
|
private urlOverride?: string | undefined
|
|
543
547
|
|
|
544
548
|
constructor(
|
|
@@ -546,7 +550,7 @@ class ClientRequestImpl extends Inspectable.Class implements HttpServerRequest {
|
|
|
546
550
|
originalUrl: string,
|
|
547
551
|
urlOverride?: string,
|
|
548
552
|
headersOverride?: Headers.Headers,
|
|
549
|
-
remoteAddressOverride?: string
|
|
553
|
+
remoteAddressOverride?: Option.Option<string>
|
|
550
554
|
) {
|
|
551
555
|
super()
|
|
552
556
|
this[TypeId] = TypeId
|
|
@@ -570,7 +574,7 @@ class ClientRequestImpl extends Inspectable.Class implements HttpServerRequest {
|
|
|
570
574
|
options: {
|
|
571
575
|
readonly url?: string | undefined
|
|
572
576
|
readonly headers?: Headers.Headers | undefined
|
|
573
|
-
readonly remoteAddress?: string | undefined
|
|
577
|
+
readonly remoteAddress?: Option.Option<string> | undefined
|
|
574
578
|
}
|
|
575
579
|
) {
|
|
576
580
|
return new ClientRequestImpl(
|
|
@@ -578,7 +582,7 @@ class ClientRequestImpl extends Inspectable.Class implements HttpServerRequest {
|
|
|
578
582
|
this.originalUrl,
|
|
579
583
|
options.url ?? this.url,
|
|
580
584
|
options.headers ?? this.headersOverride,
|
|
581
|
-
options.remoteAddress
|
|
585
|
+
"remoteAddress" in options ? options.remoteAddress : this.remoteAddressOverride
|
|
582
586
|
)
|
|
583
587
|
}
|
|
584
588
|
|
|
@@ -590,8 +594,8 @@ class ClientRequestImpl extends Inspectable.Class implements HttpServerRequest {
|
|
|
590
594
|
return this.urlOverride ?? removeHost(this.originalUrl)
|
|
591
595
|
}
|
|
592
596
|
|
|
593
|
-
get remoteAddress(): string
|
|
594
|
-
return this.remoteAddressOverride
|
|
597
|
+
get remoteAddress(): Option.Option<string> {
|
|
598
|
+
return this.remoteAddressOverride ?? Option.none()
|
|
595
599
|
}
|
|
596
600
|
|
|
597
601
|
get headers(): Headers.Headers {
|
|
@@ -664,10 +668,10 @@ class ClientRequestImpl extends Inspectable.Class implements HttpServerRequest {
|
|
|
664
668
|
return Effect.map(this.bytes, (bytes) => textDecoder.decode(bytes))
|
|
665
669
|
}
|
|
666
670
|
|
|
667
|
-
get json(): Effect.Effect<
|
|
671
|
+
get json(): Effect.Effect<Schema.Json, HttpServerError> {
|
|
668
672
|
return Effect.flatMap(this.text, (text) =>
|
|
669
673
|
Effect.try({
|
|
670
|
-
try: () => text === "" ? null : JSON.parse(text)
|
|
674
|
+
try: () => text === "" ? null : JSON.parse(text),
|
|
671
675
|
catch: (cause) => requestParseError(this, undefined, cause)
|
|
672
676
|
}))
|
|
673
677
|
}
|
|
@@ -877,13 +881,13 @@ const textDecoder = new TextDecoder()
|
|
|
877
881
|
* @since 4.0.0
|
|
878
882
|
* @category conversions
|
|
879
883
|
*/
|
|
880
|
-
export const toURL = (self: HttpServerRequest): URL
|
|
884
|
+
export const toURL = (self: HttpServerRequest): Option.Option<URL> => {
|
|
881
885
|
const host = self.headers.host ?? "localhost"
|
|
882
886
|
const protocol = self.headers["x-forwarded-proto"] === "https" ? "https" : "http"
|
|
883
887
|
try {
|
|
884
|
-
return new URL(self.url, `${protocol}://${host}`)
|
|
888
|
+
return Option.some(new URL(self.url, `${protocol}://${host}`))
|
|
885
889
|
} catch {
|
|
886
|
-
return
|
|
890
|
+
return Option.none()
|
|
887
891
|
}
|
|
888
892
|
}
|
|
889
893
|
|
|
@@ -899,7 +903,7 @@ export const toWebResult = (self: HttpServerRequest, options?: {
|
|
|
899
903
|
return Result.succeed(self.source)
|
|
900
904
|
}
|
|
901
905
|
const url = toURL(self)
|
|
902
|
-
if (url
|
|
906
|
+
if (Option.isNone(url)) {
|
|
903
907
|
return Result.fail(
|
|
904
908
|
new RequestParseError({
|
|
905
909
|
request: self,
|
|
@@ -918,7 +922,7 @@ export const toWebResult = (self: HttpServerRequest, options?: {
|
|
|
918
922
|
requestInit.body = Stream.toReadableStreamWith(self.stream, options?.services ?? ServiceMap.empty())
|
|
919
923
|
;(requestInit as any).duplex = "half"
|
|
920
924
|
}
|
|
921
|
-
return Result.succeed(new Request(url, requestInit))
|
|
925
|
+
return Result.succeed(new Request(url.value, requestInit))
|
|
922
926
|
}
|
|
923
927
|
|
|
924
928
|
/**
|
|
@@ -7,6 +7,7 @@ import type * as FileSystem from "../../FileSystem.ts"
|
|
|
7
7
|
import { dual } from "../../Function.ts"
|
|
8
8
|
import * as Inspectable from "../../Inspectable.ts"
|
|
9
9
|
import { PipeInspectableProto } from "../../internal/core.ts"
|
|
10
|
+
import * as Option from "../../Option.ts"
|
|
10
11
|
import { type Pipeable, pipeArguments } from "../../Pipeable.ts"
|
|
11
12
|
import type { PlatformError } from "../../PlatformError.ts"
|
|
12
13
|
import { hasProperty } from "../../Predicate.ts"
|
|
@@ -965,8 +966,8 @@ class ServerHttpClientResponse extends Inspectable.Class implements HttpClientRe
|
|
|
965
966
|
return this.response.cookies
|
|
966
967
|
}
|
|
967
968
|
|
|
968
|
-
get remoteAddress(): string
|
|
969
|
-
return
|
|
969
|
+
get remoteAddress(): Option.Option<string> {
|
|
970
|
+
return Option.none()
|
|
970
971
|
}
|
|
971
972
|
|
|
972
973
|
get stream(): Stream.Stream<Uint8Array, HttpClientError.HttpClientError> {
|
|
@@ -1015,10 +1016,10 @@ class ServerHttpClientResponse extends Inspectable.Class implements HttpClientRe
|
|
|
1015
1016
|
}
|
|
1016
1017
|
}
|
|
1017
1018
|
|
|
1018
|
-
get json(): Effect.Effect<
|
|
1019
|
+
get json(): Effect.Effect<Schema.Json, HttpClientError.HttpClientError> {
|
|
1019
1020
|
return Effect.flatMap(this.text, (text) =>
|
|
1020
1021
|
Effect.try({
|
|
1021
|
-
try: () => text === "" ? null : JSON.parse(text)
|
|
1022
|
+
try: () => text === "" ? null : JSON.parse(text),
|
|
1022
1023
|
catch: (cause) =>
|
|
1023
1024
|
new HttpClientError.HttpClientError({
|
|
1024
1025
|
reason: new HttpClientError.DecodeError({
|
|
@@ -1137,7 +1138,7 @@ export const fromClientResponse = (
|
|
|
1137
1138
|
cookies: response.cookies,
|
|
1138
1139
|
body: Body.stream(
|
|
1139
1140
|
Stream.catchIf(response.stream, isEmptyBodyError, () => Stream.empty),
|
|
1140
|
-
Headers.get(headers, "content-type"),
|
|
1141
|
+
Option.getOrUndefined(Headers.get(headers, "content-type")),
|
|
1141
1142
|
getContentLength(headers)
|
|
1142
1143
|
)
|
|
1143
1144
|
})
|
|
@@ -1152,7 +1153,7 @@ const isEmptyBodyError = (
|
|
|
1152
1153
|
HttpClientError.isHttpClientError(error) && error.reason._tag === "EmptyBodyError"
|
|
1153
1154
|
|
|
1154
1155
|
const getContentLength = (headers: Headers.Headers): number | undefined => {
|
|
1155
|
-
const contentLength = Headers.get(headers, "content-length")
|
|
1156
|
+
const contentLength = Option.getOrUndefined(Headers.get(headers, "content-length"))
|
|
1156
1157
|
if (contentLength === undefined) {
|
|
1157
1158
|
return undefined
|
|
1158
1159
|
}
|