feat(21-01): add shared chat types and Zod validators

- Create ChatConversation, ChatConversationListItem, ChatMessage, and list response types
- Create createConversationSchema, updateConversationSchema, createMessageSchema validators
- Re-export from @paperclipai/shared barrel files (types/index.ts, validators/index.ts)
This commit is contained in:
Nexus Dev 2026-04-01 16:37:19 +00:00
parent d9aab2e1fb
commit c2ef322835
4 changed files with 67 additions and 0 deletions

View file

@ -0,0 +1,41 @@
export interface ChatConversation {
id: string;
companyId: string;
title: string | null;
agentId: string | null;
pinnedAt: string | null;
archivedAt: string | null;
deletedAt: string | null;
createdAt: string;
updatedAt: string;
}
export interface ChatConversationListItem {
id: string;
companyId: string;
title: string | null;
agentId: string | null;
pinnedAt: string | null;
archivedAt: string | null;
updatedAt: string;
lastMessagePreview: string | null;
}
export interface ChatMessage {
id: string;
conversationId: string;
role: "user" | "assistant" | "system";
content: string;
agentId: string | null;
createdAt: string;
}
export interface ChatConversationListResponse {
items: ChatConversationListItem[];
hasMore: boolean;
}
export interface ChatMessageListResponse {
items: ChatMessage[];
hasMore: boolean;
}

View file

@ -179,6 +179,7 @@ export type {
CompanyPortabilityImportResult,
CompanyPortabilityExportRequest,
} from "./company-portability.js";
export * from "./chat.js";
export type {
JsonSchema,
PluginJobDeclaration,

View file

@ -0,0 +1,23 @@
import { z } from "zod";
export const createConversationSchema = z.object({
title: z.string().max(200).optional(),
agentId: z.string().uuid().optional(),
});
export const updateConversationSchema = z.object({
title: z.string().max(200).optional(),
agentId: z.string().uuid().nullable().optional(),
pinnedAt: z.string().datetime().nullable().optional(),
archivedAt: z.string().datetime().nullable().optional(),
});
export const createMessageSchema = z.object({
role: z.enum(["user", "assistant", "system"]),
content: z.string().min(1).max(100_000),
agentId: z.string().uuid().optional(),
});
export type CreateConversation = z.infer<typeof createConversationSchema>;
export type UpdateConversation = z.infer<typeof updateConversationSchema>;
export type CreateMessage = z.infer<typeof createMessageSchema>;

View file

@ -1,3 +1,5 @@
export * from "./chat.js";
export {
instanceGeneralSettingsSchema,
patchInstanceGeneralSettingsSchema,