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:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user