import { Destination as Destination$1, Mapping as Mapping$1 } from '@walkeros/core'; import { DestinationServer, sendServer } from '@walkeros/server-core'; import { WebClient, ChatPostMessageArguments, ChatPostMessageResponse, ChatPostEphemeralArguments, ChatPostEphemeralResponse, ConversationsOpenArguments, ConversationsOpenResponse } from '@slack/web-api'; /** A single Block Kit block (kept loose -- Slack does not export a union type). */ type SlackBlock = Record; interface Settings { /** Slack Bot token (xoxb-...). Enables Web API mode. */ token?: string; /** Incoming Webhook URL. Enables webhook mode. */ webhookUrl?: string; /** Default channel ID or name. Required for Web API mode unless every rule provides one. */ channel?: string; /** Default text template. Supports `${data.field}` interpolation against the walkerOS event. */ text?: string; /** Default Block Kit blocks applied when no mapping override is set. */ blocks?: SlackBlock[]; /** Auto-add an event-name header block when generating default blocks. Default: true. */ includeHeader?: boolean; /** Enable link unfurling. Default: false. */ unfurlLinks?: boolean; /** Enable media unfurling. Default: false. */ unfurlMedia?: boolean; /** Use mrkdwn formatting. Default: true. */ mrkdwn?: boolean; /** Static thread_ts to reply to (rarely set at destination level). */ threadTs?: string; /** Retry policy passed to WebClient. Default: 'default'. */ retryConfig?: 'default' | 'fiveRetriesInFiveMinutes' | 'none'; _client?: WebClient; } type InitSettings = Partial; /** * Per-rule mapping settings. Override channel, text, blocks, and route * to threads / DMs / ephemeral. */ interface Mapping { /** Override the channel for this rule (Web API mode only). */ channel?: string; /** Override the text template for this rule. */ text?: string; /** Override Block Kit blocks for this rule. */ blocks?: SlackBlock[]; /** thread_ts for posting as a reply in a thread. */ threadTs?: string; /** Also broadcast the threaded reply back to the channel. */ replyBroadcast?: boolean; /** Send via chat.postEphemeral instead of chat.postMessage. */ ephemeral?: boolean; /** Slack user ID for ephemeral or DM delivery. */ user?: string; /** Send as DM (conversations.open + chat.postMessage). Requires `user`. */ dm?: boolean; } /** * Mock-friendly interface for the WebClient methods the destination calls. * Tests inject this via env.slackClient. */ interface SlackClientMock { chat: { postMessage: (opts: ChatPostMessageArguments) => Promise; postEphemeral: (opts: ChatPostEphemeralArguments) => Promise; }; conversations: { open: (opts: ConversationsOpenArguments) => Promise; }; } /** * Env -- optional SDK / transport overrides. Production leaves these undefined. * Tests inject `slackClient` (Web API mode) and/or `sendServer` (webhook mode). */ interface Env extends DestinationServer.Env { slackClient?: SlackClientMock; sendServer?: typeof sendServer; } type Types = Destination$1.Types; interface Destination extends DestinationServer.Destination { init: DestinationServer.InitFn; } type Config = { settings: Settings; } & DestinationServer.Config; type InitFn = DestinationServer.InitFn; type PushFn = DestinationServer.PushFn; type PartialConfig = DestinationServer.PartialConfig; type PushEvents = DestinationServer.PushEvents; type Rule = Mapping$1.Rule; type Rules = Mapping$1.Rules; type index_Config = Config; type index_Destination = Destination; type index_Env = Env; type index_InitFn = InitFn; type index_InitSettings = InitSettings; type index_Mapping = Mapping; type index_PartialConfig = PartialConfig; type index_PushEvents = PushEvents; type index_PushFn = PushFn; type index_Rule = Rule; type index_Rules = Rules; type index_Settings = Settings; type index_SlackBlock = SlackBlock; type index_SlackClientMock = SlackClientMock; type index_Types = Types; declare namespace index { export type { index_Config as Config, index_Destination as Destination, index_Env as Env, index_InitFn as InitFn, index_InitSettings as InitSettings, index_Mapping as Mapping, index_PartialConfig as PartialConfig, index_PushEvents as PushEvents, index_PushFn as PushFn, index_Rule as Rule, index_Rules as Rules, index_Settings as Settings, index_SlackBlock as SlackBlock, index_SlackClientMock as SlackClientMock, index_Types as Types }; } declare const destinationSlack: Destination; export { index as DestinationSlack, destinationSlack as default, destinationSlack };