mirror of
https://github.com/d0zingcat/alert-message-center.git
synced 2026-05-13 15:09:19 +00:00
feat: bump version to 1.4.0 and allow users to request global topics
This commit is contained in:
11
AGENTS.md
11
AGENTS.md
@@ -4,7 +4,7 @@ This document provides instructions for AI agents working on the Alert Message C
|
|||||||
|
|
||||||
## 🛠 Commands
|
## 🛠 Commands
|
||||||
|
|
||||||
### Development & Build
|
### Workspace Operations
|
||||||
- **Install**: `bun install`
|
- **Install**: `bun install`
|
||||||
- **Root Dev**: `bun run dev` (starts both server and web)
|
- **Root Dev**: `bun run dev` (starts both server and web)
|
||||||
- **Root Build**: `bun run build`
|
- **Root Build**: `bun run build`
|
||||||
@@ -25,6 +25,10 @@ This document provides instructions for AI agents working on the Alert Message C
|
|||||||
- **Dev**: `bun run dev`
|
- **Dev**: `bun run dev`
|
||||||
- **Build**: `bun run build`
|
- **Build**: `bun run build`
|
||||||
|
|
||||||
|
### Testing
|
||||||
|
- No automated tests currently exist in the repository. If adding tests, use **Bun Test**.
|
||||||
|
- **Run Single Test**: `bun test path/to/file.test.ts`
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 📜 Code Style & Conventions
|
## 📜 Code Style & Conventions
|
||||||
@@ -35,7 +39,7 @@ This document provides instructions for AI agents working on the Alert Message C
|
|||||||
- **Naming**:
|
- **Naming**:
|
||||||
- Variables/Functions: `camelCase`
|
- Variables/Functions: `camelCase`
|
||||||
- Components/Classes/Interfaces: `PascalCase`
|
- Components/Classes/Interfaces: `PascalCase`
|
||||||
- Database Tables: `snake_case` (e.g., `topic_group_chats`)
|
- Database Tables/Columns: `snake_case` (e.g., `topic_group_chats`)
|
||||||
- URL Slugs: `kebab-case`
|
- URL Slugs: `kebab-case`
|
||||||
|
|
||||||
### 2. TypeScript & Type Safety
|
### 2. TypeScript & Type Safety
|
||||||
@@ -46,7 +50,7 @@ This document provides instructions for AI agents working on the Alert Message C
|
|||||||
|
|
||||||
### 3. Backend (Hono + Drizzle)
|
### 3. Backend (Hono + Drizzle)
|
||||||
- **Routing**: Group logic into sub-apps (e.g., `api.ts`, `auth.ts`, `webhook.ts`).
|
- **Routing**: Group logic into sub-apps (e.g., `api.ts`, `auth.ts`, `webhook.ts`).
|
||||||
- **Database**: Use Drizzle ORM. Prefer relational queries where possible.
|
- **Database**: Use Drizzle ORM. Prefer relational queries where possible (`db.query.xxx.findMany`).
|
||||||
- **Validation**: Use `@hono/zod-validator` for request validation.
|
- **Validation**: Use `@hono/zod-validator` for request validation.
|
||||||
- **Logging**: Use the structured logger in `src/lib/logger.ts` (Pino).
|
- **Logging**: Use the structured logger in `src/lib/logger.ts` (Pino).
|
||||||
- **Pattern**: `logger.error({ err, context }, "Message")`.
|
- **Pattern**: `logger.error({ err, context }, "Message")`.
|
||||||
@@ -76,3 +80,4 @@ This document provides instructions for AI agents working on the Alert Message C
|
|||||||
- **Biome First**: Always run `bun run check` before concluding a task.
|
- **Biome First**: Always run `bun run check` before concluding a task.
|
||||||
- **Preserve Patterns**: Follow existing structure in `apps/server/src` and `apps/web/src`.
|
- **Preserve Patterns**: Follow existing structure in `apps/server/src` and `apps/web/src`.
|
||||||
- **Minimalism**: Fix bugs minimally. Avoid large refactors unless requested.
|
- **Minimalism**: Fix bugs minimally. Avoid large refactors unless requested.
|
||||||
|
- **Context**: Agent-specific context is located in `@docs/`. Refer to `docs/copilot-context.md` for additional instructions.
|
||||||
|
|||||||
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
**CHANGELOG** | [简体中文](./CHANGELOG.zh-CN.md)
|
**CHANGELOG** | [简体中文](./CHANGELOG.zh-CN.md)
|
||||||
|
|
||||||
|
## [1.4.0] - 2026-01-23
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- **Global Topics**: Introduced a new topic type that broadcasts alerts to all users automatically.
|
||||||
|
- **User Requests**: All users can now request a topic to be "Global" during creation.
|
||||||
|
- **Admin Control**: Admins can promote any topic to "Global" or create new global topics via the Admin Dashboard.
|
||||||
|
- **Automatic Distribution**: Alerts sent to Global Topics are delivered to every registered user without requiring individual subscriptions.
|
||||||
|
- **UI Indicators**: Added "Global" badges and specialized management actions in the Topics and Admin views.
|
||||||
|
|
||||||
## [1.3.3] - 2026-01-17
|
## [1.3.3] - 2026-01-17
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -7,6 +7,15 @@
|
|||||||
|
|
||||||
**更新日志** | [English](./CHANGELOG.md)
|
**更新日志** | [English](./CHANGELOG.md)
|
||||||
|
|
||||||
|
## [1.4.0] - 2026-01-23
|
||||||
|
|
||||||
|
### 新增
|
||||||
|
- **全局话题 (Global Topics)**: 引入了全新的话题类型,可自动向所有用户广播告警。
|
||||||
|
- **用户申请**: 现在所有用户在创建话题时都可以选择申请将其设为“全局话题”。
|
||||||
|
- **管理员控制**: 管理员可以通过管理员后台将任何话题提升为“全局话题”,或直接创建新的全局话题。
|
||||||
|
- **自动分发**: 发送到全局话题的告警将投递给每一位已注册的用户,无需用户手动订阅。
|
||||||
|
- **UI 标识**: 在话题列表和管理员视图中增加了“全局”标识和专门的管理操作。
|
||||||
|
|
||||||
## [1.3.3] - 2026-01-17
|
## [1.3.3] - 2026-01-17
|
||||||
|
|
||||||
### 新增
|
### 新增
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@alertmessagecenter/server",
|
"name": "@alertmessagecenter/server",
|
||||||
"version": "1.3.3",
|
"version": "1.4.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "bun run --env-file .env --watch src/index.ts",
|
"dev": "bun run --env-file .env --watch src/index.ts",
|
||||||
"start": "bun run src/index.ts",
|
"start": "bun run src/index.ts",
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ api.post("/topics", requireAuth, zValidator("json", topicSchema), async (c) => {
|
|||||||
.insert(topics)
|
.insert(topics)
|
||||||
.values({
|
.values({
|
||||||
...body,
|
...body,
|
||||||
isGlobal: session.isAdmin ? (body.isGlobal ?? false) : false,
|
isGlobal: body.isGlobal ?? false,
|
||||||
status,
|
status,
|
||||||
createdBy: session.id,
|
createdBy: session.id,
|
||||||
approvedBy: session.isAdmin || session.isTrusted ? session.id : null,
|
approvedBy: session.isAdmin || session.isTrusted ? session.id : null,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@alertmessagecenter/web",
|
"name": "@alertmessagecenter/web",
|
||||||
"version": "1.3.3",
|
"version": "1.4.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "bun run --env-file .env vite",
|
"dev": "bun run --env-file .env vite",
|
||||||
|
|||||||
@@ -534,42 +534,52 @@ export default function TopicsView() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{currentUser && (
|
{currentUser && (
|
||||||
<div className="mt-3 space-y-3">
|
<div
|
||||||
<div className="bg-gray-50 p-2 rounded border border-gray-200">
|
className={`mt-3 ${topic.isGlobal ? "grid grid-cols-1 md:grid-cols-2 gap-4" : "space-y-3"}`}
|
||||||
<div className="flex justify-between items-center">
|
>
|
||||||
<span className="text-xs font-semibold text-gray-500 uppercase tracking-wider">
|
<div className="bg-gray-50 p-3 rounded-lg border border-gray-200 shadow-sm flex flex-col justify-between">
|
||||||
Your Personal Webhook
|
<div>
|
||||||
</span>
|
<div className="flex justify-between items-center mb-1.5">
|
||||||
<button
|
<span className="text-[10px] font-bold text-gray-500 uppercase tracking-widest">
|
||||||
type="button"
|
Your Personal Webhook
|
||||||
onClick={() =>
|
</span>
|
||||||
copyToClipboard(
|
<button
|
||||||
getWebhookUrl(topic.slug),
|
type="button"
|
||||||
topic.id,
|
onClick={() =>
|
||||||
)
|
copyToClipboard(
|
||||||
}
|
getWebhookUrl(topic.slug),
|
||||||
className="text-indigo-600 hover:text-indigo-800 flex items-center text-xs font-medium"
|
topic.id,
|
||||||
>
|
)
|
||||||
{copiedId === topic.id ? (
|
}
|
||||||
<>
|
className="text-indigo-600 hover:text-indigo-800 flex items-center text-xs font-semibold bg-white px-2 py-0.5 rounded border border-gray-200 shadow-sm transition-all hover:shadow hover:translate-y-[-1px]"
|
||||||
<Check className="w-3 h-3 mr-1" />
|
>
|
||||||
Copied!
|
{copiedId === topic.id ? (
|
||||||
</>
|
<>
|
||||||
) : (
|
<Check className="w-3 h-3 mr-1" />
|
||||||
<>
|
Copied
|
||||||
<Copy className="w-3 h-3 mr-1" />
|
</>
|
||||||
Copy URL
|
) : (
|
||||||
</>
|
<>
|
||||||
)}
|
<Copy className="w-3 h-3 mr-1" />
|
||||||
</button>
|
Copy URL
|
||||||
</div>
|
</>
|
||||||
<div className="mt-1 text-xs font-mono text-gray-600 break-all select-all">
|
)}
|
||||||
{getWebhookUrl(topic.slug)}
|
</button>
|
||||||
|
</div>
|
||||||
|
<div className="text-[11px] font-mono text-gray-600 break-all select-all bg-white/60 p-1.5 rounded border border-gray-100/50 leading-relaxed">
|
||||||
|
{getWebhookUrl(topic.slug)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{topic.isGlobal && (
|
||||||
|
<p className="mt-1.5 text-[10px] text-gray-400 italic">
|
||||||
|
* Requires your personal token to identify you
|
||||||
|
as the sender.
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{topic.isGlobal && (
|
{topic.isGlobal && (
|
||||||
<div className="bg-purple-50/50 p-3 rounded-lg border border-purple-100 shadow-sm relative overflow-hidden group">
|
<div className="bg-purple-50/50 p-3 rounded-lg border border-purple-100 shadow-sm relative overflow-hidden group flex flex-col justify-between">
|
||||||
<div className="absolute top-0 right-0 p-1 opacity-10 group-hover:opacity-20 transition-opacity">
|
<div className="absolute top-0 right-0 p-1 opacity-10 group-hover:opacity-20 transition-opacity">
|
||||||
<Globe className="w-12 h-12 text-purple-600" />
|
<Globe className="w-12 h-12 text-purple-600" />
|
||||||
</div>
|
</div>
|
||||||
@@ -746,25 +756,26 @@ export default function TopicsView() {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{currentUser?.isAdmin && (
|
<div className="flex items-center">
|
||||||
<div className="flex items-center">
|
<input
|
||||||
<input
|
id="is-global"
|
||||||
id="is-global"
|
type="checkbox"
|
||||||
type="checkbox"
|
className="h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded"
|
||||||
className="h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded"
|
checked={formData.isGlobal || false}
|
||||||
checked={formData.isGlobal || false}
|
onChange={(e) =>
|
||||||
onChange={(e) =>
|
setFormData({ ...formData, isGlobal: e.target.checked })
|
||||||
setFormData({ ...formData, isGlobal: e.target.checked })
|
}
|
||||||
}
|
/>
|
||||||
/>
|
<label
|
||||||
<label
|
htmlFor="is-global"
|
||||||
htmlFor="is-global"
|
className="ml-2 block text-sm text-gray-900 font-medium"
|
||||||
className="ml-2 block text-sm text-gray-900 font-medium"
|
>
|
||||||
>
|
Global Topic
|
||||||
Global Topic (Bypass personal token authentication)
|
</label>
|
||||||
</label>
|
<p className="ml-2 text-xs text-gray-500">
|
||||||
</div>
|
(Broadcast to ALL users. Requires Admin approval)
|
||||||
)}
|
</p>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label
|
<label
|
||||||
htmlFor="topic-description"
|
htmlFor="topic-description"
|
||||||
|
|||||||
@@ -1,7 +1,14 @@
|
|||||||
# Project Context for GitHub Copilot (v1.3.3)
|
# Project Context for GitHub Copilot (v1.4.0)
|
||||||
|
|
||||||
This document provides technical context, architectural decisions, and code conventions for the **Alert Message Center** project. It is intended to help AI assistants understand the codebase.
|
This document provides technical context, architectural decisions, and code conventions for the **Alert Message Center** project. It is intended to help AI assistants understand the codebase.
|
||||||
|
|
||||||
|
## 0. AI/Agent Specific Instructions
|
||||||
|
> [!IMPORTANT]
|
||||||
|
> **AI Agents MUST read [AGENTS.md](../AGENTS.md) first.** It contains critical information about:
|
||||||
|
> - Build/lint/test commands.
|
||||||
|
> - Required code style (tabs, double quotes, naming conventions).
|
||||||
|
> - Hard rules (NO `any`, Biome checks).
|
||||||
|
|
||||||
## 1. Project Overview
|
## 1. Project Overview
|
||||||
|
|
||||||
**Alert Message Center** (formerly Alert Manager) is a centralized alert dispatching system.
|
**Alert Message Center** (formerly Alert Manager) is a centralized alert dispatching system.
|
||||||
@@ -41,6 +48,7 @@ The database schema is defined in `apps/server/src/db/schema.ts`.
|
|||||||
- `name`: Display name (e.g., "Payment Service Errors").
|
- `name`: Display name (e.g., "Payment Service Errors").
|
||||||
- `slug`: URL-safe identifier (e.g., `payment-errors`). Used in webhook URLs.
|
- `slug`: URL-safe identifier (e.g., `payment-errors`). Used in webhook URLs.
|
||||||
- `description`: Optional text.
|
- `description`: Optional text.
|
||||||
|
- `isGlobal`: Boolean flag. If true, alerts are sent to all users automatically.
|
||||||
- `status`: `pending`, `approved`, or `rejected`.
|
- `status`: `pending`, `approved`, or `rejected`.
|
||||||
- `createdBy`: Foreign Key -> `users.id`.
|
- `createdBy`: Foreign Key -> `users.id`.
|
||||||
- `approvedBy`: Foreign Key -> `users.id`.
|
- `approvedBy`: Foreign Key -> `users.id`.
|
||||||
@@ -115,7 +123,11 @@ The database schema is defined in `apps/server/src/db/schema.ts`.
|
|||||||
- **Topic-based**: `POST /api/webhook/:token/topic/:slug`
|
- **Topic-based**: `POST /api/webhook/:token/topic/:slug`
|
||||||
- **Direct (Inbox)**: `POST /api/webhook/:token/dm`
|
- **Direct (Inbox)**: `POST /api/webhook/:token/dm`
|
||||||
2. **Lookup**:
|
2. **Lookup**:
|
||||||
- For Topic-based: Find `Topic` by `slug` and fetch all `subscriptions`.
|
- For Topic-based: Find `Topic` by `slug`.
|
||||||
|
- **Recipients**:
|
||||||
|
- If `isGlobal` is true: Fetch all active users from DB.
|
||||||
|
- If not global: Fetch all `subscriptions` for that topic.
|
||||||
|
- Always fetch all bound `topic_group_chats`.
|
||||||
- For Direct: Identify the user via `token`.
|
- For Direct: Identify the user via `token`.
|
||||||
3. **Dispatch**:
|
3. **Dispatch**:
|
||||||
- Call `FeishuClient.sendMessage` for each recipient.
|
- Call `FeishuClient.sendMessage` for each recipient.
|
||||||
@@ -171,7 +183,7 @@ The database schema is defined in `apps/server/src/db/schema.ts`.
|
|||||||
- `GET /api/topics/my-requests`: List user's own topic requests.
|
- `GET /api/topics/my-requests`: List user's own topic requests.
|
||||||
- `GET /api/topics/requests`: List pending topic requests (Admin only).
|
- `GET /api/topics/requests`: List pending topic requests (Admin only).
|
||||||
- `GET /api/topics/all`: List all topics regardless of status (Admin only).
|
- `GET /api/topics/all`: List all topics regardless of status (Admin only).
|
||||||
- `POST /api/topics`: Create a topic (Admin creates approved, User creates pending).
|
- `POST /api/topics`: Create a topic (Admin/Trusted creates approved, User creates pending; Supports `isGlobal`).
|
||||||
- `POST /api/topics/:id/approve`: Approve a topic request (Admin only).
|
- `POST /api/topics/:id/approve`: Approve a topic request (Admin only).
|
||||||
- `POST /api/topics/:id/reject`: Reject a topic request (Admin only).
|
- `POST /api/topics/:id/reject`: Reject a topic request (Admin only).
|
||||||
- `DELETE /api/topics/:id`: Delete a topic (Admin only).
|
- `DELETE /api/topics/:id`: Delete a topic (Admin only).
|
||||||
@@ -250,5 +262,6 @@ The database schema is defined in `apps/server/src/db/schema.ts`.
|
|||||||
|
|
||||||
- **[README.md](file:///Users/lilithgames/Workspace/play/alert-message-center/README.md)**: Main project documentation (English version).
|
- **[README.md](file:///Users/lilithgames/Workspace/play/alert-message-center/README.md)**: Main project documentation (English version).
|
||||||
- **[README.zh-CN.md](file:///Users/lilithgames/Workspace/play/alert-message-center/README.zh-CN.md)**: Simplified Chinese version of the documentation.
|
- **[README.zh-CN.md](file:///Users/lilithgames/Workspace/play/alert-message-center/README.zh-CN.md)**: Simplified Chinese version of the documentation.
|
||||||
|
- **[AGENTS.md](file:///Users/lilithgames/Workspace/play/alert-message-center/AGENTS.md)**: Specialized instructions and conventions for AI agents.
|
||||||
- **[CHANGELOG.md](file:///Users/lilithgames/Workspace/play/alert-message-center/CHANGELOG.md)**: Record of version changes.
|
- **[CHANGELOG.md](file:///Users/lilithgames/Workspace/play/alert-message-center/CHANGELOG.md)**: Record of version changes.
|
||||||
- **[todo.md](file:///Users/lilithgames/Workspace/play/alert-message-center/todo.md)**: Task tracking.
|
- **[todo.md](file:///Users/lilithgames/Workspace/play/alert-message-center/todo.md)**: Task tracking.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "alertmessagecenter",
|
"name": "alertmessagecenter",
|
||||||
"version": "1.1.1",
|
"version": "1.4.0",
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"apps/*"
|
"apps/*"
|
||||||
],
|
],
|
||||||
|
|||||||
1
todo.md
1
todo.md
@@ -16,6 +16,7 @@
|
|||||||
## Phase 2: Enhancements
|
## Phase 2: Enhancements
|
||||||
- [x] **Authentication**: Feishu SSO integration and role-based access control.
|
- [x] **Authentication**: Feishu SSO integration and role-based access control.
|
||||||
- [x] **Global Monitoring Dashboard**: Real-time System Load metrics (Grafana-style).
|
- [x] **Global Monitoring Dashboard**: Real-time System Load metrics (Grafana-style).
|
||||||
|
- [x] **Global Topics**: Support for broadcasting alerts to all users automatically.
|
||||||
- [ ] **Message Preview**: Preview Feishu card JSON in the UI.
|
- [ ] **Message Preview**: Preview Feishu card JSON in the UI.
|
||||||
- [x] **History/Logs**: Basic tracking for sent alerts (Alert Tasks/Logs).
|
- [x] **History/Logs**: Basic tracking for sent alerts (Alert Tasks/Logs).
|
||||||
- [x] **Admin Topic Management**: Approve, reject, and delete topics (with audit trail).
|
- [x] **Admin Topic Management**: Approve, reject, and delete topics (with audit trail).
|
||||||
|
|||||||
Reference in New Issue
Block a user