2023-01-25 11:35:28 -05:00
|
|
|
import { AssetEntity, AssetType } from '@app/infra/db/entities';
|
2022-07-13 07:23:48 -05:00
|
|
|
import { ApiProperty } from '@nestjs/swagger';
|
2023-01-25 11:35:28 -05:00
|
|
|
import { mapTag, TagResponseDto } from '../../tag';
|
2022-06-18 17:56:36 +02:00
|
|
|
import { ExifResponseDto, mapExif } from './exif-response.dto';
|
|
|
|
|
import { SmartInfoResponseDto, mapSmartInfo } from './smart-info-response.dto';
|
|
|
|
|
|
2022-07-08 21:26:50 -05:00
|
|
|
export class AssetResponseDto {
|
|
|
|
|
id!: string;
|
|
|
|
|
deviceAssetId!: string;
|
|
|
|
|
ownerId!: string;
|
|
|
|
|
deviceId!: string;
|
2022-07-13 07:23:48 -05:00
|
|
|
|
|
|
|
|
@ApiProperty({ enumName: 'AssetTypeEnum', enum: AssetType })
|
2022-07-08 21:26:50 -05:00
|
|
|
type!: AssetType;
|
|
|
|
|
originalPath!: string;
|
|
|
|
|
resizePath!: string | null;
|
|
|
|
|
createdAt!: string;
|
|
|
|
|
modifiedAt!: string;
|
|
|
|
|
isFavorite!: boolean;
|
|
|
|
|
mimeType!: string | null;
|
|
|
|
|
duration!: string;
|
|
|
|
|
webpPath!: string | null;
|
2022-11-26 17:16:02 +01:00
|
|
|
encodedVideoPath?: string | null;
|
2022-06-18 17:56:36 +02:00
|
|
|
exifInfo?: ExifResponseDto;
|
|
|
|
|
smartInfo?: SmartInfoResponseDto;
|
2022-11-26 17:16:02 +01:00
|
|
|
livePhotoVideoId?: string | null;
|
2022-12-05 11:56:44 -06:00
|
|
|
tags!: TagResponseDto[];
|
2022-06-18 17:56:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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-07-08 21:26:50 -05:00
|
|
|
webpPath: entity.webpPath,
|
|
|
|
|
encodedVideoPath: entity.encodedVideoPath,
|
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,
|
2022-11-18 23:12:54 -06:00
|
|
|
livePhotoVideoId: entity.livePhotoVideoId,
|
2022-12-05 11:56:44 -06:00
|
|
|
tags: entity.tags?.map(mapTag),
|
2022-06-18 17:56:36 +02:00
|
|
|
};
|
|
|
|
|
}
|
2023-01-21 22:15:16 -06:00
|
|
|
|
|
|
|
|
export function mapAssetWithoutExif(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,
|
|
|
|
|
webpPath: entity.webpPath,
|
|
|
|
|
encodedVideoPath: entity.encodedVideoPath,
|
|
|
|
|
duration: entity.duration ?? '0:00:00.00000',
|
|
|
|
|
exifInfo: undefined,
|
|
|
|
|
smartInfo: entity.smartInfo ? mapSmartInfo(entity.smartInfo) : undefined,
|
|
|
|
|
livePhotoVideoId: entity.livePhotoVideoId,
|
|
|
|
|
tags: entity.tags?.map(mapTag),
|
|
|
|
|
};
|
|
|
|
|
}
|