because I got bored of customising my CV for every job
1import type {
2 CV as PrismaCV,
3 CVTemplate as PrismaCVTemplate,
4} from "@prisma/client";
5import { cvTemplateMapper } from "./cv-template.mapper";
6import { CV } from "./graphql/cv.type";
7
8export type PrismaCVWithTemplate = PrismaCV & {
9 template: PrismaCVTemplate;
10};
11
12export const cvMapper = {
13 toDomain: (cv: PrismaCVWithTemplate): CV => {
14 return new CV(
15 cv.id,
16 cv.userId,
17 cv.title,
18 cv.createdAt,
19 cv.updatedAt,
20 cvTemplateMapper.toDomain(cv.template),
21 cv.introduction ?? null,
22 );
23 },
24
25 mapToDomain: (cvs: PrismaCVWithTemplate[]): CV[] => {
26 return cvs.map((cv) => cvMapper.toDomain(cv));
27 },
28};