import type { UseCaseOutputPort } from '@core/shared/application'; import type { GetMediaResult } from '@core/media/application/use-cases/GetMediaUseCase'; import type { GetMediaOutputDTO } from '../dtos/GetMediaOutputDTO'; export type GetMediaResponseModel = GetMediaOutputDTO | null; export class GetMediaPresenter implements UseCaseOutputPort { private model: GetMediaResponseModel | null = null; reset(): void { this.model = null; } present(result: GetMediaResult): void { const media = result.media; this.model = { id: media.id, url: media.url, type: media.type, // Best-effort mapping from arbitrary metadata category: (media.metadata as { category?: string } | undefined)?.category, uploadedAt: media.uploadedAt, size: media.size, }; } getResponseModel(): GetMediaResponseModel | null { return this.model; } get responseModel(): GetMediaResponseModel { return this.model ?? null; } }