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
package/src/Effect.ts
CHANGED
|
@@ -15,7 +15,7 @@ import type * as Cause from "./Cause.ts"
|
|
|
15
15
|
import type { Clock } from "./Clock.ts"
|
|
16
16
|
import * as Context from "./Context.ts"
|
|
17
17
|
import * as Duration from "./Duration.ts"
|
|
18
|
-
import type
|
|
18
|
+
import type * as ExecutionPlan from "./ExecutionPlan.ts"
|
|
19
19
|
import * as Exit from "./Exit.ts"
|
|
20
20
|
import type { Fiber } from "./Fiber.ts"
|
|
21
21
|
import type * as Filter from "./Filter.ts"
|
|
@@ -7790,6 +7790,14 @@ export const ignoreCause: <
|
|
|
7790
7790
|
* and retry timing is derived per step (the first attempt uses the remaining
|
|
7791
7791
|
* attempts schedule; later retries apply the step schedule at least once).
|
|
7792
7792
|
*
|
|
7793
|
+
* Attempts can be observed from outside the effect by passing
|
|
7794
|
+
* `options.onEvent`, which receives an `ExecutionPlan.Event` before each
|
|
7795
|
+
* attempt and after it settles. The handler is awaited inline before and after
|
|
7796
|
+
* every attempt, so events are strictly ordered; keep it cheap. It cannot
|
|
7797
|
+
* fail, which keeps observation from changing the plan's outcome, and its
|
|
7798
|
+
* requirements are added to the resulting effect. Terminal events run like
|
|
7799
|
+
* finalizers, so they are emitted even when the attempt is interrupted.
|
|
7800
|
+
*
|
|
7793
7801
|
* **Example** (Retrying with an execution plan)
|
|
7794
7802
|
*
|
|
7795
7803
|
* ```ts import.meta.vitest
|
|
@@ -7814,6 +7822,36 @@ export const ignoreCause: <
|
|
|
7814
7822
|
* Effect.runSync(program) // => "good"
|
|
7815
7823
|
* ```
|
|
7816
7824
|
*
|
|
7825
|
+
* **Example** (Observing execution-plan attempts)
|
|
7826
|
+
*
|
|
7827
|
+
* ```ts import.meta.vitest
|
|
7828
|
+
* import { Context, Effect, ExecutionPlan, Layer } from "effect"
|
|
7829
|
+
*
|
|
7830
|
+
* const Endpoint = Context.Service<{ url: string }>("Endpoint")
|
|
7831
|
+
*
|
|
7832
|
+
* const fetchUrl = Effect.gen(function*() {
|
|
7833
|
+
* const endpoint = yield* Effect.service(Endpoint)
|
|
7834
|
+
* if (endpoint.url === "bad") {
|
|
7835
|
+
* return yield* Effect.fail("Unavailable")
|
|
7836
|
+
* }
|
|
7837
|
+
* return endpoint.url
|
|
7838
|
+
* })
|
|
7839
|
+
*
|
|
7840
|
+
* const plan = ExecutionPlan.make(
|
|
7841
|
+
* { provide: Layer.succeed(Endpoint, { url: "bad" }) },
|
|
7842
|
+
* { provide: Layer.succeed(Endpoint, { url: "good" }) }
|
|
7843
|
+
* )
|
|
7844
|
+
*
|
|
7845
|
+
* const events: Array<string> = []
|
|
7846
|
+
* const program = Effect.withExecutionPlan(fetchUrl, plan, {
|
|
7847
|
+
* onEvent: (event) => Effect.sync(() => events.push(`${event._tag}:${event.stepIndex}`))
|
|
7848
|
+
* })
|
|
7849
|
+
*
|
|
7850
|
+
* await Effect.runPromise(program) // => "good"
|
|
7851
|
+
*
|
|
7852
|
+
* events // => ["AttemptStart:0", "AttemptFailure:0", "AttemptStart:1", "AttemptSuccess:1"]
|
|
7853
|
+
* ```
|
|
7854
|
+
*
|
|
7817
7855
|
* @category error handling
|
|
7818
7856
|
* @since 3.16.0
|
|
7819
7857
|
*/
|
|
@@ -7828,6 +7866,14 @@ export const withExecutionPlan: {
|
|
|
7828
7866
|
* and retry timing is derived per step (the first attempt uses the remaining
|
|
7829
7867
|
* attempts schedule; later retries apply the step schedule at least once).
|
|
7830
7868
|
*
|
|
7869
|
+
* Attempts can be observed from outside the effect by passing
|
|
7870
|
+
* `options.onEvent`, which receives an `ExecutionPlan.Event` before each
|
|
7871
|
+
* attempt and after it settles. The handler is awaited inline before and after
|
|
7872
|
+
* every attempt, so events are strictly ordered; keep it cheap. It cannot
|
|
7873
|
+
* fail, which keeps observation from changing the plan's outcome, and its
|
|
7874
|
+
* requirements are added to the resulting effect. Terminal events run like
|
|
7875
|
+
* finalizers, so they are emitted even when the attempt is interrupted.
|
|
7876
|
+
*
|
|
7831
7877
|
* **Example** (Retrying with an execution plan)
|
|
7832
7878
|
*
|
|
7833
7879
|
* ```ts import.meta.vitest
|
|
@@ -7852,14 +7898,47 @@ export const withExecutionPlan: {
|
|
|
7852
7898
|
* Effect.runSync(program) // => "good"
|
|
7853
7899
|
* ```
|
|
7854
7900
|
*
|
|
7901
|
+
* **Example** (Observing execution-plan attempts)
|
|
7902
|
+
*
|
|
7903
|
+
* ```ts import.meta.vitest
|
|
7904
|
+
* import { Context, Effect, ExecutionPlan, Layer } from "effect"
|
|
7905
|
+
*
|
|
7906
|
+
* const Endpoint = Context.Service<{ url: string }>("Endpoint")
|
|
7907
|
+
*
|
|
7908
|
+
* const fetchUrl = Effect.gen(function*() {
|
|
7909
|
+
* const endpoint = yield* Effect.service(Endpoint)
|
|
7910
|
+
* if (endpoint.url === "bad") {
|
|
7911
|
+
* return yield* Effect.fail("Unavailable")
|
|
7912
|
+
* }
|
|
7913
|
+
* return endpoint.url
|
|
7914
|
+
* })
|
|
7915
|
+
*
|
|
7916
|
+
* const plan = ExecutionPlan.make(
|
|
7917
|
+
* { provide: Layer.succeed(Endpoint, { url: "bad" }) },
|
|
7918
|
+
* { provide: Layer.succeed(Endpoint, { url: "good" }) }
|
|
7919
|
+
* )
|
|
7920
|
+
*
|
|
7921
|
+
* const events: Array<string> = []
|
|
7922
|
+
* const program = Effect.withExecutionPlan(fetchUrl, plan, {
|
|
7923
|
+
* onEvent: (event) => Effect.sync(() => events.push(`${event._tag}:${event.stepIndex}`))
|
|
7924
|
+
* })
|
|
7925
|
+
*
|
|
7926
|
+
* await Effect.runPromise(program) // => "good"
|
|
7927
|
+
*
|
|
7928
|
+
* events // => ["AttemptStart:0", "AttemptFailure:0", "AttemptStart:1", "AttemptSuccess:1"]
|
|
7929
|
+
* ```
|
|
7930
|
+
*
|
|
7855
7931
|
* @category error handling
|
|
7856
7932
|
* @since 3.16.0
|
|
7857
7933
|
*/
|
|
7858
|
-
<Input, Provides, PlanE, PlanR>(
|
|
7859
|
-
plan: ExecutionPlan<{ provides: Provides; input: Input; error: PlanE; requirements: PlanR }
|
|
7934
|
+
<Input, Provides, PlanE, PlanR, RX = never>(
|
|
7935
|
+
plan: ExecutionPlan.ExecutionPlan<{ provides: Provides; input: Input; error: PlanE; requirements: PlanR }>,
|
|
7936
|
+
options?: {
|
|
7937
|
+
readonly onEvent?: ((event: ExecutionPlan.Event<Input | PlanE>) => Effect<void, never, RX>) | undefined
|
|
7938
|
+
}
|
|
7860
7939
|
): <A, E extends Input, R>(
|
|
7861
7940
|
effect: Effect<A, E, R>
|
|
7862
|
-
) => Effect<A, E | PlanE, Exclude<R, Provides> | PlanR>
|
|
7941
|
+
) => Effect<A, E | PlanE, Exclude<R, Provides> | PlanR | RX>
|
|
7863
7942
|
/**
|
|
7864
7943
|
* Applies an `ExecutionPlan` to an effect, retrying with step-provided resources
|
|
7865
7944
|
* until it succeeds or the plan is exhausted.
|
|
@@ -7870,6 +7949,14 @@ export const withExecutionPlan: {
|
|
|
7870
7949
|
* and retry timing is derived per step (the first attempt uses the remaining
|
|
7871
7950
|
* attempts schedule; later retries apply the step schedule at least once).
|
|
7872
7951
|
*
|
|
7952
|
+
* Attempts can be observed from outside the effect by passing
|
|
7953
|
+
* `options.onEvent`, which receives an `ExecutionPlan.Event` before each
|
|
7954
|
+
* attempt and after it settles. The handler is awaited inline before and after
|
|
7955
|
+
* every attempt, so events are strictly ordered; keep it cheap. It cannot
|
|
7956
|
+
* fail, which keeps observation from changing the plan's outcome, and its
|
|
7957
|
+
* requirements are added to the resulting effect. Terminal events run like
|
|
7958
|
+
* finalizers, so they are emitted even when the attempt is interrupted.
|
|
7959
|
+
*
|
|
7873
7960
|
* **Example** (Retrying with an execution plan)
|
|
7874
7961
|
*
|
|
7875
7962
|
* ```ts import.meta.vitest
|
|
@@ -7894,13 +7981,46 @@ export const withExecutionPlan: {
|
|
|
7894
7981
|
* Effect.runSync(program) // => "good"
|
|
7895
7982
|
* ```
|
|
7896
7983
|
*
|
|
7984
|
+
* **Example** (Observing execution-plan attempts)
|
|
7985
|
+
*
|
|
7986
|
+
* ```ts import.meta.vitest
|
|
7987
|
+
* import { Context, Effect, ExecutionPlan, Layer } from "effect"
|
|
7988
|
+
*
|
|
7989
|
+
* const Endpoint = Context.Service<{ url: string }>("Endpoint")
|
|
7990
|
+
*
|
|
7991
|
+
* const fetchUrl = Effect.gen(function*() {
|
|
7992
|
+
* const endpoint = yield* Effect.service(Endpoint)
|
|
7993
|
+
* if (endpoint.url === "bad") {
|
|
7994
|
+
* return yield* Effect.fail("Unavailable")
|
|
7995
|
+
* }
|
|
7996
|
+
* return endpoint.url
|
|
7997
|
+
* })
|
|
7998
|
+
*
|
|
7999
|
+
* const plan = ExecutionPlan.make(
|
|
8000
|
+
* { provide: Layer.succeed(Endpoint, { url: "bad" }) },
|
|
8001
|
+
* { provide: Layer.succeed(Endpoint, { url: "good" }) }
|
|
8002
|
+
* )
|
|
8003
|
+
*
|
|
8004
|
+
* const events: Array<string> = []
|
|
8005
|
+
* const program = Effect.withExecutionPlan(fetchUrl, plan, {
|
|
8006
|
+
* onEvent: (event) => Effect.sync(() => events.push(`${event._tag}:${event.stepIndex}`))
|
|
8007
|
+
* })
|
|
8008
|
+
*
|
|
8009
|
+
* await Effect.runPromise(program) // => "good"
|
|
8010
|
+
*
|
|
8011
|
+
* events // => ["AttemptStart:0", "AttemptFailure:0", "AttemptStart:1", "AttemptSuccess:1"]
|
|
8012
|
+
* ```
|
|
8013
|
+
*
|
|
7897
8014
|
* @category error handling
|
|
7898
8015
|
* @since 3.16.0
|
|
7899
8016
|
*/
|
|
7900
|
-
<A, E extends Input, R, Provides, Input, PlanE, PlanR>(
|
|
8017
|
+
<A, E extends Input, R, Provides, Input, PlanE, PlanR, RX = never>(
|
|
7901
8018
|
effect: Effect<A, E, R>,
|
|
7902
|
-
plan: ExecutionPlan<{ provides: Provides; input: Input; error: PlanE; requirements: PlanR }
|
|
7903
|
-
|
|
8019
|
+
plan: ExecutionPlan.ExecutionPlan<{ provides: Provides; input: Input; error: PlanE; requirements: PlanR }>,
|
|
8020
|
+
options?: {
|
|
8021
|
+
readonly onEvent?: ((event: ExecutionPlan.Event<E | PlanE>) => Effect<void, never, RX>) | undefined
|
|
8022
|
+
}
|
|
8023
|
+
): Effect<A, E | PlanE, Exclude<R, Provides> | PlanR | RX>
|
|
7904
8024
|
} = internalExecutionPlan.withExecutionPlan
|
|
7905
8025
|
|
|
7906
8026
|
/**
|
|
@@ -12005,7 +12125,7 @@ export const updateService: {
|
|
|
12005
12125
|
* @category providing services
|
|
12006
12126
|
* @since 2.0.0
|
|
12007
12127
|
*/
|
|
12008
|
-
<I, A>(service: Context.Key<I, A>, f: (value: A) => A): <XA, E, R>(self: Effect<XA, E, R>) => Effect<XA, E, R | I>
|
|
12128
|
+
<I, A>(service: Context.Key<I, A>, f: (value: A) => NoInfer<A>): <XA, E, R>(self: Effect<XA, E, R>) => Effect<XA, E, R | I>
|
|
12009
12129
|
/**
|
|
12010
12130
|
* Runs an effect with a service implementation transformed by the provided
|
|
12011
12131
|
* function.
|
|
@@ -12041,7 +12161,11 @@ export const updateService: {
|
|
|
12041
12161
|
* @category providing services
|
|
12042
12162
|
* @since 2.0.0
|
|
12043
12163
|
*/
|
|
12044
|
-
<XA, E, R, I, A>(
|
|
12164
|
+
<XA, E, R, I, A>(
|
|
12165
|
+
self: Effect<XA, E, R>,
|
|
12166
|
+
service: Context.Key<I, A>,
|
|
12167
|
+
f: (value: A) => NoInfer<A>
|
|
12168
|
+
): Effect<XA, E, R | I>
|
|
12045
12169
|
} = internal.updateService
|
|
12046
12170
|
|
|
12047
12171
|
/**
|
|
@@ -12105,7 +12229,7 @@ export const updateService: {
|
|
|
12105
12229
|
*/
|
|
12106
12230
|
export const updateServiceScoped: <I, A>(
|
|
12107
12231
|
service: Context.Key<I, A>,
|
|
12108
|
-
f: (value: A) => A
|
|
12232
|
+
f: (value: A) => NoInfer<A>,
|
|
12109
12233
|
options?: {
|
|
12110
12234
|
readonly reset?: ((original: A, updated: A, current: A) => A) | undefined
|
|
12111
12235
|
} | undefined
|
|
@@ -12513,7 +12637,7 @@ export const provideServiceEffect: {
|
|
|
12513
12637
|
* @category providing services
|
|
12514
12638
|
* @since 2.0.0
|
|
12515
12639
|
*/
|
|
12516
|
-
<I, S, E2, R2>(service: Context.Key<I, S>, acquire: Effect<S
|
|
12640
|
+
<I, S, E2, R2>(service: Context.Key<I, S>, acquire: Effect<NoInfer<S>, E2, R2>): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E | E2, Exclude<R, I> | R2>
|
|
12517
12641
|
/**
|
|
12518
12642
|
* Provides one service to an effect using an effectful acquisition.
|
|
12519
12643
|
*
|
|
@@ -12572,7 +12696,7 @@ export const provideServiceEffect: {
|
|
|
12572
12696
|
<A, E, R, I, S, E2, R2>(
|
|
12573
12697
|
self: Effect<A, E, R>,
|
|
12574
12698
|
service: Context.Key<I, S>,
|
|
12575
|
-
acquire: Effect<S
|
|
12699
|
+
acquire: Effect<NoInfer<S>, E2, R2>
|
|
12576
12700
|
): Effect<A, E | E2, Exclude<R, I> | R2>
|
|
12577
12701
|
} = internal.provideServiceEffect
|
|
12578
12702
|
|
|
@@ -15378,7 +15502,7 @@ export const schedule: {
|
|
|
15378
15502
|
* @category repetition
|
|
15379
15503
|
* @since 2.0.0
|
|
15380
15504
|
*/
|
|
15381
|
-
<Output, Error, Env>(schedule: Schedule<Output, unknown, Error, Env>): <A, E, R>(self: Effect<A, E, R>) => Effect<Output, E, R | Env>
|
|
15505
|
+
<Output, Error, Env>(schedule: Schedule<Output, unknown, Error, Env>): <A, E, R>(self: Effect<A, E, R>) => Effect<Output, E | Error, R | Env>
|
|
15382
15506
|
/**
|
|
15383
15507
|
* Runs an effect repeatedly according to a schedule and returns the schedule's
|
|
15384
15508
|
* final output.
|
|
@@ -15419,11 +15543,11 @@ export const schedule: {
|
|
|
15419
15543
|
* @category repetition
|
|
15420
15544
|
* @since 2.0.0
|
|
15421
15545
|
*/
|
|
15422
|
-
<A, E, R, Output, Error, Env>(self: Effect<A, E, R>, schedule: Schedule<Output, unknown, Error, Env>): Effect<Output, E, R | Env>
|
|
15546
|
+
<A, E, R, Output, Error, Env>(self: Effect<A, E, R>, schedule: Schedule<Output, unknown, Error, Env>): Effect<Output, E | Error, R | Env>
|
|
15423
15547
|
} = dual(2, <A, E, R, Output, Error, Env>(
|
|
15424
15548
|
self: Effect<A, E, R>,
|
|
15425
15549
|
schedule: Schedule<Output, unknown, Error, Env>
|
|
15426
|
-
): Effect<Output, E, R | Env> => scheduleFrom(self, undefined, schedule))
|
|
15550
|
+
): Effect<Output, E | Error, R | Env> => scheduleFrom(self, undefined, schedule))
|
|
15427
15551
|
|
|
15428
15552
|
/**
|
|
15429
15553
|
* Runs an effect repeatedly according to a schedule that is initialized with a
|
|
@@ -15502,7 +15626,7 @@ export const scheduleFrom: {
|
|
|
15502
15626
|
* @category repetition
|
|
15503
15627
|
* @since 2.0.0
|
|
15504
15628
|
*/
|
|
15505
|
-
<Input, Output, Error, Env>(initial: Input, schedule: Schedule<Output, Input, Error, Env>): <E, R>(self: Effect<Input, E, R>) => Effect<Output, E, R | Env>
|
|
15629
|
+
<Input, Output, Error, Env>(initial: Input, schedule: Schedule<Output, Input, Error, Env>): <E, R>(self: Effect<Input, E, R>) => Effect<Output, E | Error, R | Env>
|
|
15506
15630
|
/**
|
|
15507
15631
|
* Runs an effect repeatedly according to a schedule that is initialized with a
|
|
15508
15632
|
* specific schedule input.
|
|
@@ -15545,7 +15669,7 @@ export const scheduleFrom: {
|
|
|
15545
15669
|
self: Effect<Input, E, R>,
|
|
15546
15670
|
initial: Input,
|
|
15547
15671
|
schedule: Schedule<Output, Input, Error, Env>
|
|
15548
|
-
): Effect<Output, E, R | Env>
|
|
15672
|
+
): Effect<Output, E | Error, R | Env>
|
|
15549
15673
|
} = internalSchedule.scheduleFrom
|
|
15550
15674
|
|
|
15551
15675
|
// -----------------------------------------------------------------------------
|
package/src/Equal.ts
CHANGED
|
@@ -360,10 +360,14 @@ function compareRecords(
|
|
|
360
360
|
/** @internal */
|
|
361
361
|
export function makeCompareMap<K, V>(keyEquivalence: Equivalence<K>, valueEquivalence: Equivalence<V>) {
|
|
362
362
|
return function compareMaps(self: Iterable<[K, V]>, that: Iterable<[K, V]>): boolean {
|
|
363
|
+
const thatEntries = Array.from(that)
|
|
363
364
|
for (const [selfKey, selfValue] of self) {
|
|
364
365
|
let found = false
|
|
365
|
-
for (
|
|
366
|
+
for (let i = 0; i < thatEntries.length; i++) {
|
|
367
|
+
const [thatKey, thatValue] = thatEntries[i]
|
|
366
368
|
if (keyEquivalence(selfKey, thatKey) && valueEquivalence(selfValue, thatValue)) {
|
|
369
|
+
thatEntries[i] = thatEntries[thatEntries.length - 1]
|
|
370
|
+
thatEntries.pop()
|
|
367
371
|
found = true
|
|
368
372
|
break
|
|
369
373
|
}
|
|
@@ -382,10 +386,14 @@ const compareMaps = makeCompareMap(compareBoth, compareBoth)
|
|
|
382
386
|
/** @internal */
|
|
383
387
|
export function makeCompareSet<A>(equivalence: Equivalence<A>) {
|
|
384
388
|
return function compareSets(self: Iterable<A>, that: Iterable<A>): boolean {
|
|
389
|
+
const thatValues = Array.from(that)
|
|
385
390
|
for (const selfValue of self) {
|
|
386
391
|
let found = false
|
|
387
|
-
for (
|
|
392
|
+
for (let i = 0; i < thatValues.length; i++) {
|
|
393
|
+
const thatValue = thatValues[i]
|
|
388
394
|
if (equivalence(selfValue, thatValue)) {
|
|
395
|
+
thatValues[i] = thatValues[thatValues.length - 1]
|
|
396
|
+
thatValues.pop()
|
|
389
397
|
found = true
|
|
390
398
|
break
|
|
391
399
|
}
|
package/src/ExecutionPlan.ts
CHANGED
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
* @since 3.16.0
|
|
11
11
|
*/
|
|
12
12
|
import type { NonEmptyReadonlyArray } from "./Array.ts"
|
|
13
|
+
import type * as Cause from "./Cause.ts"
|
|
13
14
|
import * as Context from "./Context.ts"
|
|
15
|
+
import type * as Duration from "./Duration.ts"
|
|
14
16
|
import type * as Effect from "./Effect.ts"
|
|
15
17
|
import { constant } from "./Function.ts"
|
|
16
18
|
import * as effect from "./internal/effect.ts"
|
|
@@ -179,7 +181,7 @@ export const make = <const Steps extends NonEmptyReadonlyArray<make.Step>>(
|
|
|
179
181
|
| (Steps[number]["schedule"] extends Schedule.Schedule<infer _O, infer _I, infer R> ? R : never)
|
|
180
182
|
}> =>
|
|
181
183
|
makeProto(steps.map((options, i) => {
|
|
182
|
-
if (options.attempts && options.attempts < 1) {
|
|
184
|
+
if (options.attempts !== undefined && options.attempts < 1) {
|
|
183
185
|
throw new Error(`ExecutionPlan.make: step[${i}].attempts must be greater than 0`)
|
|
184
186
|
}
|
|
185
187
|
return {
|
|
@@ -372,3 +374,78 @@ export const CurrentMetadata = Context.Reference<Metadata>("effect/ExecutionPlan
|
|
|
372
374
|
stepIndex: 0
|
|
373
375
|
})
|
|
374
376
|
})
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Lifecycle event emitted before an execution-plan attempt runs.
|
|
380
|
+
*
|
|
381
|
+
* **Details**
|
|
382
|
+
*
|
|
383
|
+
* `attempt` is the cumulative 1-based attempt number across all steps and
|
|
384
|
+
* matches `CurrentMetadata.attempt` for the same attempt. `stepAttempt` is the
|
|
385
|
+
* 1-based attempt number within the current step, and `stepIndex` is the
|
|
386
|
+
* 0-based index of the step being attempted.
|
|
387
|
+
*
|
|
388
|
+
* @category models
|
|
389
|
+
* @since 4.0.0
|
|
390
|
+
*/
|
|
391
|
+
export interface AttemptStart {
|
|
392
|
+
readonly _tag: "AttemptStart"
|
|
393
|
+
readonly attempt: number
|
|
394
|
+
readonly stepAttempt: number
|
|
395
|
+
readonly stepIndex: number
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Lifecycle event emitted when an execution-plan attempt succeeds.
|
|
400
|
+
*
|
|
401
|
+
* **Details**
|
|
402
|
+
*
|
|
403
|
+
* A successful attempt completes the plan, so this is always the final event.
|
|
404
|
+
* `duration` is the elapsed time of the attempt.
|
|
405
|
+
*
|
|
406
|
+
* @category models
|
|
407
|
+
* @since 4.0.0
|
|
408
|
+
*/
|
|
409
|
+
export interface AttemptSuccess {
|
|
410
|
+
readonly _tag: "AttemptSuccess"
|
|
411
|
+
readonly attempt: number
|
|
412
|
+
readonly stepAttempt: number
|
|
413
|
+
readonly stepIndex: number
|
|
414
|
+
readonly duration: Duration.Duration
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Lifecycle event emitted when an execution-plan attempt fails.
|
|
419
|
+
*
|
|
420
|
+
* **Details**
|
|
421
|
+
*
|
|
422
|
+
* `cause` holds the full failure cause, so defects and interruption are
|
|
423
|
+
* reported as well as expected errors. Whether the plan retries or fails over
|
|
424
|
+
* afterwards is decided by the step's `attempts`, `while`, and `schedule`; a
|
|
425
|
+
* following `AttemptStart` indicates another attempt was made.
|
|
426
|
+
*
|
|
427
|
+
* @category models
|
|
428
|
+
* @since 4.0.0
|
|
429
|
+
*/
|
|
430
|
+
export interface AttemptFailure<E> {
|
|
431
|
+
readonly _tag: "AttemptFailure"
|
|
432
|
+
readonly attempt: number
|
|
433
|
+
readonly stepAttempt: number
|
|
434
|
+
readonly stepIndex: number
|
|
435
|
+
readonly duration: Duration.Duration
|
|
436
|
+
readonly cause: Cause.Cause<E>
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Union of the lifecycle events emitted while an execution plan runs.
|
|
441
|
+
*
|
|
442
|
+
* **Details**
|
|
443
|
+
*
|
|
444
|
+
* Every `AttemptStart` is followed by exactly one terminal event, either
|
|
445
|
+
* `AttemptSuccess` or `AttemptFailure`. An interrupted attempt emits
|
|
446
|
+
* `AttemptFailure` with the interruption cause.
|
|
447
|
+
*
|
|
448
|
+
* @category models
|
|
449
|
+
* @since 4.0.0
|
|
450
|
+
*/
|
|
451
|
+
export type Event<E> = AttemptStart | AttemptSuccess | AttemptFailure<E>
|
package/src/FiberSet.ts
CHANGED
package/src/FileSystem.ts
CHANGED
|
@@ -1010,7 +1010,7 @@ export const isFile = (u: unknown): u is File => hasProperty(u, FileTypeId)
|
|
|
1010
1010
|
* const file: FileSystem.File = {
|
|
1011
1011
|
* [FileSystem.FileTypeId]: FileSystem.FileTypeId,
|
|
1012
1012
|
* stat: Effect.succeed({ size: FileSystem.Size(5) } as FileSystem.File.Info),
|
|
1013
|
-
* seek: () => Effect.
|
|
1013
|
+
* seek: () => Effect.succeed(FileSystem.Size(0)),
|
|
1014
1014
|
* sync: Effect.void,
|
|
1015
1015
|
* read: (buffer) => Effect.sync(() => {
|
|
1016
1016
|
* buffer.set([1, 2, 3, 4, 5])
|
|
@@ -1040,7 +1040,7 @@ export const isFile = (u: unknown): u is File => hasProperty(u, FileTypeId)
|
|
|
1040
1040
|
export interface File {
|
|
1041
1041
|
readonly [FileTypeId]: typeof FileTypeId
|
|
1042
1042
|
readonly stat: Effect.Effect<File.Info, PlatformError>
|
|
1043
|
-
readonly seek: (offset: SizeInput, from: SeekMode) => Effect.Effect<
|
|
1043
|
+
readonly seek: (offset: SizeInput, from: SeekMode) => Effect.Effect<Size>
|
|
1044
1044
|
readonly sync: Effect.Effect<void, PlatformError>
|
|
1045
1045
|
readonly read: (buffer: Uint8Array) => Effect.Effect<Size, PlatformError>
|
|
1046
1046
|
readonly readAlloc: (size: SizeInput) => Effect.Effect<Option.Option<Uint8Array>, PlatformError>
|
package/src/Function.ts
CHANGED
|
@@ -1493,11 +1493,12 @@ export const SK = <A, B>(_: A, b: B): B => b
|
|
|
1493
1493
|
* **Details**
|
|
1494
1494
|
*
|
|
1495
1495
|
* Each memoized wrapper owns a private `WeakMap` keyed by object identity.
|
|
1496
|
-
* Cached `undefined` results are still returned because the cache is checked
|
|
1497
|
-
* with `WeakMap.has`.
|
|
1498
1496
|
*
|
|
1499
1497
|
* **Gotchas**
|
|
1500
1498
|
*
|
|
1499
|
+
* `undefined` is reserved to represent a cache miss and is therefore not
|
|
1500
|
+
* supported as a return value.
|
|
1501
|
+
*
|
|
1501
1502
|
* Structurally equal objects do not share cache entries. If the same object is
|
|
1502
1503
|
* mutated after its first call, later calls still return the cached result for
|
|
1503
1504
|
* that reference.
|
|
@@ -1505,12 +1506,11 @@ export const SK = <A, B>(_: A, b: B): B => b
|
|
|
1505
1506
|
* @category caching
|
|
1506
1507
|
* @since 4.0.0
|
|
1507
1508
|
*/
|
|
1508
|
-
export function memoize<A extends object, O>(f: (a: A) => O): (ast: A) => O {
|
|
1509
|
+
export function memoize<A extends object, O extends {} | null>(f: (a: A) => O): (ast: A) => O {
|
|
1509
1510
|
const cache = new WeakMap<object, O>()
|
|
1510
1511
|
return (a) => {
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
}
|
|
1512
|
+
const cached = cache.get(a)
|
|
1513
|
+
if (cached !== undefined) return cached
|
|
1514
1514
|
const result = f(a)
|
|
1515
1515
|
cache.set(a, result)
|
|
1516
1516
|
return result
|
package/src/Iterable.ts
CHANGED
|
@@ -3276,19 +3276,20 @@ export const flatten = <A>(self: Iterable<Iterable<A>>): Iterable<A> => ({
|
|
|
3276
3276
|
const outerIterator = self[Symbol.iterator]()
|
|
3277
3277
|
let innerIterator: Iterator<A> | undefined
|
|
3278
3278
|
function next() {
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3279
|
+
while (true) {
|
|
3280
|
+
if (innerIterator === undefined) {
|
|
3281
|
+
const next = outerIterator.next()
|
|
3282
|
+
if (next.done) {
|
|
3283
|
+
return next
|
|
3284
|
+
}
|
|
3285
|
+
innerIterator = next.value[Symbol.iterator]()
|
|
3286
|
+
}
|
|
3287
|
+
const result = innerIterator.next()
|
|
3288
|
+
if (!result.done) {
|
|
3289
|
+
return result
|
|
3283
3290
|
}
|
|
3284
|
-
innerIterator = next.value[Symbol.iterator]()
|
|
3285
|
-
}
|
|
3286
|
-
const result = innerIterator.next()
|
|
3287
|
-
if (result.done) {
|
|
3288
3291
|
innerIterator = undefined
|
|
3289
|
-
return next()
|
|
3290
3292
|
}
|
|
3291
|
-
return result
|
|
3292
3293
|
}
|
|
3293
3294
|
return { next }
|
|
3294
3295
|
}
|
package/src/Layer.ts
CHANGED
|
@@ -447,11 +447,13 @@ class MemoMapImpl implements MemoMap {
|
|
|
447
447
|
scope: Scope.Scope,
|
|
448
448
|
build: (memoMap: MemoMap, scope: Scope.Scope) => Effect<Context.Context<ROut>, E, RIn>
|
|
449
449
|
): Effect<Context.Context<ROut>, E, RIn> {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
450
|
+
return internalEffect.suspend(() => {
|
|
451
|
+
const existing = this.get(layer, scope)
|
|
452
|
+
if (existing) {
|
|
453
|
+
return existing
|
|
454
|
+
}
|
|
455
|
+
return memoMapBuild(this, layer, scope, build)
|
|
456
|
+
})
|
|
455
457
|
}
|
|
456
458
|
}
|
|
457
459
|
|