package application import ( "context" "io" "time" "mtusi2026lab4/internal/domain" ) type UserRepository interface { CreateUser(ctx context.Context, username, displayName, passwordHash string) (domain.User, error) GetUserByUsername(ctx context.Context, username string) (domain.User, string, error) } type SessionRepository interface { CreateSession(ctx context.Context, tokenHash []byte, userID string, expiresAt time.Time) error GetUserBySession(ctx context.Context, tokenHash []byte) (domain.User, error) DeleteSession(ctx context.Context, tokenHash []byte) error } type ChatRepository interface { CreateChat(ctx context.Context, title string, memberIDs []string) (domain.Chat, error) GetChatByID(ctx context.Context, chatID, callerID string) (domain.Chat, error) GetChatsForUser(ctx context.Context, userID string, limit int, cursor *domain.ChatCursor) ([]domain.Chat, bool, error) } type IdempotentMessageWrite struct { ActorID string ChatID string Text string AttachmentIDs []string Method string CanonicalPath string Key string RequestHash [32]byte TTL time.Duration } type MessageRepository interface { CreateMessageIdempotently(ctx context.Context, write IdempotentMessageWrite) (domain.Message, error) GetMessages(ctx context.Context, chatID, callerID string, limit int, cursor *domain.MessageCursor) ([]domain.Message, bool, error) } type AttachmentRepository interface { CreateAttachment(ctx context.Context, attachment domain.Attachment) (domain.Attachment, error) MarkAttachmentReady(ctx context.Context, attachmentID string, updatedAt time.Time) (domain.Attachment, error) MarkAttachmentFailed(ctx context.Context, attachmentID, errorCode string, updatedAt time.Time) error GetAttachment(ctx context.Context, attachmentID, callerID string) (domain.Attachment, error) } type Repository interface { UserRepository SessionRepository ChatRepository MessageRepository AttachmentRepository } type ObjectPut struct { Key string ContentType string SizeBytes int64 Body io.Reader } type ObjectContent struct { Body io.ReadCloser SizeBytes int64 } type ObjectStore interface { Put(ctx context.Context, object ObjectPut) error Get(ctx context.Context, key string) (ObjectContent, error) Delete(ctx context.Context, key string) error }