import { PublishStatus, SourceType } from '../common/enums'; import { Scene } from '../entities/scene.entity'; import type { SceneConfig } from './scene-config'; /** 契约 data-models.md §7 的对外表示 */ export interface SceneDto { id: number; name: string; glbUrl: string | null; thumbnailUrl: string | null; fileSize: number | null; fileSha256: string | null; conversionNote: string | null; /** 物理 / 环境 / 出生点 / 相机(服务端只存参数,仿真在客户端) */ config: SceneConfig | null; stats: Record | null; sourceType: SourceType; sourceName: string; sourceUrl: string; license: string; author: string; status: PublishStatus; createdAt: string; updatedAt: string; } export interface SceneUrlLookup { glbUrl: string | null; thumbnailUrl: string | null; } export function toSceneDto(scene: Scene, urls: SceneUrlLookup): SceneDto { return { id: scene.id, name: scene.name, glbUrl: urls.glbUrl, thumbnailUrl: urls.thumbnailUrl, fileSize: scene.fileSize ?? null, fileSha256: scene.fileSha256 ?? null, conversionNote: scene.conversionNote ?? null, config: scene.config ?? null, stats: scene.stats ?? null, sourceType: scene.sourceType, sourceName: scene.sourceName, sourceUrl: scene.sourceUrl, license: scene.license, author: scene.author, status: scene.status, createdAt: scene.createdAt.toISOString(), updatedAt: scene.updatedAt.toISOString(), }; }