feat(P4B.T2): WhiteboardPayload + shared whiteboards CRUD wrappers + tests

Adds WhiteboardPayload wire-format variant to MessagePayload/ParsedMessagePayload,
creates the whiteboards.ts CRUD wrapper (createWhiteboard, listWhiteboardStrokes,
insertWhiteboardStroke, clearWhiteboardStrokes), writes 5 unit tests (38/38 pass),
re-exports from chat/index.ts, and registers conversation_whiteboards +
whiteboard_strokes in packages/db-types so typecheck passes cleanly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
byGalax
2026-05-16 20:23:45 +02:00
parent f95858c703
commit 3df7cc01ea
5 changed files with 301 additions and 1 deletions
+22 -1
View File
@@ -76,7 +76,17 @@ export interface PollPayload {
options: PollOption[];
}
export type MessagePayload = TextMessagePayload | CallEventPayload | PollPayload;
export interface WhiteboardPayload {
v: 1;
type: 'whiteboard';
whiteboard_id: string;
}
export type MessagePayload =
| TextMessagePayload
| CallEventPayload
| PollPayload
| WhiteboardPayload;
export type ParsedMessagePayload =
| {
@@ -95,6 +105,10 @@ export type ParsedMessagePayload =
kind: 'poll';
question: string;
options: PollOption[];
}
| {
kind: 'whiteboard';
whiteboardId: string;
};
export function serializeMessagePayload(payload: MessagePayload): string {
@@ -151,6 +165,13 @@ export function parseMessagePayload(raw: string | null): ParsedMessagePayload {
options,
};
}
if (obj.type === 'whiteboard') {
const p = obj as Partial<WhiteboardPayload>;
const id = typeof p.whiteboard_id === 'string' && p.whiteboard_id.length > 0
? p.whiteboard_id
: '';
return { kind: 'whiteboard', whiteboardId: id };
}
const t = obj as TextMessagePayload;
return {
kind: 'text',