feat(m8): SSE hub + realtime chat with mentions, tests, e2e

- SseHub (project-scoped client mgmt + broadcast, implements SseBroadcaster)
  with SSE-formatted payload; singleton getSseHub
- ChatRepository (message CRUD, soft-delete, search, pagination, project
  isolation) + ChatService (membership permission, send/edit/delete,
  @email mention -> mention notification, SSE broadcast of created/updated/deleted)
- SSE stream endpoint (ReadableStream + heartbeat + abort cleanup, membership)
- Chat message API routes (history/send/edit/delete)
- ChatWindow client (EventSource auto-reconnect, history fetch, realtime
  append/update/delete), chat page, ProjectNav チャット link
- SseEvent type now carries ChatMessage for chat events
- Unit (SseHub, ChatRepository, ChatService) + integration chat-sse-broadcast
  + e2e chat-sse (two contexts realtime)
This commit is contained in:
Ken Yasue
2026-06-25 01:45:34 +02:00
parent 83a02265f5
commit ddad5ae78c
16 changed files with 1183 additions and 7 deletions

View File

@ -11,6 +11,9 @@ import { BoardService } from '@/services/BoardService';
import { BoardRepository } from '@/repositories/BoardRepository';
import { NoteService } from '@/services/NoteService';
import { ProjectNoteRepository } from '@/repositories/ProjectNoteRepository';
import { ChatService } from '@/services/ChatService';
import { ChatRepository } from '@/repositories/ChatRepository';
import { getSseHub } from '@/lib/sse/hub';
/**
* Route Handler用に各Repository/Serviceを構築するファクトリ。
@ -54,6 +57,17 @@ export function createNoteService(): NoteService {
);
}
export function createChatService(): ChatService {
const db = getDb();
return new ChatService(
new ChatRepository(db),
new ProjectMemberRepository(db),
new UserRepository(db),
new NotificationService(new NotificationRepository(db)),
getSseHub()
);
}
export function createUserRepository(): UserRepository {
return new UserRepository(getDb());
}