2023-03-30 15:38:55 -04:00
|
|
|
import { AssetEntity, AssetType } from '@app/infra/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;
|
2023-04-11 05:23:39 -05:00
|
|
|
originalFileName!: string;
|
2022-07-08 21:26:50 -05:00
|
|
|
resizePath!: string | null;
|
2023-02-19 16:44:53 +00:00
|
|
|
fileCreatedAt!: string;
|
|
|
|
|
fileModifiedAt!: string;
|
2023-02-06 10:24:58 -06:00
|
|
|
updatedAt!: string;
|
2022-07-08 21:26:50 -05:00
|
|
|
isFavorite!: boolean;
|
2023-04-12 18:37:52 +03:00
|
|
|
isArchived!: boolean;
|
2022-07-08 21:26:50 -05:00
|
|
|
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;
|
2023-02-06 20:47:06 -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,
|
2023-02-19 16:44:53 +00:00
|
|
|
ownerId: entity.ownerId,
|
2022-06-18 17:56:36 +02:00
|
|
|
deviceId: entity.deviceId,
|
|
|
|
|
type: entity.type,
|
|
|
|
|
originalPath: entity.originalPath,
|
2023-04-11 05:23:39 -05:00
|
|
|
originalFileName: entity.originalFileName,
|
2022-06-18 17:56:36 +02:00
|
|
|
resizePath: entity.resizePath,
|
2023-02-19 16:44:53 +00:00
|
|
|
fileCreatedAt: entity.fileCreatedAt,
|
|
|
|
|
fileModifiedAt: entity.fileModifiedAt,
|
2023-02-06 10:24:58 -06:00
|
|
|
updatedAt: entity.updatedAt,
|
2022-06-18 17:56:36 +02:00
|
|
|
isFavorite: entity.isFavorite,
|
2023-04-12 18:37:52 +03:00
|
|
|
isArchived: entity.isArchived,
|
2022-06-18 17:56:36 +02:00
|
|
|
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,
|
2023-02-19 16:44:53 +00:00
|
|
|
ownerId: entity.ownerId,
|
2023-01-21 22:15:16 -06:00
|
|
|
deviceId: entity.deviceId,
|
|
|
|
|
type: entity.type,
|
|
|
|
|
originalPath: entity.originalPath,
|
2023-04-11 05:23:39 -05:00
|
|
|
originalFileName: entity.originalFileName,
|
2023-01-21 22:15:16 -06:00
|
|
|
resizePath: entity.resizePath,
|
2023-02-19 16:44:53 +00:00
|
|
|
fileCreatedAt: entity.fileCreatedAt,
|
|
|
|
|
fileModifiedAt: entity.fileModifiedAt,
|
2023-02-06 10:24:58 -06:00
|
|
|
updatedAt: entity.updatedAt,
|
2023-01-21 22:15:16 -06:00
|
|
|
isFavorite: entity.isFavorite,
|
2023-04-12 18:37:52 +03:00
|
|
|
isArchived: entity.isArchived,
|
2023-01-21 22:15:16 -06:00
|
|
|
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),
|
|
|
|
|
};
|
|
|
|
|
}
|