feishu-bot-notify
Version:
基于 tsdown 打包的飞书机器人通知工具
77 lines • 1.97 kB
text/typescript
//#region src/card.d.ts
interface ComponentUpdateCardOptions {
/**
* 组件名称,卡片中会以加粗形式展示
*/
componentName: string;
/**
* 版本号,建议遵循语义化版本
*/
version: string;
/**
* 更新说明或者更新说明列表,将渲染成 Markdown 项目符号。
*/
changes: string | string[];
/**
* 按钮跳转链接,例如组件文档或体验地址
*/
buttonUrl: string;
/**
* 卡片标题,可依据业务场景调整
*/
title?: string;
/**
* 按钮文字,默认使用“去看看”
*/
buttonText?: string;
}
interface FeishuInteractiveCard {
schema: "2.0";
config: {
update_multi: boolean;
style?: Record<string, unknown>;
};
header: {
title: {
tag: "plain_text";
content: string;
};
template?: string;
icon?: Record<string, unknown>;
padding?: string;
};
body: {
direction: "vertical";
padding: string;
elements: Array<Record<string, unknown>>;
};
}
//#endregion
//#region src/sender.d.ts
interface FeishuWebhookResponse {
code: number;
msg: string;
data?: unknown;
}
//#endregion
//#region src/index.d.ts
interface SendComponentUpdateOptions extends ComponentUpdateCardOptions {
/**
* 飞书机器人 webhook 地址
*/
webhookUrl: string;
/**
* 请求超时时间(毫秒),默认不限制
*/
timeoutMs?: number;
}
/**
* 基于组件更新信息构建卡片并推送至飞书机器人
*/
declare function sendComponentUpdateNotification(options: SendComponentUpdateOptions): Promise<FeishuWebhookResponse>;
/**
* 仅构建飞书交互式卡片,便于在外部服务中复用
*/
declare function createComponentUpdateCard(options: ComponentUpdateCardOptions): FeishuInteractiveCard;
//#endregion
export { type ComponentUpdateCardOptions, type FeishuInteractiveCard, type FeishuWebhookResponse, SendComponentUpdateOptions, createComponentUpdateCard, sendComponentUpdateNotification };