import { BaseConnector } from '../../base/base.connector'; import type { IChatOptions, IChatProvider, ISendMessageSuccessResponse, WithPassthrough, ChatSendResult, IChatConnector } from '../../types'; import { ChannelTypeEnum } from '../../types'; import type { MsTeamsConfig } from './ms-teams.config'; import type { MsTeamsNarrowedInput } from './ms-teams.types'; /** * Webhook-URL-as-auth. No Authorization header; the webhookUrl IS the * credential. * * Two webhook generations are accepted: Workflows webhooks (Power Automate / * Logic Apps "When a Teams webhook request is received"), which answer * `202 Accepted` with an empty body, and legacy Office 365 connector webhooks * (`*.webhook.office.com`, `outlook.office.com`), which answer HTTP 200 with * plain text `'1'`. Neither returns a message identifier, so * `providerMessageId` is always `null`. * * outlier: Teams' Incoming Webhook expects a fixed envelope — * `{ type: 'message', attachments: [{ contentType: 'application/vnd.microsoft.card.adaptive', content: }] }`. * The connector synthesizes this envelope locally; consumers needing legacy * MessageCard shapes can override via `_passthrough.body` (deep-merge). */ export declare class MsTeamsChatConnector extends BaseConnector implements IChatProvider, IChatConnector { private config; readonly id: "ms-teams"; readonly channelType: ChannelTypeEnum.CHAT; constructor(config: MsTeamsConfig, fetchImpl?: typeof fetch); /** * Thinwrap-native send. Implements `IChatConnector`. * * `to` is intentionally absent from `MsTeamsNarrowedInput` — the webhook URL * targets the channel directly. When `input.card` is unset, the * connector synthesizes a default Adaptive Card v1.4 with a single * `TextBlock` containing `input.body`. When `input.card` is set, it replaces * the synthesized card; `input.body` is NOT auto-inserted as a TextBlock. */ send(input: MsTeamsNarrowedInput): Promise; /** * Decides whether a 2xx response is really a failure, returning the * effective HTTP status to map, or `null` for success. * * - Workflows webhooks ("When a Teams webhook request is received") run on * the Azure Logic Apps Request trigger, which answers **202 Accepted** * with no body when the flow has no Response action — so 202 is success * whatever the body says. * - Legacy Office 365 connector webhooks return plain text `"1"` on * success, but on failure (including throttling) still answer HTTP 200 * with an error string such as * "...Teams endpoint returned HTTP error 429 with ContextId...". The * embedded code drives the taxonomy. * - Any other body from a legacy connector host is a failure (502) so it * is not silently reported as sent. Workflows URLs may return whatever * body the flow's Response action defines, so a non-legacy host's 2xx * without the embedded error text is success. */ private failureStatusFor2xx; /** * HTTP-layer mapping. ConnectorError carries no * `retryAfterSeconds` field — retry is consumer policy: * parsed seconds embedded in `providerMessage` text, raw header preserved on * `cause.retryAfter`. Wrapper performs no retry. * * Teams-specific quirk: revoked / malformed webhook URLs return HTTP 400 * with a plain-text body containing `Invalid webhook URL` — not 404 like * Slack/Discord. Special-cased to `auth_failed`. */ private mapVendorError; sendMessage(options: IChatOptions, bridgeProviderData?: WithPassthrough>): Promise; }