extend chat model with CRUD actions for event changes

- Add ProposedEventChange type with create/update/delete actions
- Replace proposedEvent with proposedChange in ChatMessage
- Add currentDate to AIContext for time-aware AI responses
- Add AI test endpoint for development (/api/ai/test)
- Fix MongoUserRepository type safety with explicit toUser mapping
- Update CLAUDE.md documentation
This commit is contained in:
2026-01-03 19:37:27 +01:00
parent 105a9a4980
commit e553103470
7 changed files with 82 additions and 34 deletions

View File

@@ -1,10 +1,10 @@
import mongoose, { Schema, Document } from 'mongoose';
import { ChatMessage, Conversation, CreateEventDTO } from '@caldav/shared';
import { ChatMessage, Conversation, CreateEventDTO, UpdateEventDTO, ProposedEventChange } from '@caldav/shared';
export interface ChatMessageDocument extends Omit<ChatMessage, 'id'>, Document {}
export interface ConversationDocument extends Omit<Conversation, 'id'>, Document {}
const ProposedEventSchema = new Schema<CreateEventDTO>(
const EventSchema = new Schema<CreateEventDTO>(
{
title: { type: String, required: true },
description: { type: String },
@@ -17,6 +17,29 @@ const ProposedEventSchema = new Schema<CreateEventDTO>(
{ _id: false }
);
const UpdatesSchema = new Schema<UpdateEventDTO>(
{
title: { type: String },
description: { type: String },
startTime: { type: Date },
endTime: { type: Date },
note: { type: String },
isRecurring: { type: Boolean },
recurrenceRule: { type: String },
},
{ _id: false }
);
const ProposedChangeSchema = new Schema<ProposedEventChange>(
{
action: { type: String, enum: ['create', 'update', 'delete'], required: true },
eventId: { type: String },
event: { type: EventSchema },
updates: { type: UpdatesSchema },
},
{ _id: false }
);
const ChatMessageSchema = new Schema<ChatMessageDocument>(
{
conversationId: {
@@ -32,8 +55,8 @@ const ChatMessageSchema = new Schema<ChatMessageDocument>(
type: String,
required: true,
},
proposedEvent: {
type: ProposedEventSchema,
proposedChange: {
type: ProposedChangeSchema,
},
},
{