effect 4.0.0-beta.103 → 4.0.0-beta.105
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/AGENTS.md +381 -0
- package/CLAUDE.md +381 -0
- package/ai-docs/README.md +44 -0
- package/ai-docs/package.json +36 -0
- package/ai-docs/src/01_effect/01_basics/01_effect-gen.ts +30 -0
- package/ai-docs/src/01_effect/01_basics/02_effect-fn.ts +39 -0
- package/ai-docs/src/01_effect/01_basics/10_creating-effects.ts +74 -0
- package/ai-docs/src/01_effect/01_basics/index.md +5 -0
- package/ai-docs/src/01_effect/02_schema/10_schema-basics.ts +43 -0
- package/ai-docs/src/01_effect/02_schema/index.md +7 -0
- package/ai-docs/src/01_effect/03_services/01_service.ts +45 -0
- package/ai-docs/src/01_effect/03_services/10_reference.ts +10 -0
- package/ai-docs/src/01_effect/03_services/20_layer-composition.ts +70 -0
- package/ai-docs/src/01_effect/03_services/20_layer-unwrap.ts +66 -0
- package/ai-docs/src/01_effect/03_services/index.md +5 -0
- package/ai-docs/src/01_effect/04_errors/01_error-handling.ts +30 -0
- package/ai-docs/src/01_effect/04_errors/10_catch-tags.ts +24 -0
- package/ai-docs/src/01_effect/04_errors/20_reason-errors.ts +64 -0
- package/ai-docs/src/01_effect/04_errors/index.md +1 -0
- package/ai-docs/src/01_effect/05_resources/10_acquire-release.ts +105 -0
- package/ai-docs/src/01_effect/05_resources/20_layer-side-effects.ts +31 -0
- package/ai-docs/src/01_effect/05_resources/30_layer-map.ts +86 -0
- package/ai-docs/src/01_effect/05_resources/index.md +3 -0
- package/ai-docs/src/01_effect/06_running/10_run-main.ts +30 -0
- package/ai-docs/src/01_effect/06_running/20_layer-launch.ts +27 -0
- package/ai-docs/src/01_effect/06_running/index.md +1 -0
- package/ai-docs/src/01_effect/07_pubsub/10_pubsub.ts +56 -0
- package/ai-docs/src/01_effect/07_pubsub/index.md +3 -0
- package/ai-docs/src/03_stream/10_creating-streams.ts +103 -0
- package/ai-docs/src/03_stream/20_consuming-streams.ts +137 -0
- package/ai-docs/src/03_stream/30_encoding.ts +165 -0
- package/ai-docs/src/03_stream/index.md +4 -0
- package/ai-docs/src/04_integration/10_managed-runtime.ts +129 -0
- package/ai-docs/src/04_integration/index.md +5 -0
- package/ai-docs/src/05_batching/10_request-resolver.ts +89 -0
- package/ai-docs/src/05_batching/index.md +3 -0
- package/ai-docs/src/06_schedule/10_schedules.ts +110 -0
- package/ai-docs/src/06_schedule/index.md +3 -0
- package/ai-docs/src/07_datetime/10_creating-and-formatting.ts +30 -0
- package/ai-docs/src/07_datetime/20_time-zones.ts +44 -0
- package/ai-docs/src/07_datetime/index.md +5 -0
- package/ai-docs/src/08_observability/10_logging.ts +66 -0
- package/ai-docs/src/08_observability/20_otlp-tracing.ts +95 -0
- package/ai-docs/src/08_observability/index.md +7 -0
- package/ai-docs/src/09_testing/10_effect-tests.ts +55 -0
- package/ai-docs/src/09_testing/20_layer-tests.ts +138 -0
- package/ai-docs/src/09_testing/index.md +1 -0
- package/ai-docs/src/10_predicate/01_basics.ts +14 -0
- package/ai-docs/src/10_predicate/index.md +9 -0
- package/ai-docs/src/50_http-client/10_basics.ts +102 -0
- package/ai-docs/src/50_http-client/index.md +3 -0
- package/ai-docs/src/51_http-server/10_basics.ts +116 -0
- package/ai-docs/src/51_http-server/fixtures/api/Api.ts +14 -0
- package/ai-docs/src/51_http-server/fixtures/api/Authorization.ts +36 -0
- package/ai-docs/src/51_http-server/fixtures/api/System.ts +10 -0
- package/ai-docs/src/51_http-server/fixtures/api/Users.ts +91 -0
- package/ai-docs/src/51_http-server/fixtures/domain/User.ts +12 -0
- package/ai-docs/src/51_http-server/fixtures/domain/UserErrors.ts +22 -0
- package/ai-docs/src/51_http-server/fixtures/server/Authorization.ts +36 -0
- package/ai-docs/src/51_http-server/fixtures/server/Users/http.ts +71 -0
- package/ai-docs/src/51_http-server/fixtures/server/Users.ts +62 -0
- package/ai-docs/src/51_http-server/index.md +3 -0
- package/ai-docs/src/60_child-process/10_working-with-child-processes.ts +117 -0
- package/ai-docs/src/60_child-process/index.md +3 -0
- package/ai-docs/src/70_cli/10_basics.ts +136 -0
- package/ai-docs/src/70_cli/index.md +5 -0
- package/ai-docs/src/71_ai/10_language-model.ts +156 -0
- package/ai-docs/src/71_ai/20_tools.ts +226 -0
- package/ai-docs/src/71_ai/30_chat.ts +158 -0
- package/ai-docs/src/71_ai/fixtures/domain/LaunchPlan.ts +9 -0
- package/ai-docs/src/71_ai/index.md +5 -0
- package/ai-docs/src/80_cluster/10_entities.ts +97 -0
- package/ai-docs/src/80_cluster/index.md +4 -0
- package/ai-docs/src/index.md +10 -0
- package/ai-docs/tsconfig.json +24 -0
- package/dist/Brand.d.ts +3 -3
- package/dist/Brand.d.ts.map +1 -1
- package/dist/Brand.js +4 -3
- package/dist/Brand.js.map +1 -1
- package/dist/Cache.js +1 -1
- package/dist/Cache.js.map +1 -1
- package/dist/Channel.d.ts +1 -1
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js.map +1 -1
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +30 -8
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.d.ts.map +1 -1
- package/dist/ConfigProvider.js +2 -1
- package/dist/ConfigProvider.js.map +1 -1
- package/dist/Context.d.ts +2 -3
- package/dist/Context.d.ts.map +1 -1
- package/dist/Context.js +1 -22
- package/dist/Context.js.map +1 -1
- package/dist/Cron.d.ts +31 -0
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +58 -2
- package/dist/Cron.js.map +1 -1
- package/dist/Crypto.d.ts.map +1 -1
- package/dist/Crypto.js +13 -5
- package/dist/Crypto.js.map +1 -1
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +12 -1
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +132 -14
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +38 -0
- package/dist/Effect.js.map +1 -1
- package/dist/Equal.d.ts.map +1 -1
- package/dist/Equal.js +10 -2
- package/dist/Equal.js.map +1 -1
- package/dist/ExecutionPlan.d.ts +73 -0
- package/dist/ExecutionPlan.d.ts.map +1 -1
- package/dist/ExecutionPlan.js +1 -1
- package/dist/ExecutionPlan.js.map +1 -1
- package/dist/FiberSet.js +1 -1
- package/dist/FileSystem.d.ts +2 -2
- package/dist/Function.d.ts +4 -3
- package/dist/Function.d.ts.map +1 -1
- package/dist/Function.js +5 -5
- package/dist/Function.js.map +1 -1
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +11 -10
- package/dist/Iterable.js.map +1 -1
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +7 -5
- package/dist/Layer.js.map +1 -1
- package/dist/Optic.d.ts +35 -21
- package/dist/Optic.d.ts.map +1 -1
- package/dist/Optic.js +33 -34
- package/dist/Optic.js.map +1 -1
- package/dist/Schedule.d.ts +8 -8
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +4 -4
- package/dist/Schedule.js.map +1 -1
- package/dist/Schema.d.ts +105 -57
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +105 -67
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +33 -3
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +87 -63
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaError.d.ts +8 -8
- package/dist/SchemaError.d.ts.map +1 -1
- package/dist/SchemaError.js +7 -6
- package/dist/SchemaError.js.map +1 -1
- package/dist/SchemaGetter.d.ts +8 -5
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +41 -37
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaIssue.d.ts +195 -38
- package/dist/SchemaIssue.d.ts.map +1 -1
- package/dist/SchemaIssue.js +243 -68
- package/dist/SchemaIssue.js.map +1 -1
- package/dist/SchemaParser.d.ts +30 -0
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +74 -62
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +2 -2
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +26 -26
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/ScopedCache.js +1 -1
- package/dist/ScopedCache.js.map +1 -1
- package/dist/Sink.d.ts +1 -1
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Stdio.d.ts +17 -4
- package/dist/Stdio.d.ts.map +1 -1
- package/dist/Stdio.js +6 -3
- package/dist/Stdio.js.map +1 -1
- package/dist/Stream.d.ts +27 -4
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +27 -2
- package/dist/Stream.js.map +1 -1
- package/dist/SynchronizedRef.js +1 -1
- package/dist/SynchronizedRef.js.map +1 -1
- package/dist/Terminal.js +1 -1
- package/dist/Terminal.js.map +1 -1
- package/dist/Tuple.d.ts +6 -4
- package/dist/Tuple.d.ts.map +1 -1
- package/dist/Tuple.js.map +1 -1
- package/dist/TxReentrantLock.d.ts +0 -56
- package/dist/TxReentrantLock.d.ts.map +1 -1
- package/dist/TxReentrantLock.js +8 -8
- package/dist/TxReentrantLock.js.map +1 -1
- package/dist/internal/dateTime.js +1 -1
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/executionPlan.js +51 -3
- package/dist/internal/executionPlan.js.map +1 -1
- package/dist/internal/hashMap.js +12 -8
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/matcher.js +1 -1
- package/dist/internal/matcher.js.map +1 -1
- package/dist/internal/schedule.js.map +1 -1
- package/dist/internal/schema/annotations.js +2 -0
- package/dist/internal/schema/annotations.js.map +1 -1
- package/dist/internal/schema/schema.js +1 -9
- package/dist/internal/schema/schema.js.map +1 -1
- package/dist/internal/schema/toArbitrary.js +1 -1
- package/dist/internal/schema/toArbitrary.js.map +1 -1
- package/dist/internal/trie.js +13 -3
- package/dist/internal/trie.js.map +1 -1
- package/dist/testing/TestClock.d.ts.map +1 -1
- package/dist/testing/TestClock.js +11 -1
- package/dist/testing/TestClock.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +2 -2
- package/dist/testing/TestSchema.d.ts.map +1 -1
- package/dist/testing/TestSchema.js +8 -7
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/unstable/ai/AiError.js +19 -19
- package/dist/unstable/ai/AiError.js.map +1 -1
- package/dist/unstable/ai/Chat.js +1 -1
- package/dist/unstable/ai/Chat.js.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +4 -2
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/ai/McpSchema.d.ts +132 -132
- package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
- package/dist/unstable/ai/McpSchema.js +8 -8
- package/dist/unstable/ai/McpSchema.js.map +1 -1
- package/dist/unstable/ai/McpServer.js +1 -1
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/ai/Prompt.d.ts +15 -3
- package/dist/unstable/ai/Prompt.d.ts.map +1 -1
- package/dist/unstable/ai/Prompt.js +10 -7
- package/dist/unstable/ai/Prompt.js.map +1 -1
- package/dist/unstable/cli/CliError.d.ts +3 -3
- package/dist/unstable/cli/CliError.js +11 -11
- package/dist/unstable/cli/CliError.js.map +1 -1
- package/dist/unstable/cli/Command.d.ts +9 -9
- package/dist/unstable/cli/Command.d.ts.map +1 -1
- package/dist/unstable/cli/Command.js +8 -6
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cli/Param.d.ts +7 -5
- package/dist/unstable/cli/Param.d.ts.map +1 -1
- package/dist/unstable/cli/Param.js +15 -11
- package/dist/unstable/cli/Param.js.map +1 -1
- package/dist/unstable/cli/Primitive.d.ts.map +1 -1
- package/dist/unstable/cli/Primitive.js +31 -24
- package/dist/unstable/cli/Primitive.js.map +1 -1
- package/dist/unstable/cli/Prompt.d.ts.map +1 -1
- package/dist/unstable/cli/Prompt.js +31 -17
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/cli/internal/ansi.js +2 -2
- package/dist/unstable/cli/internal/ansi.js.map +1 -1
- package/dist/unstable/cli/internal/command.d.ts +2 -2
- package/dist/unstable/cli/internal/command.d.ts.map +1 -1
- package/dist/unstable/cli/internal/command.js +10 -9
- package/dist/unstable/cli/internal/command.js.map +1 -1
- package/dist/unstable/cli/internal/completions/bash.js +69 -9
- package/dist/unstable/cli/internal/completions/bash.js.map +1 -1
- package/dist/unstable/cli/internal/completions/descriptor.js +24 -18
- package/dist/unstable/cli/internal/completions/descriptor.js.map +1 -1
- package/dist/unstable/cli/internal/completions/fish.js +5 -5
- package/dist/unstable/cli/internal/completions/fish.js.map +1 -1
- package/dist/unstable/cli/internal/help.d.ts.map +1 -1
- package/dist/unstable/cli/internal/help.js +4 -2
- package/dist/unstable/cli/internal/help.js.map +1 -1
- package/dist/unstable/cli/internal/parser.js +3 -3
- package/dist/unstable/cli/internal/parser.js.map +1 -1
- package/dist/unstable/cli/internal/wizard.js +2 -2
- package/dist/unstable/cli/internal/wizard.js.map +1 -1
- package/dist/unstable/cluster/ClusterError.js +7 -7
- package/dist/unstable/cluster/ClusterError.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/MessageStorage.js +8 -1
- package/dist/unstable/cluster/MessageStorage.js.map +1 -1
- package/dist/unstable/cluster/Reply.d.ts +8 -0
- package/dist/unstable/cluster/Reply.d.ts.map +1 -1
- package/dist/unstable/cluster/Reply.js +16 -4
- package/dist/unstable/cluster/Reply.js.map +1 -1
- package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerServer.js +4 -2
- package/dist/unstable/cluster/RunnerServer.js.map +1 -1
- package/dist/unstable/cluster/RunnerStorage.d.ts +1 -2
- package/dist/unstable/cluster/RunnerStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerStorage.js +7 -6
- package/dist/unstable/cluster/RunnerStorage.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +22 -4
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/internal/entityManager.js +1 -1
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/cluster/internal/resourceMap.js +2 -2
- package/dist/unstable/cluster/internal/resourceMap.js.map +1 -1
- package/dist/unstable/cluster/internal/resourceRef.js +17 -0
- package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
- package/dist/unstable/devtools/DevToolsClient.d.ts.map +1 -1
- package/dist/unstable/devtools/DevToolsClient.js +7 -2
- package/dist/unstable/devtools/DevToolsClient.js.map +1 -1
- package/dist/unstable/encoding/Ini.d.ts +20 -0
- package/dist/unstable/encoding/Ini.d.ts.map +1 -0
- package/dist/unstable/encoding/Ini.js +153 -0
- package/dist/unstable/encoding/Ini.js.map +1 -0
- package/dist/unstable/encoding/Msgpack.d.ts +2 -1
- package/dist/unstable/encoding/Msgpack.d.ts.map +1 -1
- package/dist/unstable/encoding/Msgpack.js +27 -13
- package/dist/unstable/encoding/Msgpack.js.map +1 -1
- package/dist/unstable/encoding/Ndjson.d.ts.map +1 -1
- package/dist/unstable/encoding/Ndjson.js +7 -1
- package/dist/unstable/encoding/Ndjson.js.map +1 -1
- package/dist/unstable/encoding/Sse.d.ts.map +1 -1
- package/dist/unstable/encoding/Sse.js +14 -23
- package/dist/unstable/encoding/Sse.js.map +1 -1
- package/dist/unstable/encoding/Toml.d.ts +19 -0
- package/dist/unstable/encoding/Toml.d.ts.map +1 -0
- package/dist/unstable/encoding/Toml.js +434 -0
- package/dist/unstable/encoding/Toml.js.map +1 -0
- package/dist/unstable/encoding/Yaml.d.ts +19 -0
- package/dist/unstable/encoding/Yaml.d.ts.map +1 -0
- package/dist/unstable/encoding/Yaml.js +461 -0
- package/dist/unstable/encoding/Yaml.js.map +1 -0
- package/dist/unstable/encoding/index.d.ts +12 -0
- package/dist/unstable/encoding/index.d.ts.map +1 -1
- package/dist/unstable/encoding/index.js +12 -0
- package/dist/unstable/encoding/index.js.map +1 -1
- package/dist/unstable/eventlog/EventJournal.d.ts +1 -1
- package/dist/unstable/eventlog/EventJournal.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventJournal.js +13 -5
- package/dist/unstable/eventlog/EventJournal.js.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.js +1 -1
- package/dist/unstable/eventlog/EventLogMessage.js.map +1 -1
- package/dist/unstable/eventlog/EventLogServerUnencrypted.js +1 -1
- package/dist/unstable/eventlog/EventLogServerUnencrypted.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventJournal.d.ts.map +1 -1
- package/dist/unstable/eventlog/SqlEventJournal.js +1 -4
- package/dist/unstable/eventlog/SqlEventJournal.js.map +1 -1
- package/dist/unstable/http/FindMyWay/internal/queryString.d.ts +11 -0
- package/dist/unstable/http/FindMyWay/internal/queryString.d.ts.map +1 -0
- package/dist/unstable/http/FindMyWay/internal/queryString.js +259 -0
- package/dist/unstable/http/FindMyWay/internal/queryString.js.map +1 -0
- package/dist/unstable/http/FindMyWay/internal/router.d.ts +2 -0
- package/dist/unstable/http/FindMyWay/internal/router.d.ts.map +1 -0
- package/dist/unstable/http/FindMyWay/internal/router.js +665 -0
- package/dist/unstable/http/FindMyWay/internal/router.js.map +1 -0
- package/dist/unstable/http/FindMyWay.d.ts +33 -8
- package/dist/unstable/http/FindMyWay.d.ts.map +1 -1
- package/dist/unstable/http/FindMyWay.js +4 -7
- package/dist/unstable/http/FindMyWay.js.map +1 -1
- package/dist/unstable/http/HttpClient.d.ts +59 -3
- package/dist/unstable/http/HttpClient.d.ts.map +1 -1
- package/dist/unstable/http/HttpClient.js +33 -19
- package/dist/unstable/http/HttpClient.js.map +1 -1
- package/dist/unstable/http/HttpClientError.js +1 -1
- package/dist/unstable/http/HttpClientError.js.map +1 -1
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.js +2 -14
- package/dist/unstable/http/HttpClientRequest.js.map +1 -1
- package/dist/unstable/http/HttpClientResponse.js +1 -16
- package/dist/unstable/http/HttpClientResponse.js.map +1 -1
- package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
- package/dist/unstable/http/HttpPlatform.js +21 -3
- package/dist/unstable/http/HttpPlatform.js.map +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRequest.js +7 -6
- package/dist/unstable/http/HttpServerRequest.js.map +1 -1
- package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerResponse.js +8 -6
- package/dist/unstable/http/HttpServerResponse.js.map +1 -1
- package/dist/unstable/http/Multipart.d.ts +1 -1
- package/dist/unstable/http/Multipart.d.ts.map +1 -1
- package/dist/unstable/http/Multipart.js +9 -2
- package/dist/unstable/http/Multipart.js.map +1 -1
- package/dist/unstable/http/MultipartParser/HeadersParser.d.ts +53 -0
- package/dist/unstable/http/MultipartParser/HeadersParser.d.ts.map +1 -0
- package/dist/unstable/http/MultipartParser/HeadersParser.js +14 -0
- package/dist/unstable/http/MultipartParser/HeadersParser.js.map +1 -0
- package/dist/unstable/http/MultipartParser/Search.d.ts +11 -0
- package/dist/unstable/http/MultipartParser/Search.d.ts.map +1 -0
- package/dist/unstable/http/MultipartParser/Search.js +14 -0
- package/dist/unstable/http/MultipartParser/Search.js.map +1 -0
- package/dist/unstable/http/MultipartParser/internal/contentType.d.ts +5 -0
- package/dist/unstable/http/MultipartParser/internal/contentType.d.ts.map +1 -0
- package/dist/unstable/http/MultipartParser/internal/contentType.js +82 -0
- package/dist/unstable/http/MultipartParser/internal/contentType.js.map +1 -0
- package/dist/unstable/http/MultipartParser/internal/headers.d.ts +3 -0
- package/dist/unstable/http/MultipartParser/internal/headers.d.ts.map +1 -0
- package/dist/unstable/http/MultipartParser/internal/headers.js +194 -0
- package/dist/unstable/http/MultipartParser/internal/headers.js.map +1 -0
- package/dist/unstable/http/MultipartParser/internal/multipart.d.ts +8 -0
- package/dist/unstable/http/MultipartParser/internal/multipart.d.ts.map +1 -0
- package/dist/unstable/http/MultipartParser/internal/multipart.js +226 -0
- package/dist/unstable/http/MultipartParser/internal/multipart.js.map +1 -0
- package/dist/unstable/http/MultipartParser/internal/search.d.ts +5 -0
- package/dist/unstable/http/MultipartParser/internal/search.d.ts.map +1 -0
- package/dist/unstable/http/MultipartParser/internal/search.js +120 -0
- package/dist/unstable/http/MultipartParser/internal/search.js.map +1 -0
- package/dist/unstable/http/MultipartParser.d.ts +98 -0
- package/dist/unstable/http/MultipartParser.d.ts.map +1 -0
- package/dist/unstable/http/MultipartParser.js +23 -0
- package/dist/unstable/http/MultipartParser.js.map +1 -0
- package/dist/unstable/http/Template.d.ts.map +1 -1
- package/dist/unstable/http/Template.js +2 -2
- package/dist/unstable/http/Template.js.map +1 -1
- package/dist/unstable/http/index.d.ts +1 -1
- package/dist/unstable/http/index.d.ts.map +1 -1
- package/dist/unstable/http/index.js +1 -1
- package/dist/unstable/http/index.js.map +1 -1
- package/dist/unstable/http/internal/httpBody.d.ts +2 -0
- package/dist/unstable/http/internal/httpBody.d.ts.map +1 -0
- package/dist/unstable/http/internal/httpBody.js +10 -0
- package/dist/unstable/http/internal/httpBody.js.map +1 -0
- package/dist/unstable/httpapi/HttpApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApi.js +5 -5
- package/dist/unstable/httpapi/HttpApi.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +73 -20
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.d.ts +1 -1
- package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js +74 -34
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +6 -4
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.js +73 -16
- package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.d.ts +5 -5
- package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.js +17 -17
- package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.js +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.d.ts +219 -0
- package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.js +170 -0
- package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts +8 -0
- package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/OpenApi.js +45 -18
- package/dist/unstable/httpapi/OpenApi.js.map +1 -1
- package/dist/unstable/observability/OtlpExporter.d.ts +1 -1
- package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.js +2 -1
- package/dist/unstable/observability/OtlpExporter.js.map +1 -1
- package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpLogger.js +2 -2
- package/dist/unstable/observability/OtlpLogger.js.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.d.ts +2 -2
- package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.js +28 -15
- package/dist/unstable/observability/OtlpMetrics.js.map +1 -1
- package/dist/unstable/observability/OtlpTracer.js +1 -1
- package/dist/unstable/observability/OtlpTracer.js.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.js +9 -9
- package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
- package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
- package/dist/unstable/persistence/Persistence.js +17 -7
- package/dist/unstable/persistence/Persistence.js.map +1 -1
- package/dist/unstable/persistence/RateLimiter.d.ts +22 -12
- package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
- package/dist/unstable/persistence/RateLimiter.js +15 -42
- package/dist/unstable/persistence/RateLimiter.js.map +1 -1
- package/dist/unstable/persistence/Redis.js +1 -1
- package/dist/unstable/persistence/Redis.js.map +1 -1
- package/dist/unstable/reactivity/AsyncResult.d.ts.map +1 -1
- package/dist/unstable/reactivity/AsyncResult.js +4 -4
- package/dist/unstable/reactivity/AsyncResult.js.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts +26 -11
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +9 -22
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts +14 -0
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +21 -10
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/rpc/RpcClientError.js +2 -2
- package/dist/unstable/rpc/RpcClientError.js.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.js +3 -1
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +3 -2
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/schema/Model.d.ts +1 -1
- package/dist/unstable/schema/Model.d.ts.map +1 -1
- package/dist/unstable/schema/VariantSchema.d.ts +5 -5
- package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
- package/dist/unstable/schema/VariantSchema.js +17 -9
- package/dist/unstable/schema/VariantSchema.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +28 -12
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
- package/dist/unstable/sql/SqlClient.js +7 -3
- package/dist/unstable/sql/SqlClient.js.map +1 -1
- package/dist/unstable/sql/SqlError.js +13 -13
- package/dist/unstable/sql/SqlError.js.map +1 -1
- package/dist/unstable/sql/SqlResolver.js +8 -6
- package/dist/unstable/sql/SqlResolver.js.map +1 -1
- package/dist/unstable/sql/Statement.d.ts.map +1 -1
- package/dist/unstable/sql/Statement.js +8 -6
- package/dist/unstable/sql/Statement.js.map +1 -1
- package/dist/unstable/workers/WorkerError.js +5 -5
- package/dist/unstable/workers/WorkerError.js.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
- package/dist/unstable/workflow/Workflow.js +2 -2
- package/dist/unstable/workflow/Workflow.js.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js +3 -3
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +6 -9
- package/src/Brand.ts +4 -4
- package/src/Cache.ts +1 -1
- package/src/Channel.ts +1 -1
- package/src/Config.ts +31 -8
- package/src/ConfigProvider.ts +4 -1
- package/src/Context.ts +6 -28
- package/src/Cron.ts +65 -2
- package/src/Crypto.ts +17 -8
- package/src/Duration.ts +16 -2
- package/src/Effect.ts +141 -17
- package/src/Equal.ts +10 -2
- package/src/ExecutionPlan.ts +78 -1
- package/src/FiberSet.ts +1 -1
- package/src/FileSystem.ts +2 -2
- package/src/Function.ts +6 -6
- package/src/Iterable.ts +11 -10
- package/src/Layer.ts +7 -5
- package/src/Optic.ts +59 -58
- package/src/Schedule.ts +13 -13
- package/src/Schema.ts +195 -112
- package/src/SchemaAST.ts +154 -85
- package/src/SchemaError.ts +9 -9
- package/src/SchemaGetter.ts +89 -30
- package/src/SchemaIssue.ts +285 -80
- package/src/SchemaParser.ts +126 -86
- package/src/SchemaTransformation.ts +66 -18
- package/src/ScopedCache.ts +1 -1
- package/src/Sink.ts +1 -1
- package/src/Stdio.ts +23 -4
- package/src/Stream.ts +77 -10
- package/src/SynchronizedRef.ts +1 -1
- package/src/Terminal.ts +1 -1
- package/src/Tuple.ts +7 -4
- package/src/TxReentrantLock.ts +39 -35
- package/src/internal/dateTime.ts +1 -1
- package/src/internal/executionPlan.ts +105 -10
- package/src/internal/hashMap.ts +20 -14
- package/src/internal/matcher.ts +2 -2
- package/src/internal/schedule.ts +4 -4
- package/src/internal/schema/annotations.ts +3 -0
- package/src/internal/schema/schema.ts +1 -17
- package/src/internal/schema/toArbitrary.ts +3 -1
- package/src/internal/trie.ts +12 -2
- package/src/testing/TestClock.ts +13 -1
- package/src/testing/TestSchema.ts +9 -9
- package/src/unstable/ai/AiError.ts +19 -19
- package/src/unstable/ai/Chat.ts +1 -1
- package/src/unstable/ai/LanguageModel.ts +4 -2
- package/src/unstable/ai/McpSchema.ts +17 -16
- package/src/unstable/ai/McpServer.ts +1 -1
- package/src/unstable/ai/Prompt.ts +35 -10
- package/src/unstable/cli/CliError.ts +12 -12
- package/src/unstable/cli/Command.ts +12 -10
- package/src/unstable/cli/Param.ts +41 -19
- package/src/unstable/cli/Primitive.ts +11 -5
- package/src/unstable/cli/Prompt.ts +36 -20
- package/src/unstable/cli/internal/ansi.ts +2 -2
- package/src/unstable/cli/internal/command.ts +15 -10
- package/src/unstable/cli/internal/completions/bash.ts +59 -9
- package/src/unstable/cli/internal/completions/descriptor.ts +14 -20
- package/src/unstable/cli/internal/completions/fish.ts +5 -7
- package/src/unstable/cli/internal/help.ts +4 -2
- package/src/unstable/cli/internal/parser.ts +3 -3
- package/src/unstable/cli/internal/wizard.ts +2 -2
- package/src/unstable/cluster/ClusterError.ts +7 -7
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +4 -1
- package/src/unstable/cluster/MessageStorage.ts +9 -5
- package/src/unstable/cluster/Reply.ts +25 -4
- package/src/unstable/cluster/RunnerServer.ts +4 -10
- package/src/unstable/cluster/RunnerStorage.ts +9 -7
- package/src/unstable/cluster/Sharding.ts +35 -7
- package/src/unstable/cluster/internal/entityManager.ts +1 -1
- package/src/unstable/cluster/internal/resourceMap.ts +5 -2
- package/src/unstable/cluster/internal/resourceRef.ts +27 -5
- package/src/unstable/devtools/DevToolsClient.ts +3 -2
- package/src/unstable/encoding/Ini.ts +174 -0
- package/src/unstable/encoding/Msgpack.ts +59 -36
- package/src/unstable/encoding/Ndjson.ts +9 -1
- package/src/unstable/encoding/Sse.ts +11 -21
- package/src/unstable/encoding/Toml.ts +504 -0
- package/src/unstable/encoding/Yaml.ts +541 -0
- package/src/unstable/encoding/index.ts +15 -0
- package/src/unstable/eventlog/EventJournal.ts +14 -6
- package/src/unstable/eventlog/EventLogMessage.ts +1 -1
- package/src/unstable/eventlog/EventLogServerUnencrypted.ts +1 -1
- package/src/unstable/eventlog/SqlEventJournal.ts +6 -4
- package/src/unstable/http/FindMyWay/internal/queryString.ts +420 -0
- package/src/unstable/http/FindMyWay/internal/router.ts +950 -0
- package/src/unstable/http/FindMyWay.ts +65 -6
- package/src/unstable/http/HttpClient.ts +132 -23
- package/src/unstable/http/HttpClientError.ts +1 -1
- package/src/unstable/http/HttpClientRequest.ts +2 -14
- package/src/unstable/http/HttpClientResponse.ts +1 -17
- package/src/unstable/http/HttpPlatform.ts +34 -6
- package/src/unstable/http/HttpServerRequest.ts +14 -6
- package/src/unstable/http/HttpServerResponse.ts +9 -7
- package/src/unstable/http/Multipart.ts +9 -2
- package/src/unstable/http/MultipartParser/HeadersParser.ts +68 -0
- package/src/unstable/http/MultipartParser/Search.ts +17 -0
- package/src/unstable/http/MultipartParser/internal/contentType.ts +103 -0
- package/src/unstable/http/MultipartParser/internal/headers.ts +615 -0
- package/src/unstable/http/MultipartParser/internal/multipart.ts +262 -0
- package/src/unstable/http/MultipartParser/internal/search.ts +167 -0
- package/src/unstable/http/MultipartParser.ts +115 -0
- package/src/unstable/http/Template.ts +6 -5
- package/src/unstable/http/index.ts +1 -1
- package/src/unstable/http/internal/httpBody.ts +15 -0
- package/src/unstable/httpapi/HttpApi.ts +6 -7
- package/src/unstable/httpapi/HttpApiBuilder.ts +142 -25
- package/src/unstable/httpapi/HttpApiClient.ts +130 -49
- package/src/unstable/httpapi/HttpApiEndpoint.ts +117 -29
- package/src/unstable/httpapi/HttpApiError.ts +33 -39
- package/src/unstable/httpapi/HttpApiMiddleware.ts +1 -1
- package/src/unstable/httpapi/HttpApiSchema.ts +353 -0
- package/src/unstable/httpapi/OpenApi.ts +70 -20
- package/src/unstable/observability/OtlpExporter.ts +4 -2
- package/src/unstable/observability/OtlpLogger.ts +3 -1
- package/src/unstable/observability/OtlpMetrics.ts +32 -18
- package/src/unstable/observability/OtlpTracer.ts +1 -1
- package/src/unstable/persistence/PersistedQueue.ts +12 -9
- package/src/unstable/persistence/Persistence.ts +27 -7
- package/src/unstable/persistence/RateLimiter.ts +54 -31
- package/src/unstable/persistence/Redis.ts +1 -1
- package/src/unstable/reactivity/AsyncResult.ts +11 -6
- package/src/unstable/reactivity/Atom.ts +44 -25
- package/src/unstable/rpc/RpcClient.ts +42 -13
- package/src/unstable/rpc/RpcClientError.ts +2 -2
- package/src/unstable/rpc/RpcSerialization.ts +1 -1
- package/src/unstable/rpc/RpcServer.ts +4 -2
- package/src/unstable/schema/VariantSchema.ts +36 -18
- package/src/unstable/socket/Socket.ts +24 -14
- package/src/unstable/sql/SqlClient.ts +65 -56
- package/src/unstable/sql/SqlError.ts +13 -13
- package/src/unstable/sql/SqlResolver.ts +8 -6
- package/src/unstable/sql/Statement.ts +13 -8
- package/src/unstable/workers/WorkerError.ts +5 -5
- package/src/unstable/workflow/Workflow.ts +2 -5
- package/src/unstable/workflow/WorkflowEngine.ts +8 -3
- package/dist/unstable/http/Multipasta/HeadersParser.d.ts +0 -14
- package/dist/unstable/http/Multipasta/HeadersParser.d.ts.map +0 -1
- package/dist/unstable/http/Multipasta/HeadersParser.js +0 -14
- package/dist/unstable/http/Multipasta/HeadersParser.js.map +0 -1
- package/dist/unstable/http/Multipasta/Node.d.ts +0 -14
- package/dist/unstable/http/Multipasta/Node.d.ts.map +0 -1
- package/dist/unstable/http/Multipasta/Node.js +0 -14
- package/dist/unstable/http/Multipasta/Node.js.map +0 -1
- package/dist/unstable/http/Multipasta/Search.d.ts +0 -14
- package/dist/unstable/http/Multipasta/Search.d.ts.map +0 -1
- package/dist/unstable/http/Multipasta/Search.js +0 -14
- package/dist/unstable/http/Multipasta/Search.js.map +0 -1
- package/dist/unstable/http/Multipasta/Web.d.ts +0 -14
- package/dist/unstable/http/Multipasta/Web.d.ts.map +0 -1
- package/dist/unstable/http/Multipasta/Web.js +0 -14
- package/dist/unstable/http/Multipasta/Web.js.map +0 -1
- package/dist/unstable/http/Multipasta.d.ts +0 -15
- package/dist/unstable/http/Multipasta.d.ts.map +0 -1
- package/dist/unstable/http/Multipasta.js +0 -15
- package/dist/unstable/http/Multipasta.js.map +0 -1
- package/src/unstable/http/Multipasta/HeadersParser.ts +0 -14
- package/src/unstable/http/Multipasta/Node.ts +0 -14
- package/src/unstable/http/Multipasta/Search.ts +0 -14
- package/src/unstable/http/Multipasta/Web.ts +0 -14
- package/src/unstable/http/Multipasta.ts +0 -15
|
@@ -71,8 +71,8 @@ export type AggregationTemporality = "cumulative" | "delta"
|
|
|
71
71
|
*
|
|
72
72
|
* The exporter snapshots registered Effect metrics on the configured interval, serializes them with the selected aggregation temporality, and flushes during scope finalization up to `shutdownTimeout`.
|
|
73
73
|
* Manual flushing also triggers a snapshot. With delta temporality, each
|
|
74
|
-
*
|
|
75
|
-
* delta aggregation windows.
|
|
74
|
+
* successful export advances the previous-export state, so frequent successful
|
|
75
|
+
* flushes narrow the delta aggregation windows.
|
|
76
76
|
*
|
|
77
77
|
* @category constructors
|
|
78
78
|
* @since 4.0.0
|
|
@@ -108,15 +108,22 @@ export const make: (options: {
|
|
|
108
108
|
|
|
109
109
|
// State for delta temporality tracking
|
|
110
110
|
let previousExportTimeNanos: bigint = startTimeNanos
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
111
|
+
let previousCounterState = new Map<string, number | bigint>()
|
|
112
|
+
let previousHistogramState = new Map<string, PreviousHistogramState>()
|
|
113
|
+
let previousFrequencyState = new Map<string, Map<string, number>>()
|
|
114
|
+
let previousSummaryState = new Map<string, PreviousSummaryState>()
|
|
115
|
+
let snapshotSequence = 0
|
|
116
|
+
let committedSnapshotSequence = -1
|
|
117
|
+
|
|
118
|
+
const snapshot = (): readonly [body: HttpBody, onSuccess: Effect.Effect<void>] => {
|
|
117
119
|
const snapshot = Metric.snapshotUnsafe(services)
|
|
120
|
+
const currentSnapshotSequence = snapshotSequence++
|
|
118
121
|
const nowNanos = clock.currentTimeNanosUnsafe()
|
|
119
122
|
const nowTime = String(nowNanos)
|
|
123
|
+
const nextCounterState = new Map(previousCounterState)
|
|
124
|
+
const nextHistogramState = new Map(previousHistogramState)
|
|
125
|
+
const nextFrequencyState = new Map(previousFrequencyState)
|
|
126
|
+
const nextSummaryState = new Map(previousSummaryState)
|
|
120
127
|
const metricData: Array<IMetric> = []
|
|
121
128
|
const metricDataByName = new Map<string, IMetric>()
|
|
122
129
|
const addMetricData = (data: IMetric) => {
|
|
@@ -162,7 +169,7 @@ export const make: (options: {
|
|
|
162
169
|
}
|
|
163
170
|
}
|
|
164
171
|
}
|
|
165
|
-
|
|
172
|
+
nextCounterState.set(metricKey, currentCount)
|
|
166
173
|
}
|
|
167
174
|
|
|
168
175
|
const dataPoint: INumberDataPoint = {
|
|
@@ -253,7 +260,7 @@ export const make: (options: {
|
|
|
253
260
|
// Note: This is a limitation - true delta min/max would require tracking
|
|
254
261
|
// observations within each interval
|
|
255
262
|
}
|
|
256
|
-
|
|
263
|
+
nextHistogramState.set(metricKey, {
|
|
257
264
|
count: state.state.count,
|
|
258
265
|
sum: state.state.sum,
|
|
259
266
|
bucketCounts: currentBuckets.counts.slice(),
|
|
@@ -314,7 +321,7 @@ export const make: (options: {
|
|
|
314
321
|
}
|
|
315
322
|
|
|
316
323
|
if (isDelta) {
|
|
317
|
-
|
|
324
|
+
nextFrequencyState.set(metricKey, currentOccurrences)
|
|
318
325
|
}
|
|
319
326
|
|
|
320
327
|
if (metricDataByName.has(state.id)) {
|
|
@@ -366,7 +373,7 @@ export const make: (options: {
|
|
|
366
373
|
reportCount = state.state.count - previousState.count
|
|
367
374
|
reportSum = state.state.sum - previousState.sum
|
|
368
375
|
}
|
|
369
|
-
|
|
376
|
+
nextSummaryState.set(metricKey, {
|
|
370
377
|
count: state.state.count,
|
|
371
378
|
sum: state.state.sum
|
|
372
379
|
})
|
|
@@ -426,12 +433,7 @@ export const make: (options: {
|
|
|
426
433
|
}
|
|
427
434
|
}
|
|
428
435
|
|
|
429
|
-
|
|
430
|
-
if (isDelta) {
|
|
431
|
-
previousExportTimeNanos = nowNanos
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
return serialization.metrics({
|
|
436
|
+
const body = serialization.metrics({
|
|
435
437
|
resourceMetrics: [{
|
|
436
438
|
resource,
|
|
437
439
|
scopeMetrics: [{
|
|
@@ -440,6 +442,18 @@ export const make: (options: {
|
|
|
440
442
|
}]
|
|
441
443
|
}]
|
|
442
444
|
})
|
|
445
|
+
const onSuccess = isDelta
|
|
446
|
+
? Effect.sync(() => {
|
|
447
|
+
if (currentSnapshotSequence < committedSnapshotSequence) return
|
|
448
|
+
previousCounterState = nextCounterState
|
|
449
|
+
previousHistogramState = nextHistogramState
|
|
450
|
+
previousFrequencyState = nextFrequencyState
|
|
451
|
+
previousSummaryState = nextSummaryState
|
|
452
|
+
previousExportTimeNanos = nowNanos
|
|
453
|
+
committedSnapshotSequence = currentSnapshotSequence
|
|
454
|
+
})
|
|
455
|
+
: Effect.void
|
|
456
|
+
return [body, onSuccess]
|
|
443
457
|
}
|
|
444
458
|
|
|
445
459
|
yield* Exporter.make({
|
|
@@ -217,7 +217,7 @@ export type ErrorTypeId = "~@effect/experimental/PersistedQueue/PersistedQueueEr
|
|
|
217
217
|
* @category errors
|
|
218
218
|
* @since 4.0.0
|
|
219
219
|
*/
|
|
220
|
-
export class PersistedQueueError extends Schema.
|
|
220
|
+
export class PersistedQueueError extends Schema.Error<PersistedQueueError>(
|
|
221
221
|
"effect/persistence/PersistedQueue/PersistedQueueError"
|
|
222
222
|
)({
|
|
223
223
|
_tag: Schema.tag("PersistedQueueError"),
|
|
@@ -294,9 +294,9 @@ export const layerStoreMemory: Layer.Layer<
|
|
|
294
294
|
attempts: number
|
|
295
295
|
readonly element: unknown
|
|
296
296
|
}
|
|
297
|
-
const ids = new Set<string>()
|
|
298
297
|
const queues = new Map<string, {
|
|
299
298
|
latch: Latch.Latch
|
|
299
|
+
ids: Set<string>
|
|
300
300
|
items: Set<Entry>
|
|
301
301
|
}>()
|
|
302
302
|
const getOrCreateQueue = (name: string) => {
|
|
@@ -304,6 +304,7 @@ export const layerStoreMemory: Layer.Layer<
|
|
|
304
304
|
if (!queue) {
|
|
305
305
|
queue = {
|
|
306
306
|
latch: Latch.makeUnsafe(false),
|
|
307
|
+
ids: new Set(),
|
|
307
308
|
items: new Set()
|
|
308
309
|
}
|
|
309
310
|
queues.set(name, queue)
|
|
@@ -314,9 +315,9 @@ export const layerStoreMemory: Layer.Layer<
|
|
|
314
315
|
return PersistedQueueStore.of({
|
|
315
316
|
offer: (options) =>
|
|
316
317
|
Effect.sync(() => {
|
|
317
|
-
if (ids.has(options.id)) return
|
|
318
|
-
ids.add(options.id)
|
|
319
318
|
const queue = getOrCreateQueue(options.name)
|
|
319
|
+
if (queue.ids.has(options.id)) return
|
|
320
|
+
queue.ids.add(options.id)
|
|
320
321
|
queue.items.add({ id: options.id, attempts: 0, element: options.element })
|
|
321
322
|
queue.latch.openUnsafe()
|
|
322
323
|
}),
|
|
@@ -857,9 +858,11 @@ export const makeStoreSql: (
|
|
|
857
858
|
yield* sql.onDialectOrElse({
|
|
858
859
|
mssql: () =>
|
|
859
860
|
sql`IF NOT EXISTS (SELECT * FROM sys.indexes WHERE name = N'idx_${tableName}_id')
|
|
860
|
-
CREATE UNIQUE INDEX idx_${tableNameSql}_id ON ${tableNameSql} (id)`,
|
|
861
|
-
mysql: () =>
|
|
862
|
-
|
|
861
|
+
CREATE UNIQUE INDEX idx_${tableNameSql}_id ON ${tableNameSql} (id, queue_name)`,
|
|
862
|
+
mysql: () =>
|
|
863
|
+
sql`CREATE UNIQUE INDEX ${sql(`idx_${tableName}_id`)} ON ${tableNameSql} (id, queue_name)`.pipe(Effect.ignore),
|
|
864
|
+
orElse: () =>
|
|
865
|
+
sql`CREATE UNIQUE INDEX IF NOT EXISTS ${sql(`idx_${tableName}_id`)} ON ${tableNameSql} (id, queue_name)`
|
|
863
866
|
})
|
|
864
867
|
|
|
865
868
|
yield* sql.onDialectOrElse({
|
|
@@ -894,7 +897,7 @@ export const makeStoreSql: (
|
|
|
894
897
|
sql`
|
|
895
898
|
INSERT INTO ${tableNameSql} (id, queue_name, element, completed, attempts, created_at, updated_at)
|
|
896
899
|
VALUES (${id}, ${name}, ${element}, FALSE, 0, ${sqlNow}, ${sqlNow})
|
|
897
|
-
ON CONFLICT (id) DO NOTHING
|
|
900
|
+
ON CONFLICT (id, queue_name) DO NOTHING
|
|
898
901
|
`,
|
|
899
902
|
mysql: () => (id: string, name: string, element: string) =>
|
|
900
903
|
sql`
|
|
@@ -903,7 +906,7 @@ export const makeStoreSql: (
|
|
|
903
906
|
`,
|
|
904
907
|
mssql: () => (id: string, name: string, element: string) =>
|
|
905
908
|
sql`
|
|
906
|
-
IF NOT EXISTS (SELECT 1 FROM ${tableNameSql} WHERE id = ${id})
|
|
909
|
+
IF NOT EXISTS (SELECT 1 FROM ${tableNameSql} WHERE id = ${id} AND queue_name = ${name})
|
|
907
910
|
BEGIN
|
|
908
911
|
INSERT INTO ${tableNameSql} (id, queue_name, element, completed, attempts, created_at, updated_at)
|
|
909
912
|
VALUES (${id}, ${name}, ${element}, 0, 0, ${sqlNow}, ${sqlNow})
|
|
@@ -35,7 +35,7 @@ const ErrorTypeId = "~effect/persistence/Persistence/PersistenceError" as const
|
|
|
35
35
|
* @category errors
|
|
36
36
|
* @since 4.0.0
|
|
37
37
|
*/
|
|
38
|
-
export class PersistenceError extends Schema.
|
|
38
|
+
export class PersistenceError extends Schema.Error<PersistenceError>(ErrorTypeId)({
|
|
39
39
|
_tag: Schema.tag("PersistenceError"),
|
|
40
40
|
message: Schema.String,
|
|
41
41
|
cause: Schema.optional(Schema.Defect())
|
|
@@ -304,7 +304,8 @@ export const layerBackingSqlMultiTable: Layer.Layer<
|
|
|
304
304
|
return BackingPersistence.of({
|
|
305
305
|
make: Effect.fnUntraced(function*(storeId) {
|
|
306
306
|
const clock = yield* Clock.Clock
|
|
307
|
-
const
|
|
307
|
+
const tableName = `effect_persistence_${storeId}`
|
|
308
|
+
const table = sql(tableName)
|
|
308
309
|
yield* sql.onDialectOrElse({
|
|
309
310
|
mysql: () =>
|
|
310
311
|
sql`
|
|
@@ -324,7 +325,7 @@ export const layerBackingSqlMultiTable: Layer.Layer<
|
|
|
324
325
|
`,
|
|
325
326
|
mssql: () =>
|
|
326
327
|
sql`
|
|
327
|
-
IF NOT EXISTS (SELECT * FROM sysobjects WHERE name=${
|
|
328
|
+
IF NOT EXISTS (SELECT * FROM sysobjects WHERE name=${tableName} AND xtype='U')
|
|
328
329
|
CREATE TABLE ${table} (
|
|
329
330
|
id NVARCHAR(450) PRIMARY KEY,
|
|
330
331
|
value NVARCHAR(MAX) NOT NULL,
|
|
@@ -362,6 +363,20 @@ export const layerBackingSqlMultiTable: Layer.Layer<
|
|
|
362
363
|
INSERT INTO ${table} ${sql.insert(entries)}
|
|
363
364
|
ON DUPLICATE KEY UPDATE value=VALUES(value), expires=VALUES(expires)
|
|
364
365
|
`.unprepared,
|
|
366
|
+
mssql: (): UpsertFn => (entries) =>
|
|
367
|
+
Effect.forEach(
|
|
368
|
+
entries,
|
|
369
|
+
(entry) =>
|
|
370
|
+
sql`
|
|
371
|
+
MERGE ${table} AS target
|
|
372
|
+
USING (SELECT ${entry.id} AS id, ${entry.value} AS value, ${entry.expires} AS expires) AS source
|
|
373
|
+
ON target.id = source.id
|
|
374
|
+
WHEN MATCHED THEN UPDATE SET value = source.value, expires = source.expires
|
|
375
|
+
WHEN NOT MATCHED THEN INSERT (id, value, expires)
|
|
376
|
+
VALUES (source.id, source.value, source.expires);
|
|
377
|
+
`,
|
|
378
|
+
{ discard: true }
|
|
379
|
+
),
|
|
365
380
|
// sqlite
|
|
366
381
|
orElse: (): UpsertFn => (entries) =>
|
|
367
382
|
sql`
|
|
@@ -538,7 +553,7 @@ export const layerBackingSql: Layer.Layer<
|
|
|
538
553
|
`,
|
|
539
554
|
mssql: () =>
|
|
540
555
|
sql`
|
|
541
|
-
IF NOT EXISTS (SELECT * FROM sysobjects WHERE name=${
|
|
556
|
+
IF NOT EXISTS (SELECT * FROM sysobjects WHERE name=${"effect_persistence"} AND xtype='U')
|
|
542
557
|
CREATE TABLE ${table} (
|
|
543
558
|
store_id NVARCHAR(191) NOT NULL,
|
|
544
559
|
id NVARCHAR(191) NOT NULL,
|
|
@@ -928,7 +943,13 @@ export const layerBackingRedis: Layer.Layer<
|
|
|
928
943
|
Effect.mapError(
|
|
929
944
|
ttl === undefined
|
|
930
945
|
? redis.send("SET", prefixed(key), JSON.stringify(value))
|
|
931
|
-
: redis.send(
|
|
946
|
+
: redis.send(
|
|
947
|
+
"SET",
|
|
948
|
+
prefixed(key),
|
|
949
|
+
JSON.stringify(value),
|
|
950
|
+
"PX",
|
|
951
|
+
String(Math.ceil(Duration.toMillis(ttl)))
|
|
952
|
+
),
|
|
932
953
|
({ cause }) =>
|
|
933
954
|
new PersistenceError({
|
|
934
955
|
message: `Failed to set key ${key} in Redis`,
|
|
@@ -943,7 +964,7 @@ export const layerBackingRedis: Layer.Layer<
|
|
|
943
964
|
const pkey = prefixed(key)
|
|
944
965
|
sets.set(pkey, JSON.stringify(value))
|
|
945
966
|
if (ttl) {
|
|
946
|
-
expires.set(pkey, Duration.toMillis(ttl))
|
|
967
|
+
expires.set(pkey, Math.ceil(Duration.toMillis(ttl)))
|
|
947
968
|
}
|
|
948
969
|
}
|
|
949
970
|
return Effect.mapError(
|
|
@@ -1090,7 +1111,6 @@ export const layerBackingKvs: Layer.Layer<
|
|
|
1090
1111
|
setMany: (entries) =>
|
|
1091
1112
|
Effect.forEach(entries, ([key, value, ttl]) => {
|
|
1092
1113
|
const expires = unsafeTtlToExpires(clock, ttl)
|
|
1093
|
-
if (expires === null) return Effect.void
|
|
1094
1114
|
const encoded = JSON.stringify([value, expires])
|
|
1095
1115
|
return store.set(key, encoded)
|
|
1096
1116
|
}, { concurrency: "unbounded", discard: true }).pipe(
|
|
@@ -285,7 +285,7 @@ export const makeWithRateLimiter: Effect.Effect<
|
|
|
285
285
|
)
|
|
286
286
|
|
|
287
287
|
/**
|
|
288
|
-
*
|
|
288
|
+
* Sleeps when the rate limit is exceeded.
|
|
289
289
|
*
|
|
290
290
|
* **Example** (Sleeping until rate limit permits)
|
|
291
291
|
*
|
|
@@ -294,52 +294,75 @@ export const makeWithRateLimiter: Effect.Effect<
|
|
|
294
294
|
* import { RateLimiter } from "effect/unstable/persistence"
|
|
295
295
|
*
|
|
296
296
|
* const program = Effect.gen(function*() {
|
|
297
|
-
*
|
|
298
|
-
* const
|
|
299
|
-
*
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
*
|
|
297
|
+
* const limiter = yield* RateLimiter.RateLimiter
|
|
298
|
+
* const partiallyApplied = RateLimiter.sleep(limiter)
|
|
299
|
+
* const partial = yield* partiallyApplied({
|
|
300
|
+
* key: "partial",
|
|
301
|
+
* limit: 10,
|
|
302
|
+
* window: "5 seconds",
|
|
303
|
+
* algorithm: "fixed-window"
|
|
304
|
+
* })
|
|
305
|
+
* const direct = yield* RateLimiter.sleep(limiter, {
|
|
306
|
+
* key: "direct",
|
|
304
307
|
* limit: 10,
|
|
305
308
|
* window: "5 seconds",
|
|
306
309
|
* algorithm: "fixed-window"
|
|
307
310
|
* })
|
|
308
|
-
* return
|
|
311
|
+
* return [partial.remaining, direct.remaining]
|
|
309
312
|
* }).pipe(
|
|
310
313
|
* Effect.provide(RateLimiter.layer.pipe(Layer.provide(RateLimiter.layerStoreMemory)))
|
|
311
314
|
* )
|
|
312
315
|
*
|
|
313
|
-
* await Effect.runPromise(program) // => 9
|
|
316
|
+
* await Effect.runPromise(program) // => [9, 9]
|
|
314
317
|
* ```
|
|
315
318
|
*
|
|
316
319
|
* @category accessors
|
|
317
320
|
* @since 4.0.0
|
|
318
321
|
*/
|
|
319
|
-
export
|
|
320
|
-
|
|
322
|
+
export function sleep(self: RateLimiter): (options: {
|
|
323
|
+
readonly algorithm?: "fixed-window" | "token-bucket" | undefined
|
|
324
|
+
readonly window: Duration.Input
|
|
325
|
+
readonly limit: number
|
|
326
|
+
readonly key: string
|
|
327
|
+
readonly tokens?: number | undefined
|
|
328
|
+
}) => Effect.Effect<ConsumeResult, RateLimiterError>
|
|
329
|
+
export function sleep(self: RateLimiter, options: {
|
|
330
|
+
readonly algorithm?: "fixed-window" | "token-bucket" | undefined
|
|
331
|
+
readonly window: Duration.Input
|
|
332
|
+
readonly limit: number
|
|
333
|
+
readonly key: string
|
|
334
|
+
readonly tokens?: number | undefined
|
|
335
|
+
}): Effect.Effect<ConsumeResult, RateLimiterError>
|
|
336
|
+
export function sleep(self: RateLimiter, options?: {
|
|
337
|
+
readonly algorithm?: "fixed-window" | "token-bucket" | undefined
|
|
338
|
+
readonly window: Duration.Input
|
|
339
|
+
readonly limit: number
|
|
340
|
+
readonly key: string
|
|
341
|
+
readonly tokens?: number | undefined
|
|
342
|
+
}):
|
|
343
|
+
| Effect.Effect<ConsumeResult, RateLimiterError>
|
|
344
|
+
| ((options: {
|
|
321
345
|
readonly algorithm?: "fixed-window" | "token-bucket" | undefined
|
|
322
346
|
readonly window: Duration.Input
|
|
323
347
|
readonly limit: number
|
|
324
348
|
readonly key: string
|
|
325
349
|
readonly tokens?: number | undefined
|
|
326
|
-
}) => Effect.Effect<ConsumeResult, RateLimiterError>)
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
)
|
|
350
|
+
}) => Effect.Effect<ConsumeResult, RateLimiterError>)
|
|
351
|
+
{
|
|
352
|
+
if (options === undefined) {
|
|
353
|
+
return (options) => sleep(self, options)
|
|
354
|
+
}
|
|
355
|
+
return Effect.flatMap(
|
|
356
|
+
self.consume({
|
|
357
|
+
...options,
|
|
358
|
+
onExceeded: "delay"
|
|
359
|
+
}),
|
|
360
|
+
(result) => {
|
|
361
|
+
if (Duration.isZero(result.delay)) return Effect.succeed(result)
|
|
362
|
+
return Effect.as(Effect.sleep(result.delay), result)
|
|
363
|
+
}
|
|
341
364
|
)
|
|
342
|
-
|
|
365
|
+
}
|
|
343
366
|
|
|
344
367
|
/**
|
|
345
368
|
* Runtime type identifier for `RateLimiterError`.
|
|
@@ -367,7 +390,7 @@ export type ErrorTypeId = "~@effect/experimental/RateLimiter/RateLimiterError"
|
|
|
367
390
|
* @category errors
|
|
368
391
|
* @since 4.0.0
|
|
369
392
|
*/
|
|
370
|
-
export class RateLimitExceeded extends Schema.
|
|
393
|
+
export class RateLimitExceeded extends Schema.Error<RateLimitExceeded>(
|
|
371
394
|
"effect/persistence/RateLimiter/RateLimitExceeded"
|
|
372
395
|
)({
|
|
373
396
|
_tag: Schema.tag("RateLimitExceeded"),
|
|
@@ -392,7 +415,7 @@ export class RateLimitExceeded extends Schema.ErrorClass<RateLimitExceeded>(
|
|
|
392
415
|
* @category errors
|
|
393
416
|
* @since 4.0.0
|
|
394
417
|
*/
|
|
395
|
-
export class RateLimitStoreError extends Schema.
|
|
418
|
+
export class RateLimitStoreError extends Schema.Error<RateLimitStoreError>(
|
|
396
419
|
"effect/persistence/RateLimiter/RateLimitStoreError"
|
|
397
420
|
)({
|
|
398
421
|
_tag: Schema.tag("RateLimitStoreError"),
|
|
@@ -426,7 +449,7 @@ export const RateLimiterErrorReason: Schema.Union<[
|
|
|
426
449
|
* @category errors
|
|
427
450
|
* @since 4.0.0
|
|
428
451
|
*/
|
|
429
|
-
export class RateLimiterError extends Schema.
|
|
452
|
+
export class RateLimiterError extends Schema.Error<RateLimiterError>(ErrorTypeId)({
|
|
430
453
|
_tag: Schema.tag("RateLimiterError"),
|
|
431
454
|
reason: RateLimiterErrorReason
|
|
432
455
|
}) {
|
|
@@ -100,7 +100,7 @@ const ErrorTypeId: ErrorTypeId = "~effect/persistence/Redis/RedisError"
|
|
|
100
100
|
* @category errors
|
|
101
101
|
* @since 4.0.0
|
|
102
102
|
*/
|
|
103
|
-
export class RedisError extends Schema.
|
|
103
|
+
export class RedisError extends Schema.Error<RedisError>(ErrorTypeId)({
|
|
104
104
|
_tag: Schema.tag("RedisError"),
|
|
105
105
|
cause: Schema.Defect()
|
|
106
106
|
}) {
|
|
@@ -1101,7 +1101,7 @@ export const Schema = <
|
|
|
1101
1101
|
[success_, Schema_.Cause(error, Schema_.Defect())],
|
|
1102
1102
|
([value, cause]) => (input, ast, options) => {
|
|
1103
1103
|
if (!isAsyncResult(input)) {
|
|
1104
|
-
return Effect.fail(new SchemaIssue.InvalidType(ast))
|
|
1104
|
+
return Effect.fail(new SchemaIssue.InvalidType(ast, input, options))
|
|
1105
1105
|
}
|
|
1106
1106
|
switch (input._tag) {
|
|
1107
1107
|
case "Initial":
|
|
@@ -1111,7 +1111,7 @@ export const Schema = <
|
|
|
1111
1111
|
SchemaParser.decodeUnknownEffect(value)(input.value, options),
|
|
1112
1112
|
{
|
|
1113
1113
|
onSuccess: (value) => success(value, input),
|
|
1114
|
-
onFailure: (issue) =>
|
|
1114
|
+
onFailure: (issue) => SchemaIssue.makeCompositeAtKey(ast, "value", issue, input, options)
|
|
1115
1115
|
}
|
|
1116
1116
|
)
|
|
1117
1117
|
case "Failure": {
|
|
@@ -1122,9 +1122,14 @@ export const Schema = <
|
|
|
1122
1122
|
{
|
|
1123
1123
|
onSuccess: (value) => Option.some(success<A["Type"], E["Type"]>(value, ps)),
|
|
1124
1124
|
onFailure: (issue) =>
|
|
1125
|
-
new SchemaIssue.Composite(
|
|
1126
|
-
|
|
1127
|
-
|
|
1125
|
+
new SchemaIssue.Composite(
|
|
1126
|
+
ast,
|
|
1127
|
+
[
|
|
1128
|
+
new SchemaIssue.Pointer(["previousSuccess", "value"], issue)
|
|
1129
|
+
],
|
|
1130
|
+
input,
|
|
1131
|
+
options
|
|
1132
|
+
)
|
|
1128
1133
|
}
|
|
1129
1134
|
)
|
|
1130
1135
|
),
|
|
@@ -1132,7 +1137,7 @@ export const Schema = <
|
|
|
1132
1137
|
)
|
|
1133
1138
|
const causeEffect = Effect.mapErrorEager(
|
|
1134
1139
|
SchemaParser.decodeUnknownEffect(cause)(input.cause, options),
|
|
1135
|
-
(issue) =>
|
|
1140
|
+
(issue) => SchemaIssue.makeCompositeAtKey(ast, "cause", issue, input, options)
|
|
1136
1141
|
)
|
|
1137
1142
|
return Effect.flatMapEager(
|
|
1138
1143
|
prevSuccessEffect,
|
|
@@ -790,7 +790,7 @@ export interface AtomRuntime<R, ER = never> extends Atom<AsyncResult.AsyncResult
|
|
|
790
790
|
}
|
|
791
791
|
|
|
792
792
|
/**
|
|
793
|
-
* Factory for `AtomRuntime` values that share a
|
|
793
|
+
* Factory for `AtomRuntime` values that share a set of global layers.
|
|
794
794
|
*
|
|
795
795
|
* @category models
|
|
796
796
|
* @since 4.0.0
|
|
@@ -801,7 +801,6 @@ export interface RuntimeFactory {
|
|
|
801
801
|
| Layer.Layer<R, E, AtomRegistry | Reactivity.Reactivity>
|
|
802
802
|
| ((get: AtomContext) => Layer.Layer<R, E, AtomRegistry | Reactivity.Reactivity>)
|
|
803
803
|
): AtomRuntime<R, E>
|
|
804
|
-
readonly memoMap: Layer.MemoMap
|
|
805
804
|
readonly addGlobalLayer: <A, E>(layer: Layer.Layer<A, E, AtomRegistry | Reactivity.Reactivity>) => void
|
|
806
805
|
|
|
807
806
|
/**
|
|
@@ -814,14 +813,40 @@ export interface RuntimeFactory {
|
|
|
814
813
|
}
|
|
815
814
|
|
|
816
815
|
/**
|
|
817
|
-
*
|
|
816
|
+
* A `RuntimeFactory` backed by an atom whose memo map is scoped to each registry.
|
|
818
817
|
*
|
|
819
|
-
* @category
|
|
818
|
+
* @category models
|
|
820
819
|
* @since 4.0.0
|
|
821
820
|
*/
|
|
822
|
-
export
|
|
821
|
+
export interface RegistryRuntimeFactory extends RuntimeFactory {
|
|
822
|
+
readonly memoMap: Atom<Layer.MemoMap>
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
/**
|
|
826
|
+
* A `RuntimeFactory` backed by a concrete memo map shared across registries.
|
|
827
|
+
*
|
|
828
|
+
* @category models
|
|
829
|
+
* @since 4.0.0
|
|
830
|
+
*/
|
|
831
|
+
export interface SharedRuntimeFactory extends RuntimeFactory {
|
|
823
832
|
readonly memoMap: Layer.MemoMap
|
|
824
|
-
}
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* Creates a `RuntimeFactory` backed by a registry-scoped memo map by default,
|
|
837
|
+
* or by the supplied atom or concrete `Layer.MemoMap`.
|
|
838
|
+
*
|
|
839
|
+
* @category constructors
|
|
840
|
+
* @since 4.0.0
|
|
841
|
+
*/
|
|
842
|
+
export function context(): RegistryRuntimeFactory
|
|
843
|
+
export function context(options: { readonly memoMap: Atom<Layer.MemoMap> }): RegistryRuntimeFactory
|
|
844
|
+
export function context(options: { readonly memoMap: Layer.MemoMap }): SharedRuntimeFactory
|
|
845
|
+
export function context(options?: {
|
|
846
|
+
readonly memoMap: Atom<Layer.MemoMap> | Layer.MemoMap
|
|
847
|
+
}): RegistryRuntimeFactory | SharedRuntimeFactory {
|
|
848
|
+
const memoMap = options?.memoMap ?? removeTtl(make(() => Layer.makeMemoMapUnsafe()))
|
|
849
|
+
const resolveMemoMap = (get: AtomContext): Layer.MemoMap => isAtom(memoMap) ? get(memoMap) : memoMap
|
|
825
850
|
let globalLayer: Layer.Layer<any, any, AtomRegistry> = Reactivity.layer
|
|
826
851
|
function factory<E, R>(
|
|
827
852
|
create:
|
|
@@ -843,23 +868,25 @@ export const context: (options: {
|
|
|
843
868
|
|
|
844
869
|
self.read = function read(get: AtomContext) {
|
|
845
870
|
const layer = get(layerAtom)
|
|
846
|
-
const build = Effect.flatMap(Effect.scope, (scope) => Layer.buildWithMemoMap(layer,
|
|
871
|
+
const build = Effect.flatMap(Effect.scope, (scope) => Layer.buildWithMemoMap(layer, resolveMemoMap(get), scope))
|
|
847
872
|
return effect(get, build, { uninterruptible: true })
|
|
848
873
|
}
|
|
849
874
|
|
|
850
875
|
return self
|
|
851
876
|
}
|
|
852
|
-
factory.memoMap =
|
|
877
|
+
factory.memoMap = memoMap
|
|
853
878
|
factory.addGlobalLayer = (layer: Layer.Layer<any, any, AtomRegistry | Reactivity.Reactivity>) => {
|
|
854
879
|
globalLayer = Layer.provideMerge(globalLayer, Layer.provide(layer, Reactivity.layer))
|
|
855
880
|
}
|
|
856
|
-
const reactivityAtom = removeTtl(
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
881
|
+
const reactivityAtom = removeTtl(
|
|
882
|
+
make((get) =>
|
|
883
|
+
Effect.contextWith((services: Context.Context<Scope.Scope>) =>
|
|
884
|
+
Layer.buildWithMemoMap(Reactivity.layer, resolveMemoMap(get), Context.get(services, Scope.Scope))
|
|
885
|
+
).pipe(
|
|
886
|
+
Effect.map(Context.get(Reactivity.Reactivity))
|
|
887
|
+
)
|
|
861
888
|
)
|
|
862
|
-
)
|
|
889
|
+
)
|
|
863
890
|
factory.withReactivity =
|
|
864
891
|
(keys: ReadonlyArray<unknown> | ReadonlyRecord<string, ReadonlyArray<unknown>>) =>
|
|
865
892
|
<A extends Atom<any>>(atom: A): A =>
|
|
@@ -871,24 +898,16 @@ export const context: (options: {
|
|
|
871
898
|
get.subscribe(atom, (value) => get.setSelf(value))
|
|
872
899
|
return get.once(atom)
|
|
873
900
|
}, { initialValueTarget: atom }) as any as A
|
|
874
|
-
return factory
|
|
901
|
+
return factory as any
|
|
875
902
|
}
|
|
876
903
|
|
|
877
904
|
/**
|
|
878
|
-
* Default
|
|
879
|
-
*
|
|
880
|
-
* @category context
|
|
881
|
-
* @since 4.0.0
|
|
882
|
-
*/
|
|
883
|
-
export const defaultMemoMap: Layer.MemoMap = Layer.makeMemoMapUnsafe()
|
|
884
|
-
|
|
885
|
-
/**
|
|
886
|
-
* Default `RuntimeFactory` created with `defaultMemoMap`.
|
|
905
|
+
* Default registry-scoped `RuntimeFactory`.
|
|
887
906
|
*
|
|
888
907
|
* @category context
|
|
889
908
|
* @since 4.0.0
|
|
890
909
|
*/
|
|
891
|
-
export const runtime:
|
|
910
|
+
export const runtime: RegistryRuntimeFactory = context()
|
|
892
911
|
|
|
893
912
|
/**
|
|
894
913
|
* Returns `Rx.runtime.withReactivity` for refreshing an atom whenever the
|