effect 4.0.0-beta.31 → 4.0.0-beta.33
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/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 +8 -15
- package/dist/Cron.js.map +1 -1
- package/dist/DateTime.d.ts +16 -15
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/DateTime.js +8 -8
- 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 +26 -24
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +23 -22
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +7 -3
- 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 +84 -0
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +27 -0
- 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 +4 -4
- 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 +30 -0
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +28 -1
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaGetter.js +6 -4
- package/dist/SchemaGetter.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 +9 -9
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +20 -89
- 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.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 +8 -0
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +112 -11
- 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/ResponseIdTracker.d.ts +38 -0
- package/dist/unstable/ai/ResponseIdTracker.d.ts.map +1 -0
- package/dist/unstable/ai/ResponseIdTracker.js +68 -0
- package/dist/unstable/ai/ResponseIdTracker.js.map +1 -0
- 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/ai/index.d.ts +4 -0
- package/dist/unstable/ai/index.d.ts.map +1 -1
- package/dist/unstable/ai/index.js +4 -0
- package/dist/unstable/ai/index.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/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/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/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/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/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 +2 -1
- 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.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/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/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 +2 -1
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +5 -3
- 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/Chunk.ts +68 -63
- package/src/Config.ts +4 -1
- package/src/Cron.ts +10 -15
- package/src/DateTime.ts +16 -15
- package/src/Deferred.ts +8 -6
- package/src/Duration.ts +34 -33
- package/src/Effect.ts +12 -23
- 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 +121 -0
- 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 +6 -6
- package/src/Record.ts +52 -47
- package/src/Scheduler.ts +37 -126
- package/src/Schema.ts +49 -1
- package/src/SchemaGetter.ts +4 -4
- 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 +14 -14
- package/src/internal/effect.ts +29 -121
- 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 +6 -2
- package/src/unstable/ai/LanguageModel.ts +192 -65
- package/src/unstable/ai/OpenAiStructuredOutput.ts +4 -0
- package/src/unstable/ai/ResponseIdTracker.ts +97 -0
- package/src/unstable/ai/Tool.ts +20 -0
- package/src/unstable/ai/index.ts +5 -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/Flag.ts +2 -2
- 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/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/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/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 +3 -2
- package/src/unstable/http/HttpIncomingMessage.ts +2 -1
- 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 +25 -21
- package/src/unstable/http/HttpServerResponse.ts +5 -4
- package/src/unstable/http/HttpTraceContext.ts +31 -17
- package/src/unstable/http/UrlParams.ts +11 -14
- package/src/unstable/httpapi/HttpApiBuilder.ts +9 -3
- 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/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/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 +14 -9
- 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/src/NullOr.ts +0 -204
|
@@ -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)
|
|
@@ -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 {
|
|
@@ -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> {
|
|
@@ -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
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @since 4.0.0
|
|
3
3
|
*/
|
|
4
|
+
import * as Option from "../../Option.ts"
|
|
4
5
|
import * as Tracer from "../../Tracer.ts"
|
|
5
6
|
import * as Headers from "./Headers.ts"
|
|
6
7
|
|
|
@@ -9,7 +10,7 @@ import * as Headers from "./Headers.ts"
|
|
|
9
10
|
* @category models
|
|
10
11
|
*/
|
|
11
12
|
export interface FromHeaders {
|
|
12
|
-
(headers: Headers.Headers): Tracer.ExternalSpan
|
|
13
|
+
(headers: Headers.Headers): Option.Option<Tracer.ExternalSpan>
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -18,7 +19,12 @@ export interface FromHeaders {
|
|
|
18
19
|
*/
|
|
19
20
|
export const toHeaders = (span: Tracer.Span): Headers.Headers =>
|
|
20
21
|
Headers.fromRecordUnsafe({
|
|
21
|
-
b3: `${span.traceId}-${span.spanId}-${span.sampled ? "1" : "0"}${
|
|
22
|
+
b3: `${span.traceId}-${span.spanId}-${span.sampled ? "1" : "0"}${
|
|
23
|
+
Option.match(span.parent, {
|
|
24
|
+
onNone: () => "",
|
|
25
|
+
onSome: (parent) => `-${parent.spanId}`
|
|
26
|
+
})
|
|
27
|
+
}`,
|
|
22
28
|
traceparent: `00-${span.traceId}-${span.spanId}-${span.sampled ? "01" : "00"}`
|
|
23
29
|
})
|
|
24
30
|
|
|
@@ -26,8 +32,16 @@ export const toHeaders = (span: Tracer.Span): Headers.Headers =>
|
|
|
26
32
|
* @since 4.0.0
|
|
27
33
|
* @category decoding
|
|
28
34
|
*/
|
|
29
|
-
export const fromHeaders = (headers: Headers.Headers): Tracer.ExternalSpan
|
|
30
|
-
|
|
35
|
+
export const fromHeaders = (headers: Headers.Headers): Option.Option<Tracer.ExternalSpan> => {
|
|
36
|
+
let span = w3c(headers)
|
|
37
|
+
if (Option.isSome(span)) {
|
|
38
|
+
return span
|
|
39
|
+
}
|
|
40
|
+
span = b3(headers)
|
|
41
|
+
if (Option.isSome(span)) {
|
|
42
|
+
return span
|
|
43
|
+
}
|
|
44
|
+
return xb3(headers)
|
|
31
45
|
}
|
|
32
46
|
|
|
33
47
|
/**
|
|
@@ -36,17 +50,17 @@ export const fromHeaders = (headers: Headers.Headers): Tracer.ExternalSpan | und
|
|
|
36
50
|
*/
|
|
37
51
|
export const b3: FromHeaders = (headers) => {
|
|
38
52
|
if (!("b3" in headers)) {
|
|
39
|
-
return
|
|
53
|
+
return Option.none()
|
|
40
54
|
}
|
|
41
55
|
const parts = headers["b3"].split("-")
|
|
42
56
|
if (parts.length < 2) {
|
|
43
|
-
return
|
|
57
|
+
return Option.none()
|
|
44
58
|
}
|
|
45
|
-
return Tracer.externalSpan({
|
|
59
|
+
return Option.some(Tracer.externalSpan({
|
|
46
60
|
traceId: parts[0],
|
|
47
61
|
spanId: parts[1],
|
|
48
62
|
sampled: parts[2] ? parts[2] === "1" : true
|
|
49
|
-
})
|
|
63
|
+
}))
|
|
50
64
|
}
|
|
51
65
|
|
|
52
66
|
/**
|
|
@@ -55,13 +69,13 @@ export const b3: FromHeaders = (headers) => {
|
|
|
55
69
|
*/
|
|
56
70
|
export const xb3: FromHeaders = (headers) => {
|
|
57
71
|
if (!(headers["x-b3-traceid"]) || !(headers["x-b3-spanid"])) {
|
|
58
|
-
return
|
|
72
|
+
return Option.none()
|
|
59
73
|
}
|
|
60
|
-
return Tracer.externalSpan({
|
|
74
|
+
return Option.some(Tracer.externalSpan({
|
|
61
75
|
traceId: headers["x-b3-traceid"],
|
|
62
76
|
spanId: headers["x-b3-spanid"],
|
|
63
77
|
sampled: headers["x-b3-sampled"] ? headers["x-b3-sampled"] === "1" : true
|
|
64
|
-
})
|
|
78
|
+
}))
|
|
65
79
|
}
|
|
66
80
|
|
|
67
81
|
const w3cTraceId = /^[0-9a-f]{32}$/i
|
|
@@ -73,26 +87,26 @@ const w3cSpanId = /^[0-9a-f]{16}$/i
|
|
|
73
87
|
*/
|
|
74
88
|
export const w3c: FromHeaders = (headers) => {
|
|
75
89
|
if (!(headers["traceparent"])) {
|
|
76
|
-
return
|
|
90
|
+
return Option.none()
|
|
77
91
|
}
|
|
78
92
|
const parts = headers["traceparent"].split("-")
|
|
79
93
|
if (parts.length !== 4) {
|
|
80
|
-
return
|
|
94
|
+
return Option.none()
|
|
81
95
|
}
|
|
82
96
|
const [version, traceId, spanId, flags] = parts
|
|
83
97
|
switch (version) {
|
|
84
98
|
case "00": {
|
|
85
99
|
if (w3cTraceId.test(traceId) === false || w3cSpanId.test(spanId) === false) {
|
|
86
|
-
return
|
|
100
|
+
return Option.none()
|
|
87
101
|
}
|
|
88
|
-
return Tracer.externalSpan({
|
|
102
|
+
return Option.some(Tracer.externalSpan({
|
|
89
103
|
traceId,
|
|
90
104
|
spanId,
|
|
91
105
|
sampled: (parseInt(flags, 16) & 1) === 1
|
|
92
|
-
})
|
|
106
|
+
}))
|
|
93
107
|
}
|
|
94
108
|
default: {
|
|
95
|
-
return
|
|
109
|
+
return Option.none()
|
|
96
110
|
}
|
|
97
111
|
}
|
|
98
112
|
}
|
|
@@ -19,7 +19,6 @@ import * as Schema from "../../Schema.ts"
|
|
|
19
19
|
import * as Issue from "../../SchemaIssue.ts"
|
|
20
20
|
import * as Transformation from "../../SchemaTransformation.ts"
|
|
21
21
|
import * as Tuple from "../../Tuple.ts"
|
|
22
|
-
import * as UndefinedOr from "../../UndefinedOr.ts"
|
|
23
22
|
|
|
24
23
|
const TypeId = "~effect/http/UrlParams"
|
|
25
24
|
|
|
@@ -234,18 +233,17 @@ export const getFirst: {
|
|
|
234
233
|
* @since 4.0.0
|
|
235
234
|
* @category combinators
|
|
236
235
|
*/
|
|
237
|
-
(key: string): (self: UrlParams) => string
|
|
236
|
+
(key: string): (self: UrlParams) => Option.Option<string>
|
|
238
237
|
/**
|
|
239
238
|
* @since 4.0.0
|
|
240
239
|
* @category combinators
|
|
241
240
|
*/
|
|
242
|
-
(self: UrlParams, key: string): string
|
|
241
|
+
(self: UrlParams, key: string): Option.Option<string>
|
|
243
242
|
} = dual(
|
|
244
243
|
2,
|
|
245
|
-
(self: UrlParams, key: string): string
|
|
244
|
+
(self: UrlParams, key: string): Option.Option<string> =>
|
|
246
245
|
Arr.findFirst(self.params, ([k]) => k === key).pipe(
|
|
247
|
-
Option.map(([, value]) => value)
|
|
248
|
-
Option.getOrUndefined
|
|
246
|
+
Option.map(([, value]) => value)
|
|
249
247
|
)
|
|
250
248
|
)
|
|
251
249
|
|
|
@@ -258,16 +256,15 @@ export const getLast: {
|
|
|
258
256
|
* @since 4.0.0
|
|
259
257
|
* @category combinators
|
|
260
258
|
*/
|
|
261
|
-
(key: string): (self: UrlParams) => string
|
|
259
|
+
(key: string): (self: UrlParams) => Option.Option<string>
|
|
262
260
|
/**
|
|
263
261
|
* @since 4.0.0
|
|
264
262
|
* @category combinators
|
|
265
263
|
*/
|
|
266
|
-
(self: UrlParams, key: string): string
|
|
267
|
-
} = dual(2, (self: UrlParams, key: string): string
|
|
264
|
+
(self: UrlParams, key: string): Option.Option<string>
|
|
265
|
+
} = dual(2, (self: UrlParams, key: string): Option.Option<string> =>
|
|
268
266
|
Arr.findLast(self.params, ([k]) => k === key).pipe(
|
|
269
|
-
Option.map(([, value]) => value)
|
|
270
|
-
Option.getOrUndefined
|
|
267
|
+
Option.map(([, value]) => value)
|
|
271
268
|
))
|
|
272
269
|
|
|
273
270
|
/**
|
|
@@ -537,9 +534,9 @@ export const schemaJsonField = (field: string): schemaJsonField =>
|
|
|
537
534
|
Schema.UnknownFromJsonString,
|
|
538
535
|
Transformation.transformOrFail({
|
|
539
536
|
decode: (params) =>
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
537
|
+
Option.match(getFirst(params, field), {
|
|
538
|
+
onNone: () => Effect.fail(new Issue.Pointer([field], new Issue.MissingKey(undefined))),
|
|
539
|
+
onSome: Effect.succeed
|
|
543
540
|
}),
|
|
544
541
|
encode: (value) => Effect.succeed(make([[field, value]]))
|
|
545
542
|
})
|
|
@@ -72,10 +72,16 @@ export const layer = <Id extends string, Groups extends HttpApiGroup.Any>(
|
|
|
72
72
|
| Path
|
|
73
73
|
>()
|
|
74
74
|
const routes: Array<HttpRouter.Route<any, any>> = []
|
|
75
|
+
const availableGroups = Array.from(services.mapUnsafe.keys()).filter((key) =>
|
|
76
|
+
key.startsWith("effect/httpapi/HttpApiGroup/")
|
|
77
|
+
)
|
|
75
78
|
for (const group of Object.values(api.groups)) {
|
|
76
79
|
const groupRoutes = services.mapUnsafe.get(group.key) as Array<HttpRouter.Route<any, any>>
|
|
77
80
|
if (groupRoutes === undefined) {
|
|
78
|
-
|
|
81
|
+
const available = availableGroups.length === 0 ? "none" : availableGroups.join(", ")
|
|
82
|
+
return yield* Effect.die(
|
|
83
|
+
`HttpApiGroup "${group.identifier}" not found (key: "${group.key}"). Did you forget to provide HttpApiBuilder.group(api, "${group.identifier}", ...)? Available groups: ${available}`
|
|
84
|
+
)
|
|
79
85
|
}
|
|
80
86
|
routes.push(...groupRoutes)
|
|
81
87
|
}
|
|
@@ -630,13 +636,13 @@ const getRequestMediaType = (request: HttpServerRequest): string => {
|
|
|
630
636
|
const applyMiddleware = <A extends Effect.Effect<any, any, any>>(
|
|
631
637
|
group: HttpApiGroup.AnyWithProps,
|
|
632
638
|
endpoint: HttpApiEndpoint.AnyWithProps,
|
|
633
|
-
services: ServiceMap.ServiceMap<
|
|
639
|
+
services: ServiceMap.ServiceMap<any>,
|
|
634
640
|
handler: A
|
|
635
641
|
) => {
|
|
636
642
|
const options = { group, endpoint }
|
|
637
643
|
for (const key_ of endpoint.middlewares) {
|
|
638
644
|
const key = key_ as any as HttpApiMiddleware.AnyService
|
|
639
|
-
const service =
|
|
645
|
+
const service = ServiceMap.getUnsafe(services, key as any) as HttpApiMiddleware.HttpApiMiddleware<any, any, any>
|
|
640
646
|
const apply = HttpApiMiddleware.isSecurity(key)
|
|
641
647
|
? makeSecurityMiddleware(key, service as any)
|
|
642
648
|
: service
|