Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | import { ApprovalStatus } from '@constants/enum/approvalStatus'; import { PlanetBuildDto } from '@contracts/dto/forms/planetBuildDto'; import { DtoAndImageMapperToNewPersistence, Mapper } from '@contracts/mapper'; import { makeArrayOrDefault } from '@helpers/arrayHelper'; import { anyObject } from '@helpers/typescriptHacks'; import { PlanetBuild } from '@services/external/database/xata'; import { XataArrayFile } from '@xata.io/client'; import { IPlanetBuildImages } from './planetBuildFileHandler'; export const planetBuildDtoWithImageToPersistence: DtoAndImageMapperToNewPersistence< PlanetBuildDto, IPlanetBuildImages, PlanetBuild > = (dto: PlanetBuildDto, images: IPlanetBuildImages) => { const persistence: Omit<PlanetBuild, 'id'> = { ...dto, mediaFiles: makeArrayOrDefault(images.mediaFiles) as Array<XataArrayFile>, mediaUrls: '', buildTechniquesUsed: makeArrayOrDefault(dto.buildTechniquesUsed) .filter((l) => l.length > 0) .join(','), approvalStatus: ApprovalStatus.pending, discordWebhookId: '', }; return persistence; }; export const planetBuildPersistenceToDto: Mapper<PlanetBuild, PlanetBuildDto> = ( persistence: PlanetBuild, ) => { const dto: PlanetBuildDto = { ...persistence, mediaUrls: persistence.mediaUrls.split(',').filter((l) => l.length > 0), mediaFiles: anyObject, buildTechniquesUsed: persistence.buildTechniquesUsed.split(',').filter((l) => l.length > 0), builders: [], }; return dto; }; |