effect 4.0.0-beta.43 → 4.0.0-beta.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Cache.d.ts +12 -43
- package/dist/Cache.d.ts.map +1 -1
- package/dist/Cache.js +15 -42
- package/dist/Cache.js.map +1 -1
- package/dist/Cause.d.ts +21 -21
- package/dist/Cause.d.ts.map +1 -1
- package/dist/Cause.js +89 -10
- package/dist/Cause.js.map +1 -1
- package/dist/Channel.d.ts +42 -19
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +86 -46
- package/dist/Channel.js.map +1 -1
- package/dist/Clock.d.ts +2 -2
- package/dist/Clock.d.ts.map +1 -1
- package/dist/Clock.js.map +1 -1
- package/dist/Config.d.ts +2 -2
- package/dist/ConfigProvider.d.ts +5 -5
- package/dist/ConfigProvider.d.ts.map +1 -1
- package/dist/ConfigProvider.js +5 -5
- package/dist/ConfigProvider.js.map +1 -1
- package/dist/Console.d.ts +2 -2
- package/dist/Console.d.ts.map +1 -1
- package/dist/Console.js.map +1 -1
- package/dist/Context.d.ts +1150 -0
- package/dist/Context.d.ts.map +1 -0
- package/dist/{ServiceMap.js → Context.js} +139 -139
- package/dist/Context.js.map +1 -0
- package/dist/DateTime.d.ts +2 -2
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/DateTime.js +2 -2
- package/dist/DateTime.js.map +1 -1
- package/dist/Effect.d.ts +177 -177
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +81 -81
- package/dist/Effect.js.map +1 -1
- package/dist/ErrorReporter.d.ts +3 -3
- package/dist/ErrorReporter.d.ts.map +1 -1
- package/dist/ErrorReporter.js +1 -1
- package/dist/ErrorReporter.js.map +1 -1
- package/dist/ExecutionPlan.d.ts +6 -6
- package/dist/ExecutionPlan.d.ts.map +1 -1
- package/dist/ExecutionPlan.js +4 -4
- package/dist/ExecutionPlan.js.map +1 -1
- package/dist/Fiber.d.ts +7 -7
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/Fiber.js.map +1 -1
- package/dist/FiberHandle.d.ts +2 -2
- package/dist/FiberHandle.d.ts.map +1 -1
- package/dist/FiberHandle.js +4 -4
- package/dist/FiberHandle.js.map +1 -1
- package/dist/FiberMap.d.ts +2 -2
- package/dist/FiberMap.d.ts.map +1 -1
- package/dist/FiberMap.js +4 -4
- package/dist/FiberMap.js.map +1 -1
- package/dist/FiberSet.d.ts +2 -2
- package/dist/FiberSet.d.ts.map +1 -1
- package/dist/FiberSet.js +4 -4
- package/dist/FiberSet.js.map +1 -1
- package/dist/FileSystem.d.ts +3 -3
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js +3 -3
- package/dist/FileSystem.js.map +1 -1
- package/dist/Layer.d.ts +286 -268
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +133 -134
- package/dist/Layer.js.map +1 -1
- package/dist/LayerMap.d.ts +18 -18
- package/dist/LayerMap.d.ts.map +1 -1
- package/dist/LayerMap.js +18 -15
- package/dist/LayerMap.js.map +1 -1
- package/dist/Logger.d.ts +3 -3
- package/dist/Logger.d.ts.map +1 -1
- package/dist/Logger.js.map +1 -1
- package/dist/ManagedRuntime.d.ts +6 -6
- package/dist/ManagedRuntime.d.ts.map +1 -1
- package/dist/ManagedRuntime.js +18 -21
- package/dist/ManagedRuntime.js.map +1 -1
- package/dist/Metric.d.ts +19 -19
- package/dist/Metric.d.ts.map +1 -1
- package/dist/Metric.js +21 -21
- package/dist/Metric.js.map +1 -1
- package/dist/Path.d.ts +2 -2
- package/dist/Path.d.ts.map +1 -1
- package/dist/Path.js +2 -2
- package/dist/Path.js.map +1 -1
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +4 -4
- package/dist/Pool.js.map +1 -1
- package/dist/PubSub.d.ts.map +1 -1
- package/dist/PubSub.js +3 -3
- package/dist/PubSub.js.map +1 -1
- package/dist/Random.d.ts +2 -2
- package/dist/Random.d.ts.map +1 -1
- package/dist/Random.js +0 -23
- package/dist/Random.js.map +1 -1
- package/dist/RcMap.d.ts +2 -2
- package/dist/RcMap.d.ts.map +1 -1
- package/dist/RcMap.js +12 -12
- package/dist/RcMap.js.map +1 -1
- package/dist/Redactable.d.ts +139 -62
- package/dist/Redactable.d.ts.map +1 -1
- package/dist/Redactable.js +59 -55
- package/dist/Redactable.js.map +1 -1
- package/dist/References.d.ts +26 -14
- package/dist/References.d.ts.map +1 -1
- package/dist/References.js +0 -12
- package/dist/References.js.map +1 -1
- package/dist/Request.d.ts +5 -5
- package/dist/Request.d.ts.map +1 -1
- package/dist/Request.js.map +1 -1
- package/dist/RequestResolver.d.ts.map +1 -1
- package/dist/RequestResolver.js +6 -7
- package/dist/RequestResolver.js.map +1 -1
- package/dist/Resource.d.ts +0 -3
- package/dist/Resource.d.ts.map +1 -1
- package/dist/Resource.js +3 -3
- package/dist/Resource.js.map +1 -1
- package/dist/Schedule.d.ts +2 -2
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +2 -2
- package/dist/Schedule.js.map +1 -1
- package/dist/Scheduler.d.ts +4 -4
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +7 -4
- package/dist/Scheduler.js.map +1 -1
- package/dist/Schema.d.ts +531 -214
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +304 -103
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +5 -15
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaGetter.d.ts +49 -5
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +64 -5
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +145 -0
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +146 -0
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/Scope.d.ts +2 -2
- package/dist/Scope.d.ts.map +1 -1
- package/dist/Scope.js.map +1 -1
- package/dist/ScopedCache.d.ts.map +1 -1
- package/dist/ScopedCache.js +4 -4
- package/dist/ScopedCache.js.map +1 -1
- package/dist/Sink.d.ts +6 -6
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Sink.js +1 -1
- package/dist/Sink.js.map +1 -1
- package/dist/Stdio.d.ts +2 -2
- package/dist/Stdio.d.ts.map +1 -1
- package/dist/Stdio.js +2 -2
- package/dist/Stdio.js.map +1 -1
- package/dist/Stream.d.ts +187 -117
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +133 -57
- package/dist/Stream.js.map +1 -1
- package/dist/Terminal.d.ts +3 -3
- package/dist/Terminal.d.ts.map +1 -1
- package/dist/Terminal.js +2 -2
- package/dist/Terminal.js.map +1 -1
- package/dist/Tracer.d.ts +16 -16
- package/dist/Tracer.d.ts.map +1 -1
- package/dist/Tracer.js +11 -8
- package/dist/Tracer.js.map +1 -1
- package/dist/Unify.d.ts +8 -2
- package/dist/Unify.d.ts.map +1 -1
- package/dist/Unify.js.map +1 -1
- package/dist/index.d.ts +81 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +81 -15
- package/dist/index.js.map +1 -1
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/effect.js +74 -74
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/layer.js +3 -3
- package/dist/internal/layer.js.map +1 -1
- package/dist/internal/random.js +2 -2
- package/dist/internal/random.js.map +1 -1
- package/dist/internal/rcRef.js +9 -9
- package/dist/internal/rcRef.js.map +1 -1
- package/dist/internal/references.js +13 -13
- package/dist/internal/references.js.map +1 -1
- package/dist/internal/request.js +6 -6
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/schedule.js +1 -1
- package/dist/internal/schedule.js.map +1 -1
- package/dist/internal/schema/representation.js +11 -1
- package/dist/internal/schema/representation.js.map +1 -1
- package/dist/internal/schema/schema.d.ts +10 -1
- package/dist/internal/schema/schema.d.ts.map +1 -1
- package/dist/internal/schema/schema.js +21 -1
- package/dist/internal/schema/schema.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +3 -3
- package/dist/testing/TestSchema.d.ts.map +1 -1
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/unstable/ai/AiError.d.ts +19 -19
- package/dist/unstable/ai/AiError.d.ts.map +1 -1
- package/dist/unstable/ai/AiError.js +2 -1
- package/dist/unstable/ai/AiError.js.map +1 -1
- package/dist/unstable/ai/Chat.d.ts +4 -4
- package/dist/unstable/ai/Chat.d.ts.map +1 -1
- package/dist/unstable/ai/Chat.js +3 -3
- package/dist/unstable/ai/Chat.js.map +1 -1
- package/dist/unstable/ai/EmbeddingModel.d.ts +6 -6
- package/dist/unstable/ai/EmbeddingModel.d.ts.map +1 -1
- package/dist/unstable/ai/EmbeddingModel.js +3 -3
- package/dist/unstable/ai/EmbeddingModel.js.map +1 -1
- package/dist/unstable/ai/IdGenerator.d.ts +2 -2
- package/dist/unstable/ai/IdGenerator.d.ts.map +1 -1
- package/dist/unstable/ai/IdGenerator.js +2 -2
- package/dist/unstable/ai/IdGenerator.js.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts +2 -2
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +2 -2
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/ai/McpSchema.d.ts +54 -54
- package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
- package/dist/unstable/ai/McpSchema.js +15 -8
- package/dist/unstable/ai/McpSchema.js.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts +22 -22
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.js +25 -25
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/ai/Model.d.ts +3 -3
- package/dist/unstable/ai/Model.d.ts.map +1 -1
- package/dist/unstable/ai/Model.js +5 -5
- package/dist/unstable/ai/Model.js.map +1 -1
- package/dist/unstable/ai/Prompt.d.ts.map +1 -1
- package/dist/unstable/ai/Prompt.js +6 -9
- package/dist/unstable/ai/Prompt.js.map +1 -1
- package/dist/unstable/ai/Response.d.ts +1 -1
- package/dist/unstable/ai/Response.d.ts.map +1 -1
- package/dist/unstable/ai/Response.js +6 -7
- package/dist/unstable/ai/Response.js.map +1 -1
- package/dist/unstable/ai/ResponseIdTracker.d.ts +2 -2
- package/dist/unstable/ai/ResponseIdTracker.d.ts.map +1 -1
- package/dist/unstable/ai/ResponseIdTracker.js +2 -2
- package/dist/unstable/ai/ResponseIdTracker.js.map +1 -1
- package/dist/unstable/ai/Telemetry.d.ts +35 -2
- package/dist/unstable/ai/Telemetry.d.ts.map +1 -1
- package/dist/unstable/ai/Telemetry.js +2 -2
- package/dist/unstable/ai/Telemetry.js.map +1 -1
- package/dist/unstable/ai/Tokenizer.d.ts +2 -2
- package/dist/unstable/ai/Tokenizer.d.ts.map +1 -1
- package/dist/unstable/ai/Tokenizer.js +2 -2
- package/dist/unstable/ai/Tokenizer.js.map +1 -1
- package/dist/unstable/ai/Tool.d.ts +16 -16
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +41 -13
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/ai/Toolkit.d.ts +3 -3
- package/dist/unstable/ai/Toolkit.d.ts.map +1 -1
- package/dist/unstable/ai/Toolkit.js +10 -10
- package/dist/unstable/ai/Toolkit.js.map +1 -1
- package/dist/unstable/cli/Argument.d.ts +2 -3
- package/dist/unstable/cli/Argument.d.ts.map +1 -1
- package/dist/unstable/cli/Argument.js.map +1 -1
- package/dist/unstable/cli/CliError.d.ts +29 -8
- package/dist/unstable/cli/CliError.d.ts.map +1 -1
- package/dist/unstable/cli/CliError.js +8 -1
- package/dist/unstable/cli/CliError.js.map +1 -1
- package/dist/unstable/cli/CliOutput.d.ts +2 -2
- package/dist/unstable/cli/CliOutput.d.ts.map +1 -1
- package/dist/unstable/cli/CliOutput.js +2 -2
- package/dist/unstable/cli/CliOutput.js.map +1 -1
- package/dist/unstable/cli/Command.d.ts +14 -14
- package/dist/unstable/cli/Command.d.ts.map +1 -1
- package/dist/unstable/cli/Command.js +11 -10
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cli/Flag.d.ts +2 -3
- package/dist/unstable/cli/Flag.d.ts.map +1 -1
- package/dist/unstable/cli/Flag.js.map +1 -1
- package/dist/unstable/cli/GlobalFlag.d.ts +2 -2
- package/dist/unstable/cli/GlobalFlag.d.ts.map +1 -1
- package/dist/unstable/cli/GlobalFlag.js +2 -2
- package/dist/unstable/cli/GlobalFlag.js.map +1 -1
- package/dist/unstable/cli/HelpDoc.d.ts +8 -8
- package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
- package/dist/unstable/cli/Param.d.ts +30 -2
- package/dist/unstable/cli/Param.d.ts.map +1 -1
- package/dist/unstable/cli/Param.js +17 -7
- package/dist/unstable/cli/Param.js.map +1 -1
- package/dist/unstable/cli/Prompt.js +8 -2
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/cli/internal/command.d.ts +5 -5
- package/dist/unstable/cli/internal/command.d.ts.map +1 -1
- package/dist/unstable/cli/internal/command.js +3 -3
- package/dist/unstable/cli/internal/command.js.map +1 -1
- package/dist/unstable/cli/internal/parser.js +94 -15
- package/dist/unstable/cli/internal/parser.js.map +1 -1
- package/dist/unstable/cluster/ClusterError.d.ts +7 -7
- package/dist/unstable/cluster/ClusterSchema.d.ts +12 -9
- package/dist/unstable/cluster/ClusterSchema.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterSchema.js +9 -9
- package/dist/unstable/cluster/ClusterSchema.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +13 -14
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/Entity.d.ts +8 -8
- package/dist/unstable/cluster/Entity.d.ts.map +1 -1
- package/dist/unstable/cluster/Entity.js +12 -12
- package/dist/unstable/cluster/Entity.js.map +1 -1
- package/dist/unstable/cluster/EntityAddress.d.ts +2 -2
- package/dist/unstable/cluster/EntityProxy.js +3 -3
- package/dist/unstable/cluster/EntityProxy.js.map +1 -1
- package/dist/unstable/cluster/EntityProxyServer.d.ts.map +1 -1
- package/dist/unstable/cluster/EntityProxyServer.js +4 -4
- package/dist/unstable/cluster/EntityProxyServer.js.map +1 -1
- package/dist/unstable/cluster/EntityResource.d.ts +2 -2
- package/dist/unstable/cluster/EntityResource.d.ts.map +1 -1
- package/dist/unstable/cluster/EntityResource.js +2 -2
- package/dist/unstable/cluster/EntityResource.js.map +1 -1
- package/dist/unstable/cluster/Envelope.d.ts +3 -3
- package/dist/unstable/cluster/HttpRunner.js +2 -2
- package/dist/unstable/cluster/HttpRunner.js.map +1 -1
- package/dist/unstable/cluster/K8sHttpClient.d.ts +4 -4
- package/dist/unstable/cluster/K8sHttpClient.d.ts.map +1 -1
- package/dist/unstable/cluster/K8sHttpClient.js +2 -2
- package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
- package/dist/unstable/cluster/Message.d.ts +7 -4
- package/dist/unstable/cluster/Message.d.ts.map +1 -1
- package/dist/unstable/cluster/Message.js +5 -5
- package/dist/unstable/cluster/Message.js.map +1 -1
- package/dist/unstable/cluster/MessageStorage.d.ts +14 -14
- package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/MessageStorage.js +8 -8
- package/dist/unstable/cluster/MessageStorage.js.map +1 -1
- package/dist/unstable/cluster/Reply.d.ts +2 -2
- package/dist/unstable/cluster/Reply.d.ts.map +1 -1
- package/dist/unstable/cluster/Reply.js +5 -5
- package/dist/unstable/cluster/Reply.js.map +1 -1
- package/dist/unstable/cluster/Runner.d.ts +1 -1
- package/dist/unstable/cluster/RunnerAddress.d.ts +1 -1
- package/dist/unstable/cluster/RunnerHealth.d.ts +2 -2
- package/dist/unstable/cluster/RunnerHealth.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerHealth.js +2 -2
- package/dist/unstable/cluster/RunnerHealth.js.map +1 -1
- package/dist/unstable/cluster/RunnerServer.js +1 -1
- package/dist/unstable/cluster/RunnerServer.js.map +1 -1
- package/dist/unstable/cluster/RunnerStorage.d.ts +12 -12
- package/dist/unstable/cluster/RunnerStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerStorage.js +3 -3
- package/dist/unstable/cluster/RunnerStorage.js.map +1 -1
- package/dist/unstable/cluster/Runners.d.ts +3 -3
- package/dist/unstable/cluster/Runners.d.ts.map +1 -1
- package/dist/unstable/cluster/Runners.js +7 -7
- package/dist/unstable/cluster/Runners.js.map +1 -1
- package/dist/unstable/cluster/ShardId.d.ts +35 -49
- package/dist/unstable/cluster/ShardId.d.ts.map +1 -1
- package/dist/unstable/cluster/ShardId.js +65 -67
- package/dist/unstable/cluster/ShardId.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts +2 -2
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +21 -21
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.d.ts +2 -2
- package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.js +5 -5
- package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
- package/dist/unstable/cluster/SingletonAddress.d.ts +2 -2
- package/dist/unstable/cluster/Snowflake.d.ts +2 -2
- package/dist/unstable/cluster/Snowflake.d.ts.map +1 -1
- package/dist/unstable/cluster/Snowflake.js +2 -2
- package/dist/unstable/cluster/Snowflake.js.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/unstable/cluster/internal/entityManager.js +15 -14
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/cluster/internal/entityReaper.js +2 -2
- package/dist/unstable/cluster/internal/entityReaper.js.map +1 -1
- package/dist/unstable/cluster/internal/resourceMap.js +3 -3
- package/dist/unstable/cluster/internal/resourceMap.js.map +1 -1
- package/dist/unstable/devtools/DevToolsClient.d.ts +2 -2
- package/dist/unstable/devtools/DevToolsClient.d.ts.map +1 -1
- package/dist/unstable/devtools/DevToolsClient.js +5 -5
- package/dist/unstable/devtools/DevToolsClient.js.map +1 -1
- package/dist/unstable/eventlog/EventJournal.d.ts +4 -4
- package/dist/unstable/eventlog/EventJournal.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventJournal.js +2 -2
- package/dist/unstable/eventlog/EventJournal.js.map +1 -1
- package/dist/unstable/eventlog/EventLog.d.ts +5 -5
- package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLog.js +18 -18
- package/dist/unstable/eventlog/EventLog.js.map +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.d.ts +2 -2
- package/dist/unstable/eventlog/EventLogEncryption.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.js +2 -2
- package/dist/unstable/eventlog/EventLogEncryption.js.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.d.ts +15 -12
- package/dist/unstable/eventlog/EventLogRemote.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.js +2 -2
- package/dist/unstable/eventlog/EventLogRemote.js.map +1 -1
- package/dist/unstable/eventlog/EventLogServer.d.ts +3 -3
- package/dist/unstable/eventlog/EventLogServer.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogServer.js +2 -2
- package/dist/unstable/eventlog/EventLogServer.js.map +1 -1
- package/dist/unstable/http/Etag.d.ts +2 -2
- package/dist/unstable/http/Etag.d.ts.map +1 -1
- package/dist/unstable/http/Etag.js +2 -2
- package/dist/unstable/http/Etag.js.map +1 -1
- package/dist/unstable/http/FetchHttpClient.d.ts +6 -3
- package/dist/unstable/http/FetchHttpClient.d.ts.map +1 -1
- package/dist/unstable/http/FetchHttpClient.js +5 -5
- package/dist/unstable/http/FetchHttpClient.js.map +1 -1
- package/dist/unstable/http/Headers.d.ts +5 -2
- package/dist/unstable/http/Headers.d.ts.map +1 -1
- package/dist/unstable/http/Headers.js +3 -3
- package/dist/unstable/http/Headers.js.map +1 -1
- package/dist/unstable/http/HttpClient.d.ts +8 -6
- package/dist/unstable/http/HttpClient.d.ts.map +1 -1
- package/dist/unstable/http/HttpClient.js +6 -6
- package/dist/unstable/http/HttpClient.js.map +1 -1
- package/dist/unstable/http/HttpClientError.d.ts +1 -1
- package/dist/unstable/http/HttpClientRequest.d.ts +2 -2
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.js +4 -4
- package/dist/unstable/http/HttpClientRequest.js.map +1 -1
- package/dist/unstable/http/HttpEffect.d.ts +6 -6
- package/dist/unstable/http/HttpEffect.d.ts.map +1 -1
- package/dist/unstable/http/HttpEffect.js +24 -24
- package/dist/unstable/http/HttpEffect.js.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.d.ts +2 -2
- package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.js +2 -2
- package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts +3 -3
- package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/unstable/http/HttpMiddleware.js +26 -14
- package/dist/unstable/http/HttpMiddleware.js.map +1 -1
- package/dist/unstable/http/HttpPlatform.d.ts +2 -2
- package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
- package/dist/unstable/http/HttpPlatform.js +2 -2
- package/dist/unstable/http/HttpPlatform.js.map +1 -1
- package/dist/unstable/http/HttpRouter.d.ts +7 -7
- package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
- package/dist/unstable/http/HttpRouter.js +29 -29
- package/dist/unstable/http/HttpRouter.js.map +1 -1
- package/dist/unstable/http/HttpServer.d.ts +2 -2
- 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 +3 -3
- package/dist/unstable/http/HttpServerError.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerError.js +3 -3
- package/dist/unstable/http/HttpServerError.js.map +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts +4 -4
- package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRequest.js +6 -6
- package/dist/unstable/http/HttpServerRequest.js.map +1 -1
- package/dist/unstable/http/HttpServerResponse.d.ts +2 -2
- package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerResponse.js +6 -6
- package/dist/unstable/http/HttpServerResponse.js.map +1 -1
- package/dist/unstable/http/Multipart.d.ts +6 -6
- package/dist/unstable/http/Multipart.d.ts.map +1 -1
- package/dist/unstable/http/Multipart.js +7 -7
- package/dist/unstable/http/Multipart.js.map +1 -1
- package/dist/unstable/httpapi/HttpApi.d.ts +9 -9
- package/dist/unstable/httpapi/HttpApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApi.js +8 -8
- package/dist/unstable/httpapi/HttpApi.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts +0 -3
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +20 -20
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +7 -7
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.js +4 -4
- package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.d.ts +13 -13
- package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.d.ts +8 -8
- package/dist/unstable/httpapi/HttpApiGroup.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.js +4 -4
- package/dist/unstable/httpapi/HttpApiGroup.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +6 -6
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.js +5 -5
- package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSecurity.d.ts +9 -6
- package/dist/unstable/httpapi/HttpApiSecurity.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSecurity.js +6 -6
- package/dist/unstable/httpapi/HttpApiSecurity.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts +15 -15
- package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/OpenApi.js +23 -23
- package/dist/unstable/httpapi/OpenApi.js.map +1 -1
- package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.js +5 -5
- package/dist/unstable/observability/OtlpExporter.js.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.js +1 -1
- package/dist/unstable/observability/OtlpMetrics.js.map +1 -1
- package/dist/unstable/observability/OtlpSerialization.d.ts +2 -2
- package/dist/unstable/observability/OtlpSerialization.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpSerialization.js +2 -2
- package/dist/unstable/observability/OtlpSerialization.js.map +1 -1
- package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpTracer.js.map +1 -1
- package/dist/unstable/observability/PrometheusMetrics.d.ts +3 -3
- package/dist/unstable/observability/PrometheusMetrics.d.ts.map +1 -1
- package/dist/unstable/observability/PrometheusMetrics.js +4 -33
- package/dist/unstable/observability/PrometheusMetrics.js.map +1 -1
- package/dist/unstable/persistence/KeyValueStore.d.ts +23 -2
- package/dist/unstable/persistence/KeyValueStore.d.ts.map +1 -1
- package/dist/unstable/persistence/KeyValueStore.js +144 -2
- package/dist/unstable/persistence/KeyValueStore.js.map +1 -1
- package/dist/unstable/persistence/PersistedCache.d.ts +1 -2
- package/dist/unstable/persistence/PersistedCache.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedCache.js +10 -11
- package/dist/unstable/persistence/PersistedCache.js.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.d.ts +4 -4
- package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.js +3 -3
- package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
- package/dist/unstable/persistence/Persistence.d.ts +4 -4
- package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
- package/dist/unstable/persistence/Persistence.js +3 -3
- package/dist/unstable/persistence/Persistence.js.map +1 -1
- package/dist/unstable/persistence/RateLimiter.d.ts +6 -6
- package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
- package/dist/unstable/persistence/RateLimiter.js +3 -3
- package/dist/unstable/persistence/RateLimiter.js.map +1 -1
- package/dist/unstable/persistence/Redis.d.ts +3 -3
- package/dist/unstable/persistence/Redis.d.ts.map +1 -1
- package/dist/unstable/persistence/Redis.js +2 -2
- package/dist/unstable/persistence/Redis.js.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.d.ts +45 -2
- package/dist/unstable/process/ChildProcessSpawner.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.js +2 -2
- package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts +36 -36
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +9 -9
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts +3 -3
- package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.js +2 -2
- package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.d.ts +2 -2
- package/dist/unstable/reactivity/AtomRegistry.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js +3 -3
- package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.d.ts +3 -3
- package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.js +2 -2
- package/dist/unstable/reactivity/AtomRpc.js.map +1 -1
- package/dist/unstable/reactivity/Reactivity.d.ts +2 -2
- package/dist/unstable/reactivity/Reactivity.d.ts.map +1 -1
- package/dist/unstable/reactivity/Reactivity.js +6 -6
- package/dist/unstable/reactivity/Reactivity.js.map +1 -1
- package/dist/unstable/rpc/Rpc.d.ts +11 -11
- package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.js +4 -4
- package/dist/unstable/rpc/Rpc.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts +18 -8
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +27 -18
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/rpc/RpcClientError.d.ts +2 -2
- package/dist/unstable/rpc/RpcGroup.d.ts +7 -7
- package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcGroup.js +20 -20
- package/dist/unstable/rpc/RpcGroup.js.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.d.ts +6 -6
- package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.js +5 -5
- package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
- package/dist/unstable/rpc/RpcSchema.d.ts +3 -3
- package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSchema.js +3 -3
- package/dist/unstable/rpc/RpcSchema.js.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.d.ts +2 -2
- package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.js +2 -2
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts +2 -2
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +18 -18
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/rpc/RpcWorker.d.ts +2 -2
- package/dist/unstable/rpc/RpcWorker.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcWorker.js +4 -4
- package/dist/unstable/rpc/RpcWorker.js.map +1 -1
- package/dist/unstable/rpc/Utils.d.ts +0 -3
- package/dist/unstable/rpc/Utils.d.ts.map +1 -1
- package/dist/unstable/rpc/Utils.js +2 -5
- package/dist/unstable/rpc/Utils.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts +10 -10
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +9 -9
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/dist/unstable/socket/SocketServer.d.ts +5 -2
- package/dist/unstable/socket/SocketServer.d.ts.map +1 -1
- package/dist/unstable/socket/SocketServer.js +2 -2
- package/dist/unstable/socket/SocketServer.js.map +1 -1
- package/dist/unstable/sql/SqlClient.d.ts +5 -5
- package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
- package/dist/unstable/sql/SqlClient.js +7 -7
- package/dist/unstable/sql/SqlClient.js.map +1 -1
- package/dist/unstable/sql/SqlConnection.d.ts +2 -2
- package/dist/unstable/sql/SqlConnection.d.ts.map +1 -1
- package/dist/unstable/sql/SqlConnection.js +5 -2
- package/dist/unstable/sql/SqlConnection.js.map +1 -1
- package/dist/unstable/sql/SqlError.d.ts +12 -12
- package/dist/unstable/sql/SqlModel.d.ts +8 -9
- package/dist/unstable/sql/SqlModel.d.ts.map +1 -1
- package/dist/unstable/sql/SqlModel.js +9 -35
- package/dist/unstable/sql/SqlModel.js.map +1 -1
- package/dist/unstable/sql/SqlResolver.js +11 -11
- package/dist/unstable/sql/SqlResolver.js.map +1 -1
- package/dist/unstable/sql/Statement.d.ts +2 -2
- package/dist/unstable/sql/Statement.d.ts.map +1 -1
- package/dist/unstable/sql/Statement.js +2 -2
- package/dist/unstable/sql/Statement.js.map +1 -1
- package/dist/unstable/workers/Transferable.d.ts +2 -2
- package/dist/unstable/workers/Transferable.d.ts.map +1 -1
- package/dist/unstable/workers/Transferable.js +6 -6
- package/dist/unstable/workers/Transferable.js.map +1 -1
- package/dist/unstable/workers/Worker.d.ts +3 -3
- package/dist/unstable/workers/Worker.d.ts.map +1 -1
- package/dist/unstable/workers/Worker.js +6 -3
- package/dist/unstable/workers/Worker.js.map +1 -1
- package/dist/unstable/workers/WorkerError.d.ts +5 -5
- package/dist/unstable/workers/WorkerRunner.d.ts +2 -2
- package/dist/unstable/workers/WorkerRunner.d.ts.map +1 -1
- package/dist/unstable/workers/WorkerRunner.js +5 -2
- package/dist/unstable/workers/WorkerRunner.js.map +1 -1
- package/dist/unstable/workflow/Activity.d.ts +7 -7
- package/dist/unstable/workflow/Activity.d.ts.map +1 -1
- package/dist/unstable/workflow/Activity.js +7 -7
- package/dist/unstable/workflow/Activity.js.map +1 -1
- package/dist/unstable/workflow/DurableClock.d.ts +0 -3
- package/dist/unstable/workflow/DurableClock.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableClock.js +3 -3
- package/dist/unstable/workflow/DurableClock.js.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.d.ts +1 -1
- package/dist/unstable/workflow/DurableDeferred.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.js +7 -7
- package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts +9 -9
- package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
- package/dist/unstable/workflow/Workflow.js +18 -18
- package/dist/unstable/workflow/Workflow.js.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts +3 -3
- package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js +5 -5
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/dist/unstable/workflow/WorkflowProxyServer.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowProxyServer.js +4 -4
- package/dist/unstable/workflow/WorkflowProxyServer.js.map +1 -1
- package/package.json +1 -1
- package/src/Cache.ts +18 -46
- package/src/Cause.ts +21 -21
- package/src/Channel.ts +120 -79
- package/src/Clock.ts +2 -2
- package/src/Config.ts +2 -2
- package/src/ConfigProvider.ts +5 -5
- package/src/Console.ts +2 -2
- package/src/{ServiceMap.ts → Context.ts} +337 -340
- package/src/DateTime.ts +2 -2
- package/src/Effect.ts +182 -184
- package/src/ErrorReporter.ts +3 -3
- package/src/ExecutionPlan.ts +8 -9
- package/src/Fiber.ts +7 -7
- package/src/FiberHandle.ts +5 -5
- package/src/FiberMap.ts +5 -5
- package/src/FiberSet.ts +5 -5
- package/src/FileSystem.ts +3 -3
- package/src/Layer.ts +333 -307
- package/src/LayerMap.ts +27 -26
- package/src/Logger.ts +3 -3
- package/src/ManagedRuntime.ts +32 -32
- package/src/Metric.ts +58 -58
- package/src/Path.ts +2 -2
- package/src/Pool.ts +5 -5
- package/src/PubSub.ts +3 -3
- package/src/Random.ts +2 -2
- package/src/RcMap.ts +14 -14
- package/src/Redactable.ts +146 -72
- package/src/References.ts +14 -14
- package/src/Request.ts +5 -5
- package/src/RequestResolver.ts +6 -7
- package/src/Resource.ts +4 -4
- package/src/Schedule.ts +2 -2
- package/src/Scheduler.ts +4 -4
- package/src/Schema.ts +837 -397
- package/src/SchemaAST.ts +5 -14
- package/src/SchemaGetter.ts +69 -11
- package/src/SchemaTransformation.ts +166 -0
- package/src/Scope.ts +2 -2
- package/src/ScopedCache.ts +5 -5
- package/src/Sink.ts +9 -9
- package/src/Stdio.ts +2 -2
- package/src/Stream.ts +234 -158
- package/src/Terminal.ts +3 -3
- package/src/Tracer.ts +17 -17
- package/src/Unify.ts +26 -2
- package/src/index.ts +82 -16
- package/src/internal/core.ts +7 -7
- package/src/internal/effect.ts +106 -106
- package/src/internal/layer.ts +7 -7
- package/src/internal/random.ts +2 -2
- package/src/internal/rcRef.ts +10 -10
- package/src/internal/references.ts +13 -13
- package/src/internal/request.ts +8 -8
- package/src/internal/schedule.ts +3 -1
- package/src/internal/schema/representation.ts +8 -1
- package/src/internal/schema/schema.ts +24 -1
- package/src/testing/TestSchema.ts +3 -3
- package/src/unstable/ai/AiError.ts +3 -2
- package/src/unstable/ai/Chat.ts +3 -3
- package/src/unstable/ai/EmbeddingModel.ts +3 -3
- package/src/unstable/ai/IdGenerator.ts +2 -2
- package/src/unstable/ai/LanguageModel.ts +2 -2
- package/src/unstable/ai/McpSchema.ts +11 -9
- package/src/unstable/ai/McpServer.ts +44 -44
- package/src/unstable/ai/Model.ts +8 -8
- package/src/unstable/ai/Prompt.ts +6 -12
- package/src/unstable/ai/Response.ts +6 -8
- package/src/unstable/ai/ResponseIdTracker.ts +2 -4
- package/src/unstable/ai/Telemetry.ts +2 -2
- package/src/unstable/ai/Tokenizer.ts +2 -2
- package/src/unstable/ai/Tool.ts +25 -25
- package/src/unstable/ai/Toolkit.ts +12 -12
- package/src/unstable/cli/Argument.ts +3 -4
- package/src/unstable/cli/CliError.ts +22 -9
- package/src/unstable/cli/CliOutput.ts +2 -2
- package/src/unstable/cli/Command.ts +36 -30
- package/src/unstable/cli/Flag.ts +3 -4
- package/src/unstable/cli/GlobalFlag.ts +3 -3
- package/src/unstable/cli/HelpDoc.ts +8 -8
- package/src/unstable/cli/Param.ts +39 -16
- package/src/unstable/cli/Prompt.ts +13 -6
- package/src/unstable/cli/internal/command.ts +7 -7
- package/src/unstable/cli/internal/parser.ts +130 -21
- package/src/unstable/cluster/ClusterSchema.ts +12 -12
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +14 -15
- package/src/unstable/cluster/Entity.ts +25 -25
- package/src/unstable/cluster/EntityProxy.ts +3 -3
- package/src/unstable/cluster/EntityProxyServer.ts +4 -4
- package/src/unstable/cluster/EntityResource.ts +2 -2
- package/src/unstable/cluster/HttpRunner.ts +2 -2
- package/src/unstable/cluster/K8sHttpClient.ts +2 -2
- package/src/unstable/cluster/Message.ts +8 -8
- package/src/unstable/cluster/MessageStorage.ts +11 -11
- package/src/unstable/cluster/Reply.ts +7 -7
- package/src/unstable/cluster/RunnerHealth.ts +2 -2
- package/src/unstable/cluster/RunnerServer.ts +1 -1
- package/src/unstable/cluster/RunnerStorage.ts +9 -9
- package/src/unstable/cluster/Runners.ts +7 -7
- package/src/unstable/cluster/ShardId.ts +84 -74
- package/src/unstable/cluster/Sharding.ts +26 -26
- package/src/unstable/cluster/ShardingConfig.ts +5 -5
- package/src/unstable/cluster/Snowflake.ts +2 -2
- package/src/unstable/cluster/SqlMessageStorage.ts +1 -1
- package/src/unstable/cluster/internal/entityManager.ts +27 -23
- package/src/unstable/cluster/internal/entityReaper.ts +2 -2
- package/src/unstable/cluster/internal/resourceMap.ts +3 -3
- package/src/unstable/devtools/DevToolsClient.ts +5 -5
- package/src/unstable/eventlog/EventJournal.ts +2 -2
- package/src/unstable/eventlog/EventLog.ts +21 -21
- package/src/unstable/eventlog/EventLogEncryption.ts +2 -2
- package/src/unstable/eventlog/EventLogRemote.ts +2 -2
- package/src/unstable/eventlog/EventLogServer.ts +2 -2
- package/src/unstable/http/Etag.ts +2 -2
- package/src/unstable/http/FetchHttpClient.ts +5 -5
- package/src/unstable/http/Headers.ts +4 -4
- package/src/unstable/http/HttpClient.ts +9 -8
- package/src/unstable/http/HttpClientRequest.ts +5 -5
- package/src/unstable/http/HttpEffect.ts +35 -35
- package/src/unstable/http/HttpIncomingMessage.ts +2 -2
- package/src/unstable/http/HttpMiddleware.ts +28 -14
- package/src/unstable/http/HttpPlatform.ts +2 -2
- package/src/unstable/http/HttpRouter.ts +37 -37
- package/src/unstable/http/HttpServer.ts +2 -2
- package/src/unstable/http/HttpServerError.ts +4 -4
- package/src/unstable/http/HttpServerRequest.ts +7 -7
- package/src/unstable/http/HttpServerResponse.ts +8 -8
- package/src/unstable/http/Multipart.ts +8 -8
- package/src/unstable/httpapi/HttpApi.ts +18 -18
- package/src/unstable/httpapi/HttpApiBuilder.ts +20 -20
- package/src/unstable/httpapi/HttpApiClient.ts +4 -4
- package/src/unstable/httpapi/HttpApiEndpoint.ts +14 -14
- package/src/unstable/httpapi/HttpApiGroup.ts +16 -16
- package/src/unstable/httpapi/HttpApiMiddleware.ts +14 -14
- package/src/unstable/httpapi/HttpApiSecurity.ts +13 -13
- package/src/unstable/httpapi/OpenApi.ts +29 -31
- package/src/unstable/observability/OtlpExporter.ts +5 -5
- package/src/unstable/observability/OtlpMetrics.ts +1 -1
- package/src/unstable/observability/OtlpSerialization.ts +2 -2
- package/src/unstable/observability/OtlpTracer.ts +2 -2
- package/src/unstable/observability/PrometheusMetrics.ts +5 -5
- package/src/unstable/persistence/KeyValueStore.ts +226 -3
- package/src/unstable/persistence/PersistedCache.ts +20 -17
- package/src/unstable/persistence/PersistedQueue.ts +3 -3
- package/src/unstable/persistence/Persistence.ts +4 -4
- package/src/unstable/persistence/RateLimiter.ts +3 -3
- package/src/unstable/persistence/Redis.ts +2 -2
- package/src/unstable/process/ChildProcessSpawner.ts +46 -2
- package/src/unstable/reactivity/Atom.ts +79 -79
- package/src/unstable/reactivity/AtomHttpApi.ts +4 -4
- package/src/unstable/reactivity/AtomRegistry.ts +4 -4
- package/src/unstable/reactivity/AtomRpc.ts +4 -4
- package/src/unstable/reactivity/Reactivity.ts +6 -6
- package/src/unstable/rpc/Rpc.ts +17 -17
- package/src/unstable/rpc/RpcClient.ts +44 -30
- package/src/unstable/rpc/RpcGroup.ts +30 -30
- package/src/unstable/rpc/RpcMiddleware.ts +14 -14
- package/src/unstable/rpc/RpcSchema.ts +4 -4
- package/src/unstable/rpc/RpcSerialization.ts +2 -2
- package/src/unstable/rpc/RpcServer.ts +19 -19
- package/src/unstable/rpc/RpcWorker.ts +5 -5
- package/src/unstable/rpc/Utils.ts +4 -4
- package/src/unstable/socket/Socket.ts +9 -9
- package/src/unstable/socket/SocketServer.ts +2 -2
- package/src/unstable/sql/SqlClient.ts +11 -11
- package/src/unstable/sql/SqlConnection.ts +2 -2
- package/src/unstable/sql/SqlModel.ts +54 -82
- package/src/unstable/sql/SqlResolver.ts +11 -11
- package/src/unstable/sql/Statement.ts +2 -2
- package/src/unstable/workers/Transferable.ts +6 -6
- package/src/unstable/workers/Worker.ts +4 -4
- package/src/unstable/workers/WorkerRunner.ts +2 -2
- package/src/unstable/workflow/Activity.ts +14 -14
- package/src/unstable/workflow/DurableClock.ts +3 -3
- package/src/unstable/workflow/DurableDeferred.ts +8 -8
- package/src/unstable/workflow/Workflow.ts +23 -23
- package/src/unstable/workflow/WorkflowEngine.ts +6 -6
- package/src/unstable/workflow/WorkflowProxyServer.ts +4 -4
- package/dist/ServiceMap.d.ts +0 -1150
- package/dist/ServiceMap.d.ts.map +0 -1
- package/dist/ServiceMap.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This module provides a data structure called `
|
|
2
|
+
* This module provides a data structure called `Context` that can be used
|
|
3
3
|
* for dependency injection in effectful programs. It is essentially a table
|
|
4
4
|
* mapping `Service`s identifiers to their implementations, and can be used to
|
|
5
|
-
* manage dependencies in a type-safe way. The `
|
|
5
|
+
* manage dependencies in a type-safe way. The `Context` data structure is
|
|
6
6
|
* essentially a way of providing access to a set of related services that can
|
|
7
7
|
* be passed around as a single unit. This module provides functions to create,
|
|
8
|
-
* modify, and query the contents of a `
|
|
9
|
-
* utility types for working with a `
|
|
8
|
+
* modify, and query the contents of a `Context`, as well as a number of
|
|
9
|
+
* utility types for working with a `Context`.
|
|
10
10
|
*
|
|
11
11
|
* @since 4.0.0
|
|
12
12
|
*/
|
|
@@ -26,16 +26,16 @@ import type * as Types from "./Types.ts"
|
|
|
26
26
|
* @since 4.0.0
|
|
27
27
|
* @category Type Identifiers
|
|
28
28
|
*/
|
|
29
|
-
export type ServiceTypeId = "~effect/
|
|
29
|
+
export type ServiceTypeId = "~effect/Context/Service"
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* @since 4.0.0
|
|
33
33
|
* @category Type Identifiers
|
|
34
34
|
*/
|
|
35
|
-
export const ServiceTypeId: ServiceTypeId = "~effect/
|
|
35
|
+
export const ServiceTypeId: ServiceTypeId = "~effect/Context/Service"
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
|
-
* The base type used for all
|
|
38
|
+
* The base type used for all Context keys.
|
|
39
39
|
*
|
|
40
40
|
* @since 4.0.0
|
|
41
41
|
* @category Models
|
|
@@ -52,15 +52,15 @@ export interface Key<out Identifier, out Shape> extends Pipeable, Inspectable {
|
|
|
52
52
|
/**
|
|
53
53
|
* @example
|
|
54
54
|
* ```ts
|
|
55
|
-
* import {
|
|
55
|
+
* import { Context } from "effect"
|
|
56
56
|
*
|
|
57
57
|
* // Define an identifier for a database service
|
|
58
|
-
* const Database =
|
|
58
|
+
* const Database = Context.Service<{ query: (sql: string) => string }>(
|
|
59
59
|
* "Database"
|
|
60
60
|
* )
|
|
61
61
|
*
|
|
62
62
|
* // The key can be used to store and retrieve services
|
|
63
|
-
* const
|
|
63
|
+
* const context = Context.make(Database, { query: (sql) => `Result: ${sql}` })
|
|
64
64
|
* ```
|
|
65
65
|
*
|
|
66
66
|
* @since 4.0.0
|
|
@@ -70,7 +70,7 @@ export interface Service<in out Identifier, in out Shape>
|
|
|
70
70
|
extends Key<Identifier, Shape>, Yieldable<Service<Identifier, Shape>, Shape, never, Identifier>
|
|
71
71
|
{
|
|
72
72
|
of(this: void, self: Shape): Shape
|
|
73
|
-
|
|
73
|
+
context(self: Shape): Context<Identifier>
|
|
74
74
|
use<A, E, R>(f: (service: Shape) => Effect<A, E, R>): Effect<A, E, R | Identifier>
|
|
75
75
|
useSync<A>(f: (service: Shape) => A): Effect<A, never, Identifier>
|
|
76
76
|
}
|
|
@@ -105,23 +105,23 @@ export declare namespace ServiceClass {
|
|
|
105
105
|
/**
|
|
106
106
|
* @example
|
|
107
107
|
* ```ts
|
|
108
|
-
* import {
|
|
108
|
+
* import { Context } from "effect"
|
|
109
109
|
*
|
|
110
110
|
* // Create a simple service
|
|
111
|
-
* const Database =
|
|
111
|
+
* const Database = Context.Service<{
|
|
112
112
|
* query: (sql: string) => string
|
|
113
113
|
* }>("Database")
|
|
114
114
|
*
|
|
115
115
|
* // Create a service class
|
|
116
|
-
* class Config extends
|
|
116
|
+
* class Config extends Context.Service<Config, {
|
|
117
117
|
* port: number
|
|
118
118
|
* }>()("Config") {}
|
|
119
119
|
*
|
|
120
|
-
* // Use the services to create
|
|
121
|
-
* const db =
|
|
120
|
+
* // Use the services to create contexts
|
|
121
|
+
* const db = Context.make(Database, {
|
|
122
122
|
* query: (sql) => `Result: ${sql}`
|
|
123
123
|
* })
|
|
124
|
-
* const config =
|
|
124
|
+
* const config = Context.make(Config, { port: 8080 })
|
|
125
125
|
* ```
|
|
126
126
|
*
|
|
127
127
|
* @since 4.0.0
|
|
@@ -131,23 +131,23 @@ export const Service: {
|
|
|
131
131
|
/**
|
|
132
132
|
* @example
|
|
133
133
|
* ```ts
|
|
134
|
-
* import {
|
|
134
|
+
* import { Context } from "effect"
|
|
135
135
|
*
|
|
136
136
|
* // Create a simple service
|
|
137
|
-
* const Database =
|
|
137
|
+
* const Database = Context.Service<{
|
|
138
138
|
* query: (sql: string) => string
|
|
139
139
|
* }>("Database")
|
|
140
140
|
*
|
|
141
141
|
* // Create a service class
|
|
142
|
-
* class Config extends
|
|
142
|
+
* class Config extends Context.Service<Config, {
|
|
143
143
|
* port: number
|
|
144
144
|
* }>()("Config") {}
|
|
145
145
|
*
|
|
146
|
-
* // Use the services to create
|
|
147
|
-
* const db =
|
|
146
|
+
* // Use the services to create contexts
|
|
147
|
+
* const db = Context.make(Database, {
|
|
148
148
|
* query: (sql) => `Result: ${sql}`
|
|
149
149
|
* })
|
|
150
|
-
* const config =
|
|
150
|
+
* const config = Context.make(Config, { port: 8080 })
|
|
151
151
|
* ```
|
|
152
152
|
*
|
|
153
153
|
* @since 4.0.0
|
|
@@ -157,23 +157,23 @@ export const Service: {
|
|
|
157
157
|
/**
|
|
158
158
|
* @example
|
|
159
159
|
* ```ts
|
|
160
|
-
* import {
|
|
160
|
+
* import { Context } from "effect"
|
|
161
161
|
*
|
|
162
162
|
* // Create a simple service
|
|
163
|
-
* const Database =
|
|
163
|
+
* const Database = Context.Service<{
|
|
164
164
|
* query: (sql: string) => string
|
|
165
165
|
* }>("Database")
|
|
166
166
|
*
|
|
167
167
|
* // Create a service class
|
|
168
|
-
* class Config extends
|
|
168
|
+
* class Config extends Context.Service<Config, {
|
|
169
169
|
* port: number
|
|
170
170
|
* }>()("Config") {}
|
|
171
171
|
*
|
|
172
|
-
* // Use the services to create
|
|
173
|
-
* const db =
|
|
172
|
+
* // Use the services to create contexts
|
|
173
|
+
* const db = Context.make(Database, {
|
|
174
174
|
* query: (sql) => `Result: ${sql}`
|
|
175
175
|
* })
|
|
176
|
-
* const config =
|
|
176
|
+
* const config = Context.make(Config, { port: 8080 })
|
|
177
177
|
* ```
|
|
178
178
|
*
|
|
179
179
|
* @since 4.0.0
|
|
@@ -196,23 +196,23 @@ export const Service: {
|
|
|
196
196
|
/**
|
|
197
197
|
* @example
|
|
198
198
|
* ```ts
|
|
199
|
-
* import {
|
|
199
|
+
* import { Context } from "effect"
|
|
200
200
|
*
|
|
201
201
|
* // Create a simple service
|
|
202
|
-
* const Database =
|
|
202
|
+
* const Database = Context.Service<{
|
|
203
203
|
* query: (sql: string) => string
|
|
204
204
|
* }>("Database")
|
|
205
205
|
*
|
|
206
206
|
* // Create a service class
|
|
207
|
-
* class Config extends
|
|
207
|
+
* class Config extends Context.Service<Config, {
|
|
208
208
|
* port: number
|
|
209
209
|
* }>()("Config") {}
|
|
210
210
|
*
|
|
211
|
-
* // Use the services to create
|
|
212
|
-
* const db =
|
|
211
|
+
* // Use the services to create contexts
|
|
212
|
+
* const db = Context.make(Database, {
|
|
213
213
|
* query: (sql) => `Result: ${sql}`
|
|
214
214
|
* })
|
|
215
|
-
* const config =
|
|
215
|
+
* const config = Context.make(Config, { port: 8080 })
|
|
216
216
|
* ```
|
|
217
217
|
*
|
|
218
218
|
* @since 4.0.0
|
|
@@ -280,42 +280,42 @@ const ServiceProto: any = {
|
|
|
280
280
|
}
|
|
281
281
|
},
|
|
282
282
|
asEffect(this: any) {
|
|
283
|
-
const fn = this.asEffect = constant(withFiber((fiber) => exitSucceed(get(fiber.
|
|
283
|
+
const fn = this.asEffect = constant(withFiber((fiber) => exitSucceed(get(fiber.context, this))))
|
|
284
284
|
return fn()
|
|
285
285
|
},
|
|
286
286
|
of<Service>(this: void, self: Service): Service {
|
|
287
287
|
return self
|
|
288
288
|
},
|
|
289
|
-
|
|
289
|
+
context<Identifier, Shape>(
|
|
290
290
|
this: Service<Identifier, Shape>,
|
|
291
291
|
self: Shape
|
|
292
|
-
):
|
|
292
|
+
): Context<Identifier> {
|
|
293
293
|
return make(this, self)
|
|
294
294
|
},
|
|
295
295
|
use<A, E, R>(this: Service<never, any>, f: (service: any) => Effect<A, E, R>): Effect<A, E, R> {
|
|
296
|
-
return withFiber((fiber) => f(get(fiber.
|
|
296
|
+
return withFiber((fiber) => f(get(fiber.context, this)))
|
|
297
297
|
},
|
|
298
298
|
useSync<A>(this: Service<never, any>, f: (service: any) => A): Effect<A, never, never> {
|
|
299
|
-
return withFiber((fiber) => exitSucceed(f(get(fiber.
|
|
299
|
+
return withFiber((fiber) => exitSucceed(f(get(fiber.context, this))))
|
|
300
300
|
}
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
-
const ReferenceTypeId = "~effect/
|
|
303
|
+
const ReferenceTypeId = "~effect/Context/Reference" as const
|
|
304
304
|
|
|
305
305
|
/**
|
|
306
306
|
* @example
|
|
307
307
|
* ```ts
|
|
308
|
-
* import {
|
|
308
|
+
* import { Context } from "effect"
|
|
309
309
|
*
|
|
310
310
|
* // Define a reference with a default value
|
|
311
|
-
* const LoggerRef:
|
|
312
|
-
*
|
|
311
|
+
* const LoggerRef: Context.Reference<{ log: (msg: string) => void }> =
|
|
312
|
+
* Context.Reference("Logger", {
|
|
313
313
|
* defaultValue: () => ({ log: (msg: string) => console.log(msg) })
|
|
314
314
|
* })
|
|
315
315
|
*
|
|
316
316
|
* // The reference can be used without explicit provision
|
|
317
|
-
* const
|
|
318
|
-
* const logger =
|
|
317
|
+
* const context = Context.empty()
|
|
318
|
+
* const logger = Context.get(context, LoggerRef) // Uses default value
|
|
319
319
|
* ```
|
|
320
320
|
*
|
|
321
321
|
* @since 4.0.0
|
|
@@ -331,17 +331,17 @@ export interface Reference<in out Shape> extends Service<never, Shape> {
|
|
|
331
331
|
/**
|
|
332
332
|
* @example
|
|
333
333
|
* ```ts
|
|
334
|
-
* import {
|
|
334
|
+
* import { Context } from "effect"
|
|
335
335
|
*
|
|
336
|
-
* const Database =
|
|
336
|
+
* const Database = Context.Service<{
|
|
337
337
|
* query: (sql: string) => string
|
|
338
338
|
* }>("Database")
|
|
339
339
|
*
|
|
340
340
|
* // Extract service type from a key
|
|
341
|
-
* type DatabaseService =
|
|
341
|
+
* type DatabaseService = Context.Service.Shape<typeof Database>
|
|
342
342
|
*
|
|
343
343
|
* // Extract identifier type from a key
|
|
344
|
-
* type DatabaseId =
|
|
344
|
+
* type DatabaseId = Context.Service.Identifier<typeof Database>
|
|
345
345
|
* ```
|
|
346
346
|
*
|
|
347
347
|
* @since 4.0.0
|
|
@@ -351,12 +351,12 @@ export declare namespace Service {
|
|
|
351
351
|
/**
|
|
352
352
|
* @example
|
|
353
353
|
* ```ts
|
|
354
|
-
* import {
|
|
354
|
+
* import { Context } from "effect"
|
|
355
355
|
*
|
|
356
356
|
* // Any represents any possible service type
|
|
357
|
-
* const services: Array<
|
|
358
|
-
*
|
|
359
|
-
*
|
|
357
|
+
* const services: Array<Context.Service.Any> = [
|
|
358
|
+
* Context.Service<{ log: (msg: string) => void }>("Logger"),
|
|
359
|
+
* Context.Service<{ query: (sql: string) => string }>("Database")
|
|
360
360
|
* ]
|
|
361
361
|
* ```
|
|
362
362
|
*
|
|
@@ -368,14 +368,14 @@ export declare namespace Service {
|
|
|
368
368
|
/**
|
|
369
369
|
* @example
|
|
370
370
|
* ```ts
|
|
371
|
-
* import {
|
|
371
|
+
* import { Context } from "effect"
|
|
372
372
|
*
|
|
373
|
-
* const Database =
|
|
373
|
+
* const Database = Context.Service<{ query: (sql: string) => string }>(
|
|
374
374
|
* "Database"
|
|
375
375
|
* )
|
|
376
376
|
*
|
|
377
377
|
* // Extract the service shape from the service
|
|
378
|
-
* type DatabaseService =
|
|
378
|
+
* type DatabaseService = Context.Service.Shape<typeof Database>
|
|
379
379
|
* // DatabaseService is { query: (sql: string) => string }
|
|
380
380
|
* ```
|
|
381
381
|
*
|
|
@@ -387,14 +387,14 @@ export declare namespace Service {
|
|
|
387
387
|
/**
|
|
388
388
|
* @example
|
|
389
389
|
* ```ts
|
|
390
|
-
* import {
|
|
390
|
+
* import { Context } from "effect"
|
|
391
391
|
*
|
|
392
|
-
* const Database =
|
|
392
|
+
* const Database = Context.Service<{ query: (sql: string) => string }>(
|
|
393
393
|
* "Database"
|
|
394
394
|
* )
|
|
395
395
|
*
|
|
396
396
|
* // Extract the identifier type from a key
|
|
397
|
-
* type DatabaseId =
|
|
397
|
+
* type DatabaseId = Context.Service.Identifier<typeof Database>
|
|
398
398
|
* // DatabaseId is the identifier type
|
|
399
399
|
* ```
|
|
400
400
|
*
|
|
@@ -404,29 +404,29 @@ export declare namespace Service {
|
|
|
404
404
|
export type Identifier<T> = T extends Key<infer I, infer _S> ? I : never
|
|
405
405
|
}
|
|
406
406
|
|
|
407
|
-
const TypeId = "~effect/
|
|
407
|
+
const TypeId = "~effect/Context" as const
|
|
408
408
|
|
|
409
409
|
/**
|
|
410
410
|
* @example
|
|
411
411
|
* ```ts
|
|
412
|
-
* import {
|
|
412
|
+
* import { Context } from "effect"
|
|
413
413
|
*
|
|
414
|
-
* // Create a
|
|
415
|
-
* const Logger =
|
|
416
|
-
* const Database =
|
|
414
|
+
* // Create a context with multiple services
|
|
415
|
+
* const Logger = Context.Service<{ log: (msg: string) => void }>("Logger")
|
|
416
|
+
* const Database = Context.Service<{ query: (sql: string) => string }>(
|
|
417
417
|
* "Database"
|
|
418
418
|
* )
|
|
419
419
|
*
|
|
420
|
-
* const
|
|
420
|
+
* const context = Context.make(Logger, {
|
|
421
421
|
* log: (msg: string) => console.log(msg)
|
|
422
422
|
* })
|
|
423
|
-
* .pipe(
|
|
423
|
+
* .pipe(Context.add(Database, { query: (sql) => `Result: ${sql}` }))
|
|
424
424
|
* ```
|
|
425
425
|
*
|
|
426
426
|
* @since 4.0.0
|
|
427
427
|
* @category Models
|
|
428
428
|
*/
|
|
429
|
-
export interface
|
|
429
|
+
export interface Context<in Services> extends Equal.Equal, Pipeable, Inspectable {
|
|
430
430
|
readonly [TypeId]: {
|
|
431
431
|
readonly _Services: Types.Contravariant<Services>
|
|
432
432
|
}
|
|
@@ -437,40 +437,40 @@ export interface ServiceMap<in Services> extends Equal.Equal, Pipeable, Inspecta
|
|
|
437
437
|
/**
|
|
438
438
|
* @example
|
|
439
439
|
* ```ts
|
|
440
|
-
* import {
|
|
440
|
+
* import { Context } from "effect"
|
|
441
441
|
*
|
|
442
|
-
* // Create a
|
|
442
|
+
* // Create a context from a Map (unsafe)
|
|
443
443
|
* const map = new Map([
|
|
444
444
|
* ["Logger", { log: (msg: string) => console.log(msg) }]
|
|
445
445
|
* ])
|
|
446
446
|
*
|
|
447
|
-
* const
|
|
447
|
+
* const context = Context.makeUnsafe(map)
|
|
448
448
|
* ```
|
|
449
449
|
*
|
|
450
450
|
* @since 4.0.0
|
|
451
451
|
* @category Constructors
|
|
452
452
|
*/
|
|
453
|
-
export const makeUnsafe = <Services = never>(mapUnsafe: ReadonlyMap<string, any>):
|
|
453
|
+
export const makeUnsafe = <Services = never>(mapUnsafe: ReadonlyMap<string, any>): Context<Services> => {
|
|
454
454
|
const self = Object.create(Proto)
|
|
455
455
|
self.mapUnsafe = mapUnsafe
|
|
456
456
|
self.mutable = false
|
|
457
457
|
return self
|
|
458
458
|
}
|
|
459
459
|
|
|
460
|
-
const Proto: Omit<
|
|
460
|
+
const Proto: Omit<Context<never>, "mapUnsafe" | "mutable"> = {
|
|
461
461
|
...PipeInspectableProto,
|
|
462
462
|
[TypeId]: {
|
|
463
463
|
_Services: (_: never) => _
|
|
464
464
|
},
|
|
465
|
-
toJSON(this:
|
|
465
|
+
toJSON(this: Context<never>) {
|
|
466
466
|
return {
|
|
467
|
-
_id: "
|
|
467
|
+
_id: "Context",
|
|
468
468
|
services: Array.from(this.mapUnsafe).map(([key, value]) => ({ key, value }))
|
|
469
469
|
}
|
|
470
470
|
},
|
|
471
|
-
[Equal.symbol]<A>(this:
|
|
471
|
+
[Equal.symbol]<A>(this: Context<A>, that: unknown): boolean {
|
|
472
472
|
if (
|
|
473
|
-
!
|
|
473
|
+
!isContext(that)
|
|
474
474
|
|| this.mapUnsafe.size !== that.mapUnsafe.size
|
|
475
475
|
) return false
|
|
476
476
|
for (const k of this.mapUnsafe.keys()) {
|
|
@@ -483,36 +483,36 @@ const Proto: Omit<ServiceMap<never>, "mapUnsafe" | "mutable"> = {
|
|
|
483
483
|
}
|
|
484
484
|
return true
|
|
485
485
|
},
|
|
486
|
-
[Hash.symbol]<A>(this:
|
|
486
|
+
[Hash.symbol]<A>(this: Context<A>): number {
|
|
487
487
|
return Hash.number(this.mapUnsafe.size)
|
|
488
488
|
}
|
|
489
489
|
}
|
|
490
490
|
|
|
491
491
|
/**
|
|
492
|
-
* Checks if the provided argument is a `
|
|
492
|
+
* Checks if the provided argument is a `Context`.
|
|
493
493
|
*
|
|
494
494
|
* @example
|
|
495
495
|
* ```ts
|
|
496
|
-
* import {
|
|
496
|
+
* import { Context } from "effect"
|
|
497
497
|
* import * as assert from "node:assert"
|
|
498
498
|
*
|
|
499
|
-
* assert.strictEqual(
|
|
499
|
+
* assert.strictEqual(Context.isContext(Context.empty()), true)
|
|
500
500
|
* ```
|
|
501
501
|
*
|
|
502
502
|
* @since 4.0.0
|
|
503
503
|
* @category Guards
|
|
504
504
|
*/
|
|
505
|
-
export const
|
|
505
|
+
export const isContext = (u: unknown): u is Context<never> => hasProperty(u, TypeId)
|
|
506
506
|
|
|
507
507
|
/**
|
|
508
508
|
* Checks if the provided argument is a `Key`.
|
|
509
509
|
*
|
|
510
510
|
* @example
|
|
511
511
|
* ```ts
|
|
512
|
-
* import {
|
|
512
|
+
* import { Context } from "effect"
|
|
513
513
|
* import * as assert from "node:assert"
|
|
514
514
|
*
|
|
515
|
-
* assert.strictEqual(
|
|
515
|
+
* assert.strictEqual(Context.isKey(Context.Service("Service")), true)
|
|
516
516
|
* ```
|
|
517
517
|
*
|
|
518
518
|
* @since 4.0.0
|
|
@@ -525,15 +525,15 @@ export const isKey = (u: unknown): u is Key<any, any> => hasProperty(u, ServiceT
|
|
|
525
525
|
*
|
|
526
526
|
* @example
|
|
527
527
|
* ```ts
|
|
528
|
-
* import {
|
|
528
|
+
* import { Context } from "effect"
|
|
529
529
|
* import * as assert from "node:assert"
|
|
530
530
|
*
|
|
531
|
-
* const LoggerRef =
|
|
531
|
+
* const LoggerRef = Context.Reference("Logger", {
|
|
532
532
|
* defaultValue: () => ({ log: (msg: string) => console.log(msg) })
|
|
533
533
|
* })
|
|
534
534
|
*
|
|
535
|
-
* assert.strictEqual(
|
|
536
|
-
* assert.strictEqual(
|
|
535
|
+
* assert.strictEqual(Context.isReference(LoggerRef), true)
|
|
536
|
+
* assert.strictEqual(Context.isReference(Context.Service("Key")), false)
|
|
537
537
|
* ```
|
|
538
538
|
*
|
|
539
539
|
* @since 4.0.0
|
|
@@ -542,35 +542,35 @@ export const isKey = (u: unknown): u is Key<any, any> => hasProperty(u, ServiceT
|
|
|
542
542
|
export const isReference = (u: unknown): u is Reference<any> => hasProperty(u, ReferenceTypeId)
|
|
543
543
|
|
|
544
544
|
/**
|
|
545
|
-
* Returns an empty `
|
|
545
|
+
* Returns an empty `Context`.
|
|
546
546
|
*
|
|
547
547
|
* @example
|
|
548
548
|
* ```ts
|
|
549
|
-
* import {
|
|
549
|
+
* import { Context } from "effect"
|
|
550
550
|
* import * as assert from "node:assert"
|
|
551
551
|
*
|
|
552
|
-
* assert.strictEqual(
|
|
552
|
+
* assert.strictEqual(Context.isContext(Context.empty()), true)
|
|
553
553
|
* ```
|
|
554
554
|
*
|
|
555
555
|
* @since 4.0.0
|
|
556
556
|
* @category Constructors
|
|
557
557
|
*/
|
|
558
|
-
export const empty = ():
|
|
559
|
-
const
|
|
558
|
+
export const empty = (): Context<never> => emptyContext
|
|
559
|
+
const emptyContext = makeUnsafe(new Map())
|
|
560
560
|
|
|
561
561
|
/**
|
|
562
|
-
* Creates a new `
|
|
562
|
+
* Creates a new `Context` with a single service associated to the key.
|
|
563
563
|
*
|
|
564
564
|
* @example
|
|
565
565
|
* ```ts
|
|
566
|
-
* import {
|
|
566
|
+
* import { Context } from "effect"
|
|
567
567
|
* import * as assert from "node:assert"
|
|
568
568
|
*
|
|
569
|
-
* const Port =
|
|
569
|
+
* const Port = Context.Service<{ PORT: number }>("Port")
|
|
570
570
|
*
|
|
571
|
-
* const
|
|
571
|
+
* const context = Context.make(Port, { PORT: 8080 })
|
|
572
572
|
*
|
|
573
|
-
* assert.deepStrictEqual(
|
|
573
|
+
* assert.deepStrictEqual(Context.get(context, Port), { PORT: 8080 })
|
|
574
574
|
* ```
|
|
575
575
|
*
|
|
576
576
|
* @since 4.0.0
|
|
@@ -579,28 +579,28 @@ const emptyServiceMap = makeUnsafe(new Map())
|
|
|
579
579
|
export const make = <I, S>(
|
|
580
580
|
key: Key<I, S>,
|
|
581
581
|
service: Types.NoInfer<S>
|
|
582
|
-
):
|
|
582
|
+
): Context<I> => makeUnsafe(new Map([[key.key, service]]))
|
|
583
583
|
|
|
584
584
|
/**
|
|
585
|
-
* Adds a service to a given `
|
|
585
|
+
* Adds a service to a given `Context`.
|
|
586
586
|
*
|
|
587
587
|
* @example
|
|
588
588
|
* ```ts
|
|
589
|
-
* import { pipe,
|
|
589
|
+
* import { pipe, Context } from "effect"
|
|
590
590
|
* import * as assert from "node:assert"
|
|
591
591
|
*
|
|
592
|
-
* const Port =
|
|
593
|
-
* const Timeout =
|
|
592
|
+
* const Port = Context.Service<{ PORT: number }>("Port")
|
|
593
|
+
* const Timeout = Context.Service<{ TIMEOUT: number }>("Timeout")
|
|
594
594
|
*
|
|
595
|
-
* const
|
|
595
|
+
* const someContext = Context.make(Port, { PORT: 8080 })
|
|
596
596
|
*
|
|
597
|
-
* const
|
|
598
|
-
*
|
|
599
|
-
*
|
|
597
|
+
* const context = pipe(
|
|
598
|
+
* someContext,
|
|
599
|
+
* Context.add(Timeout, { TIMEOUT: 5000 })
|
|
600
600
|
* )
|
|
601
601
|
*
|
|
602
|
-
* assert.deepStrictEqual(
|
|
603
|
-
* assert.deepStrictEqual(
|
|
602
|
+
* assert.deepStrictEqual(Context.get(context, Port), { PORT: 8080 })
|
|
603
|
+
* assert.deepStrictEqual(Context.get(context, Timeout), { TIMEOUT: 5000 })
|
|
604
604
|
* ```
|
|
605
605
|
*
|
|
606
606
|
* @since 4.0.0
|
|
@@ -608,62 +608,62 @@ export const make = <I, S>(
|
|
|
608
608
|
*/
|
|
609
609
|
export const add: {
|
|
610
610
|
/**
|
|
611
|
-
* Adds a service to a given `
|
|
611
|
+
* Adds a service to a given `Context`.
|
|
612
612
|
*
|
|
613
613
|
* @example
|
|
614
614
|
* ```ts
|
|
615
|
-
* import { pipe,
|
|
615
|
+
* import { pipe, Context } from "effect"
|
|
616
616
|
* import * as assert from "node:assert"
|
|
617
617
|
*
|
|
618
|
-
* const Port =
|
|
619
|
-
* const Timeout =
|
|
618
|
+
* const Port = Context.Service<{ PORT: number }>("Port")
|
|
619
|
+
* const Timeout = Context.Service<{ TIMEOUT: number }>("Timeout")
|
|
620
620
|
*
|
|
621
|
-
* const
|
|
621
|
+
* const someContext = Context.make(Port, { PORT: 8080 })
|
|
622
622
|
*
|
|
623
|
-
* const
|
|
624
|
-
*
|
|
625
|
-
*
|
|
623
|
+
* const context = pipe(
|
|
624
|
+
* someContext,
|
|
625
|
+
* Context.add(Timeout, { TIMEOUT: 5000 })
|
|
626
626
|
* )
|
|
627
627
|
*
|
|
628
|
-
* assert.deepStrictEqual(
|
|
629
|
-
* assert.deepStrictEqual(
|
|
628
|
+
* assert.deepStrictEqual(Context.get(context, Port), { PORT: 8080 })
|
|
629
|
+
* assert.deepStrictEqual(Context.get(context, Timeout), { TIMEOUT: 5000 })
|
|
630
630
|
* ```
|
|
631
631
|
*
|
|
632
632
|
* @since 4.0.0
|
|
633
633
|
* @category Adders
|
|
634
634
|
*/
|
|
635
|
-
<I, S>(key: Key<I, S>, service: Types.NoInfer<S>): <Services>(self:
|
|
635
|
+
<I, S>(key: Key<I, S>, service: Types.NoInfer<S>): <Services>(self: Context<Services>) => Context<Services | I>
|
|
636
636
|
/**
|
|
637
|
-
* Adds a service to a given `
|
|
637
|
+
* Adds a service to a given `Context`.
|
|
638
638
|
*
|
|
639
639
|
* @example
|
|
640
640
|
* ```ts
|
|
641
|
-
* import { pipe,
|
|
641
|
+
* import { pipe, Context } from "effect"
|
|
642
642
|
* import * as assert from "node:assert"
|
|
643
643
|
*
|
|
644
|
-
* const Port =
|
|
645
|
-
* const Timeout =
|
|
644
|
+
* const Port = Context.Service<{ PORT: number }>("Port")
|
|
645
|
+
* const Timeout = Context.Service<{ TIMEOUT: number }>("Timeout")
|
|
646
646
|
*
|
|
647
|
-
* const
|
|
647
|
+
* const someContext = Context.make(Port, { PORT: 8080 })
|
|
648
648
|
*
|
|
649
|
-
* const
|
|
650
|
-
*
|
|
651
|
-
*
|
|
649
|
+
* const context = pipe(
|
|
650
|
+
* someContext,
|
|
651
|
+
* Context.add(Timeout, { TIMEOUT: 5000 })
|
|
652
652
|
* )
|
|
653
653
|
*
|
|
654
|
-
* assert.deepStrictEqual(
|
|
655
|
-
* assert.deepStrictEqual(
|
|
654
|
+
* assert.deepStrictEqual(Context.get(context, Port), { PORT: 8080 })
|
|
655
|
+
* assert.deepStrictEqual(Context.get(context, Timeout), { TIMEOUT: 5000 })
|
|
656
656
|
* ```
|
|
657
657
|
*
|
|
658
658
|
* @since 4.0.0
|
|
659
659
|
* @category Adders
|
|
660
660
|
*/
|
|
661
|
-
<Services, I, S>(self:
|
|
661
|
+
<Services, I, S>(self: Context<Services>, key: Key<I, S>, service: Types.NoInfer<S>): Context<Services | I>
|
|
662
662
|
} = dual(3, <Services, I, S>(
|
|
663
|
-
self:
|
|
663
|
+
self: Context<Services>,
|
|
664
664
|
key: Key<I, S>,
|
|
665
665
|
service: Types.NoInfer<S>
|
|
666
|
-
):
|
|
666
|
+
): Context<Services | I> =>
|
|
667
667
|
withMapUnsafe(self, (map) => {
|
|
668
668
|
map.set(key.key, service)
|
|
669
669
|
}))
|
|
@@ -677,21 +677,21 @@ export const addOrOmit: {
|
|
|
677
677
|
* @since 4.0.0
|
|
678
678
|
* @category Adders
|
|
679
679
|
*/
|
|
680
|
-
<I, S>(key: Key<I, S>, service: Option.Option<Types.NoInfer<S>>): <Services>(self:
|
|
680
|
+
<I, S>(key: Key<I, S>, service: Option.Option<Types.NoInfer<S>>): <Services>(self: Context<Services>) => Context<Services | I>
|
|
681
681
|
/**
|
|
682
682
|
* @since 4.0.0
|
|
683
683
|
* @category Adders
|
|
684
684
|
*/
|
|
685
685
|
<Services, I, S>(
|
|
686
|
-
self:
|
|
686
|
+
self: Context<Services>,
|
|
687
687
|
key: Key<I, S>,
|
|
688
688
|
service: Option.Option<Types.NoInfer<S>>
|
|
689
|
-
):
|
|
689
|
+
): Context<Services | I>
|
|
690
690
|
} = dual(3, <Services, I, S>(
|
|
691
|
-
self:
|
|
691
|
+
self: Context<Services>,
|
|
692
692
|
key: Key<I, S>,
|
|
693
693
|
service: Option.Option<Types.NoInfer<S>>
|
|
694
|
-
):
|
|
694
|
+
): Context<Services | I> =>
|
|
695
695
|
withMapUnsafe(self, (map) => {
|
|
696
696
|
if (service._tag === "None") {
|
|
697
697
|
map.delete(key.key)
|
|
@@ -706,21 +706,21 @@ export const addOrOmit: {
|
|
|
706
706
|
*
|
|
707
707
|
* @example
|
|
708
708
|
* ```ts
|
|
709
|
-
* import {
|
|
709
|
+
* import { Context } from "effect"
|
|
710
710
|
* import * as assert from "node:assert"
|
|
711
711
|
*
|
|
712
|
-
* const Logger =
|
|
713
|
-
* const Database =
|
|
712
|
+
* const Logger = Context.Service<{ log: (msg: string) => void }>("Logger")
|
|
713
|
+
* const Database = Context.Service<{ query: (sql: string) => string }>(
|
|
714
714
|
* "Database"
|
|
715
715
|
* )
|
|
716
716
|
*
|
|
717
|
-
* const
|
|
717
|
+
* const context = Context.make(Logger, {
|
|
718
718
|
* log: (msg: string) => console.log(msg)
|
|
719
719
|
* })
|
|
720
720
|
*
|
|
721
|
-
* const logger =
|
|
722
|
-
* const database =
|
|
723
|
-
*
|
|
721
|
+
* const logger = Context.getOrElse(context, Logger, () => ({ log: () => {} }))
|
|
722
|
+
* const database = Context.getOrElse(
|
|
723
|
+
* context,
|
|
724
724
|
* Database,
|
|
725
725
|
* () => ({ query: () => "fallback" })
|
|
726
726
|
* )
|
|
@@ -739,21 +739,21 @@ export const getOrElse: {
|
|
|
739
739
|
*
|
|
740
740
|
* @example
|
|
741
741
|
* ```ts
|
|
742
|
-
* import {
|
|
742
|
+
* import { Context } from "effect"
|
|
743
743
|
* import * as assert from "node:assert"
|
|
744
744
|
*
|
|
745
|
-
* const Logger =
|
|
746
|
-
* const Database =
|
|
745
|
+
* const Logger = Context.Service<{ log: (msg: string) => void }>("Logger")
|
|
746
|
+
* const Database = Context.Service<{ query: (sql: string) => string }>(
|
|
747
747
|
* "Database"
|
|
748
748
|
* )
|
|
749
749
|
*
|
|
750
|
-
* const
|
|
750
|
+
* const context = Context.make(Logger, {
|
|
751
751
|
* log: (msg: string) => console.log(msg)
|
|
752
752
|
* })
|
|
753
753
|
*
|
|
754
|
-
* const logger =
|
|
755
|
-
* const database =
|
|
756
|
-
*
|
|
754
|
+
* const logger = Context.getOrElse(context, Logger, () => ({ log: () => {} }))
|
|
755
|
+
* const database = Context.getOrElse(
|
|
756
|
+
* context,
|
|
757
757
|
* Database,
|
|
758
758
|
* () => ({ query: () => "fallback" })
|
|
759
759
|
* )
|
|
@@ -765,28 +765,28 @@ export const getOrElse: {
|
|
|
765
765
|
* @since 4.0.0
|
|
766
766
|
* @category Getters
|
|
767
767
|
*/
|
|
768
|
-
<S, I, B>(key: Key<I, S>, orElse: LazyArg<B>): <Services>(self:
|
|
768
|
+
<S, I, B>(key: Key<I, S>, orElse: LazyArg<B>): <Services>(self: Context<Services>) => S | B
|
|
769
769
|
/**
|
|
770
770
|
* Get a service from the context that corresponds to the given key, or
|
|
771
771
|
* use the fallback value.
|
|
772
772
|
*
|
|
773
773
|
* @example
|
|
774
774
|
* ```ts
|
|
775
|
-
* import {
|
|
775
|
+
* import { Context } from "effect"
|
|
776
776
|
* import * as assert from "node:assert"
|
|
777
777
|
*
|
|
778
|
-
* const Logger =
|
|
779
|
-
* const Database =
|
|
778
|
+
* const Logger = Context.Service<{ log: (msg: string) => void }>("Logger")
|
|
779
|
+
* const Database = Context.Service<{ query: (sql: string) => string }>(
|
|
780
780
|
* "Database"
|
|
781
781
|
* )
|
|
782
782
|
*
|
|
783
|
-
* const
|
|
783
|
+
* const context = Context.make(Logger, {
|
|
784
784
|
* log: (msg: string) => console.log(msg)
|
|
785
785
|
* })
|
|
786
786
|
*
|
|
787
|
-
* const logger =
|
|
788
|
-
* const database =
|
|
789
|
-
*
|
|
787
|
+
* const logger = Context.getOrElse(context, Logger, () => ({ log: () => {} }))
|
|
788
|
+
* const database = Context.getOrElse(
|
|
789
|
+
* context,
|
|
790
790
|
* Database,
|
|
791
791
|
* () => ({ query: () => "fallback" })
|
|
792
792
|
* )
|
|
@@ -798,8 +798,8 @@ export const getOrElse: {
|
|
|
798
798
|
* @since 4.0.0
|
|
799
799
|
* @category Getters
|
|
800
800
|
*/
|
|
801
|
-
<Services, S, I, B>(self:
|
|
802
|
-
} = dual(3, <Services, S, I, B>(self:
|
|
801
|
+
<Services, S, I, B>(self: Context<Services>, key: Key<I, S>, orElse: LazyArg<B>): S | B
|
|
802
|
+
} = dual(3, <Services, S, I, B>(self: Context<Services>, key: Key<I, S>, orElse: LazyArg<B>): S | B => {
|
|
803
803
|
if (self.mapUnsafe.has(key.key)) {
|
|
804
804
|
return self.mapUnsafe.get(key.key)! as any
|
|
805
805
|
}
|
|
@@ -815,15 +815,15 @@ export const getOrUndefined: {
|
|
|
815
815
|
* @since 4.0.0
|
|
816
816
|
* @category Getters
|
|
817
817
|
*/
|
|
818
|
-
<S, I>(key: Key<I, S>): <Services>(self:
|
|
818
|
+
<S, I>(key: Key<I, S>): <Services>(self: Context<Services>) => S | undefined
|
|
819
819
|
/**
|
|
820
820
|
* @since 4.0.0
|
|
821
821
|
* @category Getters
|
|
822
822
|
*/
|
|
823
|
-
<Services, S, I>(self:
|
|
823
|
+
<Services, S, I>(self: Context<Services>, key: Key<I, S>): S | undefined
|
|
824
824
|
} = dual(
|
|
825
825
|
2,
|
|
826
|
-
<Services, S, I>(self:
|
|
826
|
+
<Services, S, I>(self: Context<Services>, key: Key<I, S>): S | undefined => self.mapUnsafe.get(key.key)
|
|
827
827
|
)
|
|
828
828
|
|
|
829
829
|
/**
|
|
@@ -834,21 +834,21 @@ export const getOrUndefined: {
|
|
|
834
834
|
*
|
|
835
835
|
* For a safer version see {@link getOption}.
|
|
836
836
|
*
|
|
837
|
-
* @param self - The `
|
|
837
|
+
* @param self - The `Context` to search for the service.
|
|
838
838
|
* @param service - The `Service` of the service to retrieve.
|
|
839
839
|
*
|
|
840
840
|
* @example
|
|
841
841
|
* ```ts
|
|
842
|
-
* import {
|
|
842
|
+
* import { Context } from "effect"
|
|
843
843
|
* import * as assert from "node:assert"
|
|
844
844
|
*
|
|
845
|
-
* const Port =
|
|
846
|
-
* const Timeout =
|
|
845
|
+
* const Port = Context.Service<{ PORT: number }>("Port")
|
|
846
|
+
* const Timeout = Context.Service<{ TIMEOUT: number }>("Timeout")
|
|
847
847
|
*
|
|
848
|
-
* const
|
|
848
|
+
* const context = Context.make(Port, { PORT: 8080 })
|
|
849
849
|
*
|
|
850
|
-
* assert.deepStrictEqual(
|
|
851
|
-
* assert.throws(() =>
|
|
850
|
+
* assert.deepStrictEqual(Context.getUnsafe(context, Port), { PORT: 8080 })
|
|
851
|
+
* assert.throws(() => Context.getUnsafe(context, Timeout))
|
|
852
852
|
* ```
|
|
853
853
|
*
|
|
854
854
|
* @since 4.0.0
|
|
@@ -863,27 +863,27 @@ export const getUnsafe: {
|
|
|
863
863
|
*
|
|
864
864
|
* For a safer version see {@link getOption}.
|
|
865
865
|
*
|
|
866
|
-
* @param self - The `
|
|
866
|
+
* @param self - The `Context` to search for the service.
|
|
867
867
|
* @param service - The `Service` of the service to retrieve.
|
|
868
868
|
*
|
|
869
869
|
* @example
|
|
870
870
|
* ```ts
|
|
871
|
-
* import {
|
|
871
|
+
* import { Context } from "effect"
|
|
872
872
|
* import * as assert from "node:assert"
|
|
873
873
|
*
|
|
874
|
-
* const Port =
|
|
875
|
-
* const Timeout =
|
|
874
|
+
* const Port = Context.Service<{ PORT: number }>("Port")
|
|
875
|
+
* const Timeout = Context.Service<{ TIMEOUT: number }>("Timeout")
|
|
876
876
|
*
|
|
877
|
-
* const
|
|
877
|
+
* const context = Context.make(Port, { PORT: 8080 })
|
|
878
878
|
*
|
|
879
|
-
* assert.deepStrictEqual(
|
|
880
|
-
* assert.throws(() =>
|
|
879
|
+
* assert.deepStrictEqual(Context.getUnsafe(context, Port), { PORT: 8080 })
|
|
880
|
+
* assert.throws(() => Context.getUnsafe(context, Timeout))
|
|
881
881
|
* ```
|
|
882
882
|
*
|
|
883
883
|
* @since 4.0.0
|
|
884
884
|
* @category unsafe
|
|
885
885
|
*/
|
|
886
|
-
<S, I>(service: Key<I, S>): <Services>(self:
|
|
886
|
+
<S, I>(service: Key<I, S>): <Services>(self: Context<Services>) => S
|
|
887
887
|
/**
|
|
888
888
|
* Get a service from the context that corresponds to the given key.
|
|
889
889
|
*
|
|
@@ -892,30 +892,30 @@ export const getUnsafe: {
|
|
|
892
892
|
*
|
|
893
893
|
* For a safer version see {@link getOption}.
|
|
894
894
|
*
|
|
895
|
-
* @param self - The `
|
|
895
|
+
* @param self - The `Context` to search for the service.
|
|
896
896
|
* @param service - The `Service` of the service to retrieve.
|
|
897
897
|
*
|
|
898
898
|
* @example
|
|
899
899
|
* ```ts
|
|
900
|
-
* import {
|
|
900
|
+
* import { Context } from "effect"
|
|
901
901
|
* import * as assert from "node:assert"
|
|
902
902
|
*
|
|
903
|
-
* const Port =
|
|
904
|
-
* const Timeout =
|
|
903
|
+
* const Port = Context.Service<{ PORT: number }>("Port")
|
|
904
|
+
* const Timeout = Context.Service<{ TIMEOUT: number }>("Timeout")
|
|
905
905
|
*
|
|
906
|
-
* const
|
|
906
|
+
* const context = Context.make(Port, { PORT: 8080 })
|
|
907
907
|
*
|
|
908
|
-
* assert.deepStrictEqual(
|
|
909
|
-
* assert.throws(() =>
|
|
908
|
+
* assert.deepStrictEqual(Context.getUnsafe(context, Port), { PORT: 8080 })
|
|
909
|
+
* assert.throws(() => Context.getUnsafe(context, Timeout))
|
|
910
910
|
* ```
|
|
911
911
|
*
|
|
912
912
|
* @since 4.0.0
|
|
913
913
|
* @category unsafe
|
|
914
914
|
*/
|
|
915
|
-
<Services, S, I>(self:
|
|
915
|
+
<Services, S, I>(self: Context<Services>, services: Key<I, S>): S
|
|
916
916
|
} = dual(
|
|
917
917
|
2,
|
|
918
|
-
<Services, I extends Services, S>(self:
|
|
918
|
+
<Services, I extends Services, S>(self: Context<Services>, service: Key<I, S>): S => {
|
|
919
919
|
if (!self.mapUnsafe.has(service.key)) {
|
|
920
920
|
if (ReferenceTypeId in service) return getDefaultValue(service as any)
|
|
921
921
|
throw serviceNotFoundError(service)
|
|
@@ -927,23 +927,23 @@ export const getUnsafe: {
|
|
|
927
927
|
/**
|
|
928
928
|
* Get a service from the context that corresponds to the given key.
|
|
929
929
|
*
|
|
930
|
-
* @param self - The `
|
|
930
|
+
* @param self - The `Context` to search for the service.
|
|
931
931
|
* @param service - The `Service` of the service to retrieve.
|
|
932
932
|
*
|
|
933
933
|
* @example
|
|
934
934
|
* ```ts
|
|
935
|
-
* import { pipe,
|
|
935
|
+
* import { pipe, Context } from "effect"
|
|
936
936
|
* import * as assert from "node:assert"
|
|
937
937
|
*
|
|
938
|
-
* const Port =
|
|
939
|
-
* const Timeout =
|
|
938
|
+
* const Port = Context.Service<{ PORT: number }>("Port")
|
|
939
|
+
* const Timeout = Context.Service<{ TIMEOUT: number }>("Timeout")
|
|
940
940
|
*
|
|
941
|
-
* const
|
|
942
|
-
*
|
|
943
|
-
*
|
|
941
|
+
* const context = pipe(
|
|
942
|
+
* Context.make(Port, { PORT: 8080 }),
|
|
943
|
+
* Context.add(Timeout, { TIMEOUT: 5000 })
|
|
944
944
|
* )
|
|
945
945
|
*
|
|
946
|
-
* assert.deepStrictEqual(
|
|
946
|
+
* assert.deepStrictEqual(Context.get(context, Timeout), { TIMEOUT: 5000 })
|
|
947
947
|
* ```
|
|
948
948
|
*
|
|
949
949
|
* @since 4.0.0
|
|
@@ -953,69 +953,69 @@ export const get: {
|
|
|
953
953
|
/**
|
|
954
954
|
* Get a service from the context that corresponds to the given key.
|
|
955
955
|
*
|
|
956
|
-
* @param self - The `
|
|
956
|
+
* @param self - The `Context` to search for the service.
|
|
957
957
|
* @param service - The `Service` of the service to retrieve.
|
|
958
958
|
*
|
|
959
959
|
* @example
|
|
960
960
|
* ```ts
|
|
961
|
-
* import { pipe,
|
|
961
|
+
* import { pipe, Context } from "effect"
|
|
962
962
|
* import * as assert from "node:assert"
|
|
963
963
|
*
|
|
964
|
-
* const Port =
|
|
965
|
-
* const Timeout =
|
|
964
|
+
* const Port = Context.Service<{ PORT: number }>("Port")
|
|
965
|
+
* const Timeout = Context.Service<{ TIMEOUT: number }>("Timeout")
|
|
966
966
|
*
|
|
967
|
-
* const
|
|
968
|
-
*
|
|
969
|
-
*
|
|
967
|
+
* const context = pipe(
|
|
968
|
+
* Context.make(Port, { PORT: 8080 }),
|
|
969
|
+
* Context.add(Timeout, { TIMEOUT: 5000 })
|
|
970
970
|
* )
|
|
971
971
|
*
|
|
972
|
-
* assert.deepStrictEqual(
|
|
972
|
+
* assert.deepStrictEqual(Context.get(context, Timeout), { TIMEOUT: 5000 })
|
|
973
973
|
* ```
|
|
974
974
|
*
|
|
975
975
|
* @since 4.0.0
|
|
976
976
|
* @category Getters
|
|
977
977
|
*/
|
|
978
|
-
<Services, I extends Services, S>(service: Key<I, S>): (self:
|
|
978
|
+
<Services, I extends Services, S>(service: Key<I, S>): (self: Context<Services>) => S
|
|
979
979
|
/**
|
|
980
980
|
* Get a service from the context that corresponds to the given key.
|
|
981
981
|
*
|
|
982
|
-
* @param self - The `
|
|
982
|
+
* @param self - The `Context` to search for the service.
|
|
983
983
|
* @param service - The `Service` of the service to retrieve.
|
|
984
984
|
*
|
|
985
985
|
* @example
|
|
986
986
|
* ```ts
|
|
987
|
-
* import { pipe,
|
|
987
|
+
* import { pipe, Context } from "effect"
|
|
988
988
|
* import * as assert from "node:assert"
|
|
989
989
|
*
|
|
990
|
-
* const Port =
|
|
991
|
-
* const Timeout =
|
|
990
|
+
* const Port = Context.Service<{ PORT: number }>("Port")
|
|
991
|
+
* const Timeout = Context.Service<{ TIMEOUT: number }>("Timeout")
|
|
992
992
|
*
|
|
993
|
-
* const
|
|
994
|
-
*
|
|
995
|
-
*
|
|
993
|
+
* const context = pipe(
|
|
994
|
+
* Context.make(Port, { PORT: 8080 }),
|
|
995
|
+
* Context.add(Timeout, { TIMEOUT: 5000 })
|
|
996
996
|
* )
|
|
997
997
|
*
|
|
998
|
-
* assert.deepStrictEqual(
|
|
998
|
+
* assert.deepStrictEqual(Context.get(context, Timeout), { TIMEOUT: 5000 })
|
|
999
999
|
* ```
|
|
1000
1000
|
*
|
|
1001
1001
|
* @since 4.0.0
|
|
1002
1002
|
* @category Getters
|
|
1003
1003
|
*/
|
|
1004
|
-
<Services, I extends Services, S>(self:
|
|
1004
|
+
<Services, I extends Services, S>(self: Context<Services>, service: Key<I, S>): S
|
|
1005
1005
|
} = getUnsafe
|
|
1006
1006
|
|
|
1007
1007
|
/**
|
|
1008
1008
|
* @example
|
|
1009
1009
|
* ```ts
|
|
1010
|
-
* import {
|
|
1010
|
+
* import { Context } from "effect"
|
|
1011
1011
|
* import * as assert from "node:assert"
|
|
1012
1012
|
*
|
|
1013
|
-
* const LoggerRef =
|
|
1013
|
+
* const LoggerRef = Context.Reference("Logger", {
|
|
1014
1014
|
* defaultValue: () => ({ log: (msg: string) => console.log(msg) })
|
|
1015
1015
|
* })
|
|
1016
1016
|
*
|
|
1017
|
-
* const
|
|
1018
|
-
* const logger =
|
|
1017
|
+
* const context = Context.empty()
|
|
1018
|
+
* const logger = Context.getReferenceUnsafe(context, LoggerRef)
|
|
1019
1019
|
*
|
|
1020
1020
|
* assert.deepStrictEqual(logger, { log: (msg: string) => console.log(msg) })
|
|
1021
1021
|
* ```
|
|
@@ -1023,14 +1023,14 @@ export const get: {
|
|
|
1023
1023
|
* @since 4.0.0
|
|
1024
1024
|
* @category unsafe
|
|
1025
1025
|
*/
|
|
1026
|
-
export const getReferenceUnsafe = <Services, S>(self:
|
|
1026
|
+
export const getReferenceUnsafe = <Services, S>(self: Context<Services>, service: Reference<S>): S => {
|
|
1027
1027
|
if (!self.mapUnsafe.has(service.key)) {
|
|
1028
1028
|
return getDefaultValue(service as any)
|
|
1029
1029
|
}
|
|
1030
1030
|
return self.mapUnsafe.get(service.key)! as any
|
|
1031
1031
|
}
|
|
1032
1032
|
|
|
1033
|
-
const defaultValueCacheKey = "~effect/
|
|
1033
|
+
const defaultValueCacheKey = "~effect/Context/defaultValue" as const
|
|
1034
1034
|
|
|
1035
1035
|
const getDefaultValue = (ref: Reference<any>) => {
|
|
1036
1036
|
if (defaultValueCacheKey in ref) {
|
|
@@ -1065,24 +1065,24 @@ const serviceNotFoundError = (service: Key<any, any>) => {
|
|
|
1065
1065
|
* an `Option` object. If the key is not found, the `Option` object will be
|
|
1066
1066
|
* `None`.
|
|
1067
1067
|
*
|
|
1068
|
-
* @param self - The `
|
|
1068
|
+
* @param self - The `Context` to search for the service.
|
|
1069
1069
|
* @param service - The `Service` of the service to retrieve.
|
|
1070
1070
|
*
|
|
1071
1071
|
* @example
|
|
1072
1072
|
* ```ts
|
|
1073
|
-
* import { Option,
|
|
1073
|
+
* import { Option, Context } from "effect"
|
|
1074
1074
|
* import * as assert from "node:assert"
|
|
1075
1075
|
*
|
|
1076
|
-
* const Port =
|
|
1077
|
-
* const Timeout =
|
|
1076
|
+
* const Port = Context.Service<{ PORT: number }>("Port")
|
|
1077
|
+
* const Timeout = Context.Service<{ TIMEOUT: number }>("Timeout")
|
|
1078
1078
|
*
|
|
1079
|
-
* const
|
|
1079
|
+
* const context = Context.make(Port, { PORT: 8080 })
|
|
1080
1080
|
*
|
|
1081
1081
|
* assert.deepStrictEqual(
|
|
1082
|
-
*
|
|
1082
|
+
* Context.getOption(context, Port),
|
|
1083
1083
|
* Option.some({ PORT: 8080 })
|
|
1084
1084
|
* )
|
|
1085
|
-
* assert.deepStrictEqual(
|
|
1085
|
+
* assert.deepStrictEqual(Context.getOption(context, Timeout), Option.none())
|
|
1086
1086
|
* ```
|
|
1087
1087
|
*
|
|
1088
1088
|
* @since 4.0.0
|
|
@@ -1094,60 +1094,60 @@ export const getOption: {
|
|
|
1094
1094
|
* an `Option` object. If the key is not found, the `Option` object will be
|
|
1095
1095
|
* `None`.
|
|
1096
1096
|
*
|
|
1097
|
-
* @param self - The `
|
|
1097
|
+
* @param self - The `Context` to search for the service.
|
|
1098
1098
|
* @param service - The `Service` of the service to retrieve.
|
|
1099
1099
|
*
|
|
1100
1100
|
* @example
|
|
1101
1101
|
* ```ts
|
|
1102
|
-
* import { Option,
|
|
1102
|
+
* import { Option, Context } from "effect"
|
|
1103
1103
|
* import * as assert from "node:assert"
|
|
1104
1104
|
*
|
|
1105
|
-
* const Port =
|
|
1106
|
-
* const Timeout =
|
|
1105
|
+
* const Port = Context.Service<{ PORT: number }>("Port")
|
|
1106
|
+
* const Timeout = Context.Service<{ TIMEOUT: number }>("Timeout")
|
|
1107
1107
|
*
|
|
1108
|
-
* const
|
|
1108
|
+
* const context = Context.make(Port, { PORT: 8080 })
|
|
1109
1109
|
*
|
|
1110
1110
|
* assert.deepStrictEqual(
|
|
1111
|
-
*
|
|
1111
|
+
* Context.getOption(context, Port),
|
|
1112
1112
|
* Option.some({ PORT: 8080 })
|
|
1113
1113
|
* )
|
|
1114
|
-
* assert.deepStrictEqual(
|
|
1114
|
+
* assert.deepStrictEqual(Context.getOption(context, Timeout), Option.none())
|
|
1115
1115
|
* ```
|
|
1116
1116
|
*
|
|
1117
1117
|
* @since 4.0.0
|
|
1118
1118
|
* @category Getters
|
|
1119
1119
|
*/
|
|
1120
|
-
<S, I>(service: Key<I, S>): <Services>(self:
|
|
1120
|
+
<S, I>(service: Key<I, S>): <Services>(self: Context<Services>) => Option.Option<S>
|
|
1121
1121
|
/**
|
|
1122
1122
|
* Get the value associated with the specified key from the context wrapped in
|
|
1123
1123
|
* an `Option` object. If the key is not found, the `Option` object will be
|
|
1124
1124
|
* `None`.
|
|
1125
1125
|
*
|
|
1126
|
-
* @param self - The `
|
|
1126
|
+
* @param self - The `Context` to search for the service.
|
|
1127
1127
|
* @param service - The `Service` of the service to retrieve.
|
|
1128
1128
|
*
|
|
1129
1129
|
* @example
|
|
1130
1130
|
* ```ts
|
|
1131
|
-
* import { Option,
|
|
1131
|
+
* import { Option, Context } from "effect"
|
|
1132
1132
|
* import * as assert from "node:assert"
|
|
1133
1133
|
*
|
|
1134
|
-
* const Port =
|
|
1135
|
-
* const Timeout =
|
|
1134
|
+
* const Port = Context.Service<{ PORT: number }>("Port")
|
|
1135
|
+
* const Timeout = Context.Service<{ TIMEOUT: number }>("Timeout")
|
|
1136
1136
|
*
|
|
1137
|
-
* const
|
|
1137
|
+
* const context = Context.make(Port, { PORT: 8080 })
|
|
1138
1138
|
*
|
|
1139
1139
|
* assert.deepStrictEqual(
|
|
1140
|
-
*
|
|
1140
|
+
* Context.getOption(context, Port),
|
|
1141
1141
|
* Option.some({ PORT: 8080 })
|
|
1142
1142
|
* )
|
|
1143
|
-
* assert.deepStrictEqual(
|
|
1143
|
+
* assert.deepStrictEqual(Context.getOption(context, Timeout), Option.none())
|
|
1144
1144
|
* ```
|
|
1145
1145
|
*
|
|
1146
1146
|
* @since 4.0.0
|
|
1147
1147
|
* @category Getters
|
|
1148
1148
|
*/
|
|
1149
|
-
<Services, S, I>(self:
|
|
1150
|
-
} = dual(2, <Services, I extends Services, S>(self:
|
|
1149
|
+
<Services, S, I>(self: Context<Services>, service: Key<I, S>): Option.Option<S>
|
|
1150
|
+
} = dual(2, <Services, I extends Services, S>(self: Context<Services>, service: Key<I, S>): Option.Option<S> => {
|
|
1151
1151
|
if (self.mapUnsafe.has(service.key)) {
|
|
1152
1152
|
return Option.some(self.mapUnsafe.get(service.key)! as any)
|
|
1153
1153
|
}
|
|
@@ -1155,26 +1155,26 @@ export const getOption: {
|
|
|
1155
1155
|
})
|
|
1156
1156
|
|
|
1157
1157
|
/**
|
|
1158
|
-
* Merges two `
|
|
1158
|
+
* Merges two `Context`s, returning a new `Context` containing the services of both.
|
|
1159
1159
|
*
|
|
1160
|
-
* @param self - The first `
|
|
1161
|
-
* @param that - The second `
|
|
1160
|
+
* @param self - The first `Context` to merge.
|
|
1161
|
+
* @param that - The second `Context` to merge.
|
|
1162
1162
|
*
|
|
1163
1163
|
* @example
|
|
1164
1164
|
* ```ts
|
|
1165
|
-
* import {
|
|
1165
|
+
* import { Context } from "effect"
|
|
1166
1166
|
* import * as assert from "node:assert"
|
|
1167
1167
|
*
|
|
1168
|
-
* const Port =
|
|
1169
|
-
* const Timeout =
|
|
1168
|
+
* const Port = Context.Service<{ PORT: number }>("Port")
|
|
1169
|
+
* const Timeout = Context.Service<{ TIMEOUT: number }>("Timeout")
|
|
1170
1170
|
*
|
|
1171
|
-
* const
|
|
1172
|
-
* const
|
|
1171
|
+
* const firstContext = Context.make(Port, { PORT: 8080 })
|
|
1172
|
+
* const secondContext = Context.make(Timeout, { TIMEOUT: 5000 })
|
|
1173
1173
|
*
|
|
1174
|
-
* const
|
|
1174
|
+
* const context = Context.merge(firstContext, secondContext)
|
|
1175
1175
|
*
|
|
1176
|
-
* assert.deepStrictEqual(
|
|
1177
|
-
* assert.deepStrictEqual(
|
|
1176
|
+
* assert.deepStrictEqual(Context.get(context, Port), { PORT: 8080 })
|
|
1177
|
+
* assert.deepStrictEqual(Context.get(context, Timeout), { TIMEOUT: 5000 })
|
|
1178
1178
|
* ```
|
|
1179
1179
|
*
|
|
1180
1180
|
* @since 4.0.0
|
|
@@ -1182,60 +1182,60 @@ export const getOption: {
|
|
|
1182
1182
|
*/
|
|
1183
1183
|
export const merge: {
|
|
1184
1184
|
/**
|
|
1185
|
-
* Merges two `
|
|
1185
|
+
* Merges two `Context`s, returning a new `Context` containing the services of both.
|
|
1186
1186
|
*
|
|
1187
|
-
* @param self - The first `
|
|
1188
|
-
* @param that - The second `
|
|
1187
|
+
* @param self - The first `Context` to merge.
|
|
1188
|
+
* @param that - The second `Context` to merge.
|
|
1189
1189
|
*
|
|
1190
1190
|
* @example
|
|
1191
1191
|
* ```ts
|
|
1192
|
-
* import {
|
|
1192
|
+
* import { Context } from "effect"
|
|
1193
1193
|
* import * as assert from "node:assert"
|
|
1194
1194
|
*
|
|
1195
|
-
* const Port =
|
|
1196
|
-
* const Timeout =
|
|
1195
|
+
* const Port = Context.Service<{ PORT: number }>("Port")
|
|
1196
|
+
* const Timeout = Context.Service<{ TIMEOUT: number }>("Timeout")
|
|
1197
1197
|
*
|
|
1198
|
-
* const
|
|
1199
|
-
* const
|
|
1198
|
+
* const firstContext = Context.make(Port, { PORT: 8080 })
|
|
1199
|
+
* const secondContext = Context.make(Timeout, { TIMEOUT: 5000 })
|
|
1200
1200
|
*
|
|
1201
|
-
* const
|
|
1201
|
+
* const context = Context.merge(firstContext, secondContext)
|
|
1202
1202
|
*
|
|
1203
|
-
* assert.deepStrictEqual(
|
|
1204
|
-
* assert.deepStrictEqual(
|
|
1203
|
+
* assert.deepStrictEqual(Context.get(context, Port), { PORT: 8080 })
|
|
1204
|
+
* assert.deepStrictEqual(Context.get(context, Timeout), { TIMEOUT: 5000 })
|
|
1205
1205
|
* ```
|
|
1206
1206
|
*
|
|
1207
1207
|
* @since 4.0.0
|
|
1208
1208
|
* @category Utils
|
|
1209
1209
|
*/
|
|
1210
|
-
<R1>(that:
|
|
1210
|
+
<R1>(that: Context<R1>): <Services>(self: Context<Services>) => Context<R1 | Services>
|
|
1211
1211
|
/**
|
|
1212
|
-
* Merges two `
|
|
1212
|
+
* Merges two `Context`s, returning a new `Context` containing the services of both.
|
|
1213
1213
|
*
|
|
1214
|
-
* @param self - The first `
|
|
1215
|
-
* @param that - The second `
|
|
1214
|
+
* @param self - The first `Context` to merge.
|
|
1215
|
+
* @param that - The second `Context` to merge.
|
|
1216
1216
|
*
|
|
1217
1217
|
* @example
|
|
1218
1218
|
* ```ts
|
|
1219
|
-
* import {
|
|
1219
|
+
* import { Context } from "effect"
|
|
1220
1220
|
* import * as assert from "node:assert"
|
|
1221
1221
|
*
|
|
1222
|
-
* const Port =
|
|
1223
|
-
* const Timeout =
|
|
1222
|
+
* const Port = Context.Service<{ PORT: number }>("Port")
|
|
1223
|
+
* const Timeout = Context.Service<{ TIMEOUT: number }>("Timeout")
|
|
1224
1224
|
*
|
|
1225
|
-
* const
|
|
1226
|
-
* const
|
|
1225
|
+
* const firstContext = Context.make(Port, { PORT: 8080 })
|
|
1226
|
+
* const secondContext = Context.make(Timeout, { TIMEOUT: 5000 })
|
|
1227
1227
|
*
|
|
1228
|
-
* const
|
|
1228
|
+
* const context = Context.merge(firstContext, secondContext)
|
|
1229
1229
|
*
|
|
1230
|
-
* assert.deepStrictEqual(
|
|
1231
|
-
* assert.deepStrictEqual(
|
|
1230
|
+
* assert.deepStrictEqual(Context.get(context, Port), { PORT: 8080 })
|
|
1231
|
+
* assert.deepStrictEqual(Context.get(context, Timeout), { TIMEOUT: 5000 })
|
|
1232
1232
|
* ```
|
|
1233
1233
|
*
|
|
1234
1234
|
* @since 4.0.0
|
|
1235
1235
|
* @category Utils
|
|
1236
1236
|
*/
|
|
1237
|
-
<Services, R1>(self:
|
|
1238
|
-
} = dual(2, <Services, R1>(self:
|
|
1237
|
+
<Services, R1>(self: Context<Services>, that: Context<R1>): Context<Services | R1>
|
|
1238
|
+
} = dual(2, <Services, R1>(self: Context<Services>, that: Context<R1>): Context<Services | R1> => {
|
|
1239
1239
|
if (self.mapUnsafe.size === 0) return that as any
|
|
1240
1240
|
if (that.mapUnsafe.size === 0) return self as any
|
|
1241
1241
|
return withMapUnsafe(self, (map) => {
|
|
@@ -1244,37 +1244,37 @@ export const merge: {
|
|
|
1244
1244
|
})
|
|
1245
1245
|
|
|
1246
1246
|
/**
|
|
1247
|
-
* Merges any number of `
|
|
1247
|
+
* Merges any number of `Context`s, returning a new `Context` containing the services of all.
|
|
1248
1248
|
*
|
|
1249
1249
|
* @example
|
|
1250
1250
|
* ```ts
|
|
1251
|
-
* import {
|
|
1251
|
+
* import { Context } from "effect"
|
|
1252
1252
|
* import * as assert from "node:assert"
|
|
1253
1253
|
*
|
|
1254
|
-
* const Port =
|
|
1255
|
-
* const Timeout =
|
|
1256
|
-
* const Host =
|
|
1254
|
+
* const Port = Context.Service<{ PORT: number }>("Port")
|
|
1255
|
+
* const Timeout = Context.Service<{ TIMEOUT: number }>("Timeout")
|
|
1256
|
+
* const Host = Context.Service<{ HOST: string }>("Host")
|
|
1257
1257
|
*
|
|
1258
|
-
* const
|
|
1259
|
-
* const
|
|
1260
|
-
* const
|
|
1258
|
+
* const firstContext = Context.make(Port, { PORT: 8080 })
|
|
1259
|
+
* const secondContext = Context.make(Timeout, { TIMEOUT: 5000 })
|
|
1260
|
+
* const thirdContext = Context.make(Host, { HOST: "localhost" })
|
|
1261
1261
|
*
|
|
1262
|
-
* const
|
|
1263
|
-
*
|
|
1264
|
-
*
|
|
1265
|
-
*
|
|
1262
|
+
* const context = Context.mergeAll(
|
|
1263
|
+
* firstContext,
|
|
1264
|
+
* secondContext,
|
|
1265
|
+
* thirdContext
|
|
1266
1266
|
* )
|
|
1267
1267
|
*
|
|
1268
|
-
* assert.deepStrictEqual(
|
|
1269
|
-
* assert.deepStrictEqual(
|
|
1270
|
-
* assert.deepStrictEqual(
|
|
1268
|
+
* assert.deepStrictEqual(Context.get(context, Port), { PORT: 8080 })
|
|
1269
|
+
* assert.deepStrictEqual(Context.get(context, Timeout), { TIMEOUT: 5000 })
|
|
1270
|
+
* assert.deepStrictEqual(Context.get(context, Host), { HOST: "localhost" })
|
|
1271
1271
|
* ```
|
|
1272
1272
|
*
|
|
1273
1273
|
* @since 3.12.0
|
|
1274
1274
|
*/
|
|
1275
1275
|
export const mergeAll = <T extends Array<unknown>>(
|
|
1276
|
-
...ctxs: [...{ [K in keyof T]:
|
|
1277
|
-
):
|
|
1276
|
+
...ctxs: [...{ [K in keyof T]: Context<T[K]> }]
|
|
1277
|
+
): Context<T[number]> => {
|
|
1278
1278
|
const map = new Map()
|
|
1279
1279
|
for (let i = 0; i < ctxs.length; i++) {
|
|
1280
1280
|
ctxs[i].mapUnsafe.forEach((value, key) => {
|
|
@@ -1285,31 +1285,31 @@ export const mergeAll = <T extends Array<unknown>>(
|
|
|
1285
1285
|
}
|
|
1286
1286
|
|
|
1287
1287
|
/**
|
|
1288
|
-
* Returns a new `
|
|
1288
|
+
* Returns a new `Context` that contains only the specified services.
|
|
1289
1289
|
*
|
|
1290
|
-
* @param self - The `
|
|
1291
|
-
* @param services - The list of `Service`s to be included in the new `
|
|
1290
|
+
* @param self - The `Context` to prune services from.
|
|
1291
|
+
* @param services - The list of `Service`s to be included in the new `Context`.
|
|
1292
1292
|
*
|
|
1293
1293
|
* @example
|
|
1294
1294
|
* ```ts
|
|
1295
|
-
* import { Option, pipe,
|
|
1295
|
+
* import { Option, pipe, Context } from "effect"
|
|
1296
1296
|
* import * as assert from "node:assert"
|
|
1297
1297
|
*
|
|
1298
|
-
* const Port =
|
|
1299
|
-
* const Timeout =
|
|
1298
|
+
* const Port = Context.Service<{ PORT: number }>("Port")
|
|
1299
|
+
* const Timeout = Context.Service<{ TIMEOUT: number }>("Timeout")
|
|
1300
1300
|
*
|
|
1301
|
-
* const
|
|
1302
|
-
*
|
|
1303
|
-
*
|
|
1301
|
+
* const someContext = pipe(
|
|
1302
|
+
* Context.make(Port, { PORT: 8080 }),
|
|
1303
|
+
* Context.add(Timeout, { TIMEOUT: 5000 })
|
|
1304
1304
|
* )
|
|
1305
1305
|
*
|
|
1306
|
-
* const
|
|
1306
|
+
* const context = pipe(someContext, Context.pick(Port))
|
|
1307
1307
|
*
|
|
1308
1308
|
* assert.deepStrictEqual(
|
|
1309
|
-
*
|
|
1309
|
+
* Context.getOption(context, Port),
|
|
1310
1310
|
* Option.some({ PORT: 8080 })
|
|
1311
1311
|
* )
|
|
1312
|
-
* assert.deepStrictEqual(
|
|
1312
|
+
* assert.deepStrictEqual(Context.getOption(context, Timeout), Option.none())
|
|
1313
1313
|
* ```
|
|
1314
1314
|
*
|
|
1315
1315
|
* @since 4.0.0
|
|
@@ -1318,7 +1318,7 @@ export const mergeAll = <T extends Array<unknown>>(
|
|
|
1318
1318
|
export const pick = <S extends ReadonlyArray<Key<any, any>>>(
|
|
1319
1319
|
...services: S
|
|
1320
1320
|
) =>
|
|
1321
|
-
<Services>(self:
|
|
1321
|
+
<Services>(self: Context<Services>): Context<Services & Service.Identifier<S[number]>> =>
|
|
1322
1322
|
withMapUnsafe(self, (map) => {
|
|
1323
1323
|
const keySet = new Set(services.map((key) => key.key))
|
|
1324
1324
|
map.forEach((_, key) => {
|
|
@@ -1330,24 +1330,24 @@ export const pick = <S extends ReadonlyArray<Key<any, any>>>(
|
|
|
1330
1330
|
/**
|
|
1331
1331
|
* @example
|
|
1332
1332
|
* ```ts
|
|
1333
|
-
* import { Option, pipe,
|
|
1333
|
+
* import { Option, pipe, Context } from "effect"
|
|
1334
1334
|
* import * as assert from "node:assert"
|
|
1335
1335
|
*
|
|
1336
|
-
* const Port =
|
|
1337
|
-
* const Timeout =
|
|
1336
|
+
* const Port = Context.Service<{ PORT: number }>("Port")
|
|
1337
|
+
* const Timeout = Context.Service<{ TIMEOUT: number }>("Timeout")
|
|
1338
1338
|
*
|
|
1339
|
-
* const
|
|
1340
|
-
*
|
|
1341
|
-
*
|
|
1339
|
+
* const someContext = pipe(
|
|
1340
|
+
* Context.make(Port, { PORT: 8080 }),
|
|
1341
|
+
* Context.add(Timeout, { TIMEOUT: 5000 })
|
|
1342
1342
|
* )
|
|
1343
1343
|
*
|
|
1344
|
-
* const
|
|
1344
|
+
* const context = pipe(someContext, Context.omit(Timeout))
|
|
1345
1345
|
*
|
|
1346
1346
|
* assert.deepStrictEqual(
|
|
1347
|
-
*
|
|
1347
|
+
* Context.getOption(context, Port),
|
|
1348
1348
|
* Option.some({ PORT: 8080 })
|
|
1349
1349
|
* )
|
|
1350
|
-
* assert.deepStrictEqual(
|
|
1350
|
+
* assert.deepStrictEqual(Context.getOption(context, Timeout), Option.none())
|
|
1351
1351
|
* ```
|
|
1352
1352
|
*
|
|
1353
1353
|
* @since 4.0.0
|
|
@@ -1356,7 +1356,7 @@ export const pick = <S extends ReadonlyArray<Key<any, any>>>(
|
|
|
1356
1356
|
export const omit = <S extends ReadonlyArray<Key<any, any>>>(
|
|
1357
1357
|
...keys: S
|
|
1358
1358
|
) =>
|
|
1359
|
-
<Services>(self:
|
|
1359
|
+
<Services>(self: Context<Services>): Context<Exclude<Services, Service.Identifier<S[number]>>> =>
|
|
1360
1360
|
withMapUnsafe(self, (map) => {
|
|
1361
1361
|
for (let i = 0; i < keys.length; i++) {
|
|
1362
1362
|
map.delete(keys[i].key)
|
|
@@ -1364,7 +1364,7 @@ export const omit = <S extends ReadonlyArray<Key<any, any>>>(
|
|
|
1364
1364
|
})
|
|
1365
1365
|
|
|
1366
1366
|
/**
|
|
1367
|
-
* Perform a series of mutations on a `
|
|
1367
|
+
* Perform a series of mutations on a `Context`. Prevents unnecessary copying
|
|
1368
1368
|
* of the underlying map when multiple mutations are needed.
|
|
1369
1369
|
*
|
|
1370
1370
|
* @since 4.0.0
|
|
@@ -1372,29 +1372,26 @@ export const omit = <S extends ReadonlyArray<Key<any, any>>>(
|
|
|
1372
1372
|
*/
|
|
1373
1373
|
export const mutate: {
|
|
1374
1374
|
/**
|
|
1375
|
-
* Perform a series of mutations on a `
|
|
1375
|
+
* Perform a series of mutations on a `Context`. Prevents unnecessary copying
|
|
1376
1376
|
* of the underlying map when multiple mutations are needed.
|
|
1377
1377
|
*
|
|
1378
1378
|
* @since 4.0.0
|
|
1379
1379
|
* @category Utils
|
|
1380
1380
|
*/
|
|
1381
|
-
<Services, B>(f: (
|
|
1381
|
+
<Services, B>(f: (context: Context<Services>) => Context<B>): <Services>(self: Context<Services>) => Context<B>
|
|
1382
1382
|
/**
|
|
1383
|
-
* Perform a series of mutations on a `
|
|
1383
|
+
* Perform a series of mutations on a `Context`. Prevents unnecessary copying
|
|
1384
1384
|
* of the underlying map when multiple mutations are needed.
|
|
1385
1385
|
*
|
|
1386
1386
|
* @since 4.0.0
|
|
1387
1387
|
* @category Utils
|
|
1388
1388
|
*/
|
|
1389
|
-
<Services, B>(
|
|
1390
|
-
self: ServiceMap<Services>,
|
|
1391
|
-
f: (serviceMap: ServiceMap<Services>) => ServiceMap<B>
|
|
1392
|
-
): ServiceMap<B>
|
|
1389
|
+
<Services, B>(self: Context<Services>, f: (context: Context<Services>) => Context<B>): Context<B>
|
|
1393
1390
|
} = dual(
|
|
1394
1391
|
2,
|
|
1395
|
-
<Services, B>(self:
|
|
1392
|
+
<Services, B>(self: Context<Services>, f: (context: Context<Services>) => Context<B>): Context<B> => {
|
|
1396
1393
|
const next = makeUnsafe</**
|
|
1397
|
-
* Perform a series of mutations on a `
|
|
1394
|
+
* Perform a series of mutations on a `Context`. Prevents unnecessary copying
|
|
1398
1395
|
* of the underlying map when multiple mutations are needed.
|
|
1399
1396
|
*
|
|
1400
1397
|
* @since 4.0.0
|
|
@@ -1408,7 +1405,7 @@ export const mutate: {
|
|
|
1408
1405
|
}
|
|
1409
1406
|
)
|
|
1410
1407
|
|
|
1411
|
-
const withMapUnsafe = <Services, B>(self:
|
|
1408
|
+
const withMapUnsafe = <Services, B>(self: Context<Services>, f: (map: Map<string, any>) => void): Context<B> => {
|
|
1412
1409
|
if (self.mutable) {
|
|
1413
1410
|
f(self.mapUnsafe as any)
|
|
1414
1411
|
return self as any
|
|
@@ -1419,33 +1416,33 @@ const withMapUnsafe = <Services, B>(self: ServiceMap<Services>, f: (map: Map<str
|
|
|
1419
1416
|
}
|
|
1420
1417
|
|
|
1421
1418
|
/**
|
|
1422
|
-
* Creates a
|
|
1419
|
+
* Creates a context key with a default value.
|
|
1423
1420
|
*
|
|
1424
1421
|
* **Details**
|
|
1425
1422
|
*
|
|
1426
|
-
* `
|
|
1423
|
+
* `Context.Reference` allows you to create a key that can hold a value. You
|
|
1427
1424
|
* can provide a default value for the service, which will automatically be used
|
|
1428
1425
|
* when the context is accessed, or override it with a custom implementation
|
|
1429
1426
|
* when needed.
|
|
1430
1427
|
*
|
|
1431
1428
|
* @example
|
|
1432
1429
|
* ```ts
|
|
1433
|
-
* import {
|
|
1430
|
+
* import { Context } from "effect"
|
|
1434
1431
|
*
|
|
1435
1432
|
* // Create a reference with a default value
|
|
1436
|
-
* const LoggerRef =
|
|
1433
|
+
* const LoggerRef = Context.Reference("Logger", {
|
|
1437
1434
|
* defaultValue: () => ({ log: (msg: string) => console.log(msg) })
|
|
1438
1435
|
* })
|
|
1439
1436
|
*
|
|
1440
1437
|
* // The reference provides the default value when accessed from an empty context
|
|
1441
|
-
* const
|
|
1442
|
-
* const logger =
|
|
1438
|
+
* const context = Context.empty()
|
|
1439
|
+
* const logger = Context.get(context, LoggerRef)
|
|
1443
1440
|
*
|
|
1444
1441
|
* // You can also override the default value
|
|
1445
|
-
* const
|
|
1442
|
+
* const customContext = Context.make(LoggerRef, {
|
|
1446
1443
|
* log: (msg: string) => `Custom: ${msg}`
|
|
1447
1444
|
* })
|
|
1448
|
-
* const customLogger =
|
|
1445
|
+
* const customLogger = Context.get(customContext, LoggerRef)
|
|
1449
1446
|
* ```
|
|
1450
1447
|
*
|
|
1451
1448
|
* @since 4.0.0
|