feat(24-00): shared types, validators, and Wave 0 test stubs for phase 24
- Add ChatMessageSearchResult, ChatMessageSearchResponse to shared types - Add ChatBookmark, ChatBookmarkWithMessage, ChatBookmarkListResponse, ChatBookmarkToggleResponse - Add parentConversationId + branchFromMessageId to ChatConversation and ChatConversationListItem - Add searchMessagesSchema + branchConversationSchema to validators - Re-export all new types and validators from shared/src/index.ts - Add Wave 0 it.todo stubs: searchMessages, toggleBookmark, branchConversation, exportConversation - Add Wave 0 it.todo stubs for 4 new route groups in chat-routes.test.ts
This commit is contained in:
parent
988514db41
commit
dc6316cf28
5 changed files with 101 additions and 0 deletions
|
|
@ -593,10 +593,14 @@ export {
|
||||||
updateConversationSchema,
|
updateConversationSchema,
|
||||||
createMessageSchema,
|
createMessageSchema,
|
||||||
handoffSchema,
|
handoffSchema,
|
||||||
|
searchMessagesSchema,
|
||||||
|
branchConversationSchema,
|
||||||
type CreateConversation,
|
type CreateConversation,
|
||||||
type UpdateConversation,
|
type UpdateConversation,
|
||||||
type CreateMessage,
|
type CreateMessage,
|
||||||
type Handoff,
|
type Handoff,
|
||||||
|
type SearchMessages,
|
||||||
|
type BranchConversation,
|
||||||
} from "./validators/index.js";
|
} from "./validators/index.js";
|
||||||
|
|
||||||
export type {
|
export type {
|
||||||
|
|
@ -605,6 +609,12 @@ export type {
|
||||||
ChatMessage,
|
ChatMessage,
|
||||||
ChatConversationListResponse,
|
ChatConversationListResponse,
|
||||||
ChatMessageListResponse,
|
ChatMessageListResponse,
|
||||||
|
ChatMessageSearchResult,
|
||||||
|
ChatMessageSearchResponse,
|
||||||
|
ChatBookmark,
|
||||||
|
ChatBookmarkWithMessage,
|
||||||
|
ChatBookmarkListResponse,
|
||||||
|
ChatBookmarkToggleResponse,
|
||||||
} from "./types/chat.js";
|
} from "./types/chat.js";
|
||||||
|
|
||||||
export { API_PREFIX, API } from "./api.js";
|
export { API_PREFIX, API } from "./api.js";
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ export interface ChatConversation {
|
||||||
deletedAt: string | null;
|
deletedAt: string | null;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
|
parentConversationId: string | null;
|
||||||
|
branchFromMessageId: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ChatConversationListItem {
|
export interface ChatConversationListItem {
|
||||||
|
|
@ -19,6 +21,8 @@ export interface ChatConversationListItem {
|
||||||
archivedAt: string | null;
|
archivedAt: string | null;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
lastMessagePreview: string | null;
|
lastMessagePreview: string | null;
|
||||||
|
parentConversationId: string | null;
|
||||||
|
branchFromMessageId: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ChatMessage {
|
export interface ChatMessage {
|
||||||
|
|
@ -41,3 +45,39 @@ export interface ChatMessageListResponse {
|
||||||
items: ChatMessage[];
|
items: ChatMessage[];
|
||||||
hasMore: boolean;
|
hasMore: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ChatMessageSearchResult {
|
||||||
|
messageId: string;
|
||||||
|
conversationId: string;
|
||||||
|
conversationTitle: string | null;
|
||||||
|
content: string;
|
||||||
|
role: "user" | "assistant" | "system";
|
||||||
|
agentId: string | null;
|
||||||
|
createdAt: string;
|
||||||
|
rank: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ChatMessageSearchResponse {
|
||||||
|
items: ChatMessageSearchResult[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ChatBookmark {
|
||||||
|
id: string;
|
||||||
|
companyId: string;
|
||||||
|
messageId: string;
|
||||||
|
conversationId: string;
|
||||||
|
createdAt: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ChatBookmarkWithMessage extends ChatBookmark {
|
||||||
|
message: ChatMessage;
|
||||||
|
conversationTitle: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ChatBookmarkListResponse {
|
||||||
|
items: ChatBookmarkWithMessage[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ChatBookmarkToggleResponse {
|
||||||
|
bookmarked: boolean;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,3 +33,15 @@ export type CreateConversation = z.infer<typeof createConversationSchema>;
|
||||||
export type UpdateConversation = z.infer<typeof updateConversationSchema>;
|
export type UpdateConversation = z.infer<typeof updateConversationSchema>;
|
||||||
export type CreateMessage = z.infer<typeof createMessageSchema>;
|
export type CreateMessage = z.infer<typeof createMessageSchema>;
|
||||||
export type Handoff = z.infer<typeof handoffSchema>;
|
export type Handoff = z.infer<typeof handoffSchema>;
|
||||||
|
|
||||||
|
export const searchMessagesSchema = z.object({
|
||||||
|
q: z.string().min(2).max(200),
|
||||||
|
limit: z.coerce.number().int().min(1).max(50).optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const branchConversationSchema = z.object({
|
||||||
|
branchFromMessageId: z.string().uuid(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export type SearchMessages = z.infer<typeof searchMessagesSchema>;
|
||||||
|
export type BranchConversation = z.infer<typeof branchConversationSchema>;
|
||||||
|
|
|
||||||
|
|
@ -196,4 +196,22 @@ describe("chatRoutes", () => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("GET /companies/:id/messages/search", () => {
|
||||||
|
it.todo("returns 200 with search results");
|
||||||
|
it.todo("returns 400 for short query");
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("POST /conversations/:id/bookmarks", () => {
|
||||||
|
it.todo("toggles bookmark on/off");
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("POST /conversations/:id/branch", () => {
|
||||||
|
it.todo("returns 201 with branched conversation");
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("GET /conversations/:id/export", () => {
|
||||||
|
it.todo("returns markdown file download");
|
||||||
|
it.todo("returns JSON file download");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -383,4 +383,25 @@ describe("chatService", () => {
|
||||||
expect(result.items.length).toBe(50);
|
expect(result.items.length).toBe(50);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("searchMessages", () => {
|
||||||
|
it.todo("returns ranked results for matching term");
|
||||||
|
it.todo("returns empty for no match");
|
||||||
|
it.todo("respects companyId scope");
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("toggleBookmark", () => {
|
||||||
|
it.todo("creates bookmark when not exists");
|
||||||
|
it.todo("removes bookmark when exists");
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("branchConversation", () => {
|
||||||
|
it.todo("creates child conversation with copied messages");
|
||||||
|
it.todo("throws not found for invalid message id");
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("exportConversation", () => {
|
||||||
|
it.todo("exports as markdown with agent names");
|
||||||
|
it.todo("exports as JSON with all messages");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue