- CommentAttachment link table (comment <-> file) + migration - fileIds in create/update comment; update replaces the whole set, synced in one transaction with the comment - CommentDto.attachments; empty for deleted comments - Soft delete drops attachments so GC can collect the files - Max 10 files per comment, ordered by upload time (uuid v7) - Registers comments as a file owner - Rename CommentAuthorExpanderService -> CommentExpanderService (expands authors and files) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
29 lines
1.5 KiB
TypeScript
29 lines
1.5 KiB
TypeScript
import { Comment } from '../entities/comment.entity.js';
|
|
|
|
/** DI-токен, т.к. интерфейсы стираются при компиляции TS */
|
|
export const COMMENT_REPOSITORY = Symbol('COMMENT_REPOSITORY');
|
|
|
|
export interface ICommentRepository {
|
|
/** Возвращает и мягко удалённые комментарии — решение принимает вызывающий */
|
|
findById(id: string): Promise<Comment | null>;
|
|
/**
|
|
* Комментарии задачи от старых к новым, включая удалённые.
|
|
* Курсорная пагинация: cursor — id последнего полученного комментария.
|
|
*/
|
|
findByIssue(params: {
|
|
issueId: number;
|
|
limit: number;
|
|
cursor?: string;
|
|
}): Promise<{ list: Comment[]; nextCursor: string | null }>;
|
|
/**
|
|
* Создание и обновление сохраняют и вложения (fileIds) — атомарно с комментарием.
|
|
* FileNotFoundException, если файл удалили между проверкой и записью.
|
|
*/
|
|
create(comment: Comment): Promise<Comment>;
|
|
update(comment: Comment): Promise<void>;
|
|
/** Задачи неудалённых комментариев, к которым прикреплён файл */
|
|
findIssueIdsByAttachedFile(fileId: string): Promise<number[]>;
|
|
/** Подмножество fileIds, прикреплённых хотя бы к одному комментарию */
|
|
findReferencedFileIds(fileIds: string[]): Promise<string[]>;
|
|
}
|