Files
ulitka/src/modules/file/domain/repositories/file.repository.interface.ts
T
vadimandClaude Opus 5.5 f32c6e348d Add file module for uploads and storage
- File model + migration: file metadata, content lives in object storage
- IFileStorage port with local disk and S3-compatible (RustFS/MinIO) adapters
- POST /files, GET /files/:id/download, DELETE /files/:id
- MIME sniffed from content; only safe images served inline, nosniff header
- FileOwnerRegistry: owner modules register to grant visibility and keep
  their files from GC; FileGcService removes orphaned files hourly
- TransformResponseInterceptor passes StreamableFile through

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 09:17:55 +03:00

17 lines
821 B
TypeScript

import { StoredFile } from '../entities/stored-file.entity.js';
/** DI-токен, т.к. интерфейсы стираются при компиляции TS */
export const FILE_REPOSITORY = Symbol('FILE_REPOSITORY');
export interface IFileRepository {
findById(id: string): Promise<StoredFile | null>;
findByIds(ids: string[]): Promise<StoredFile[]>;
/**
* Файлы, созданные раньше `before`, по возрастанию id (uuid v7 ≈ время создания).
* Курсорная пагинация для GC: cursor — id последнего полученного файла.
*/
findCreatedBefore(params: { before: Date; limit: number; cursor?: string }): Promise<StoredFile[]>;
create(file: StoredFile): Promise<StoredFile>;
delete(id: string): Promise<void>;
}