2022-06-18 17:56:36 +02:00
|
|
|
import { AssetEntity, AssetType } from '@app/database/entities/asset.entity';
|
|
|
|
|
import { ExifResponseDto, mapExif } from './exif-response.dto';
|
|
|
|
|
import { SmartInfoResponseDto, mapSmartInfo } from './smart-info-response.dto';
|
|
|
|
|
|
|
|
|
|
export interface AssetResponseDto {
|
|
|
|
|
id: string;
|
|
|
|
|
deviceAssetId: string;
|
|
|
|
|
ownerId: string;
|
|
|
|
|
deviceId: string;
|
|
|
|
|
type: AssetType;
|
|
|
|
|
originalPath: string;
|
|
|
|
|
resizePath: string | null;
|
|
|
|
|
createdAt: string;
|
|
|
|
|
modifiedAt: string;
|
|
|
|
|
isFavorite: boolean;
|
|
|
|
|
mimeType: string | null;
|
2022-06-25 19:53:06 +02:00
|
|
|
duration: string;
|
2022-06-18 17:56:36 +02:00
|
|
|
exifInfo?: ExifResponseDto;
|
|
|
|
|
smartInfo?: SmartInfoResponseDto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function mapAsset(entity: AssetEntity): AssetResponseDto {
|
|
|
|
|
return {
|
|
|
|
|
id: entity.id,
|
|
|
|
|
deviceAssetId: entity.deviceAssetId,
|
|
|
|
|
ownerId: entity.userId,
|
|
|
|
|
deviceId: entity.deviceId,
|
|
|
|
|
type: entity.type,
|
|
|
|
|
originalPath: entity.originalPath,
|
|
|
|
|
resizePath: entity.resizePath,
|
|
|
|
|
createdAt: entity.createdAt,
|
|
|
|
|
modifiedAt: entity.modifiedAt,
|
|
|
|
|
isFavorite: entity.isFavorite,
|
|
|
|
|
mimeType: entity.mimeType,
|
2022-06-25 19:53:06 +02:00
|
|
|
duration: entity.duration ?? '0:00:00.00000',
|
2022-06-18 17:56:36 +02:00
|
|
|
exifInfo: entity.exifInfo ? mapExif(entity.exifInfo) : undefined,
|
|
|
|
|
smartInfo: entity.smartInfo ? mapSmartInfo(entity.smartInfo) : undefined,
|
|
|
|
|
};
|
|
|
|
|
}
|