# @fayz-ai/plugin-notifications 中文文档

规范地址：https://npmcn.com/package/%40fayz-ai/plugin-notifications/

版本：0\.2\.64
npm 元数据更新时间：2026-11-11T14:53:36.601Z
中文译文更新时间：2026-11-14T12:11:47.120Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40fayz-ai/plugin-notifications
原文对照：https://npmcn.com/package/%40fayz-ai/plugin-notifications/?lang=original

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：447 kB，39 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：3 个
- peer 依赖：react ^18\.0\.0 \|\| ^19\.0\.0，react-dom ^18\.0\.0 \|\| ^19\.0\.0，lucide-react \>=0\.400\.0 \<1\.0\.0
- 首次发布：2026-09-07T23:30:42.738Z
- 最新版本发布：2026-11-11T14:53:36.364Z
- 近 30 天下载量：7604（2026-10-15 至 2026-11-13，npm 官方下载统计）
- 已发布版本数：69（近 12 个月 69 个）

## 中文简介

Fayz SDK — 插件通知插件

## 安装

```sh
npm install @fayz-ai/plugin-notifications
```

也可以使用：`pnpm add @fayz-ai/plugin-notifications`、`yarn add @fayz-ai/plugin-notifications`、`bun add @fayz-ai/plugin-notifications`

## README

# @fayz-ai/插件通知

> 将事实转换成消息的引擎:模板、队列、重试、分解 和接受者选择的频道.

[![npm](https://img.shields.io/npm/v/@fayz-ai/plugin-notifications.svg)](https://www.npmjs.com/package/@fayz-ai/plugin-notifications) [![license](https://img.shields.io/npm/l/@fayz-ai/plugin-notifications.svg)](https://github.com/FayaLabs/fayz-sdk/blob/main/LICENSE)

**状态 :** β – 发动机完整并被犬科链(schema, queue, dedupe, ext-out, ext)分级. 前1.0:还没有管理员表面,API在1.0之前可能改变.

## 安装

```bash
npm install @fayz-ai/plugin-notifications
```

```ts
import { createNotificationsPlugin } from '@fayz-ai/plugin-notifications'

export const plugins = [createNotificationsPlugin()]
```

`createNotificationsPlugin` 无屏幕挂载。 它所做的一切都可以从 SQL和它宣布的三项活动——这是有意的:a 无法发送的窗体就是这个引擎存在用来停止运输的.

## 为什么它存在

SDK有两端而不是中间 它拥有 **事件** - 持久木材 及其消费者——它拥有 **频道**数字 : `plugin-conversations` 拥有 编号、交货和选择退出. `public.notifications` 是铃声 应用它永远不会离开它。 所以,"告诉客户 他们的订单已经准备好了" 没有地方 活下来.

Dunning、任命确认、订货准备、服务后调查和 营销运动是同一个引擎,有不同的模板. 这是 发动机.

## 飞来飞去

| 图表 | 它所持有的 |
| --- | --- |
| `plg_notifications_templates` | 每个密钥、频道和地点 |
| `plg_notifications_preferences` | 一个人希望如何得到帮助 |
| `plg_notifications_queue` | 等待什么,去什么, 是什么被拒绝和为什么 |
| `plg_notifications_deliveries` | 供应商说的话 |
| `plg_notifications_channels` | 每个租户提供频道 |

## 三个变化者

1.  **没有模板,任何东西都不会离开.** `notifications_enqueue` 拒绝按键 无法在写东西之前解决.
2.  **淘汰是绝对否决**被屏蔽的信息是一个有原因的ROW 完全没有结果的退出是无法区分的 引擎静静地停止工作.
3.  **恢复活动不会发出两次.** `dedupe_key` 单个 房客,所以再审的送货 解决已经存在的信息.

## 用这个

```sql
-- write the template once
INSERT INTO public.plg_notifications_templates (tenant_id, key, channel, body, is_default)
VALUES (:tenant, 'order.completed', 'whatsapp', 'Oi {{customer_name}}, seu pedido {{order_number}} está pronto!', true);

-- everything else is a reaction: the order completes, the engine enqueues
SELECT public.consume_event_log(200);   -- scheduled by pg_cron (PRD 10)
SELECT public.notifications_drain(100); -- its own job: the provider is outside
```

下水道是 **单独** 从 `consume_event_log()` 目标: 供应商在外,队列是我们的,所以一个供应商计时出局需要重试 在这里,永远不要挂起事件记录.

## 常见问题

### @fayz-ai/plugin-notifications 是什么？

Fayz SDK — 插件通知插件

### 如何安装 @fayz-ai/plugin-notifications？

在项目目录运行 npm install @fayz-ai/plugin-notifications，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：react（^18\.0\.0 \|\| ^19\.0\.0）、react-dom（^18\.0\.0 \|\| ^19\.0\.0）、lucide-react（\>=0\.400\.0 \<1\.0\.0）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @fayz-ai/plugin-notifications 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @fayz-ai/plugin-notifications 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @fayz-ai/plugin-notifications 可以商用吗？

@fayz-ai/plugin-notifications 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @fayz-ai/plugin-notifications 的下载量有多少？

根据 npm 官方下载统计，@fayz-ai/plugin-notifications 在 2026/10/15 – 2026/11/13 这 30 天内被下载 7,604 次，日均约 253 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @fayz-ai/plugin-notifications 还在维护吗？

最新版本 0\.2\.64 发布于 2026/11/11（2 天前）；至今共发布 69 个版本，其中过去 12 个月发布了 69 个；首次发布于 2026/09/08。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

