Initial Commit
This commit is contained in:
78
openspec/changes/enterprise-api-plugin-messaging/proposal.md
Normal file
78
openspec/changes/enterprise-api-plugin-messaging/proposal.md
Normal file
@@ -0,0 +1,78 @@
|
||||
# OpenSpec Change: enterprise-api-plugin-messaging
|
||||
|
||||
- **Change ID**: enterprise-api-plugin-messaging
|
||||
- **Package**: `@suaveplan/api-plugin-messaging`
|
||||
- **Category**: api/comms
|
||||
- **Target path**: `api/comms/api-plugin-messaging`
|
||||
- **Status**: PROPOSED
|
||||
- **Date**: 2026-04-24
|
||||
- **Reference spec**: `/mnt/s/web/suaveplan/enterprise/api-plugin-messaging.md`
|
||||
|
||||
---
|
||||
|
||||
## Summary
|
||||
|
||||
Deliver `@suaveplan/api-plugin-messaging` on the genesis branch from scratch at enterprise quality. In-app messaging plugin: threads (1:1 and group), messages with rich content (text, attachments, reactions), read receipts, typing indicators via SSE or WebSocket bridge, message search, and moderation (flag/delete). Routes under `/messaging`. Per-table SurrealQL. Typed bus events: `messaging:message:sent`, `messaging:thread:created`, `messaging:message:deleted`. Integrates with `@suaveplan/api-plugin-notifications` to emit push/email notifications on new messages.
|
||||
|
||||
---
|
||||
|
||||
## Available workspace deps on genesis
|
||||
|
||||
| Package | Role |
|
||||
|---|---|
|
||||
| `@suaveplan/api` (`workspace:^`) | `definePlugin` |
|
||||
| `@suaveplan/api-shared` (`workspace:^`) | Helpers |
|
||||
| `@suaveplan/api-plugin-auth` (`workspace:^`) | `requireAuth` |
|
||||
| `@suaveplan/api-plugin-database` (`workspace:^`) | SurrealDB |
|
||||
| `@suaveplan/api-plugin-file-upload` (`workspace:^`) | Attachment uploads |
|
||||
| `@suaveplan/api-plugin-notifications` (`workspace:^`) | Push/email on new message |
|
||||
| `@suaveplan/suppression` (`workspace:^`) | Message suppression list |
|
||||
| `@suaveplan/events` (`workspace:^`) | Event bus |
|
||||
| `@suaveplan/error` (`workspace:^`) | `MessagingError` hierarchy |
|
||||
| `@suaveplan/rate-limiter` (`workspace:^`) | Send rate limits |
|
||||
| `hono` + `@hono/zod-openapi` + `zod` | Routes |
|
||||
| `@opentelemetry/api` | OTel |
|
||||
|
||||
---
|
||||
|
||||
## Public API surface
|
||||
|
||||
```ts
|
||||
function createMessagingPlugin(config?: MessagingPluginConfig): PluginDescriptor
|
||||
// Services: ThreadService, MessageService, ReactionService, ModerationService
|
||||
// Routes: /messaging/threads, /messaging/threads/:id/messages,
|
||||
// /messaging/threads/:id/read, /messaging/threads/:id/typing
|
||||
```
|
||||
|
||||
### Error codes
|
||||
|
||||
```ts
|
||||
type MessagingErrorCode =
|
||||
| "MESSAGING_THREAD_NOT_FOUND"
|
||||
| "MESSAGING_MESSAGE_NOT_FOUND"
|
||||
| "MESSAGING_NOT_PARTICIPANT"
|
||||
| "MESSAGING_SUPPRESSED"
|
||||
| "MESSAGING_ATTACHMENT_TOO_LARGE"
|
||||
| "MESSAGING_RATE_LIMITED"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## File layout
|
||||
|
||||
```text
|
||||
api/comms/api-plugin-messaging/
|
||||
package.json tsconfig.json vitest.config.ts
|
||||
surql/ (thread, thread_participant, message, reaction, read_receipt tables)
|
||||
src/
|
||||
index.ts events.ts types/ errors/
|
||||
services/thread/ services/message/ services/reaction/ services/moderation/
|
||||
routes/threads/ routes/messages/
|
||||
tests/integration.test.ts
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Impact
|
||||
|
||||
Prerequisites: `@suaveplan/api`, `@suaveplan/api-plugin-auth`, `@suaveplan/api-plugin-database`, `@suaveplan/api-plugin-file-upload`, `@suaveplan/api-plugin-notifications`, `@suaveplan/suppression`.
|
||||
56
openspec/changes/enterprise-api-plugin-messaging/tasks.md
Normal file
56
openspec/changes/enterprise-api-plugin-messaging/tasks.md
Normal file
@@ -0,0 +1,56 @@
|
||||
# Tasks: enterprise-api-plugin-messaging
|
||||
|
||||
**Change ID**: enterprise-api-plugin-messaging
|
||||
**Package**: `@suaveplan/api-plugin-messaging`
|
||||
**Target path**: `api/comms/api-plugin-messaging`
|
||||
**Prerequisite packages on Verdaccio**: `@suaveplan/api`, `@suaveplan/api-shared`, `@suaveplan/api-plugin-auth`, `@suaveplan/api-plugin-database`, `@suaveplan/api-plugin-file-upload`, `@suaveplan/api-plugin-notifications`, `@suaveplan/suppression`, `@suaveplan/events`, `@suaveplan/rate-limiter`, `@suaveplan/error`
|
||||
|
||||
---
|
||||
|
||||
## 0. Pre-flight (non-negotiable)
|
||||
|
||||
- [ ] 0.1 Confirm clean working tree (`git status` reports nothing) and no in-flight worktrees with uncommitted work (`git worktree list` then `git status` in each)
|
||||
- [ ] 0.2 If any worktrees exist under `.claude/worktrees/`, account for each one: still-active agent, work-pending-merge, or stale-and-prune. Stale worktrees MUST be removed (`git worktree remove`) before opening a new one — code that has been lost twice on main is the failure mode this guards against.
|
||||
- [ ] 0.3 Confirm the package set in `MANIFEST.md` matches `find packages -maxdepth 3 -name package.json` count. Drift here means a prior change archived without regenerating the manifest.
|
||||
|
||||
## 1. Scaffold + types + errors + events
|
||||
|
||||
- [ ] Create `api/comms/api-plugin-messaging/`; `package.json` v0.0.0; standard tooling.
|
||||
- [ ] Types: `Thread`, `ThreadParticipant`, `Message`, `Reaction`, `ReadReceipt`, `MessagingPluginConfig` (Zod).
|
||||
- [ ] Errors: 6-code union + metadata + registration. Test + doc.
|
||||
- [ ] Events: `MessagingEventMap` (messaging:message:sent, messaging:thread:created, messaging:message:deleted, messaging:reaction:added).
|
||||
|
||||
---
|
||||
|
||||
## 2. SurrealQL
|
||||
|
||||
- [ ] `thread.surql`, `thread_participant.surql`, `message.surql`, `reaction.surql`, `read_receipt.surql`. tenantId indexes; full-text on message content.
|
||||
|
||||
---
|
||||
|
||||
## 3. Services (each `.test.ts` + `.md`)
|
||||
|
||||
- [ ] **ThreadService**: `createThread` (1:1 or group), `getThread`, `listThreads`, `addParticipant`, `removeParticipant`.
|
||||
- [ ] **MessageService**: `sendMessage` (check suppression list), `editMessage`, `deleteMessage`, `listMessages` (paginated), `markRead`. Rate-limit on send. Notify via `api-plugin-notifications` on unread message.
|
||||
- [ ] **ReactionService**: `addReaction`, `removeReaction`, `listReactions`.
|
||||
- [ ] **ModerationService**: `flagMessage`, `deleteMessageAdmin`, `banParticipant`.
|
||||
|
||||
---
|
||||
|
||||
## 4. Routes
|
||||
|
||||
- [ ] `GET/POST /messaging/threads` — `requireAuth`.
|
||||
- [ ] `GET /messaging/threads/:id`, `GET/POST /messaging/threads/:id/messages` — `requireAuth`.
|
||||
- [ ] `POST /messaging/threads/:id/read` — `requireAuth`.
|
||||
- [ ] `POST /messaging/threads/:id/reactions` — `requireAuth` + rate-limit.
|
||||
- [ ] Route `.test.ts` + `.md`.
|
||||
|
||||
---
|
||||
|
||||
## 5. Plugin factory + integration tests + publish
|
||||
|
||||
- [ ] `createMessagingPlugin`: `definePlugin`, `dependencies: ["database", "auth"]`, `migrationsPath: "./surql"`.
|
||||
- [ ] Integration: create thread → send message → read receipt → notification triggered (real SurrealDB).
|
||||
- [ ] `bunx turbo lint typecheck test --filter=@suaveplan/api-plugin-messaging` — green; 100% coverage.
|
||||
- [ ] `bun scripts/publish.ts --package @suaveplan/api-plugin-messaging`.
|
||||
- [ ] Archive → `openspec/archive/2026-04-24-enterprise-api-plugin-messaging/`.
|
||||
Reference in New Issue
Block a user