refactor: migrate memory repository (#15532)
This commit is contained in:
@@ -2,8 +2,9 @@ import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Type } from 'class-transformer';
|
||||
import { IsEnum, IsInt, IsObject, IsPositive, ValidateNested } from 'class-validator';
|
||||
import { AssetResponseDto, mapAsset } from 'src/dtos/asset-response.dto';
|
||||
import { MemoryEntity } from 'src/entities/memory.entity';
|
||||
import { AssetEntity } from 'src/entities/asset.entity';
|
||||
import { MemoryType } from 'src/enum';
|
||||
import { MemoryItem } from 'src/types';
|
||||
import { ValidateBoolean, ValidateDate, ValidateUUID } from 'src/validation';
|
||||
|
||||
class MemoryBaseDto {
|
||||
@@ -69,18 +70,18 @@ export class MemoryResponseDto {
|
||||
assets!: AssetResponseDto[];
|
||||
}
|
||||
|
||||
export const mapMemory = (entity: MemoryEntity): MemoryResponseDto => {
|
||||
export const mapMemory = (entity: MemoryItem): MemoryResponseDto => {
|
||||
return {
|
||||
id: entity.id,
|
||||
createdAt: entity.createdAt,
|
||||
updatedAt: entity.updatedAt,
|
||||
deletedAt: entity.deletedAt,
|
||||
deletedAt: entity.deletedAt ?? undefined,
|
||||
memoryAt: entity.memoryAt,
|
||||
seenAt: entity.seenAt,
|
||||
seenAt: entity.seenAt ?? undefined,
|
||||
ownerId: entity.ownerId,
|
||||
type: entity.type,
|
||||
data: entity.data,
|
||||
type: entity.type as MemoryType,
|
||||
data: entity.data as unknown as MemoryData,
|
||||
isSaved: entity.isSaved,
|
||||
assets: entity.assets.map((asset) => mapAsset(asset)),
|
||||
assets: ('assets' in entity ? entity.assets : []).map((asset) => mapAsset(asset as AssetEntity)),
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user