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:
@@ -1,19 +1,29 @@
|
||||
import { User } from '@caldav/shared';
|
||||
import { UserRepository, CreateUserData } from '../../services/interfaces';
|
||||
import { UserModel } from './models';
|
||||
import { UserModel, UserDocument } from './models';
|
||||
|
||||
export class MongoUserRepository implements UserRepository {
|
||||
private toUser(doc: UserDocument): User {
|
||||
return {
|
||||
id: doc._id.toString(),
|
||||
email: doc.email,
|
||||
displayName: doc.displayName,
|
||||
createdAt: doc.createdAt,
|
||||
updatedAt: doc.updatedAt,
|
||||
};
|
||||
}
|
||||
|
||||
async findById(id: string): Promise<User | null> {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
|
||||
async findByEmail(email: string): Promise<User | null> {
|
||||
const user = await UserModel.findOne({ email: email.toLowerCase() });
|
||||
return user ? user.toJSON() as User : null;
|
||||
return user ? this.toUser(user) : null;
|
||||
}
|
||||
|
||||
async create(data: CreateUserData): Promise<User> {
|
||||
const user = await UserModel.create(data);
|
||||
return user.toJSON() as User;
|
||||
return this.toUser(user);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user