UNPKG

@dudousxd/nestjs-telescope

Version:

Laravel Telescope-style observability console for NestJS — core: watchers, recorder, correlation, SQLite store, headless API.

67 lines 2.6 kB
import type { AlertPayload } from './alert-rule.js'; /** * Optional Slack presentation overrides. Most hosts set none of these — the * incoming webhook's own default name/icon is used. Provided for hosts that route * several Telescope instances into one channel and want them visually distinct. */ export interface SlackChannelOptions { /** Override the bot username shown on the message. */ username?: string; /** Override the message icon (a Slack emoji shortcode, e.g. `:rotating_light:`). */ iconEmoji?: string; } /** * Minimal structural typings for the Block Kit subset we emit. We deliberately do * NOT pull in Slack's full SDK types — alerting must stay dependency-light, and * the shape we produce is small and stable. These exist so the formatter is fully * typed (no `any`) and tests can assert structure. */ interface SlackTextObject { type: 'plain_text' | 'mrkdwn'; text: string; emoji?: boolean; } interface SlackHeaderBlock { type: 'header'; text: SlackTextObject; } interface SlackSectionBlock { type: 'section'; text?: SlackTextObject; fields?: SlackTextObject[]; } interface SlackButtonElement { type: 'button'; text: SlackTextObject; url: string; } interface SlackActionsBlock { type: 'actions'; elements: SlackButtonElement[]; } type SlackBlock = SlackHeaderBlock | SlackSectionBlock | SlackActionsBlock; /** The full webhook body Slack expects: a fallback `text` plus the rich `blocks`. */ export interface SlackMessage { /** Fallback/notification text shown where blocks can't render. */ text: string; blocks: SlackBlock[]; username?: string; icon_emoji?: string; } /** * Render an {@link AlertPayload} into a Slack Block Kit message. Structure: * - a `header` with the severity emoji + rule label; * - a `section` whose fields carry the app/rule context (instance, value vs * threshold, window, and — for `new-exception` — route/method/status/user and * the occurrence count); * - a `section` with a fenced code block of the truncated stack (only when an * exception stack is present); * - an `actions` block with a single "Open in Telescope" button (only when a * `dashboardUrl` + entry id are available to build the deep link). * * Everything degrades gracefully: a rate rule (no `exception` context) simply * renders the header + context fields and skips the stack/button. */ export declare function formatSlackMessage(payload: AlertPayload, options?: SlackChannelOptions): SlackMessage; export {}; //# sourceMappingURL=slack-format.d.ts.map