effect 4.1.3 → 4.1.5
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/THIRD_PARTY_NOTICES.md +88 -0
- package/ai-docs/package.json +2 -2
- package/dist/Arbitrary.d.ts +44 -2
- package/dist/Arbitrary.d.ts.map +1 -1
- package/dist/Arbitrary.js +9 -1
- package/dist/Arbitrary.js.map +1 -1
- package/dist/BigInt.d.ts +200 -1
- package/dist/BigInt.d.ts.map +1 -1
- package/dist/BigInt.js +105 -9
- package/dist/BigInt.js.map +1 -1
- package/dist/Cache.d.ts.map +1 -1
- package/dist/Cache.js +4 -2
- package/dist/Cache.js.map +1 -1
- package/dist/Cause.d.ts +3 -3
- package/dist/Cause.js +1 -1
- package/dist/Chunk.d.ts +5 -0
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +7 -2
- package/dist/Chunk.js.map +1 -1
- package/dist/Clock.d.ts +5 -2
- package/dist/Clock.d.ts.map +1 -1
- package/dist/Clock.js +2 -1
- package/dist/Clock.js.map +1 -1
- package/dist/Codegen.d.ts +295 -0
- package/dist/Codegen.d.ts.map +1 -0
- package/dist/Codegen.js +521 -0
- package/dist/Codegen.js.map +1 -0
- package/dist/Config.d.ts +31 -2
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +12 -1
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.d.ts +11 -1
- package/dist/ConfigProvider.d.ts.map +1 -1
- package/dist/ConfigProvider.js +17 -6
- package/dist/ConfigProvider.js.map +1 -1
- package/dist/Effect.d.ts +869 -109
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +400 -47
- package/dist/Effect.js.map +1 -1
- package/dist/Equivalence.d.ts +11 -9
- package/dist/Equivalence.d.ts.map +1 -1
- package/dist/Equivalence.js +15 -12
- package/dist/Equivalence.js.map +1 -1
- package/dist/Fiber.d.ts +58 -8
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/Fiber.js +28 -4
- package/dist/Fiber.js.map +1 -1
- package/dist/FiberHandle.d.ts +81 -10
- package/dist/FiberHandle.d.ts.map +1 -1
- package/dist/FiberHandle.js +40 -8
- package/dist/FiberHandle.js.map +1 -1
- package/dist/FiberMap.d.ts +80 -10
- package/dist/FiberMap.d.ts.map +1 -1
- package/dist/FiberMap.js +37 -6
- package/dist/FiberMap.js.map +1 -1
- package/dist/FiberSet.d.ts +93 -8
- package/dist/FiberSet.d.ts.map +1 -1
- package/dist/FiberSet.js +46 -4
- package/dist/FiberSet.js.map +1 -1
- package/dist/Formatter.d.ts +2 -0
- package/dist/Formatter.d.ts.map +1 -1
- package/dist/Formatter.js +2 -0
- package/dist/Formatter.js.map +1 -1
- package/dist/LayerMap.d.ts +12 -3
- package/dist/LayerMap.d.ts.map +1 -1
- package/dist/LayerMap.js +12 -2
- package/dist/LayerMap.js.map +1 -1
- package/dist/LayerRef.d.ts +2 -2
- package/dist/Match.d.ts +12 -0
- package/dist/Match.d.ts.map +1 -1
- package/dist/Match.js +16 -0
- package/dist/Match.js.map +1 -1
- package/dist/Metric.js +1 -1
- package/dist/Metric.js.map +1 -1
- package/dist/Option.d.ts +4 -1
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js +6 -2
- package/dist/Option.js.map +1 -1
- package/dist/Order.d.ts +7 -5
- package/dist/Order.d.ts.map +1 -1
- package/dist/Order.js +7 -2
- package/dist/Order.js.map +1 -1
- package/dist/Pool.d.ts +4 -3
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +21 -18
- package/dist/Pool.js.map +1 -1
- package/dist/Predicate.d.ts +4 -1
- package/dist/Predicate.d.ts.map +1 -1
- package/dist/Predicate.js +5 -1
- package/dist/Predicate.js.map +1 -1
- package/dist/Queue.d.ts +69 -22
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Queue.js +40 -18
- package/dist/Queue.js.map +1 -1
- package/dist/Rational.d.ts +179 -0
- package/dist/Rational.d.ts.map +1 -1
- package/dist/Rational.js +63 -0
- package/dist/Rational.js.map +1 -1
- package/dist/Request.d.ts +20 -0
- package/dist/Request.d.ts.map +1 -1
- package/dist/Request.js +20 -0
- package/dist/Request.js.map +1 -1
- package/dist/Result.d.ts +3 -1
- package/dist/Result.d.ts.map +1 -1
- package/dist/Result.js +5 -2
- package/dist/Result.js.map +1 -1
- package/dist/Schema.d.ts +49 -19
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +44 -27
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +11 -4
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaGetter.d.ts +5 -6
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +14 -10
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +36 -67
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +5 -30
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +11 -10
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +12 -11
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/Scope.d.ts +12 -6
- package/dist/Scope.d.ts.map +1 -1
- package/dist/Scope.js +12 -6
- package/dist/Scope.js.map +1 -1
- package/dist/ScopedCache.d.ts.map +1 -1
- package/dist/ScopedCache.js +2 -1
- package/dist/ScopedCache.js.map +1 -1
- package/dist/Semaphore.d.ts.map +1 -1
- package/dist/Semaphore.js +18 -4
- package/dist/Semaphore.js.map +1 -1
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +55 -14
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +57 -3
- package/dist/String.d.ts.map +1 -1
- package/dist/String.js +62 -4
- package/dist/String.js.map +1 -1
- package/dist/Struct.d.ts +135 -1
- package/dist/Struct.d.ts.map +1 -1
- package/dist/Struct.js +64 -5
- package/dist/Struct.js.map +1 -1
- package/dist/TextDiff.d.ts +105 -0
- package/dist/TextDiff.d.ts.map +1 -1
- package/dist/TextDiff.js +137 -24
- package/dist/TextDiff.js.map +1 -1
- package/dist/TxPriorityQueue.js +2 -2
- package/dist/TxPriorityQueue.js.map +1 -1
- package/dist/ai/Chat.d.ts +1 -1
- package/dist/ai/Chat.d.ts.map +1 -1
- package/dist/ai/Chat.js.map +1 -1
- package/dist/ai/LanguageModel.d.ts +23 -4
- package/dist/ai/LanguageModel.d.ts.map +1 -1
- package/dist/ai/LanguageModel.js +9 -5
- package/dist/ai/LanguageModel.js.map +1 -1
- package/dist/ai/McpClient.d.ts +0 -5
- package/dist/ai/McpClient.d.ts.map +1 -1
- package/dist/ai/McpClient.js +1 -11
- package/dist/ai/McpClient.js.map +1 -1
- package/dist/ai/McpSchema.d.ts +128 -128
- package/dist/ai/McpSchema.d.ts.map +1 -1
- package/dist/ai/McpServer.d.ts +48 -5
- package/dist/ai/McpServer.d.ts.map +1 -1
- package/dist/ai/McpServer.js +136 -19
- package/dist/ai/McpServer.js.map +1 -1
- package/dist/ai/Tool.d.ts +3 -2
- package/dist/ai/Tool.d.ts.map +1 -1
- package/dist/ai/Tool.js +3 -2
- package/dist/ai/Tool.js.map +1 -1
- package/dist/ai/Toolkit.d.ts.map +1 -1
- package/dist/ai/Toolkit.js +5 -1
- package/dist/ai/Toolkit.js.map +1 -1
- package/dist/ai/WorkloadIdentity.d.ts +111 -0
- package/dist/ai/WorkloadIdentity.d.ts.map +1 -0
- package/dist/ai/WorkloadIdentity.js +227 -0
- package/dist/ai/WorkloadIdentity.js.map +1 -0
- package/dist/ai/index.d.ts +5 -0
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +5 -0
- package/dist/ai/index.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2024_11_05.js +3 -1
- package/dist/ai/internal/mcpProtocol/v2024_11_05.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js +3 -1
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js +3 -1
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js +3 -1
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js.map +1 -1
- package/dist/ai/internal/mcpRuntime.js +2 -4
- package/dist/ai/internal/mcpRuntime.js.map +1 -1
- package/dist/ai/internal/mcpSkills.js +80 -2
- package/dist/ai/internal/mcpSkills.js.map +1 -1
- package/dist/ai/internal/structured-output.js +5 -1
- package/dist/ai/internal/structured-output.js.map +1 -1
- package/dist/chat/Chat.d.ts +90 -0
- package/dist/chat/Chat.d.ts.map +1 -0
- package/dist/chat/Chat.js +127 -0
- package/dist/chat/Chat.js.map +1 -0
- package/dist/chat/ChatAdapter.d.ts +386 -0
- package/dist/chat/ChatAdapter.d.ts.map +1 -0
- package/dist/chat/ChatAdapter.js +110 -0
- package/dist/chat/ChatAdapter.js.map +1 -0
- package/dist/chat/ChatError.d.ts +500 -0
- package/dist/chat/ChatError.d.ts.map +1 -0
- package/dist/chat/ChatError.js +521 -0
- package/dist/chat/ChatError.js.map +1 -0
- package/dist/chat/ChatEvent.d.ts +321 -0
- package/dist/chat/ChatEvent.d.ts.map +1 -0
- package/dist/chat/ChatEvent.js +163 -0
- package/dist/chat/ChatEvent.js.map +1 -0
- package/dist/chat/ChatHandler.d.ts +81 -0
- package/dist/chat/ChatHandler.d.ts.map +1 -0
- package/dist/chat/ChatHandler.js +85 -0
- package/dist/chat/ChatHandler.js.map +1 -0
- package/dist/chat/ChatInteraction.d.ts +1519 -0
- package/dist/chat/ChatInteraction.d.ts.map +1 -0
- package/dist/chat/ChatInteraction.js +1052 -0
- package/dist/chat/ChatInteraction.js.map +1 -0
- package/dist/chat/ChatMarkdown.d.ts +280 -0
- package/dist/chat/ChatMarkdown.d.ts.map +1 -0
- package/dist/chat/ChatMarkdown.js +1172 -0
- package/dist/chat/ChatMarkdown.js.map +1 -0
- package/dist/chat/ChatMessage.d.ts +224 -0
- package/dist/chat/ChatMessage.d.ts.map +1 -0
- package/dist/chat/ChatMessage.js +172 -0
- package/dist/chat/ChatMessage.js.map +1 -0
- package/dist/chat/ChatTest.d.ts +407 -0
- package/dist/chat/ChatTest.d.ts.map +1 -0
- package/dist/chat/ChatTest.js +2145 -0
- package/dist/chat/ChatTest.js.map +1 -0
- package/dist/chat/ChatThread.d.ts +92 -0
- package/dist/chat/ChatThread.d.ts.map +1 -0
- package/dist/chat/ChatThread.js +116 -0
- package/dist/chat/ChatThread.js.map +1 -0
- package/dist/chat/ChatUi.d.ts +362 -0
- package/dist/chat/ChatUi.d.ts.map +1 -0
- package/dist/chat/ChatUi.js +209 -0
- package/dist/chat/ChatUi.js.map +1 -0
- package/dist/chat/index.d.ts +60 -0
- package/dist/chat/index.d.ts.map +1 -0
- package/dist/chat/index.js +61 -0
- package/dist/chat/index.js.map +1 -0
- package/dist/chat/internal/retries.d.ts +2 -0
- package/dist/chat/internal/retries.d.ts.map +1 -0
- package/dist/chat/internal/retries.js +7 -0
- package/dist/chat/internal/retries.js.map +1 -0
- package/dist/cli/CliOutput.d.ts.map +1 -1
- package/dist/cli/CliOutput.js +6 -7
- package/dist/cli/CliOutput.js.map +1 -1
- package/dist/cli/Command.d.ts +20 -2
- package/dist/cli/Command.d.ts.map +1 -1
- package/dist/cli/Command.js +7 -1
- package/dist/cli/Command.js.map +1 -1
- package/dist/cli/Prompt.d.ts +5 -6
- package/dist/cli/Prompt.d.ts.map +1 -1
- package/dist/cli/Prompt.js +9 -4
- package/dist/cli/Prompt.js.map +1 -1
- package/dist/cli/internal/command.d.ts +1 -1
- package/dist/cli/internal/command.d.ts.map +1 -1
- package/dist/cli/internal/config.d.ts +1 -1
- package/dist/cli/internal/config.d.ts.map +1 -1
- package/dist/cli/internal/config.js +3 -3
- package/dist/cli/internal/config.js.map +1 -1
- package/dist/cli/internal/lexer.js +13 -0
- package/dist/cli/internal/lexer.js.map +1 -1
- package/dist/cli/internal/parser.js +23 -16
- package/dist/cli/internal/parser.js.map +1 -1
- package/dist/cli/internal/wizard.d.ts.map +1 -1
- package/dist/cli/internal/wizard.js +4 -0
- package/dist/cli/internal/wizard.js.map +1 -1
- package/dist/cluster/ClusterCron.d.ts +21 -1
- package/dist/cluster/ClusterCron.d.ts.map +1 -1
- package/dist/cluster/ClusterCron.js +24 -6
- package/dist/cluster/ClusterCron.js.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.js +30 -22
- package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/cluster/Sharding.d.ts.map +1 -1
- package/dist/cluster/Sharding.js +15 -3
- package/dist/cluster/Sharding.js.map +1 -1
- package/dist/cluster/ShardingConfig.d.ts +6 -0
- package/dist/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/cluster/ShardingConfig.js.map +1 -1
- package/dist/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/cluster/SqlMessageStorage.js +13 -15
- package/dist/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/cluster/SqlRunnerStorage.d.ts.map +1 -1
- package/dist/cluster/SqlRunnerStorage.js +18 -8
- package/dist/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/cluster/internal/entityManager.js +12 -8
- package/dist/cluster/internal/entityManager.js.map +1 -1
- package/dist/cluster/internal/entityReaper.js +1 -1
- package/dist/cluster/internal/entityReaper.js.map +1 -1
- package/dist/crypto/Kdf.d.ts +2 -1
- package/dist/crypto/Kdf.d.ts.map +1 -1
- package/dist/crypto/Kdf.js +2 -1
- package/dist/crypto/Kdf.js.map +1 -1
- package/dist/crypto/Password.d.ts +162 -0
- package/dist/crypto/Password.d.ts.map +1 -0
- package/dist/crypto/Password.js +217 -0
- package/dist/crypto/Password.js.map +1 -0
- package/dist/crypto/index.d.ts +5 -0
- package/dist/crypto/index.d.ts.map +1 -1
- package/dist/crypto/index.js +5 -0
- package/dist/crypto/index.js.map +1 -1
- package/dist/encoding/Base64.d.ts +63 -0
- package/dist/encoding/Base64.d.ts.map +1 -1
- package/dist/encoding/Base64.js +77 -0
- package/dist/encoding/Base64.js.map +1 -1
- package/dist/encoding/Base64Url.d.ts +1 -0
- package/dist/encoding/Base64Url.d.ts.map +1 -1
- package/dist/encoding/Base64Url.js +1 -0
- package/dist/encoding/Base64Url.js.map +1 -1
- package/dist/encoding/Csv.d.ts.map +1 -1
- package/dist/encoding/Csv.js +44 -16
- package/dist/encoding/Csv.js.map +1 -1
- package/dist/encoding/Hex.d.ts +5 -0
- package/dist/encoding/Hex.d.ts.map +1 -1
- package/dist/encoding/Hex.js +5 -0
- package/dist/encoding/Hex.js.map +1 -1
- package/dist/encoding/SchemaBinary.d.ts.map +1 -1
- package/dist/encoding/SchemaBinary.js +13 -124
- package/dist/encoding/SchemaBinary.js.map +1 -1
- package/dist/encoding/Sse.d.ts +1 -0
- package/dist/encoding/Sse.d.ts.map +1 -1
- package/dist/encoding/Sse.js +7 -5
- package/dist/encoding/Sse.js.map +1 -1
- package/dist/encoding/Xml.d.ts +117 -11
- package/dist/encoding/Xml.d.ts.map +1 -1
- package/dist/encoding/Xml.js +332 -42
- package/dist/encoding/Xml.js.map +1 -1
- package/dist/eventlog/EventJournal.d.ts.map +1 -1
- package/dist/eventlog/EventJournal.js +3 -8
- package/dist/eventlog/EventJournal.js.map +1 -1
- package/dist/eventlog/SqlEventLogServerEncrypted.js +6 -8
- package/dist/eventlog/SqlEventLogServerEncrypted.js.map +1 -1
- package/dist/http/FindMyWay/internal/router.js +163 -116
- package/dist/http/FindMyWay/internal/router.js.map +1 -1
- package/dist/http/FindMyWay.d.ts +99 -0
- package/dist/http/FindMyWay.d.ts.map +1 -1
- package/dist/http/FindMyWay.js +39 -0
- package/dist/http/FindMyWay.js.map +1 -1
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/http/HttpClient.js +1 -1
- package/dist/http/HttpClient.js.map +1 -1
- package/dist/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/http/HttpMiddleware.js +18 -9
- package/dist/http/HttpMiddleware.js.map +1 -1
- package/dist/http/HttpRouter.d.ts +49 -1
- package/dist/http/HttpRouter.d.ts.map +1 -1
- package/dist/http/HttpRouter.js +70 -20
- package/dist/http/HttpRouter.js.map +1 -1
- package/dist/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/http/HttpServerResponse.js +24 -58
- package/dist/http/HttpServerResponse.js.map +1 -1
- package/dist/http/Mime.d.ts.map +1 -1
- package/dist/http/Mime.js +3 -2
- package/dist/http/Mime.js.map +1 -1
- package/dist/http/internal/compression.d.ts.map +1 -1
- package/dist/http/internal/compression.js +2 -2
- package/dist/http/internal/compression.js.map +1 -1
- package/dist/http/internal/mediaType.d.ts.map +1 -0
- package/dist/{http-api → http}/internal/mediaType.js +4 -0
- package/dist/{http-api → http}/internal/mediaType.js.map +1 -1
- package/dist/http/internal/redactedPath.d.ts +2 -0
- package/dist/http/internal/redactedPath.d.ts.map +1 -0
- package/dist/http/internal/redactedPath.js +138 -0
- package/dist/http/internal/redactedPath.js.map +1 -0
- package/dist/http/internal/requestState.js +16 -0
- package/dist/http/internal/requestState.js.map +1 -1
- package/dist/http-api/HttpApi.d.ts +58 -0
- package/dist/http-api/HttpApi.d.ts.map +1 -1
- package/dist/http-api/HttpApi.js +80 -0
- package/dist/http-api/HttpApi.js.map +1 -1
- package/dist/http-api/HttpApiBuilder.d.ts.map +1 -1
- package/dist/http-api/HttpApiBuilder.js +12 -3
- package/dist/http-api/HttpApiBuilder.js.map +1 -1
- package/dist/http-api/HttpApiClient.d.ts +1 -1
- package/dist/http-api/HttpApiClient.d.ts.map +1 -1
- package/dist/http-api/HttpApiClient.js +11 -7
- package/dist/http-api/HttpApiClient.js.map +1 -1
- package/dist/http-api/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/http-api/HttpApiEndpoint.js +1 -1
- package/dist/http-api/HttpApiEndpoint.js.map +1 -1
- package/dist/http-api/HttpApiScalar.d.ts +4 -0
- package/dist/http-api/HttpApiScalar.d.ts.map +1 -1
- package/dist/http-api/HttpApiScalar.js +10 -1
- package/dist/http-api/HttpApiScalar.js.map +1 -1
- package/dist/http-api/HttpApiSchema.d.ts +66 -0
- package/dist/http-api/HttpApiSchema.d.ts.map +1 -1
- package/dist/http-api/HttpApiSchema.js +67 -2
- package/dist/http-api/HttpApiSchema.js.map +1 -1
- package/dist/http-api/OpenApi.d.ts +2 -0
- package/dist/http-api/OpenApi.d.ts.map +1 -1
- package/dist/http-api/internal/httpApiScalar.js +5 -2
- package/dist/http-api/internal/httpApiScalar.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/arbitrary/model.js +0 -5
- package/dist/internal/arbitrary/model.js.map +1 -1
- package/dist/internal/arbitrary/regexp.js +2 -1
- package/dist/internal/arbitrary/regexp.js.map +1 -1
- package/dist/internal/arbitrary/runner.d.ts.map +1 -1
- package/dist/internal/arbitrary/runner.js +21 -16
- package/dist/internal/arbitrary/runner.js.map +1 -1
- package/dist/internal/arbitrary/schema.js +140 -23
- package/dist/internal/arbitrary/schema.js.map +1 -1
- package/dist/internal/codegen.d.ts +2 -0
- package/dist/internal/codegen.d.ts.map +1 -0
- package/dist/internal/codegen.js +59 -0
- package/dist/internal/codegen.js.map +1 -0
- package/dist/internal/core.js +3 -3
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/dateTime.js +26 -12
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +21 -7
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/hashMap.js +7 -7
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/matcher.js +2 -1
- package/dist/internal/matcher.js.map +1 -1
- package/dist/internal/record.js +18 -4
- package/dist/internal/record.js.map +1 -1
- package/dist/internal/result.js +1 -1
- package/dist/internal/result.js.map +1 -1
- package/dist/internal/schema/codeExpression.d.ts +4 -0
- package/dist/internal/schema/codeExpression.d.ts.map +1 -0
- package/dist/internal/schema/codeExpression.js +179 -0
- package/dist/internal/schema/codeExpression.js.map +1 -0
- package/dist/internal/schema/codeImports.d.ts +8 -0
- package/dist/internal/schema/codeImports.d.ts.map +1 -0
- package/dist/internal/schema/codeImports.js +135 -0
- package/dist/internal/schema/codeImports.js.map +1 -0
- package/dist/internal/schema/codeTokens.d.ts +8 -0
- package/dist/internal/schema/codeTokens.d.ts.map +1 -0
- package/dist/internal/schema/codeTokens.js +17 -0
- package/dist/internal/schema/codeTokens.js.map +1 -0
- package/dist/internal/schema/fromJsonSchemaDocument.js +141 -35
- package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -1
- package/dist/internal/schema/passthrough.d.ts +2 -0
- package/dist/internal/schema/passthrough.d.ts.map +1 -0
- package/dist/internal/schema/passthrough.js +8 -0
- package/dist/internal/schema/passthrough.js.map +1 -0
- package/dist/internal/schema/schemaCodegen.d.ts +2 -0
- package/dist/internal/schema/schemaCodegen.d.ts.map +1 -0
- package/dist/internal/schema/schemaCodegen.js +377 -0
- package/dist/internal/schema/schemaCodegen.js.map +1 -0
- package/dist/internal/schema/toJsonSchemaDocument.js +11 -4
- package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -1
- package/dist/internal/trie.js +51 -64
- package/dist/internal/trie.js.map +1 -1
- package/dist/internal/utf8.d.ts +2 -0
- package/dist/internal/utf8.d.ts.map +1 -0
- package/dist/internal/utf8.js +151 -0
- package/dist/internal/utf8.js.map +1 -0
- package/dist/internal/version.js +1 -1
- package/dist/jose/Jwks.d.ts +13 -0
- package/dist/jose/Jwks.d.ts.map +1 -1
- package/dist/jose/Jwks.js +10 -2
- package/dist/jose/Jwks.js.map +1 -1
- package/dist/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/observability/OtlpExporter.js +12 -10
- package/dist/observability/OtlpExporter.js.map +1 -1
- package/dist/observability/OtlpLogger.d.ts.map +1 -1
- package/dist/observability/OtlpLogger.js +5 -3
- package/dist/observability/OtlpLogger.js.map +1 -1
- package/dist/observability/internal/otlpProtobuf.d.ts +4 -2
- package/dist/observability/internal/otlpProtobuf.d.ts.map +1 -1
- package/dist/observability/internal/otlpProtobuf.js +238 -156
- package/dist/observability/internal/otlpProtobuf.js.map +1 -1
- package/dist/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/persistence/PersistedQueue.js +20 -3
- package/dist/persistence/PersistedQueue.js.map +1 -1
- package/dist/protobuf/ProtobufDescriptor.d.ts +377 -0
- package/dist/protobuf/ProtobufDescriptor.d.ts.map +1 -0
- package/dist/protobuf/ProtobufDescriptor.js +135 -0
- package/dist/protobuf/ProtobufDescriptor.js.map +1 -0
- package/dist/protobuf/ProtobufDescriptorProto.d.ts +2083 -0
- package/dist/protobuf/ProtobufDescriptorProto.d.ts.map +1 -0
- package/dist/protobuf/ProtobufDescriptorProto.js +2674 -0
- package/dist/protobuf/ProtobufDescriptorProto.js.map +1 -0
- package/dist/protobuf/ProtobufMessage.d.ts +183 -0
- package/dist/protobuf/ProtobufMessage.d.ts.map +1 -0
- package/dist/protobuf/ProtobufMessage.js +232 -0
- package/dist/protobuf/ProtobufMessage.js.map +1 -0
- package/dist/protobuf/ProtobufReader.d.ts +350 -0
- package/dist/protobuf/ProtobufReader.d.ts.map +1 -0
- package/dist/protobuf/ProtobufReader.js +698 -0
- package/dist/protobuf/ProtobufReader.js.map +1 -0
- package/dist/protobuf/ProtobufWriter.d.ts +224 -0
- package/dist/protobuf/ProtobufWriter.d.ts.map +1 -0
- package/dist/protobuf/ProtobufWriter.js +483 -0
- package/dist/protobuf/ProtobufWriter.js.map +1 -0
- package/dist/protobuf/index.d.ts +30 -0
- package/dist/protobuf/index.d.ts.map +1 -0
- package/dist/protobuf/index.js +31 -0
- package/dist/protobuf/index.js.map +1 -0
- package/dist/protobuf/internal/binary.d.ts +2 -0
- package/dist/protobuf/internal/binary.d.ts.map +1 -0
- package/dist/protobuf/internal/binary.js +966 -0
- package/dist/protobuf/internal/binary.js.map +1 -0
- package/dist/protobuf/internal/resolve.d.ts +2 -0
- package/dist/protobuf/internal/resolve.d.ts.map +1 -0
- package/dist/protobuf/internal/resolve.js +463 -0
- package/dist/protobuf/internal/resolve.js.map +1 -0
- package/dist/protobuf/internal/wireType.d.ts +2 -0
- package/dist/protobuf/internal/wireType.d.ts.map +1 -0
- package/dist/protobuf/internal/wireType.js +10 -0
- package/dist/protobuf/internal/wireType.js.map +1 -0
- package/dist/reactivity/AsyncResult.d.ts +3 -0
- package/dist/reactivity/AsyncResult.d.ts.map +1 -1
- package/dist/reactivity/AsyncResult.js +4 -1
- package/dist/reactivity/AsyncResult.js.map +1 -1
- package/dist/reactivity/Atom.d.ts +10 -4
- package/dist/reactivity/Atom.d.ts.map +1 -1
- package/dist/reactivity/Atom.js +38 -13
- package/dist/reactivity/Atom.js.map +1 -1
- package/dist/reactivity/AtomHttpApi.d.ts +5 -0
- package/dist/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/reactivity/AtomHttpApi.js +5 -1
- package/dist/reactivity/AtomHttpApi.js.map +1 -1
- package/dist/reactivity/AtomRegistry.js +13 -0
- package/dist/reactivity/AtomRegistry.js.map +1 -1
- package/dist/reactivity/AtomRpc.d.ts +5 -0
- package/dist/reactivity/AtomRpc.d.ts.map +1 -1
- package/dist/reactivity/AtomRpc.js +6 -1
- package/dist/reactivity/AtomRpc.js.map +1 -1
- package/dist/rpc/Rpc.d.ts +25 -0
- package/dist/rpc/Rpc.d.ts.map +1 -1
- package/dist/rpc/Rpc.js +18 -0
- package/dist/rpc/Rpc.js.map +1 -1
- package/dist/rpc/RpcClient.d.ts.map +1 -1
- package/dist/rpc/RpcClient.js +38 -21
- package/dist/rpc/RpcClient.js.map +1 -1
- package/dist/rpc/RpcGroup.d.ts +5 -0
- package/dist/rpc/RpcGroup.d.ts.map +1 -1
- package/dist/rpc/RpcGroup.js.map +1 -1
- package/dist/rpc/RpcMiddleware.d.ts +9 -0
- package/dist/rpc/RpcMiddleware.d.ts.map +1 -1
- package/dist/rpc/RpcMiddleware.js.map +1 -1
- package/dist/rpc/RpcSerialization.d.ts +7 -1
- package/dist/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/rpc/RpcSerialization.js +22 -5
- package/dist/rpc/RpcSerialization.js.map +1 -1
- package/dist/rpc/RpcServer.d.ts.map +1 -1
- package/dist/rpc/RpcServer.js +33 -18
- package/dist/rpc/RpcServer.js.map +1 -1
- package/dist/schema/SchemaCompiler/runtime.js +2 -1
- package/dist/schema/SchemaCompiler/runtime.js.map +1 -1
- package/dist/schema/VariantSchema.d.ts +10 -2
- package/dist/schema/VariantSchema.d.ts.map +1 -1
- package/dist/schema/VariantSchema.js +7 -1
- package/dist/schema/VariantSchema.js.map +1 -1
- package/dist/socket/Socket.d.ts +24 -10
- package/dist/socket/Socket.d.ts.map +1 -1
- package/dist/socket/Socket.js +52 -17
- package/dist/socket/Socket.js.map +1 -1
- package/dist/sql/Migrator.d.ts +3 -0
- package/dist/sql/Migrator.d.ts.map +1 -1
- package/dist/sql/Migrator.js +10 -1
- package/dist/sql/Migrator.js.map +1 -1
- package/dist/sql/SqlModel.d.ts.map +1 -1
- package/dist/sql/SqlModel.js +1 -0
- package/dist/sql/SqlModel.js.map +1 -1
- package/dist/testing/TestClock.js +3 -1
- package/dist/testing/TestClock.js.map +1 -1
- package/dist/testing/TestConsole.d.ts +96 -0
- package/dist/testing/TestConsole.d.ts.map +1 -1
- package/dist/testing/TestConsole.js +78 -6
- package/dist/testing/TestConsole.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +5 -1
- package/dist/testing/TestSchema.d.ts.map +1 -1
- package/dist/testing/TestSchema.js +7 -2
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/workers/SharedMemory.d.ts +115 -0
- package/dist/workers/SharedMemory.d.ts.map +1 -0
- package/dist/workers/SharedMemory.js +149 -0
- package/dist/workers/SharedMemory.js.map +1 -0
- package/dist/workers/Transferable.d.ts.map +1 -1
- package/dist/workers/Transferable.js +1 -4
- package/dist/workers/Transferable.js.map +1 -1
- package/dist/workers/index.d.ts +5 -0
- package/dist/workers/index.d.ts.map +1 -1
- package/dist/workers/index.js +5 -0
- package/dist/workers/index.js.map +1 -1
- package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/workflow/WorkflowEngine.js +3 -1
- package/dist/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +7 -4
- package/src/Arbitrary.ts +60 -3
- package/src/BigInt.ts +247 -9
- package/src/Cache.ts +4 -2
- package/src/Cause.ts +3 -3
- package/src/Chunk.ts +7 -3
- package/src/Clock.ts +5 -2
- package/src/Codegen.ts +741 -0
- package/src/Config.ts +35 -4
- package/src/ConfigProvider.ts +24 -7
- package/src/Effect.ts +871 -109
- package/src/Equivalence.ts +16 -13
- package/src/Fiber.ts +58 -8
- package/src/FiberHandle.ts +86 -12
- package/src/FiberMap.ts +83 -10
- package/src/FiberSet.ts +96 -8
- package/src/Formatter.ts +2 -0
- package/src/LayerMap.ts +14 -4
- package/src/LayerRef.ts +2 -2
- package/src/Match.ts +16 -0
- package/src/Metric.ts +1 -1
- package/src/Option.ts +9 -5
- package/src/Order.ts +9 -4
- package/src/Pool.ts +22 -17
- package/src/Predicate.ts +7 -3
- package/src/Queue.ts +84 -31
- package/src/Rational.ts +198 -0
- package/src/Request.ts +20 -0
- package/src/Result.ts +9 -6
- package/src/Schema.ts +69 -32
- package/src/SchemaAST.ts +15 -4
- package/src/SchemaGetter.ts +17 -10
- package/src/SchemaRepresentation.ts +37 -77
- package/src/SchemaTransformation.ts +12 -11
- package/src/Scope.ts +12 -6
- package/src/ScopedCache.ts +2 -1
- package/src/Semaphore.ts +18 -4
- package/src/Stream.ts +66 -20
- package/src/String.ts +83 -6
- package/src/Struct.ts +138 -5
- package/src/TextDiff.ts +186 -30
- package/src/TxPriorityQueue.ts +2 -2
- package/src/ai/Chat.ts +9 -3
- package/src/ai/LanguageModel.ts +72 -15
- package/src/ai/McpClient.ts +1 -11
- package/src/ai/McpServer.ts +146 -25
- package/src/ai/Tool.ts +3 -2
- package/src/ai/Toolkit.ts +3 -1
- package/src/ai/WorkloadIdentity.ts +318 -0
- package/src/ai/index.ts +6 -0
- package/src/ai/internal/mcpProtocol/v2024_11_05.ts +3 -1
- package/src/ai/internal/mcpProtocol/v2025_03_26.ts +3 -1
- package/src/ai/internal/mcpProtocol/v2025_06_18.ts +3 -1
- package/src/ai/internal/mcpProtocol/v2025_11_25.ts +3 -1
- package/src/ai/internal/mcpRuntime.ts +2 -6
- package/src/ai/internal/mcpSkills.ts +70 -2
- package/src/ai/internal/structured-output.ts +6 -1
- package/src/chat/Chat.ts +164 -0
- package/src/chat/ChatAdapter.ts +444 -0
- package/src/chat/ChatError.ts +684 -0
- package/src/chat/ChatEvent.ts +221 -0
- package/src/chat/ChatHandler.ts +102 -0
- package/src/chat/ChatInteraction.ts +1979 -0
- package/src/chat/ChatMarkdown.ts +1406 -0
- package/src/chat/ChatMessage.ts +213 -0
- package/src/chat/ChatTest.ts +2606 -0
- package/src/chat/ChatThread.ts +132 -0
- package/src/chat/ChatUi.ts +320 -0
- package/src/chat/index.ts +72 -0
- package/src/chat/internal/retries.ts +7 -0
- package/src/cli/CliOutput.ts +4 -5
- package/src/cli/Command.ts +25 -3
- package/src/cli/Prompt.ts +15 -9
- package/src/cli/internal/config.ts +8 -8
- package/src/cli/internal/lexer.ts +14 -0
- package/src/cli/internal/parser.ts +28 -20
- package/src/cli/internal/wizard.ts +4 -0
- package/src/cluster/ClusterCron.ts +33 -10
- package/src/cluster/ClusterWorkflowEngine.ts +42 -23
- package/src/cluster/Sharding.ts +17 -3
- package/src/cluster/ShardingConfig.ts +3 -0
- package/src/cluster/SqlMessageStorage.ts +16 -20
- package/src/cluster/SqlRunnerStorage.ts +21 -8
- package/src/cluster/internal/entityManager.ts +19 -10
- package/src/cluster/internal/entityReaper.ts +1 -1
- package/src/crypto/Kdf.ts +2 -1
- package/src/crypto/Password.ts +258 -0
- package/src/crypto/index.ts +6 -0
- package/src/encoding/Base64.ts +79 -0
- package/src/encoding/Base64Url.ts +1 -0
- package/src/encoding/Csv.ts +47 -20
- package/src/encoding/Hex.ts +5 -0
- package/src/encoding/SchemaBinary.ts +13 -79
- package/src/encoding/Sse.ts +7 -5
- package/src/encoding/Xml.ts +394 -47
- package/src/eventlog/EventJournal.ts +3 -8
- package/src/eventlog/SqlEventLogServerEncrypted.ts +9 -9
- package/src/http/FindMyWay/internal/router.ts +181 -129
- package/src/http/FindMyWay.ts +106 -0
- package/src/http/HttpClient.ts +2 -1
- package/src/http/HttpMiddleware.ts +34 -10
- package/src/http/HttpRouter.ts +84 -20
- package/src/http/HttpServerResponse.ts +33 -61
- package/src/http/Mime.ts +3 -2
- package/src/http/internal/compression.ts +2 -2
- package/src/{http-api → http}/internal/mediaType.ts +4 -0
- package/src/http/internal/redactedPath.ts +144 -0
- package/src/http/internal/requestState.ts +22 -0
- package/src/http-api/HttpApi.ts +103 -0
- package/src/http-api/HttpApiBuilder.ts +14 -3
- package/src/http-api/HttpApiClient.ts +23 -8
- package/src/http-api/HttpApiEndpoint.ts +1 -1
- package/src/http-api/HttpApiScalar.ts +9 -1
- package/src/http-api/HttpApiSchema.ts +69 -3
- package/src/http-api/OpenApi.ts +2 -0
- package/src/http-api/internal/httpApiScalar.ts +5 -1
- package/src/index.ts +6 -0
- package/src/internal/arbitrary/model.ts +3 -9
- package/src/internal/arbitrary/regexp.ts +3 -1
- package/src/internal/arbitrary/runner.ts +28 -14
- package/src/internal/arbitrary/schema.ts +140 -35
- package/src/internal/codegen.ts +53 -0
- package/src/internal/core.ts +3 -3
- package/src/internal/dateTime.ts +30 -13
- package/src/internal/effect.ts +25 -9
- package/src/internal/hashMap.ts +8 -7
- package/src/internal/matcher.ts +2 -1
- package/src/internal/record.ts +19 -4
- package/src/internal/result.ts +1 -1
- package/src/internal/schema/codeExpression.ts +179 -0
- package/src/internal/schema/codeImports.ts +142 -0
- package/src/internal/schema/codeTokens.ts +39 -0
- package/src/internal/schema/fromJsonSchemaDocument.ts +154 -34
- package/src/internal/schema/passthrough.ts +8 -0
- package/src/internal/schema/schemaCodegen.ts +543 -0
- package/src/internal/schema/toJsonSchemaDocument.ts +13 -4
- package/src/internal/trie.ts +46 -60
- package/src/internal/utf8.ts +106 -0
- package/src/internal/version.ts +1 -1
- package/src/jose/Jwks.ts +23 -4
- package/src/observability/OtlpExporter.ts +12 -10
- package/src/observability/OtlpLogger.ts +5 -3
- package/src/observability/internal/otlpProtobuf.ts +386 -457
- package/src/persistence/PersistedQueue.ts +21 -4
- package/src/protobuf/ProtobufDescriptor.ts +503 -0
- package/src/protobuf/ProtobufDescriptorProto.ts +3611 -0
- package/src/protobuf/ProtobufMessage.ts +277 -0
- package/src/protobuf/ProtobufReader.ts +756 -0
- package/src/protobuf/ProtobufWriter.ts +530 -0
- package/src/protobuf/index.ts +36 -0
- package/src/protobuf/internal/binary.ts +1215 -0
- package/src/protobuf/internal/resolve.ts +533 -0
- package/src/protobuf/internal/wireType.ts +9 -0
- package/src/reactivity/AsyncResult.ts +6 -1
- package/src/reactivity/Atom.ts +55 -16
- package/src/reactivity/AtomHttpApi.ts +10 -1
- package/src/reactivity/AtomRegistry.ts +16 -0
- package/src/reactivity/AtomRpc.ts +11 -1
- package/src/rpc/Rpc.ts +31 -0
- package/src/rpc/RpcClient.ts +30 -21
- package/src/rpc/RpcGroup.ts +5 -0
- package/src/rpc/RpcMiddleware.ts +9 -0
- package/src/rpc/RpcSerialization.ts +26 -6
- package/src/rpc/RpcServer.ts +33 -20
- package/src/schema/SchemaCompiler/runtime.ts +2 -3
- package/src/schema/VariantSchema.ts +12 -4
- package/src/socket/Socket.ts +67 -20
- package/src/sql/Migrator.ts +8 -1
- package/src/sql/SqlModel.ts +4 -0
- package/src/testing/TestClock.ts +1 -1
- package/src/testing/TestConsole.ts +119 -9
- package/src/testing/TestSchema.ts +8 -3
- package/src/workers/SharedMemory.ts +227 -0
- package/src/workers/Transferable.ts +1 -5
- package/src/workers/index.ts +6 -0
- package/src/workflow/WorkflowEngine.ts +3 -1
- package/dist/http-api/internal/mediaType.d.ts.map +0 -1
- package/dist/internal/schema/toCodeDocument.d.ts +0 -2
- package/dist/internal/schema/toCodeDocument.d.ts.map +0 -1
- package/dist/internal/schema/toCodeDocument.js +0 -444
- package/dist/internal/schema/toCodeDocument.js.map +0 -1
- package/dist/observability/internal/protobuf.d.ts +0 -2
- package/dist/observability/internal/protobuf.d.ts.map +0 -1
- package/dist/observability/internal/protobuf.js +0 -169
- package/dist/observability/internal/protobuf.js.map +0 -1
- package/src/internal/schema/toCodeDocument.ts +0 -570
- package/src/observability/internal/protobuf.ts +0 -225
- /package/dist/{http-api → http}/internal/mediaType.d.ts +0 -0
|
@@ -0,0 +1,1519 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed buttons, selects, modals and slash commands, and the service that
|
|
3
|
+
* receives their clicks, submits and commands.
|
|
4
|
+
*
|
|
5
|
+
* A definition carries an element's id and the schemas of its values. It
|
|
6
|
+
* builds the element to post (`of`, `open`) and gives the typed slot of its
|
|
7
|
+
* handler, the way `Rpc` and `RpcGroup` do. A `group` of definitions becomes a
|
|
8
|
+
* layer of handlers, and `layer` provides the `Handler` service that adapters
|
|
9
|
+
* call.
|
|
10
|
+
*
|
|
11
|
+
* **Example** (A button that opens a modal)
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { Effect, Layer, Schema } from "effect"
|
|
15
|
+
* import { ChatInteraction } from "effect/chat"
|
|
16
|
+
*
|
|
17
|
+
* const Deploy = Schema.Struct({ version: Schema.String })
|
|
18
|
+
*
|
|
19
|
+
* const Reject = ChatInteraction.button("reject", { label: "Reject", style: "danger", value: Deploy })
|
|
20
|
+
* const RejectReason = ChatInteraction.modal("reject-reason", {
|
|
21
|
+
* title: "Reject deploy",
|
|
22
|
+
* metadata: Deploy,
|
|
23
|
+
* fields: {
|
|
24
|
+
* reason: ChatInteraction.textInput({ label: "Reason", multiline: true })
|
|
25
|
+
* }
|
|
26
|
+
* })
|
|
27
|
+
*
|
|
28
|
+
* const Interactions = ChatInteraction.group(Reject, RejectReason).toLayer({
|
|
29
|
+
* reject: (click) => Effect.succeed(RejectReason.open({ metadata: click.value })),
|
|
30
|
+
* "reject-reason": (submit) =>
|
|
31
|
+
* submit.values.reason.length < 10
|
|
32
|
+
* ? Effect.succeed(ChatInteraction.errors({ reason: "Say a bit more." }))
|
|
33
|
+
* : Effect.succeed(ChatInteraction.close)
|
|
34
|
+
* }).pipe(Layer.provideMerge(ChatInteraction.layer()))
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* **Details**
|
|
38
|
+
*
|
|
39
|
+
* - Clicks, submits and commands are not `ChatEvent`s. They need an answer
|
|
40
|
+
* inside the platform's 3 seconds, so they go to `Handler`, which answers
|
|
41
|
+
* by return value and has no error channel.
|
|
42
|
+
* - Slack and Discord don't redeliver a click, a submit or a command, so
|
|
43
|
+
* interactions carry no dedupe key. An adapter whose platform does
|
|
44
|
+
* redeliver them documents a delivery key of its own.
|
|
45
|
+
*
|
|
46
|
+
* @stability unstable
|
|
47
|
+
* @since 4.1.5
|
|
48
|
+
*/
|
|
49
|
+
import * as Context from "../Context.ts";
|
|
50
|
+
import type * as Duration from "../Duration.ts";
|
|
51
|
+
import * as Effect from "../Effect.ts";
|
|
52
|
+
import * as Layer from "../Layer.ts";
|
|
53
|
+
import * as Option from "../Option.ts";
|
|
54
|
+
import * as Schema from "../Schema.ts";
|
|
55
|
+
import type { Scope } from "../Scope.ts";
|
|
56
|
+
import { ChatError } from "./ChatError.ts";
|
|
57
|
+
import { ChatThread } from "./ChatThread.ts";
|
|
58
|
+
import * as ChatUi from "./ChatUi.ts";
|
|
59
|
+
/**
|
|
60
|
+
* Schema for a click on a button.
|
|
61
|
+
*
|
|
62
|
+
* **Details**
|
|
63
|
+
*
|
|
64
|
+
* - `value` is still encoded, and absent for a button with no value.
|
|
65
|
+
* - `thread` and `messageId` are where the message carrying the button
|
|
66
|
+
* lives. `raw` is the platform's interaction payload.
|
|
67
|
+
*
|
|
68
|
+
* **Gotchas**
|
|
69
|
+
*
|
|
70
|
+
* On a command's private answer, `messageId` still tells which answer was
|
|
71
|
+
* clicked, but no message op works with it: `edit`, `delete` and
|
|
72
|
+
* `fetchMessage` can't reach a private answer. On Slack `chat.update` on it
|
|
73
|
+
* answered `message_not_found` live, and `edit` fails `NotFound`. On
|
|
74
|
+
* Discord only the interaction's token reaches it, which is from Discord's
|
|
75
|
+
* docs and was not run. Only `raw` tells the two apart: Slack's
|
|
76
|
+
* `container.is_ephemeral`, Discord's `message.flags` with 64.
|
|
77
|
+
*
|
|
78
|
+
* @stability unstable
|
|
79
|
+
* @category events
|
|
80
|
+
* @since 4.1.5
|
|
81
|
+
*/
|
|
82
|
+
export declare const ButtonClicked: Schema.TaggedStruct<"ButtonClicked", {
|
|
83
|
+
readonly thread: Schema.Struct<{
|
|
84
|
+
readonly platform: Schema.String;
|
|
85
|
+
readonly id: Schema.String;
|
|
86
|
+
}>;
|
|
87
|
+
readonly messageId: Schema.String;
|
|
88
|
+
readonly userId: Schema.String;
|
|
89
|
+
readonly raw: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
90
|
+
readonly id: Schema.String;
|
|
91
|
+
readonly value: Schema.optionalKey<Schema.String>;
|
|
92
|
+
}>;
|
|
93
|
+
/**
|
|
94
|
+
* A click on a button.
|
|
95
|
+
*
|
|
96
|
+
* @stability unstable
|
|
97
|
+
* @category events
|
|
98
|
+
* @since 4.1.5
|
|
99
|
+
*/
|
|
100
|
+
export type ButtonClicked = typeof ButtonClicked.Type;
|
|
101
|
+
/**
|
|
102
|
+
* Schema for a choice in a select on a message. `value` is the chosen
|
|
103
|
+
* option's value, still encoded. `messageId` is as on `ButtonClicked`: on a
|
|
104
|
+
* command's private answer it tells which answer it was, and no message op
|
|
105
|
+
* works with it.
|
|
106
|
+
*
|
|
107
|
+
* @stability unstable
|
|
108
|
+
* @category events
|
|
109
|
+
* @since 4.1.5
|
|
110
|
+
*/
|
|
111
|
+
export declare const SelectChanged: Schema.TaggedStruct<"SelectChanged", {
|
|
112
|
+
readonly thread: Schema.Struct<{
|
|
113
|
+
readonly platform: Schema.String;
|
|
114
|
+
readonly id: Schema.String;
|
|
115
|
+
}>;
|
|
116
|
+
readonly messageId: Schema.String;
|
|
117
|
+
readonly userId: Schema.String;
|
|
118
|
+
readonly raw: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
119
|
+
readonly id: Schema.String;
|
|
120
|
+
readonly value: Schema.String;
|
|
121
|
+
}>;
|
|
122
|
+
/**
|
|
123
|
+
* A choice in a select on a message.
|
|
124
|
+
*
|
|
125
|
+
* @stability unstable
|
|
126
|
+
* @category events
|
|
127
|
+
* @since 4.1.5
|
|
128
|
+
*/
|
|
129
|
+
export type SelectChanged = typeof SelectChanged.Type;
|
|
130
|
+
/**
|
|
131
|
+
* Schema for a modal submit.
|
|
132
|
+
*
|
|
133
|
+
* **Details**
|
|
134
|
+
*
|
|
135
|
+
* - `thread` and `messageId` are those of the click that opened the modal.
|
|
136
|
+
* A modal a command opened carries the command's `thread` and no
|
|
137
|
+
* `messageId`. A modal opened from a command's private answer carries
|
|
138
|
+
* that answer's id, which no message op works with, as on
|
|
139
|
+
* `ButtonClicked`.
|
|
140
|
+
* - `metadata` is still encoded.
|
|
141
|
+
* - `values` are by field id, still encoded. An optional field left empty
|
|
142
|
+
* has no key.
|
|
143
|
+
*
|
|
144
|
+
* @stability unstable
|
|
145
|
+
* @category events
|
|
146
|
+
* @since 4.1.5
|
|
147
|
+
*/
|
|
148
|
+
export declare const ModalSubmitted: Schema.TaggedStruct<"ModalSubmitted", {
|
|
149
|
+
readonly id: Schema.String;
|
|
150
|
+
readonly metadata: Schema.optionalKey<Schema.String>;
|
|
151
|
+
readonly values: Schema.$Record<Schema.String, Schema.String>;
|
|
152
|
+
readonly thread: Schema.Struct<{
|
|
153
|
+
readonly platform: Schema.String;
|
|
154
|
+
readonly id: Schema.String;
|
|
155
|
+
}>;
|
|
156
|
+
readonly messageId: Schema.optionalKey<Schema.String>;
|
|
157
|
+
readonly userId: Schema.String;
|
|
158
|
+
readonly raw: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
159
|
+
}>;
|
|
160
|
+
/**
|
|
161
|
+
* A modal submit.
|
|
162
|
+
*
|
|
163
|
+
* @stability unstable
|
|
164
|
+
* @category events
|
|
165
|
+
* @since 4.1.5
|
|
166
|
+
*/
|
|
167
|
+
export type ModalSubmitted = typeof ModalSubmitted.Type;
|
|
168
|
+
/**
|
|
169
|
+
* Schema for a slash command.
|
|
170
|
+
*
|
|
171
|
+
* **Details**
|
|
172
|
+
*
|
|
173
|
+
* - `id` is the command's name, without the slash.
|
|
174
|
+
* - `text` is what was typed after the name, as the platform sent it, and
|
|
175
|
+
* empty when nothing was. It is not normalised.
|
|
176
|
+
* - `thread` is where the command was typed. On Slack that is always a
|
|
177
|
+
* channel or a direct: Slack does not deliver an app's command typed in a
|
|
178
|
+
* thread. There is no `messageId`, since a command comes from no message.
|
|
179
|
+
* - `raw` is the platform's payload. It holds what `Chat.followUp` needs,
|
|
180
|
+
* so it is a credential for as long as `limits.followUpAge`.
|
|
181
|
+
*
|
|
182
|
+
* @stability unstable
|
|
183
|
+
* @category events
|
|
184
|
+
* @since 4.1.5
|
|
185
|
+
*/
|
|
186
|
+
export declare const CommandInvoked: Schema.TaggedStruct<"CommandInvoked", {
|
|
187
|
+
readonly id: Schema.String;
|
|
188
|
+
readonly text: Schema.String;
|
|
189
|
+
readonly thread: Schema.Struct<{
|
|
190
|
+
readonly platform: Schema.String;
|
|
191
|
+
readonly id: Schema.String;
|
|
192
|
+
}>;
|
|
193
|
+
readonly userId: Schema.String;
|
|
194
|
+
readonly raw: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
195
|
+
}>;
|
|
196
|
+
/**
|
|
197
|
+
* A slash command.
|
|
198
|
+
*
|
|
199
|
+
* @stability unstable
|
|
200
|
+
* @category events
|
|
201
|
+
* @since 4.1.5
|
|
202
|
+
*/
|
|
203
|
+
export type CommandInvoked = typeof CommandInvoked.Type;
|
|
204
|
+
/**
|
|
205
|
+
* Schema for what an adapter hands to `Handler`.
|
|
206
|
+
*
|
|
207
|
+
* **Details**
|
|
208
|
+
*
|
|
209
|
+
* Not part of `ChatEvent`: these need an answer inside the platform's 3
|
|
210
|
+
* seconds.
|
|
211
|
+
*
|
|
212
|
+
* @stability unstable
|
|
213
|
+
* @category events
|
|
214
|
+
* @since 4.1.5
|
|
215
|
+
*/
|
|
216
|
+
export declare const Interaction: Schema.Union<readonly [Schema.TaggedStruct<"ButtonClicked", {
|
|
217
|
+
readonly thread: Schema.Struct<{
|
|
218
|
+
readonly platform: Schema.String;
|
|
219
|
+
readonly id: Schema.String;
|
|
220
|
+
}>;
|
|
221
|
+
readonly messageId: Schema.String;
|
|
222
|
+
readonly userId: Schema.String;
|
|
223
|
+
readonly raw: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
224
|
+
readonly id: Schema.String;
|
|
225
|
+
readonly value: Schema.optionalKey<Schema.String>;
|
|
226
|
+
}>, Schema.TaggedStruct<"SelectChanged", {
|
|
227
|
+
readonly thread: Schema.Struct<{
|
|
228
|
+
readonly platform: Schema.String;
|
|
229
|
+
readonly id: Schema.String;
|
|
230
|
+
}>;
|
|
231
|
+
readonly messageId: Schema.String;
|
|
232
|
+
readonly userId: Schema.String;
|
|
233
|
+
readonly raw: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
234
|
+
readonly id: Schema.String;
|
|
235
|
+
readonly value: Schema.String;
|
|
236
|
+
}>, Schema.TaggedStruct<"ModalSubmitted", {
|
|
237
|
+
readonly id: Schema.String;
|
|
238
|
+
readonly metadata: Schema.optionalKey<Schema.String>;
|
|
239
|
+
readonly values: Schema.$Record<Schema.String, Schema.String>;
|
|
240
|
+
readonly thread: Schema.Struct<{
|
|
241
|
+
readonly platform: Schema.String;
|
|
242
|
+
readonly id: Schema.String;
|
|
243
|
+
}>;
|
|
244
|
+
readonly messageId: Schema.optionalKey<Schema.String>;
|
|
245
|
+
readonly userId: Schema.String;
|
|
246
|
+
readonly raw: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
247
|
+
}>, Schema.TaggedStruct<"CommandInvoked", {
|
|
248
|
+
readonly id: Schema.String;
|
|
249
|
+
readonly text: Schema.String;
|
|
250
|
+
readonly thread: Schema.Struct<{
|
|
251
|
+
readonly platform: Schema.String;
|
|
252
|
+
readonly id: Schema.String;
|
|
253
|
+
}>;
|
|
254
|
+
readonly userId: Schema.String;
|
|
255
|
+
readonly raw: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
256
|
+
}>]>;
|
|
257
|
+
/**
|
|
258
|
+
* A click, a select choice, a modal submit or a slash command.
|
|
259
|
+
*
|
|
260
|
+
* @stability unstable
|
|
261
|
+
* @category events
|
|
262
|
+
* @since 4.1.5
|
|
263
|
+
*/
|
|
264
|
+
export type Interaction = typeof Interaction.Type;
|
|
265
|
+
/**
|
|
266
|
+
* Schema for the reply that acknowledges a click. It is also what the handler
|
|
267
|
+
* service answers a command with no definition, which the adapter sends
|
|
268
|
+
* nothing for.
|
|
269
|
+
*
|
|
270
|
+
* @stability unstable
|
|
271
|
+
* @category replies
|
|
272
|
+
* @since 4.1.5
|
|
273
|
+
*/
|
|
274
|
+
export declare const Ack: Schema.TaggedStruct<"Ack", {}>;
|
|
275
|
+
/**
|
|
276
|
+
* The reply that acknowledges a click.
|
|
277
|
+
*
|
|
278
|
+
* @stability unstable
|
|
279
|
+
* @category replies
|
|
280
|
+
* @since 4.1.5
|
|
281
|
+
*/
|
|
282
|
+
export type Ack = typeof Ack.Type;
|
|
283
|
+
/**
|
|
284
|
+
* Schema for the reply that opens a modal. A click or a command can return
|
|
285
|
+
* it.
|
|
286
|
+
*
|
|
287
|
+
* @stability unstable
|
|
288
|
+
* @category replies
|
|
289
|
+
* @since 4.1.5
|
|
290
|
+
*/
|
|
291
|
+
export declare const OpenModal: Schema.TaggedStruct<"OpenModal", {
|
|
292
|
+
readonly modal: Schema.TaggedStruct<"Modal", {
|
|
293
|
+
readonly id: Schema.String;
|
|
294
|
+
readonly title: Schema.String;
|
|
295
|
+
readonly submitLabel: Schema.optionalKey<Schema.String>;
|
|
296
|
+
readonly metadata: Schema.optionalKey<Schema.String>;
|
|
297
|
+
readonly elements: Schema.$Array<Schema.Union<readonly [Schema.TaggedStruct<"TextInput", {
|
|
298
|
+
readonly id: Schema.String;
|
|
299
|
+
readonly label: Schema.String;
|
|
300
|
+
readonly multiline: Schema.optionalKey<Schema.Boolean>;
|
|
301
|
+
readonly placeholder: Schema.optionalKey<Schema.String>;
|
|
302
|
+
readonly initial: Schema.optionalKey<Schema.String>;
|
|
303
|
+
readonly optional: Schema.optionalKey<Schema.Boolean>;
|
|
304
|
+
readonly minLength: Schema.optionalKey<Schema.Int>;
|
|
305
|
+
readonly maxLength: Schema.optionalKey<Schema.Int>;
|
|
306
|
+
}>, Schema.TaggedStruct<"SelectInput", {
|
|
307
|
+
readonly id: Schema.String;
|
|
308
|
+
readonly label: Schema.String;
|
|
309
|
+
readonly placeholder: Schema.optionalKey<Schema.String>;
|
|
310
|
+
readonly options: Schema.$Array<Schema.Struct<{
|
|
311
|
+
readonly label: Schema.String;
|
|
312
|
+
readonly value: Schema.String;
|
|
313
|
+
}>>;
|
|
314
|
+
readonly initial: Schema.optionalKey<Schema.String>;
|
|
315
|
+
readonly optional: Schema.optionalKey<Schema.Boolean>;
|
|
316
|
+
}>, Schema.TaggedStruct<"Text", {
|
|
317
|
+
readonly text: Schema.String;
|
|
318
|
+
}>]>>;
|
|
319
|
+
}>;
|
|
320
|
+
}>;
|
|
321
|
+
/**
|
|
322
|
+
* The reply that opens a modal.
|
|
323
|
+
*
|
|
324
|
+
* @stability unstable
|
|
325
|
+
* @category replies
|
|
326
|
+
* @since 4.1.5
|
|
327
|
+
*/
|
|
328
|
+
export type OpenModal = typeof OpenModal.Type;
|
|
329
|
+
/**
|
|
330
|
+
* Schema for the reply that closes a submitted modal.
|
|
331
|
+
*
|
|
332
|
+
* @stability unstable
|
|
333
|
+
* @category replies
|
|
334
|
+
* @since 4.1.5
|
|
335
|
+
*/
|
|
336
|
+
export declare const Close: Schema.TaggedStruct<"Close", {}>;
|
|
337
|
+
/**
|
|
338
|
+
* The reply that closes a submitted modal.
|
|
339
|
+
*
|
|
340
|
+
* @stability unstable
|
|
341
|
+
* @category replies
|
|
342
|
+
* @since 4.1.5
|
|
343
|
+
*/
|
|
344
|
+
export type Close = typeof Close.Type;
|
|
345
|
+
/**
|
|
346
|
+
* Schema for the reply that puts a message under each named field of a
|
|
347
|
+
* submitted modal. `errors` is by field id.
|
|
348
|
+
*
|
|
349
|
+
* **Details**
|
|
350
|
+
*
|
|
351
|
+
* With `modalErrors` the modal stays open with the messages under its
|
|
352
|
+
* fields. Without it the adapter answers some other way: on Discord a private
|
|
353
|
+
* reply lists them and the modal closes.
|
|
354
|
+
*
|
|
355
|
+
* @stability unstable
|
|
356
|
+
* @category replies
|
|
357
|
+
* @since 4.1.5
|
|
358
|
+
*/
|
|
359
|
+
export declare const Errors: Schema.TaggedStruct<"Errors", {
|
|
360
|
+
readonly errors: Schema.$Record<Schema.String, Schema.String>;
|
|
361
|
+
}>;
|
|
362
|
+
/**
|
|
363
|
+
* The reply that puts a message under each named field.
|
|
364
|
+
*
|
|
365
|
+
* @stability unstable
|
|
366
|
+
* @category replies
|
|
367
|
+
* @since 4.1.5
|
|
368
|
+
*/
|
|
369
|
+
export type Errors = typeof Errors.Type;
|
|
370
|
+
/**
|
|
371
|
+
* What a click's handler may answer.
|
|
372
|
+
*
|
|
373
|
+
* @stability unstable
|
|
374
|
+
* @category replies
|
|
375
|
+
* @since 4.1.5
|
|
376
|
+
*/
|
|
377
|
+
export type ClickReply = Ack | OpenModal;
|
|
378
|
+
/**
|
|
379
|
+
* What a submit's handler may answer.
|
|
380
|
+
*
|
|
381
|
+
* @stability unstable
|
|
382
|
+
* @category replies
|
|
383
|
+
* @since 4.1.5
|
|
384
|
+
*/
|
|
385
|
+
export type SubmitReply = Close | Errors;
|
|
386
|
+
/**
|
|
387
|
+
* Schema for who sees the answer to a command: `"ephemeral"` for the person
|
|
388
|
+
* who ran it, `"public"` for the channel.
|
|
389
|
+
*
|
|
390
|
+
* @stability unstable
|
|
391
|
+
* @category replies
|
|
392
|
+
* @since 4.1.5
|
|
393
|
+
*/
|
|
394
|
+
export declare const Visibility: Schema.Literals<readonly ["ephemeral", "public"]>;
|
|
395
|
+
/**
|
|
396
|
+
* Who sees the answer to a command.
|
|
397
|
+
*
|
|
398
|
+
* @stability unstable
|
|
399
|
+
* @category replies
|
|
400
|
+
* @since 4.1.5
|
|
401
|
+
*/
|
|
402
|
+
export type Visibility = typeof Visibility.Type;
|
|
403
|
+
/**
|
|
404
|
+
* Schema for the reply that answers a command with a message, at once.
|
|
405
|
+
*
|
|
406
|
+
* **Details**
|
|
407
|
+
*
|
|
408
|
+
* `markdown` and `actions` are rendered and checked the way `post` renders
|
|
409
|
+
* and checks them, with the default post options. `withPostOptions` does
|
|
410
|
+
* not reach it, so it never mentions anyone: on Slack a mention token is
|
|
411
|
+
* escaped and shows as text, and on Discord it renders and notifies nobody.
|
|
412
|
+
* The message gets no id: it cannot be edited, deleted or fetched
|
|
413
|
+
* afterwards. A click on its elements carries a `messageId`, which for a
|
|
414
|
+
* private answer tells which answer it was and works with no message op.
|
|
415
|
+
*
|
|
416
|
+
* @stability unstable
|
|
417
|
+
* @category replies
|
|
418
|
+
* @since 4.1.5
|
|
419
|
+
*/
|
|
420
|
+
export declare const Respond: Schema.TaggedStruct<"Respond", {
|
|
421
|
+
readonly markdown: Schema.String;
|
|
422
|
+
readonly actions: Schema.optionalKey<Schema.$Array<Schema.Union<readonly [Schema.TaggedStruct<"Button", {
|
|
423
|
+
readonly id: Schema.String;
|
|
424
|
+
readonly label: Schema.String;
|
|
425
|
+
readonly style: Schema.optionalKey<Schema.Literals<readonly ["default", "primary", "danger"]>>;
|
|
426
|
+
readonly value: Schema.optionalKey<Schema.String>;
|
|
427
|
+
}>, Schema.TaggedStruct<"LinkButton", {
|
|
428
|
+
readonly label: Schema.String;
|
|
429
|
+
readonly url: Schema.String;
|
|
430
|
+
}>, Schema.TaggedStruct<"Select", {
|
|
431
|
+
readonly id: Schema.String;
|
|
432
|
+
readonly placeholder: Schema.optionalKey<Schema.String>;
|
|
433
|
+
readonly options: Schema.$Array<Schema.Struct<{
|
|
434
|
+
readonly label: Schema.String;
|
|
435
|
+
readonly value: Schema.String;
|
|
436
|
+
}>>;
|
|
437
|
+
readonly selected: Schema.optionalKey<Schema.String>;
|
|
438
|
+
}>]>>>;
|
|
439
|
+
readonly visibility: Schema.Literals<readonly ["ephemeral", "public"]>;
|
|
440
|
+
}>;
|
|
441
|
+
/**
|
|
442
|
+
* The reply that answers a command with a message.
|
|
443
|
+
*
|
|
444
|
+
* @stability unstable
|
|
445
|
+
* @category replies
|
|
446
|
+
* @since 4.1.5
|
|
447
|
+
*/
|
|
448
|
+
export type Respond = typeof Respond.Type;
|
|
449
|
+
/**
|
|
450
|
+
* Schema for the reply that says a command's answer comes later, and the
|
|
451
|
+
* value `Chat.followUp` takes to send it.
|
|
452
|
+
*
|
|
453
|
+
* **Details**
|
|
454
|
+
*
|
|
455
|
+
* - It is plain data, so it can go on a queue to another process.
|
|
456
|
+
* - `visibility` is fixed here. `followUp` has none of its own.
|
|
457
|
+
* - The first `followUp` for it is the answer. A second one is
|
|
458
|
+
* platform-specific: Slack posts another message, up to five, and Discord
|
|
459
|
+
* overwrites the first. Neither adapter stops it.
|
|
460
|
+
*
|
|
461
|
+
* **Gotchas**
|
|
462
|
+
*
|
|
463
|
+
* It holds the command's `raw`, which is a credential for as long as
|
|
464
|
+
* `limits.followUpAge`.
|
|
465
|
+
*
|
|
466
|
+
* @stability unstable
|
|
467
|
+
* @category replies
|
|
468
|
+
* @since 4.1.5
|
|
469
|
+
*/
|
|
470
|
+
export declare const Defer: Schema.TaggedStruct<"Defer", {
|
|
471
|
+
readonly command: Schema.TaggedStruct<"CommandInvoked", {
|
|
472
|
+
readonly id: Schema.String;
|
|
473
|
+
readonly text: Schema.String;
|
|
474
|
+
readonly thread: Schema.Struct<{
|
|
475
|
+
readonly platform: Schema.String;
|
|
476
|
+
readonly id: Schema.String;
|
|
477
|
+
}>;
|
|
478
|
+
readonly userId: Schema.String;
|
|
479
|
+
readonly raw: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
480
|
+
}>;
|
|
481
|
+
readonly visibility: Schema.Literals<readonly ["ephemeral", "public"]>;
|
|
482
|
+
}>;
|
|
483
|
+
/**
|
|
484
|
+
* The reply that says a command's answer comes later.
|
|
485
|
+
*
|
|
486
|
+
* @stability unstable
|
|
487
|
+
* @category replies
|
|
488
|
+
* @since 4.1.5
|
|
489
|
+
*/
|
|
490
|
+
export type Defer = typeof Defer.Type;
|
|
491
|
+
/**
|
|
492
|
+
* What the handler service may answer a command with.
|
|
493
|
+
*
|
|
494
|
+
* **Details**
|
|
495
|
+
*
|
|
496
|
+
* `Ack` is what a command with no definition gets, and the adapter sends
|
|
497
|
+
* nothing for it. A typed command handler cannot return it.
|
|
498
|
+
*
|
|
499
|
+
* @stability unstable
|
|
500
|
+
* @category replies
|
|
501
|
+
* @since 4.1.5
|
|
502
|
+
*/
|
|
503
|
+
export type CommandReply = Ack | Respond | OpenModal | Defer;
|
|
504
|
+
/**
|
|
505
|
+
* Schema for what `handle` gives when the handler ran past the deadline.
|
|
506
|
+
*
|
|
507
|
+
* **Gotchas**
|
|
508
|
+
*
|
|
509
|
+
* `Late` is never sent to a platform. It is a tagged struct, so it is itself
|
|
510
|
+
* a JSON value: test for it with `Schema.is(ChatInteraction.Late)`.
|
|
511
|
+
*
|
|
512
|
+
* @stability unstable
|
|
513
|
+
* @category replies
|
|
514
|
+
* @since 4.1.5
|
|
515
|
+
*/
|
|
516
|
+
export declare const Late: Schema.TaggedStruct<"Late", {}>;
|
|
517
|
+
/**
|
|
518
|
+
* What `handle` gives when the handler ran past the deadline.
|
|
519
|
+
*
|
|
520
|
+
* @stability unstable
|
|
521
|
+
* @category replies
|
|
522
|
+
* @since 4.1.5
|
|
523
|
+
*/
|
|
524
|
+
export type Late = typeof Late.Type;
|
|
525
|
+
/**
|
|
526
|
+
* `Errors`, with the field ids it names kept in the type, so a typed submit
|
|
527
|
+
* handler can refuse a field the modal does not have. The extra property
|
|
528
|
+
* exists only in the type.
|
|
529
|
+
*
|
|
530
|
+
* @stability unstable
|
|
531
|
+
* @category replies
|
|
532
|
+
* @since 4.1.5
|
|
533
|
+
*/
|
|
534
|
+
export interface FieldErrors<out Field extends string> extends Errors {
|
|
535
|
+
readonly "~fields"?: Field | undefined;
|
|
536
|
+
}
|
|
537
|
+
/**
|
|
538
|
+
* Acknowledges a click.
|
|
539
|
+
*
|
|
540
|
+
* @stability unstable
|
|
541
|
+
* @category replies
|
|
542
|
+
* @since 4.1.5
|
|
543
|
+
*/
|
|
544
|
+
export declare const ack: Ack;
|
|
545
|
+
/**
|
|
546
|
+
* Closes a submitted modal.
|
|
547
|
+
*
|
|
548
|
+
* @stability unstable
|
|
549
|
+
* @category replies
|
|
550
|
+
* @since 4.1.5
|
|
551
|
+
*/
|
|
552
|
+
export declare const close: Close;
|
|
553
|
+
/**
|
|
554
|
+
* Puts a message under each named field of a submitted modal.
|
|
555
|
+
*
|
|
556
|
+
* **Details**
|
|
557
|
+
*
|
|
558
|
+
* In a typed submit handler, only the modal's input ids are accepted.
|
|
559
|
+
*
|
|
560
|
+
* @stability unstable
|
|
561
|
+
* @category replies
|
|
562
|
+
* @since 4.1.5
|
|
563
|
+
*/
|
|
564
|
+
export declare const errors: <const E extends {
|
|
565
|
+
readonly [field: string]: string;
|
|
566
|
+
}>(errors: E) => FieldErrors<keyof E & string>;
|
|
567
|
+
/**
|
|
568
|
+
* Answers a command with a message, at once.
|
|
569
|
+
*
|
|
570
|
+
* **Details**
|
|
571
|
+
*
|
|
572
|
+
* `visibility` defaults to `"ephemeral"`: only the person who ran the
|
|
573
|
+
* command sees it. A platform without `ephemeral` refuses a private answer
|
|
574
|
+
* and sends nothing. It never sends it publicly instead.
|
|
575
|
+
*
|
|
576
|
+
* @stability unstable
|
|
577
|
+
* @category replies
|
|
578
|
+
* @since 4.1.5
|
|
579
|
+
*/
|
|
580
|
+
export declare const respond: (options: {
|
|
581
|
+
readonly markdown: string;
|
|
582
|
+
readonly actions?: ReadonlyArray<ChatUi.Action> | undefined;
|
|
583
|
+
readonly visibility?: Visibility | undefined;
|
|
584
|
+
}) => Respond;
|
|
585
|
+
/**
|
|
586
|
+
* Answers a command with a promise of a later answer, sent with
|
|
587
|
+
* `Chat.followUp`.
|
|
588
|
+
*
|
|
589
|
+
* **When to use**
|
|
590
|
+
*
|
|
591
|
+
* Use when the work does not fit in the deadline. The handler returns the
|
|
592
|
+
* deferral and hands it to whatever does the work.
|
|
593
|
+
*
|
|
594
|
+
* **Details**
|
|
595
|
+
*
|
|
596
|
+
* - `visibility` defaults to `"ephemeral"`, and holds for the follow-up.
|
|
597
|
+
* - One `Chat.followUp` per deferral is the portable contract. The first
|
|
598
|
+
* call is the answer. A second is platform-specific: a new message on
|
|
599
|
+
* Slack, up to five, and an overwrite of the first on Discord.
|
|
600
|
+
*
|
|
601
|
+
* @stability unstable
|
|
602
|
+
* @category replies
|
|
603
|
+
* @since 4.1.5
|
|
604
|
+
*/
|
|
605
|
+
export declare const defer: (command: CommandInvoked, options?: {
|
|
606
|
+
readonly visibility?: Visibility | undefined;
|
|
607
|
+
}) => Defer;
|
|
608
|
+
/**
|
|
609
|
+
* A click as a button's handler receives it.
|
|
610
|
+
*
|
|
611
|
+
* **Details**
|
|
612
|
+
*
|
|
613
|
+
* `value` is decoded with the button's value schema, and `undefined` when it
|
|
614
|
+
* has none.
|
|
615
|
+
*
|
|
616
|
+
* @stability unstable
|
|
617
|
+
* @category models
|
|
618
|
+
* @since 4.1.5
|
|
619
|
+
*/
|
|
620
|
+
export interface Click<out Value> {
|
|
621
|
+
readonly id: string;
|
|
622
|
+
readonly value: Value;
|
|
623
|
+
readonly thread: ChatThread;
|
|
624
|
+
readonly messageId: string;
|
|
625
|
+
readonly userId: string;
|
|
626
|
+
readonly raw: Schema.Json;
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* A choice as a select's handler receives it. `value` is the chosen option,
|
|
630
|
+
* decoded.
|
|
631
|
+
*
|
|
632
|
+
* @stability unstable
|
|
633
|
+
* @category models
|
|
634
|
+
* @since 4.1.5
|
|
635
|
+
*/
|
|
636
|
+
export interface Selected<out Value> {
|
|
637
|
+
readonly id: string;
|
|
638
|
+
readonly value: Value;
|
|
639
|
+
readonly thread: ChatThread;
|
|
640
|
+
readonly messageId: string;
|
|
641
|
+
readonly userId: string;
|
|
642
|
+
readonly raw: Schema.Json;
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* A submit as a modal's handler receives it, with the metadata and values
|
|
646
|
+
* decoded.
|
|
647
|
+
*
|
|
648
|
+
* **Details**
|
|
649
|
+
*
|
|
650
|
+
* - `values` has one key per input and none for `text`. An optional input
|
|
651
|
+
* left empty is `undefined`.
|
|
652
|
+
* - `messageId` is the message whose element opened the modal, and
|
|
653
|
+
* `undefined` when a command opened it.
|
|
654
|
+
*
|
|
655
|
+
* @stability unstable
|
|
656
|
+
* @category models
|
|
657
|
+
* @since 4.1.5
|
|
658
|
+
*/
|
|
659
|
+
export interface Submit<out Metadata, out Values> {
|
|
660
|
+
readonly id: string;
|
|
661
|
+
readonly metadata: Metadata;
|
|
662
|
+
readonly values: Values;
|
|
663
|
+
readonly thread: ChatThread;
|
|
664
|
+
readonly messageId: string | undefined;
|
|
665
|
+
readonly userId: string;
|
|
666
|
+
readonly raw: Schema.Json;
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* The type id of definitions and groups.
|
|
670
|
+
*
|
|
671
|
+
* @stability unstable
|
|
672
|
+
* @category type ids
|
|
673
|
+
* @since 4.1.5
|
|
674
|
+
*/
|
|
675
|
+
export declare const TypeId = "~effect/chat/ChatInteraction";
|
|
676
|
+
/**
|
|
677
|
+
* A value's schema.
|
|
678
|
+
*
|
|
679
|
+
* **Details**
|
|
680
|
+
*
|
|
681
|
+
* It may not need services, because it is encoded inside `of` and `open`,
|
|
682
|
+
* which are plain functions.
|
|
683
|
+
*
|
|
684
|
+
* @stability unstable
|
|
685
|
+
* @category models
|
|
686
|
+
* @since 4.1.5
|
|
687
|
+
*/
|
|
688
|
+
export type ValueSchema = Schema.Codec<any, any, never, never>;
|
|
689
|
+
type TypeOf<S, Fallback> = S extends ValueSchema ? S["Type"] : Fallback;
|
|
690
|
+
/**
|
|
691
|
+
* Encodes a value into the string an element carries.
|
|
692
|
+
*
|
|
693
|
+
* **When to use**
|
|
694
|
+
*
|
|
695
|
+
* Use when routing clicks yourself. `of` and `open` already run it.
|
|
696
|
+
*
|
|
697
|
+
* **Details**
|
|
698
|
+
*
|
|
699
|
+
* The value goes through `Schema.toCodecJson`. The form on the wire is decided
|
|
700
|
+
* once per schema, from the codec's encoded side, never per value:
|
|
701
|
+
*
|
|
702
|
+
* - when the encoded side can only be a string (`String`, a brand of it,
|
|
703
|
+
* string literals, a template literal, or a union of those), the string is
|
|
704
|
+
* sent as it is
|
|
705
|
+
* - otherwise the encoded value goes through `JSON.stringify`, and back
|
|
706
|
+
* through `JSON.parse`
|
|
707
|
+
*
|
|
708
|
+
* **Gotchas**
|
|
709
|
+
*
|
|
710
|
+
* Throws when the value has no JSON form, as `Schema.encodeSync` does.
|
|
711
|
+
*
|
|
712
|
+
* @stability unstable
|
|
713
|
+
* @category values
|
|
714
|
+
* @since 4.1.5
|
|
715
|
+
*/
|
|
716
|
+
export declare const encodeValue: <S extends ValueSchema>(schema: S, value: S["Type"]) => string;
|
|
717
|
+
/**
|
|
718
|
+
* Decodes the string an element carried, as `encodeValue` wrote it.
|
|
719
|
+
*
|
|
720
|
+
* **Details**
|
|
721
|
+
*
|
|
722
|
+
* Gives none for a string that no longer decodes, which is what a value
|
|
723
|
+
* posted under an older schema can do.
|
|
724
|
+
*
|
|
725
|
+
* @stability unstable
|
|
726
|
+
* @category values
|
|
727
|
+
* @since 4.1.5
|
|
728
|
+
*/
|
|
729
|
+
export declare const decodeValue: <S extends ValueSchema>(schema: S, encoded: string) => Option.Option<S["Type"]>;
|
|
730
|
+
/**
|
|
731
|
+
* A button definition.
|
|
732
|
+
*
|
|
733
|
+
* **Details**
|
|
734
|
+
*
|
|
735
|
+
* `of` gives the element to post. It takes the value when the definition has
|
|
736
|
+
* a schema for one, and `overrides` change the label or style of this one
|
|
737
|
+
* element.
|
|
738
|
+
*
|
|
739
|
+
* **Gotchas**
|
|
740
|
+
*
|
|
741
|
+
* `of` throws when the value cannot be encoded (a schema with no JSON form),
|
|
742
|
+
* as `Schema.encodeSync` does.
|
|
743
|
+
*
|
|
744
|
+
* @stability unstable
|
|
745
|
+
* @category definitions
|
|
746
|
+
* @since 4.1.5
|
|
747
|
+
*/
|
|
748
|
+
export interface Button<out Id extends string, out Value extends ValueSchema | undefined = undefined> {
|
|
749
|
+
readonly [TypeId]: typeof TypeId;
|
|
750
|
+
readonly kind: "button";
|
|
751
|
+
readonly id: Id;
|
|
752
|
+
readonly label: string;
|
|
753
|
+
readonly style: ChatUi.ButtonStyle | undefined;
|
|
754
|
+
readonly value: Value;
|
|
755
|
+
readonly of: (...args: Value extends ValueSchema ? [value: Value["Type"], overrides?: Button.Overrides] : [overrides?: Button.Overrides]) => ChatUi.Button;
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* Types that go with a button definition.
|
|
759
|
+
*
|
|
760
|
+
* @stability unstable
|
|
761
|
+
* @since 4.1.5
|
|
762
|
+
*/
|
|
763
|
+
export declare namespace Button {
|
|
764
|
+
/**
|
|
765
|
+
* What one element may change from its definition.
|
|
766
|
+
*
|
|
767
|
+
* @stability unstable
|
|
768
|
+
* @category models
|
|
769
|
+
* @since 4.1.5
|
|
770
|
+
*/
|
|
771
|
+
interface Overrides {
|
|
772
|
+
readonly label?: string | undefined;
|
|
773
|
+
readonly style?: ChatUi.ButtonStyle | undefined;
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* Defines a button.
|
|
778
|
+
*
|
|
779
|
+
* **Details**
|
|
780
|
+
*
|
|
781
|
+
* - The id names the handler in a `group`. It is sent to the platform as is,
|
|
782
|
+
* and counts toward `limits.actionDataLength` with the encoded value.
|
|
783
|
+
* - With no `value` schema the button carries no value, and its click's
|
|
784
|
+
* `value` is `undefined`.
|
|
785
|
+
*
|
|
786
|
+
* @stability unstable
|
|
787
|
+
* @category definitions
|
|
788
|
+
* @since 4.1.5
|
|
789
|
+
*/
|
|
790
|
+
export declare const button: <const Id extends string, Value extends ValueSchema | undefined = undefined>(id: Id, options: {
|
|
791
|
+
readonly label: string;
|
|
792
|
+
readonly style?: ChatUi.ButtonStyle | undefined;
|
|
793
|
+
readonly value?: Value;
|
|
794
|
+
}) => Button<Id, Value>;
|
|
795
|
+
/**
|
|
796
|
+
* A select definition, for a message. Its options are given at the post, to
|
|
797
|
+
* `of`.
|
|
798
|
+
*
|
|
799
|
+
* **Gotchas**
|
|
800
|
+
*
|
|
801
|
+
* `of` throws when an option's value cannot be encoded.
|
|
802
|
+
*
|
|
803
|
+
* @stability unstable
|
|
804
|
+
* @category definitions
|
|
805
|
+
* @since 4.1.5
|
|
806
|
+
*/
|
|
807
|
+
export interface Select<out Id extends string, out Value extends ValueSchema | undefined = undefined> {
|
|
808
|
+
readonly [TypeId]: typeof TypeId;
|
|
809
|
+
readonly kind: "select";
|
|
810
|
+
readonly id: Id;
|
|
811
|
+
readonly placeholder: string | undefined;
|
|
812
|
+
readonly value: Value;
|
|
813
|
+
readonly of: (options: {
|
|
814
|
+
readonly options: ReadonlyArray<{
|
|
815
|
+
readonly label: string;
|
|
816
|
+
readonly value: TypeOf<Value, string>;
|
|
817
|
+
}>;
|
|
818
|
+
readonly selected?: TypeOf<Value, string> | undefined;
|
|
819
|
+
}) => ChatUi.Select;
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* Defines a single-choice select for a message.
|
|
823
|
+
*
|
|
824
|
+
* **Details**
|
|
825
|
+
*
|
|
826
|
+
* With no `value` schema the options' values are plain strings.
|
|
827
|
+
*
|
|
828
|
+
* @stability unstable
|
|
829
|
+
* @category definitions
|
|
830
|
+
* @since 4.1.5
|
|
831
|
+
*/
|
|
832
|
+
export declare const select: <const Id extends string, Value extends ValueSchema | undefined = undefined>(id: Id, options: {
|
|
833
|
+
readonly placeholder?: string | undefined;
|
|
834
|
+
readonly value?: Value;
|
|
835
|
+
}) => Select<Id, Value>;
|
|
836
|
+
/**
|
|
837
|
+
* A text input in a modal, one line or several.
|
|
838
|
+
*
|
|
839
|
+
* @stability unstable
|
|
840
|
+
* @category fields
|
|
841
|
+
* @since 4.1.5
|
|
842
|
+
*/
|
|
843
|
+
export interface TextInput<out Optional extends boolean = false> {
|
|
844
|
+
readonly [TypeId]: typeof TypeId;
|
|
845
|
+
readonly kind: "textInput";
|
|
846
|
+
readonly label: string;
|
|
847
|
+
readonly multiline: boolean;
|
|
848
|
+
readonly placeholder: string | undefined;
|
|
849
|
+
readonly optional: Optional;
|
|
850
|
+
readonly minLength: number | undefined;
|
|
851
|
+
readonly maxLength: number | undefined;
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* Defines a text input for a modal. Its id is its key in `fields`.
|
|
855
|
+
*
|
|
856
|
+
* **Details**
|
|
857
|
+
*
|
|
858
|
+
* Its value is a `string`, or `string | undefined` when `optional` is true.
|
|
859
|
+
*
|
|
860
|
+
* @stability unstable
|
|
861
|
+
* @category fields
|
|
862
|
+
* @since 4.1.5
|
|
863
|
+
*/
|
|
864
|
+
export declare const textInput: <const Optional extends boolean = false>(options: {
|
|
865
|
+
readonly label: string;
|
|
866
|
+
readonly multiline?: boolean | undefined;
|
|
867
|
+
readonly placeholder?: string | undefined;
|
|
868
|
+
readonly optional?: Optional | undefined;
|
|
869
|
+
readonly minLength?: number | undefined;
|
|
870
|
+
readonly maxLength?: number | undefined;
|
|
871
|
+
}) => TextInput<NoInfer<Optional>>;
|
|
872
|
+
/**
|
|
873
|
+
* A select in a modal whose options are fixed in the definition.
|
|
874
|
+
*
|
|
875
|
+
* @stability unstable
|
|
876
|
+
* @category fields
|
|
877
|
+
* @since 4.1.5
|
|
878
|
+
*/
|
|
879
|
+
export interface Choice<out Value extends string, out Optional extends boolean = false> {
|
|
880
|
+
readonly [TypeId]: typeof TypeId;
|
|
881
|
+
readonly kind: "choice";
|
|
882
|
+
readonly label: string;
|
|
883
|
+
readonly placeholder: string | undefined;
|
|
884
|
+
readonly options: ReadonlyArray<{
|
|
885
|
+
readonly label: string;
|
|
886
|
+
readonly value: Value;
|
|
887
|
+
}>;
|
|
888
|
+
readonly optional: Optional;
|
|
889
|
+
}
|
|
890
|
+
/**
|
|
891
|
+
* Defines a select for a modal whose options are fixed here. Its value is the
|
|
892
|
+
* union of the option values.
|
|
893
|
+
*
|
|
894
|
+
* @stability unstable
|
|
895
|
+
* @category fields
|
|
896
|
+
* @since 4.1.5
|
|
897
|
+
*/
|
|
898
|
+
export declare const choice: <const Value extends string, const Optional extends boolean = false>(options: {
|
|
899
|
+
readonly label: string;
|
|
900
|
+
readonly placeholder?: string | undefined;
|
|
901
|
+
readonly options: ReadonlyArray<{
|
|
902
|
+
readonly label: string;
|
|
903
|
+
readonly value: Value;
|
|
904
|
+
}>;
|
|
905
|
+
readonly optional?: Optional | undefined;
|
|
906
|
+
}) => Choice<Value, NoInfer<Optional>>;
|
|
907
|
+
/**
|
|
908
|
+
* A select in a modal whose options are given when the modal opens.
|
|
909
|
+
*
|
|
910
|
+
* @stability unstable
|
|
911
|
+
* @category fields
|
|
912
|
+
* @since 4.1.5
|
|
913
|
+
*/
|
|
914
|
+
export interface SelectInput<out Value extends ValueSchema | undefined = undefined, out Optional extends boolean = false> {
|
|
915
|
+
readonly [TypeId]: typeof TypeId;
|
|
916
|
+
readonly kind: "selectInput";
|
|
917
|
+
readonly label: string;
|
|
918
|
+
readonly placeholder: string | undefined;
|
|
919
|
+
readonly value: Value;
|
|
920
|
+
readonly optional: Optional;
|
|
921
|
+
}
|
|
922
|
+
/**
|
|
923
|
+
* Defines a select for a modal. Its id is its key in `fields`, and its
|
|
924
|
+
* options are given to the modal's `open`.
|
|
925
|
+
*
|
|
926
|
+
* @stability unstable
|
|
927
|
+
* @category fields
|
|
928
|
+
* @since 4.1.5
|
|
929
|
+
*/
|
|
930
|
+
export declare const selectInput: <Value extends ValueSchema | undefined = undefined, const Optional extends boolean = false>(options: {
|
|
931
|
+
readonly label: string;
|
|
932
|
+
readonly placeholder?: string | undefined;
|
|
933
|
+
readonly value?: Value;
|
|
934
|
+
readonly optional?: Optional | undefined;
|
|
935
|
+
}) => SelectInput<Value, NoInfer<Optional>>;
|
|
936
|
+
/**
|
|
937
|
+
* Plain text between a modal's inputs.
|
|
938
|
+
*
|
|
939
|
+
* @stability unstable
|
|
940
|
+
* @category fields
|
|
941
|
+
* @since 4.1.5
|
|
942
|
+
*/
|
|
943
|
+
export interface Text {
|
|
944
|
+
readonly [TypeId]: typeof TypeId;
|
|
945
|
+
readonly kind: "text";
|
|
946
|
+
readonly text: string;
|
|
947
|
+
}
|
|
948
|
+
/**
|
|
949
|
+
* Defines plain text for a modal. It has no value, so its key is not in
|
|
950
|
+
* `submit.values`.
|
|
951
|
+
*
|
|
952
|
+
* **Gotchas**
|
|
953
|
+
*
|
|
954
|
+
* The text is plain, not Markdown.
|
|
955
|
+
*
|
|
956
|
+
* @stability unstable
|
|
957
|
+
* @category fields
|
|
958
|
+
* @since 4.1.5
|
|
959
|
+
*/
|
|
960
|
+
export declare const text: (text: string) => Text;
|
|
961
|
+
/**
|
|
962
|
+
* Any field of a modal.
|
|
963
|
+
*
|
|
964
|
+
* @stability unstable
|
|
965
|
+
* @category fields
|
|
966
|
+
* @since 4.1.5
|
|
967
|
+
*/
|
|
968
|
+
export type Field = TextInput<boolean> | Choice<string, boolean> | SelectInput<any, boolean> | Text;
|
|
969
|
+
/**
|
|
970
|
+
* A modal's fields by id, shown in key order.
|
|
971
|
+
*
|
|
972
|
+
* @stability unstable
|
|
973
|
+
* @category fields
|
|
974
|
+
* @since 4.1.5
|
|
975
|
+
*/
|
|
976
|
+
export interface Fields {
|
|
977
|
+
readonly [id: string]: Field;
|
|
978
|
+
}
|
|
979
|
+
type Maybe<A, Optional extends boolean> = Optional extends true ? A | undefined : A;
|
|
980
|
+
/**
|
|
981
|
+
* The decoded value of one field.
|
|
982
|
+
*
|
|
983
|
+
* @stability unstable
|
|
984
|
+
* @category fields
|
|
985
|
+
* @since 4.1.5
|
|
986
|
+
*/
|
|
987
|
+
export type FieldValue<F> = F extends TextInput<infer Optional> ? Maybe<string, Optional> : F extends Choice<infer Value, infer Optional> ? Maybe<Value, Optional> : F extends SelectInput<infer Value, infer Optional> ? Maybe<TypeOf<Value, string>, Optional> : never;
|
|
988
|
+
/**
|
|
989
|
+
* `submit.values`: one key per input, none for `text`.
|
|
990
|
+
*
|
|
991
|
+
* @stability unstable
|
|
992
|
+
* @category fields
|
|
993
|
+
* @since 4.1.5
|
|
994
|
+
*/
|
|
995
|
+
export type Values<Fs extends Fields> = {
|
|
996
|
+
readonly [K in keyof Fs as Fs[K] extends Text ? never : K]: FieldValue<Fs[K]>;
|
|
997
|
+
};
|
|
998
|
+
/**
|
|
999
|
+
* The options `open` must be given: one list per `selectInput` field.
|
|
1000
|
+
*
|
|
1001
|
+
* @stability unstable
|
|
1002
|
+
* @category fields
|
|
1003
|
+
* @since 4.1.5
|
|
1004
|
+
*/
|
|
1005
|
+
export type SelectOptions<Fs extends Fields> = {
|
|
1006
|
+
readonly [K in keyof Fs as Fs[K] extends SelectInput<any, any> ? K : never]: Fs[K] extends SelectInput<infer Value, any> ? ReadonlyArray<{
|
|
1007
|
+
readonly label: string;
|
|
1008
|
+
readonly value: TypeOf<Value, string>;
|
|
1009
|
+
}> : never;
|
|
1010
|
+
};
|
|
1011
|
+
/**
|
|
1012
|
+
* What a modal's `open` takes: the metadata when the modal has a schema for
|
|
1013
|
+
* it, the options of each `selectInput`, and initial values.
|
|
1014
|
+
*
|
|
1015
|
+
* @stability unstable
|
|
1016
|
+
* @category fields
|
|
1017
|
+
* @since 4.1.5
|
|
1018
|
+
*/
|
|
1019
|
+
export type OpenOptions<Metadata extends ValueSchema | undefined, Fs extends Fields> = (Metadata extends ValueSchema ? {
|
|
1020
|
+
readonly metadata: Metadata["Type"];
|
|
1021
|
+
} : {}) & ({} extends SelectOptions<Fs> ? {} : {
|
|
1022
|
+
readonly options: SelectOptions<Fs>;
|
|
1023
|
+
}) & {
|
|
1024
|
+
readonly initial?: {
|
|
1025
|
+
readonly [K in keyof Values<Fs>]?: Values<Fs>[K] | undefined;
|
|
1026
|
+
} | undefined;
|
|
1027
|
+
};
|
|
1028
|
+
/**
|
|
1029
|
+
* A modal definition.
|
|
1030
|
+
*
|
|
1031
|
+
* **Details**
|
|
1032
|
+
*
|
|
1033
|
+
* `open` gives the reply that opens the modal. A click's or a command's
|
|
1034
|
+
* handler can return it.
|
|
1035
|
+
*
|
|
1036
|
+
* **Gotchas**
|
|
1037
|
+
*
|
|
1038
|
+
* `open` throws when the metadata or an option's value cannot be encoded.
|
|
1039
|
+
*
|
|
1040
|
+
* @stability unstable
|
|
1041
|
+
* @category definitions
|
|
1042
|
+
* @since 4.1.5
|
|
1043
|
+
*/
|
|
1044
|
+
export interface Modal<out Id extends string, in out Metadata extends ValueSchema | undefined = undefined, in out Fs extends Fields = {}> {
|
|
1045
|
+
readonly [TypeId]: typeof TypeId;
|
|
1046
|
+
readonly kind: "modal";
|
|
1047
|
+
readonly id: Id;
|
|
1048
|
+
readonly title: string;
|
|
1049
|
+
readonly submitLabel: string | undefined;
|
|
1050
|
+
readonly metadata: Metadata;
|
|
1051
|
+
readonly fields: Fs;
|
|
1052
|
+
readonly open: (...args: {} extends OpenOptions<Metadata, Fs> ? [options?: OpenOptions<Metadata, Fs>] : [options: OpenOptions<Metadata, Fs>]) => OpenModal;
|
|
1053
|
+
}
|
|
1054
|
+
/**
|
|
1055
|
+
* Defines a modal.
|
|
1056
|
+
*
|
|
1057
|
+
* **Details**
|
|
1058
|
+
*
|
|
1059
|
+
* - The id names the submit's handler in a `group`. With the encoded
|
|
1060
|
+
* metadata it counts toward `limits.modalMetadataLength`.
|
|
1061
|
+
* - Inputs and texts together count toward `limits.modalFields`.
|
|
1062
|
+
*
|
|
1063
|
+
* **Gotchas**
|
|
1064
|
+
*
|
|
1065
|
+
* A modal the platform will not take can only fail after the click's or
|
|
1066
|
+
* command's handler returned it: the adapter opens nothing and calls
|
|
1067
|
+
* `Handler.refused`. A portable modal has a title of 24 or less, labels of 45
|
|
1068
|
+
* or less, at most 5 fields, and an id plus metadata under 100 characters.
|
|
1069
|
+
*
|
|
1070
|
+
* @stability unstable
|
|
1071
|
+
* @category definitions
|
|
1072
|
+
* @since 4.1.5
|
|
1073
|
+
*/
|
|
1074
|
+
export declare const modal: <const Id extends string, const Fs extends Fields, Metadata extends ValueSchema | undefined = undefined>(id: Id, options: {
|
|
1075
|
+
readonly title: string;
|
|
1076
|
+
readonly submitLabel?: string | undefined;
|
|
1077
|
+
readonly metadata?: Metadata;
|
|
1078
|
+
readonly fields: Fs;
|
|
1079
|
+
}) => Modal<Id, Metadata, Fs>;
|
|
1080
|
+
/**
|
|
1081
|
+
* A slash command definition: a name and at most one text argument.
|
|
1082
|
+
*
|
|
1083
|
+
* **Details**
|
|
1084
|
+
*
|
|
1085
|
+
* `description` and `argument` are what registration needs. Slack reads its
|
|
1086
|
+
* own from the app manifest, so there they are documentation.
|
|
1087
|
+
*
|
|
1088
|
+
* @stability unstable
|
|
1089
|
+
* @category definitions
|
|
1090
|
+
* @since 4.1.5
|
|
1091
|
+
*/
|
|
1092
|
+
export interface Command<out Id extends string> {
|
|
1093
|
+
readonly [TypeId]: typeof TypeId;
|
|
1094
|
+
readonly kind: "command";
|
|
1095
|
+
readonly id: Id;
|
|
1096
|
+
readonly description: string;
|
|
1097
|
+
readonly argument: {
|
|
1098
|
+
readonly name: string;
|
|
1099
|
+
readonly description: string;
|
|
1100
|
+
readonly required: boolean;
|
|
1101
|
+
} | undefined;
|
|
1102
|
+
}
|
|
1103
|
+
/**
|
|
1104
|
+
* Defines a slash command.
|
|
1105
|
+
*
|
|
1106
|
+
* **Details**
|
|
1107
|
+
*
|
|
1108
|
+
* - The id is the command's name without the slash. It shares the registry's
|
|
1109
|
+
* id space with buttons, selects and modals.
|
|
1110
|
+
* - Slack sends everything typed after the name as one string. Discord gets
|
|
1111
|
+
* one `STRING` option named `argument.name`, and a command with no
|
|
1112
|
+
* `argument` has no options.
|
|
1113
|
+
* - `argument.required` defaults to false. Discord's client enforces it.
|
|
1114
|
+
* Slack cannot, so a portable handler still checks for an empty `text`.
|
|
1115
|
+
*
|
|
1116
|
+
* **Gotchas**
|
|
1117
|
+
*
|
|
1118
|
+
* A portable name matches `^[a-z0-9_-]{1,31}$` and a portable description is
|
|
1119
|
+
* 100 characters or less. Neither is checked here.
|
|
1120
|
+
*
|
|
1121
|
+
* @stability unstable
|
|
1122
|
+
* @category definitions
|
|
1123
|
+
* @since 4.1.5
|
|
1124
|
+
*/
|
|
1125
|
+
export declare const command: <const Id extends string>(id: Id, options: {
|
|
1126
|
+
readonly description: string;
|
|
1127
|
+
readonly argument?: {
|
|
1128
|
+
readonly name: string;
|
|
1129
|
+
readonly description: string;
|
|
1130
|
+
readonly required?: boolean | undefined;
|
|
1131
|
+
} | undefined;
|
|
1132
|
+
}) => Command<Id>;
|
|
1133
|
+
/**
|
|
1134
|
+
* Any definition that has a handler.
|
|
1135
|
+
*
|
|
1136
|
+
* @stability unstable
|
|
1137
|
+
* @category definitions
|
|
1138
|
+
* @since 4.1.5
|
|
1139
|
+
*/
|
|
1140
|
+
export type Definition = Button<string, any> | Select<string, any> | Modal<string, any, any> | Command<string>;
|
|
1141
|
+
/**
|
|
1142
|
+
* The handler a definition asks for. None has an error channel.
|
|
1143
|
+
*
|
|
1144
|
+
* **Details**
|
|
1145
|
+
*
|
|
1146
|
+
* A button or a select answers `ack` or a modal to open. A modal answers
|
|
1147
|
+
* `close` or `errors` naming its own inputs. A command answers `respond`,
|
|
1148
|
+
* a modal to open or `defer`, and never `ack`: Discord has no silent answer
|
|
1149
|
+
* to a command.
|
|
1150
|
+
*
|
|
1151
|
+
* @stability unstable
|
|
1152
|
+
* @category groups
|
|
1153
|
+
* @since 4.1.5
|
|
1154
|
+
*/
|
|
1155
|
+
export type HandlerFor<D extends Definition> = D extends Button<any, infer Value> ? (click: Click<TypeOf<Value, undefined>>) => Effect.Effect<ClickReply, never, any> : D extends Select<any, infer Value> ? (selected: Selected<TypeOf<Value, string>>) => Effect.Effect<ClickReply, never, any> : D extends Modal<any, infer Metadata, infer Fs> ? (submit: Submit<TypeOf<Metadata, undefined>, Values<Fs>>) => Effect.Effect<Close | FieldErrors<keyof Values<Fs> & string>, never, any> : D extends Command<any> ? (command: CommandInvoked) => Effect.Effect<Respond | OpenModal | Defer, never, any> : never;
|
|
1156
|
+
/**
|
|
1157
|
+
* One handler per id in the group.
|
|
1158
|
+
*
|
|
1159
|
+
* @stability unstable
|
|
1160
|
+
* @category groups
|
|
1161
|
+
* @since 4.1.5
|
|
1162
|
+
*/
|
|
1163
|
+
export type HandlersFrom<D extends Definition> = {
|
|
1164
|
+
readonly [Current in D as Current["id"]]: HandlerFor<Current>;
|
|
1165
|
+
};
|
|
1166
|
+
/**
|
|
1167
|
+
* The services a set of handlers needs.
|
|
1168
|
+
*
|
|
1169
|
+
* @stability unstable
|
|
1170
|
+
* @category groups
|
|
1171
|
+
* @since 4.1.5
|
|
1172
|
+
*/
|
|
1173
|
+
export type HandlersServices<Handlers> = {
|
|
1174
|
+
readonly [K in keyof Handlers]: Handlers[K] extends (...args: any) => Effect.Effect<any, any, infer R> ? R : never;
|
|
1175
|
+
}[keyof Handlers];
|
|
1176
|
+
/**
|
|
1177
|
+
* A set of definitions whose handlers are registered together.
|
|
1178
|
+
*
|
|
1179
|
+
* **Details**
|
|
1180
|
+
*
|
|
1181
|
+
* - `toLayer` registers the handlers, with their services provided. It needs
|
|
1182
|
+
* the `Registry` that `ChatInteraction.layer` provides.
|
|
1183
|
+
* - `of` is the identity, for handlers written away from `toLayer`.
|
|
1184
|
+
*
|
|
1185
|
+
* **Gotchas**
|
|
1186
|
+
*
|
|
1187
|
+
* Two definitions with one id, in one group or across groups, are a defect
|
|
1188
|
+
* when the layer is built.
|
|
1189
|
+
*
|
|
1190
|
+
* @stability unstable
|
|
1191
|
+
* @category groups
|
|
1192
|
+
* @since 4.1.5
|
|
1193
|
+
*/
|
|
1194
|
+
export interface Group<in out D extends Definition> {
|
|
1195
|
+
readonly [TypeId]: typeof TypeId;
|
|
1196
|
+
readonly definitions: ReadonlyMap<string, D>;
|
|
1197
|
+
readonly add: <const More extends ReadonlyArray<Definition>>(...definitions: More) => Group<D | More[number]>;
|
|
1198
|
+
readonly merge: <const Groups extends ReadonlyArray<Group<any>>>(...groups: Groups) => Group<D | Group.Definitions<Groups[number]>>;
|
|
1199
|
+
readonly toLayer: <Handlers extends HandlersFrom<D>, EX = never, RX = never>(build: Handlers | Effect.Effect<Handlers, EX, RX>) => Layer.Layer<never, EX, Exclude<RX, Scope> | HandlersServices<Handlers> | Registry>;
|
|
1200
|
+
readonly of: <const Handlers extends HandlersFrom<D>>(handlers: Handlers) => Handlers;
|
|
1201
|
+
}
|
|
1202
|
+
/**
|
|
1203
|
+
* Types that go with a group.
|
|
1204
|
+
*
|
|
1205
|
+
* @stability unstable
|
|
1206
|
+
* @since 4.1.5
|
|
1207
|
+
*/
|
|
1208
|
+
export declare namespace Group {
|
|
1209
|
+
/**
|
|
1210
|
+
* The definitions of a group.
|
|
1211
|
+
*
|
|
1212
|
+
* @stability unstable
|
|
1213
|
+
* @category groups
|
|
1214
|
+
* @since 4.1.5
|
|
1215
|
+
*/
|
|
1216
|
+
type Definitions<G> = G extends Group<infer D> ? D : never;
|
|
1217
|
+
}
|
|
1218
|
+
/**
|
|
1219
|
+
* Groups definitions so their handlers can be registered together.
|
|
1220
|
+
*
|
|
1221
|
+
* @stability unstable
|
|
1222
|
+
* @category groups
|
|
1223
|
+
* @since 4.1.5
|
|
1224
|
+
*/
|
|
1225
|
+
export declare const group: <const Definitions extends ReadonlyArray<Definition>>(...definitions: Definitions) => Group<Definitions[number]>;
|
|
1226
|
+
declare const Handler_base: Context.ServiceClass<Handler, "effect/chat/ChatInteraction/Handler", {
|
|
1227
|
+
readonly click: (event: ButtonClicked | SelectChanged) => Effect.Effect<ClickReply>;
|
|
1228
|
+
readonly submit: (event: ModalSubmitted) => Effect.Effect<SubmitReply>;
|
|
1229
|
+
readonly command: (event: CommandInvoked) => Effect.Effect<CommandReply>;
|
|
1230
|
+
readonly refused: (event: ButtonClicked | SelectChanged | CommandInvoked, error: ChatError) => Effect.Effect<void>;
|
|
1231
|
+
}>;
|
|
1232
|
+
/**
|
|
1233
|
+
* What an adapter calls with an interaction. Public, for a consumer that
|
|
1234
|
+
* routes clicks itself.
|
|
1235
|
+
*
|
|
1236
|
+
* **Details**
|
|
1237
|
+
*
|
|
1238
|
+
* - The contract is to answer inside the platform's 3 seconds. There is no
|
|
1239
|
+
* error channel: a handler that cannot do its work still has to answer.
|
|
1240
|
+
* - `refused` is called when a click's handler returned `OpenModal` and no
|
|
1241
|
+
* modal opened, after the click was acked: by the adapter (the platform
|
|
1242
|
+
* has no `modals`, the modal's id plus metadata is over
|
|
1243
|
+
* `limits.modalMetadataLength`, it has more than `limits.modalFields`
|
|
1244
|
+
* fields, a title or label is too long, or the platform refused the call)
|
|
1245
|
+
* or by `handle` (the reply came after the deadline).
|
|
1246
|
+
* - A command's reply can be refused too: a private answer without
|
|
1247
|
+
* `ephemeral`, an element the platform lacks, an answer over
|
|
1248
|
+
* `limits.messageLength` or an element limit, a modal that cannot open,
|
|
1249
|
+
* or a refusal by the platform. A submit's replies always have an answer
|
|
1250
|
+
* the adapter can give.
|
|
1251
|
+
* - `command` answers `Ack` for a command it has no definition for, and the
|
|
1252
|
+
* adapter sends nothing for that. On Discord another library in the same
|
|
1253
|
+
* process can still answer it.
|
|
1254
|
+
*
|
|
1255
|
+
* **Gotchas**
|
|
1256
|
+
*
|
|
1257
|
+
* Neither platform redelivers a click or a submit, so there is no dedupe key.
|
|
1258
|
+
* A submit can still arrive twice for one modal: a handler that runs past
|
|
1259
|
+
* the deadline is interrupted, the platform shows its own error, the modal
|
|
1260
|
+
* stays open and the user can submit again. Nothing marks the second one as
|
|
1261
|
+
* a repeat, and the first run may have been cut off part way.
|
|
1262
|
+
*
|
|
1263
|
+
* @stability unstable
|
|
1264
|
+
* @category services
|
|
1265
|
+
* @since 4.1.5
|
|
1266
|
+
*/
|
|
1267
|
+
export declare class Handler extends Handler_base {
|
|
1268
|
+
}
|
|
1269
|
+
/**
|
|
1270
|
+
* Calls `Handler.click`, `Handler.submit` or `Handler.command` and gives
|
|
1271
|
+
* the reply, or `Late` when `deadline` passes first.
|
|
1272
|
+
*
|
|
1273
|
+
* **When to use**
|
|
1274
|
+
*
|
|
1275
|
+
* Use to deliver an interaction from an adapter. This is the one place the
|
|
1276
|
+
* deadline rule lives. Both adapters and
|
|
1277
|
+
* `ChatTest` call it, and a third-party adapter should.
|
|
1278
|
+
*
|
|
1279
|
+
* **Details**
|
|
1280
|
+
*
|
|
1281
|
+
* - A late click leaves its handler running, detached from the caller. When
|
|
1282
|
+
* it later returns `OpenModal`, the modal is dropped and `Handler.refused`
|
|
1283
|
+
* is called with a `ChatError` whose reason is `NotFound`, op `openModal`,
|
|
1284
|
+
* detail `interaction_expired`, platform `event.thread.platform`.
|
|
1285
|
+
* - A late submit or command interrupts its handler. `Late` is given at the
|
|
1286
|
+
* deadline, without waiting for the handler's finalizers to finish. A
|
|
1287
|
+
* command handler that cannot answer in time returns `defer` first.
|
|
1288
|
+
* - `deadline` is the handler's share of the platform's 3 seconds, not the 3
|
|
1289
|
+
* seconds. The adapter subtracts what its own answer costs. This function
|
|
1290
|
+
* knows no platform.
|
|
1291
|
+
*
|
|
1292
|
+
* **Gotchas**
|
|
1293
|
+
*
|
|
1294
|
+
* A late click's handler keeps running only if the runtime lets it. One that
|
|
1295
|
+
* stops work once the response is sent (Cloudflare Workers without
|
|
1296
|
+
* `waitUntil`) kills it.
|
|
1297
|
+
*
|
|
1298
|
+
* @stability unstable
|
|
1299
|
+
* @category handling
|
|
1300
|
+
* @since 4.1.5
|
|
1301
|
+
*/
|
|
1302
|
+
export declare const handle: {
|
|
1303
|
+
/**
|
|
1304
|
+
* Calls `Handler.click`, `Handler.submit` or `Handler.command` and gives
|
|
1305
|
+
* the reply, or `Late` when `deadline` passes first.
|
|
1306
|
+
*
|
|
1307
|
+
* **When to use**
|
|
1308
|
+
*
|
|
1309
|
+
* Use to deliver an interaction from an adapter. This is the one place the
|
|
1310
|
+
* deadline rule lives. Both adapters and
|
|
1311
|
+
* `ChatTest` call it, and a third-party adapter should.
|
|
1312
|
+
*
|
|
1313
|
+
* **Details**
|
|
1314
|
+
*
|
|
1315
|
+
* - A late click leaves its handler running, detached from the caller. When
|
|
1316
|
+
* it later returns `OpenModal`, the modal is dropped and `Handler.refused`
|
|
1317
|
+
* is called with a `ChatError` whose reason is `NotFound`, op `openModal`,
|
|
1318
|
+
* detail `interaction_expired`, platform `event.thread.platform`.
|
|
1319
|
+
* - A late submit or command interrupts its handler. `Late` is given at the
|
|
1320
|
+
* deadline, without waiting for the handler's finalizers to finish. A
|
|
1321
|
+
* command handler that cannot answer in time returns `defer` first.
|
|
1322
|
+
* - `deadline` is the handler's share of the platform's 3 seconds, not the 3
|
|
1323
|
+
* seconds. The adapter subtracts what its own answer costs. This function
|
|
1324
|
+
* knows no platform.
|
|
1325
|
+
*
|
|
1326
|
+
* **Gotchas**
|
|
1327
|
+
*
|
|
1328
|
+
* A late click's handler keeps running only if the runtime lets it. One that
|
|
1329
|
+
* stops work once the response is sent (Cloudflare Workers without
|
|
1330
|
+
* `waitUntil`) kills it.
|
|
1331
|
+
*
|
|
1332
|
+
* @stability unstable
|
|
1333
|
+
* @category handling
|
|
1334
|
+
* @since 4.1.5
|
|
1335
|
+
*/
|
|
1336
|
+
(event: ButtonClicked | SelectChanged, deadline: Duration.Duration): Effect.Effect<ClickReply | Late, never, Handler>;
|
|
1337
|
+
/**
|
|
1338
|
+
* Calls `Handler.click`, `Handler.submit` or `Handler.command` and gives
|
|
1339
|
+
* the reply, or `Late` when `deadline` passes first.
|
|
1340
|
+
*
|
|
1341
|
+
* **When to use**
|
|
1342
|
+
*
|
|
1343
|
+
* Use to deliver an interaction from an adapter. This is the one place the
|
|
1344
|
+
* deadline rule lives. Both adapters and
|
|
1345
|
+
* `ChatTest` call it, and a third-party adapter should.
|
|
1346
|
+
*
|
|
1347
|
+
* **Details**
|
|
1348
|
+
*
|
|
1349
|
+
* - A late click leaves its handler running, detached from the caller. When
|
|
1350
|
+
* it later returns `OpenModal`, the modal is dropped and `Handler.refused`
|
|
1351
|
+
* is called with a `ChatError` whose reason is `NotFound`, op `openModal`,
|
|
1352
|
+
* detail `interaction_expired`, platform `event.thread.platform`.
|
|
1353
|
+
* - A late submit or command interrupts its handler. `Late` is given at the
|
|
1354
|
+
* deadline, without waiting for the handler's finalizers to finish. A
|
|
1355
|
+
* command handler that cannot answer in time returns `defer` first.
|
|
1356
|
+
* - `deadline` is the handler's share of the platform's 3 seconds, not the 3
|
|
1357
|
+
* seconds. The adapter subtracts what its own answer costs. This function
|
|
1358
|
+
* knows no platform.
|
|
1359
|
+
*
|
|
1360
|
+
* **Gotchas**
|
|
1361
|
+
*
|
|
1362
|
+
* A late click's handler keeps running only if the runtime lets it. One that
|
|
1363
|
+
* stops work once the response is sent (Cloudflare Workers without
|
|
1364
|
+
* `waitUntil`) kills it.
|
|
1365
|
+
*
|
|
1366
|
+
* @stability unstable
|
|
1367
|
+
* @category handling
|
|
1368
|
+
* @since 4.1.5
|
|
1369
|
+
*/
|
|
1370
|
+
(event: ModalSubmitted, deadline: Duration.Duration): Effect.Effect<SubmitReply | Late, never, Handler>;
|
|
1371
|
+
/**
|
|
1372
|
+
* Calls `Handler.click`, `Handler.submit` or `Handler.command` and gives
|
|
1373
|
+
* the reply, or `Late` when `deadline` passes first.
|
|
1374
|
+
*
|
|
1375
|
+
* **When to use**
|
|
1376
|
+
*
|
|
1377
|
+
* Use to deliver an interaction from an adapter. This is the one place the
|
|
1378
|
+
* deadline rule lives. Both adapters and
|
|
1379
|
+
* `ChatTest` call it, and a third-party adapter should.
|
|
1380
|
+
*
|
|
1381
|
+
* **Details**
|
|
1382
|
+
*
|
|
1383
|
+
* - A late click leaves its handler running, detached from the caller. When
|
|
1384
|
+
* it later returns `OpenModal`, the modal is dropped and `Handler.refused`
|
|
1385
|
+
* is called with a `ChatError` whose reason is `NotFound`, op `openModal`,
|
|
1386
|
+
* detail `interaction_expired`, platform `event.thread.platform`.
|
|
1387
|
+
* - A late submit or command interrupts its handler. `Late` is given at the
|
|
1388
|
+
* deadline, without waiting for the handler's finalizers to finish. A
|
|
1389
|
+
* command handler that cannot answer in time returns `defer` first.
|
|
1390
|
+
* - `deadline` is the handler's share of the platform's 3 seconds, not the 3
|
|
1391
|
+
* seconds. The adapter subtracts what its own answer costs. This function
|
|
1392
|
+
* knows no platform.
|
|
1393
|
+
*
|
|
1394
|
+
* **Gotchas**
|
|
1395
|
+
*
|
|
1396
|
+
* A late click's handler keeps running only if the runtime lets it. One that
|
|
1397
|
+
* stops work once the response is sent (Cloudflare Workers without
|
|
1398
|
+
* `waitUntil`) kills it.
|
|
1399
|
+
*
|
|
1400
|
+
* @stability unstable
|
|
1401
|
+
* @category handling
|
|
1402
|
+
* @since 4.1.5
|
|
1403
|
+
*/
|
|
1404
|
+
(event: CommandInvoked, deadline: Duration.Duration): Effect.Effect<CommandReply | Late, never, Handler>;
|
|
1405
|
+
/**
|
|
1406
|
+
* Calls `Handler.click`, `Handler.submit` or `Handler.command` and gives
|
|
1407
|
+
* the reply, or `Late` when `deadline` passes first.
|
|
1408
|
+
*
|
|
1409
|
+
* **When to use**
|
|
1410
|
+
*
|
|
1411
|
+
* Use to deliver an interaction from an adapter. This is the one place the
|
|
1412
|
+
* deadline rule lives. Both adapters and
|
|
1413
|
+
* `ChatTest` call it, and a third-party adapter should.
|
|
1414
|
+
*
|
|
1415
|
+
* **Details**
|
|
1416
|
+
*
|
|
1417
|
+
* - A late click leaves its handler running, detached from the caller. When
|
|
1418
|
+
* it later returns `OpenModal`, the modal is dropped and `Handler.refused`
|
|
1419
|
+
* is called with a `ChatError` whose reason is `NotFound`, op `openModal`,
|
|
1420
|
+
* detail `interaction_expired`, platform `event.thread.platform`.
|
|
1421
|
+
* - A late submit or command interrupts its handler. `Late` is given at the
|
|
1422
|
+
* deadline, without waiting for the handler's finalizers to finish. A
|
|
1423
|
+
* command handler that cannot answer in time returns `defer` first.
|
|
1424
|
+
* - `deadline` is the handler's share of the platform's 3 seconds, not the 3
|
|
1425
|
+
* seconds. The adapter subtracts what its own answer costs. This function
|
|
1426
|
+
* knows no platform.
|
|
1427
|
+
*
|
|
1428
|
+
* **Gotchas**
|
|
1429
|
+
*
|
|
1430
|
+
* A late click's handler keeps running only if the runtime lets it. One that
|
|
1431
|
+
* stops work once the response is sent (Cloudflare Workers without
|
|
1432
|
+
* `waitUntil`) kills it.
|
|
1433
|
+
*
|
|
1434
|
+
* @stability unstable
|
|
1435
|
+
* @category handling
|
|
1436
|
+
* @since 4.1.5
|
|
1437
|
+
*/
|
|
1438
|
+
(event: Interaction, deadline: Duration.Duration): Effect.Effect<ClickReply | SubmitReply | CommandReply | Late, never, Handler>;
|
|
1439
|
+
};
|
|
1440
|
+
/**
|
|
1441
|
+
* One registered definition with its handler, services already provided.
|
|
1442
|
+
*
|
|
1443
|
+
* **Details**
|
|
1444
|
+
*
|
|
1445
|
+
* `handle` answers `ack` or `close` without calling the handler when the
|
|
1446
|
+
* event does not match the definition or its value no longer decodes. A
|
|
1447
|
+
* command that does not match is answered `ack`.
|
|
1448
|
+
*
|
|
1449
|
+
* @stability unstable
|
|
1450
|
+
* @category services
|
|
1451
|
+
* @since 4.1.5
|
|
1452
|
+
*/
|
|
1453
|
+
export interface Registered {
|
|
1454
|
+
readonly definition: Definition;
|
|
1455
|
+
readonly handle: (event: Interaction) => Effect.Effect<ClickReply | SubmitReply | CommandReply>;
|
|
1456
|
+
}
|
|
1457
|
+
declare const Registry_base: Context.ServiceClass<Registry, "effect/chat/ChatInteraction/Registry", {
|
|
1458
|
+
readonly register: (entries: ReadonlyArray<Registered>) => Effect.Effect<void>;
|
|
1459
|
+
readonly get: (id: string) => Effect.Effect<Registered | undefined>;
|
|
1460
|
+
}>;
|
|
1461
|
+
/**
|
|
1462
|
+
* Where groups put their handlers. `ChatInteraction.layer` provides it.
|
|
1463
|
+
*
|
|
1464
|
+
* **Details**
|
|
1465
|
+
*
|
|
1466
|
+
* `register` dies when an id is already registered.
|
|
1467
|
+
*
|
|
1468
|
+
* @stability unstable
|
|
1469
|
+
* @category services
|
|
1470
|
+
* @since 4.1.5
|
|
1471
|
+
*/
|
|
1472
|
+
export declare class Registry extends Registry_base {
|
|
1473
|
+
}
|
|
1474
|
+
/**
|
|
1475
|
+
* Why an interaction reached no handler, or why its handler's reply was not
|
|
1476
|
+
* carried out.
|
|
1477
|
+
*
|
|
1478
|
+
* **Details**
|
|
1479
|
+
*
|
|
1480
|
+
* - `UnknownId`: no definition has the id, or it is a definition of another
|
|
1481
|
+
* kind.
|
|
1482
|
+
* - `InvalidValue`: the value or metadata no longer decodes, or a required
|
|
1483
|
+
* input is missing.
|
|
1484
|
+
* - `ReplyRefused`: `Handler.refused` was called, with the adapter's error.
|
|
1485
|
+
*
|
|
1486
|
+
* @stability unstable
|
|
1487
|
+
* @category models
|
|
1488
|
+
* @since 4.1.5
|
|
1489
|
+
*/
|
|
1490
|
+
export type Unhandled = {
|
|
1491
|
+
readonly reason: "UnknownId" | "InvalidValue";
|
|
1492
|
+
} | {
|
|
1493
|
+
readonly reason: "ReplyRefused";
|
|
1494
|
+
readonly error: ChatError;
|
|
1495
|
+
};
|
|
1496
|
+
/**
|
|
1497
|
+
* The `Handler` that routes by id to the registered definitions, and an
|
|
1498
|
+
* empty `Registry`. Group layers go on top with `Layer.provideMerge`.
|
|
1499
|
+
*
|
|
1500
|
+
* **Details**
|
|
1501
|
+
*
|
|
1502
|
+
* - An interaction with an unknown id, or with a value that no longer
|
|
1503
|
+
* decodes, is logged and answered `ack` or `close`. `unhandled` sees it
|
|
1504
|
+
* first. It cannot change the answer.
|
|
1505
|
+
* - A command with an unknown id is answered `ack`, which the adapter sends
|
|
1506
|
+
* nothing for, and logged at debug level: on Discord it may belong to
|
|
1507
|
+
* another library in the same process.
|
|
1508
|
+
* - `Handler.refused` is routed to `unhandled` too, as `ReplyRefused`, and
|
|
1509
|
+
* logged.
|
|
1510
|
+
*
|
|
1511
|
+
* @stability unstable
|
|
1512
|
+
* @category layers
|
|
1513
|
+
* @since 4.1.5
|
|
1514
|
+
*/
|
|
1515
|
+
export declare const layer: <R = never>(options?: {
|
|
1516
|
+
readonly unhandled?: ((event: Interaction, why: Unhandled) => Effect.Effect<void, never, R>) | undefined;
|
|
1517
|
+
}) => Layer.Layer<Handler | Registry, never, R>;
|
|
1518
|
+
export {};
|
|
1519
|
+
//# sourceMappingURL=ChatInteraction.d.ts.map
|