because I got bored of customising my CV for every job
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor(server): migrate education and job-experience to profile ownership

+131 -135
+1 -3
apps/server/src/modules/education/education.entity.ts
··· 1 - import { User } from "@cv/auth"; 2 1 import { BaseEntity } from "@cv/system"; 3 2 import type { Skill } from "@/modules/job-experience/skill/skill.entity"; 4 3 import { Institution } from "./institution.entity"; ··· 6 5 export class Education extends BaseEntity { 7 6 constructor( 8 7 id: string, 9 - public readonly userId: string, 10 - public readonly user: User | null, 8 + public readonly profileId: string, 11 9 public readonly institution: Institution, 12 10 public readonly degree: string, 13 11 public readonly fieldOfStudy: string | null,
+2 -9
apps/server/src/modules/education/education.mapper.ts
··· 1 - import { UserMapper } from "@cv/auth"; 2 1 import type { BaseMapper } from "@cv/system"; 3 2 import { Injectable } from "@nestjs/common"; 4 3 import type { Prisma } from "@prisma/client"; ··· 9 8 type PrismaEducation = Prisma.EducationGetPayload<{ 10 9 include: { 11 10 institution: true; 12 - user: { 13 - include: { 14 - credentials: true; 15 - }; 16 - }; 11 + profile: true; 17 12 skills: true; 18 13 }; 19 14 }>; ··· 22 17 export class EducationMapper implements BaseMapper<PrismaEducation, Education> { 23 18 constructor( 24 19 private readonly institutionMapper: InstitutionMapper, 25 - private readonly userMapper: UserMapper, 26 20 private readonly skillMapper: SkillMapper, 27 21 ) {} 28 22 ··· 47 41 48 42 return new Education( 49 43 prismaEducation.id, 50 - prismaEducation.userId, 51 - this.userMapper.toDomain(prismaEducation.user), 44 + prismaEducation.profileId, 52 45 institution, 53 46 prismaEducation.degree, 54 47 prismaEducation.fieldOfStudy,
+4 -3
apps/server/src/modules/education/education.module.ts
··· 1 - import { AuthorizationModule, UserModule } from "@cv/auth"; 1 + import { AuthorizationModule } from "@cv/auth"; 2 2 import { BaseModule, DatabaseModule } from "@cv/system"; 3 3 import { Module } from "@nestjs/common"; 4 4 import { AuthenticationModule } from "@/modules/authentication/authentication.module"; ··· 13 13 import { InstitutionMapper } from "./institution.mapper"; 14 14 import { InstitutionPolicy } from "./institution.policy"; 15 15 import { InstitutionService } from "./institution.service"; 16 + import { EducationOnboardingStep } from "./onboarding/education.step"; 16 17 17 18 @Module({ 18 19 imports: [ ··· 20 21 BaseModule, 21 22 AuthenticationModule, 22 23 AuthorizationModule, 23 - UserModule, 24 24 SkillModule, 25 25 ], 26 26 providers: [ ··· 34 34 InstitutionPolicy, 35 35 InstitutionResolver, 36 36 EducationUserFieldResolver, 37 + EducationOnboardingStep, 37 38 ], 38 - exports: [EducationService, EducationMapper], 39 + exports: [EducationService, EducationMapper, InstitutionService], 39 40 }) 40 41 export class EducationModule {}
+7 -2
apps/server/src/modules/education/education.policy.ts
··· 1 - import { Policy, UserOwnedResourcePolicy } from "@cv/auth"; 1 + import { Policy, ProfileOwnedResourcePolicy } from "@cv/auth"; 2 + import { PrismaService } from "@cv/system"; 2 3 import { Injectable } from "@nestjs/common"; 3 4 import { Education } from "./education.entity"; 4 5 5 6 @Injectable() 6 7 @Policy(Education) 7 - export class EducationPolicy extends UserOwnedResourcePolicy<Education> {} 8 + export class EducationPolicy extends ProfileOwnedResourcePolicy<Education> { 9 + constructor(prisma: PrismaService) { 10 + super(prisma); 11 + } 12 + }
+12 -28
apps/server/src/modules/education/education.service.ts
··· 10 10 export class EducationService { 11 11 private readonly educationInclude = { 12 12 institution: true, 13 - user: { 14 - include: { 15 - credentials: true, 16 - }, 17 - }, 13 + profile: true, 18 14 skills: true, 19 15 } satisfies Prisma.EducationInclude; 20 16 ··· 25 21 ) {} 26 22 27 23 async findMany( 28 - userId?: string, 24 + profileId?: string, 29 25 options: PaginationOptions = {}, 30 26 ): Promise<PaginationResult<Education>> { 31 - const where: Prisma.EducationWhereInput = userId ? { userId } : {}; 27 + const where: Prisma.EducationWhereInput = profileId ? { profileId } : {}; 32 28 const queryOptions = this.paginationService.buildQueryOptions( 33 29 where, 34 30 { startDate: "desc" }, ··· 40 36 ...queryOptions, 41 37 include: this.educationInclude, 42 38 }), 43 - this.count(userId), 39 + this.count(profileId), 44 40 ]); 45 41 46 42 const domainEducations = this.educationMapper.mapToDomain(items); ··· 51 47 ); 52 48 } 53 49 54 - async findManyForUser( 55 - userId: string, 50 + async findManyForProfile( 51 + profileId: string, 56 52 options: PaginationOptions = {}, 57 53 ): Promise<PaginationResult<Education>> { 58 - return this.findMany(userId, options); 54 + return this.findMany(profileId, options); 59 55 } 60 56 61 57 async findById(id: string): Promise<Education | null> { ··· 66 62 return this.educationMapper.toDomain(education); 67 63 } 68 64 69 - async count(userId?: string): Promise<number> { 70 - const where: Prisma.EducationWhereInput = userId ? { userId } : {}; 65 + async count(profileId?: string): Promise<number> { 66 + const where: Prisma.EducationWhereInput = profileId ? { profileId } : {}; 71 67 return this.prisma.education.count({ 72 68 where, 73 69 }); 74 70 } 75 71 76 72 async create( 77 - userId: string, 73 + profileId: string, 78 74 data: { 79 75 institutionId: string; 80 76 degree: string; ··· 86 82 }, 87 83 ): Promise<Education> { 88 84 const createData: Prisma.EducationCreateInput = { 89 - user: { connect: { id: userId } }, 85 + profile: { connect: { id: profileId } }, 90 86 institution: { connect: { id: data.institutionId } }, 91 87 degree: data.degree, 92 88 fieldOfStudy: data.fieldOfStudy ?? null, ··· 119 115 120 116 async update( 121 117 id: string, 122 - userId: string, 123 118 data: { 124 119 institutionId?: string; 125 120 degree?: string; ··· 130 125 skillIds?: string[]; 131 126 }, 132 127 ): Promise<Education> { 133 - const education = await this.findById(id); 134 - if (!education || education.userId !== userId) { 135 - throw new Error("Education not found or does not belong to user"); 136 - } 137 - 138 128 const updateData: Prisma.EducationUpdateInput = {}; 139 129 140 130 if (data.institutionId !== undefined) { ··· 172 162 return domainEducation; 173 163 } 174 164 175 - async delete(id: string, userId: string): Promise<void> { 176 - // Verify the education belongs to the user 177 - const education = await this.findById(id); 178 - if (!education || education.userId !== userId) { 179 - throw new Error("Education not found or does not belong to user"); 180 - } 181 - 165 + async delete(id: string): Promise<void> { 182 166 await this.prisma.education.delete({ 183 167 where: { id }, 184 168 });
+13 -13
apps/server/src/modules/education/graphql/education.resolver.ts
··· 26 26 @Mutation(() => Education) 27 27 async createEducation( 28 28 @CurrentUser() user: DomainUser, 29 + @Args("profileId") profileId: string, 29 30 @Args("institutionId") institutionId: string, 30 31 @Args("degree") degree: string, 31 32 @Args("startDate") startDate: Date, ··· 36 37 skillIds?: string[], 37 38 ): Promise<Education> { 38 39 await this.authorizationService.canCreate(user, EducationEntity, { 39 - userId: user.id, 40 + profileId, 40 41 }); 41 42 42 43 await this.institutionService.findByIdOrFail(institutionId); 43 44 44 - const education = await this.educationService.create(user.id, { 45 + const education = await this.educationService.create(profileId, { 45 46 institutionId, 46 47 degree, 47 48 fieldOfStudy: fieldOfStudy ?? null, ··· 66 67 @Args("skillIds", { type: () => [String], nullable: true }) 67 68 skillIds?: string[], 68 69 ): Promise<Education> { 69 - const existingEducation = 70 - await this.educationService.findByIdOrFail(id); 70 + const existingEducation = await this.educationService.findByIdOrFail(id); 71 71 await this.authorizationService.canUpdate( 72 72 user, 73 73 existingEducation, ··· 83 83 ); 84 84 } 85 85 86 - const education = await this.educationService.update(id, user.id, { 87 - institutionId, 88 - degree, 89 - fieldOfStudy, 90 - startDate, 91 - endDate, 92 - description, 93 - skillIds, 86 + const education = await this.educationService.update(id, { 87 + ...(institutionId !== undefined && { institutionId }), 88 + ...(degree !== undefined && { degree }), 89 + ...(fieldOfStudy !== undefined && { fieldOfStudy }), 90 + ...(startDate !== undefined && { startDate }), 91 + ...(endDate !== undefined && { endDate }), 92 + ...(description !== undefined && { description }), 93 + ...(skillIds !== undefined && { skillIds }), 94 94 }); 95 95 96 96 return Education.fromDomain(education); ··· 103 103 ): Promise<boolean> { 104 104 const education = await this.educationService.findByIdOrFail(id); 105 105 await this.authorizationService.canDelete(user, education, EducationEntity); 106 - await this.educationService.delete(id, user.id); 106 + await this.educationService.delete(id); 107 107 return true; 108 108 } 109 109 }
+4 -4
apps/server/src/modules/education/graphql/education.type.ts
··· 11 11 id: string; 12 12 13 13 @Field(() => String) 14 - userId: string; 14 + profileId: string; 15 15 16 16 @Field(() => Institution) 17 17 institution: Institution; ··· 42 42 43 43 constructor(data: { 44 44 id: string; 45 - userId: string; 45 + profileId: string; 46 46 institution: Institution; 47 47 degree: string; 48 48 fieldOfStudy: string | null; ··· 54 54 updatedAt: Date; 55 55 }) { 56 56 this.id = data.id; 57 - this.userId = data.userId; 57 + this.profileId = data.profileId; 58 58 this.institution = data.institution; 59 59 this.degree = data.degree; 60 60 this.fieldOfStudy = data.fieldOfStudy; ··· 69 69 static fromDomain(education: EducationEntity): Education { 70 70 return new Education({ 71 71 id: education.id, 72 - userId: education.userId, 72 + profileId: education.profileId, 73 73 institution: Institution.fromDomain(education.institution), 74 74 degree: education.degree, 75 75 fieldOfStudy: education.fieldOfStudy,
+16 -3
apps/server/src/modules/education/graphql/user-field.resolver.ts
··· 1 1 import { JwtAuthGuard, VerifiedScopeGuard } from "@cv/auth"; 2 - import { PaginationArgs, PaginationService } from "@cv/system"; 2 + import { PaginationArgs, PaginationService, PrismaService } from "@cv/system"; 3 3 import { UseGuards } from "@nestjs/common"; 4 4 import { Args, Parent, ResolveField, Resolver } from "@nestjs/graphql"; 5 5 import { User } from "@/modules/user/user.type"; ··· 12 12 constructor( 13 13 private readonly educationService: EducationService, 14 14 private readonly paginationService: PaginationService, 15 + private readonly prisma: PrismaService, 15 16 ) {} 16 17 17 18 @ResolveField(() => EducationConnection, { nullable: true }) ··· 19 20 @Parent() user: User, 20 21 @Args() args: PaginationArgs = {}, 21 22 ): Promise<EducationConnection> { 23 + const profile = await this.prisma.profile.findFirst({ 24 + where: { userId: user.id }, 25 + select: { id: true }, 26 + }); 27 + 28 + if (!profile) { 29 + const options = this.paginationService.parsePaginationArgs(args); 30 + return EducationConnection.fromPaginationResult( 31 + this.paginationService.buildPaginationResult([], 0, options), 32 + ); 33 + } 34 + 22 35 const options = this.paginationService.parsePaginationArgs(args); 23 - const result = await this.educationService.findManyForUser( 24 - user.id, 36 + const result = await this.educationService.findManyForProfile( 37 + profile.id, 25 38 options, 26 39 ); 27 40 return EducationConnection.fromPaginationResult(result);
+3 -2
apps/server/src/modules/job-experience/employment/employment.module.ts
··· 1 - import { AuthorizationModule, UserModule } from "@cv/auth"; 1 + import { AuthorizationModule } from "@cv/auth"; 2 2 import { BaseModule, DatabaseModule } from "@cv/system"; 3 3 import { Module } from "@nestjs/common"; 4 4 import { AuthenticationModule } from "@/modules/authentication/authentication.module"; ··· 8 8 import { SkillModule } from "@/modules/job-experience/skill/skill.module"; 9 9 import { EmploymentResolver } from "./graphql/employment.resolver"; 10 10 import { UserFieldResolver } from "./graphql/user-field.resolver"; 11 + import { CareerHistoryOnboardingStep } from "./onboarding/career-history.step"; 11 12 import { UserJobExperienceMapper } from "./user-job-experience.mapper"; 12 13 import { UserJobExperiencePolicy } from "./user-job-experience.policy"; 13 14 import { UserJobExperienceService } from "./user-job-experience.service"; ··· 18 19 BaseModule, 19 20 AuthenticationModule, 20 21 AuthorizationModule, 21 - UserModule, 22 22 CompanyModule, 23 23 RoleModule, 24 24 LevelModule, ··· 30 30 UserFieldResolver, 31 31 UserJobExperienceMapper, 32 32 UserJobExperiencePolicy, 33 + CareerHistoryOnboardingStep, 33 34 ], 34 35 exports: [UserJobExperienceService, UserJobExperienceMapper], 35 36 })
+3 -2
apps/server/src/modules/job-experience/employment/graphql/employment.resolver.ts
··· 34 34 @Mutation(() => UserJobExperience) 35 35 async createJobExperience( 36 36 @CurrentUser() user: DomainUser, 37 + @Args("profileId") profileId: string, 37 38 @Args("companyId") companyId: string, 38 39 @Args("roleId") roleId: string, 39 40 @Args("levelId") levelId: string, ··· 44 45 skillIds?: string[], 45 46 ): Promise<UserJobExperience> { 46 47 await this.authorizationService.canCreate(user, UserJobExperienceEntity, { 47 - userId: user.id, 48 + profileId, 48 49 }); 49 50 50 51 const company = await this.companyService.findByIdOrFail(companyId); ··· 57 58 : undefined; 58 59 59 60 const createData: CreateUserJobExperienceDto = { 60 - user, 61 + profileId, 61 62 company, 62 63 role, 63 64 level,
+16 -3
apps/server/src/modules/job-experience/employment/graphql/user-field.resolver.ts
··· 1 1 import { JwtAuthGuard, VerifiedScopeGuard } from "@cv/auth"; 2 - import { PaginationArgs, PaginationService } from "@cv/system"; 2 + import { PaginationArgs, PaginationService, PrismaService } from "@cv/system"; 3 3 import { UseGuards } from "@nestjs/common"; 4 4 import { Args, Parent, ResolveField, Resolver } from "@nestjs/graphql"; 5 5 import { UserJobExperienceService } from "@/modules/job-experience/employment/user-job-experience.service"; ··· 12 12 constructor( 13 13 private readonly userJobExperienceService: UserJobExperienceService, 14 14 private readonly paginationService: PaginationService, 15 + private readonly prisma: PrismaService, 15 16 ) {} 16 17 17 18 @ResolveField(() => UserJobExperienceConnection, { nullable: true }) ··· 19 20 @Parent() user: User, 20 21 @Args() args: PaginationArgs = {}, 21 22 ): Promise<UserJobExperienceConnection> { 23 + const profile = await this.prisma.profile.findFirst({ 24 + where: { userId: user.id }, 25 + select: { id: true }, 26 + }); 27 + 28 + if (!profile) { 29 + const options = this.paginationService.parsePaginationArgs(args); 30 + return UserJobExperienceConnection.fromPaginationResult( 31 + this.paginationService.buildPaginationResult([], 0, options), 32 + ); 33 + } 34 + 22 35 const options = this.paginationService.parsePaginationArgs(args); 23 - const result = await this.userJobExperienceService.findManyForUser( 24 - user.id, 36 + const result = await this.userJobExperienceService.findManyForProfile( 37 + profile.id, 25 38 options, 26 39 ); 27 40 return UserJobExperienceConnection.fromPaginationResult(result);
+6
apps/server/src/modules/job-experience/employment/graphql/user-job-experience.type.ts
··· 13 13 @Field(() => ID) 14 14 id: string; 15 15 16 + @Field() 17 + profileId: string; 18 + 16 19 @Field(() => Company) 17 20 company: Company; 18 21 ··· 42 45 43 46 constructor( 44 47 id: string, 48 + profileId: string, 45 49 company: Company, 46 50 role: Role, 47 51 level: Level, ··· 53 57 description?: string, 54 58 ) { 55 59 this.id = id; 60 + this.profileId = profileId; 56 61 this.company = company; 57 62 this.role = role; 58 63 this.level = level; ··· 73 78 ): UserJobExperience { 74 79 return new UserJobExperience( 75 80 domainExperience.id, 81 + domainExperience.profileId, 76 82 Company.fromDomain(domainExperience.company), 77 83 Role.fromDomain(domainExperience.role), 78 84 Level.fromDomain(domainExperience.level),
+1 -1
apps/server/src/modules/job-experience/employment/user-job-experience.dto.ts
··· 4 4 import type { Skill } from "@/modules/job-experience/skill/skill.entity"; 5 5 6 6 export interface CreateUserJobExperienceDto { 7 - user: { id: string }; // Only need user ID for the relation 7 + profileId: string; 8 8 company: Company; 9 9 role: Role; 10 10 level: Level;
+3 -9
apps/server/src/modules/job-experience/employment/user-job-experience.entity.ts
··· 1 - import type { User } from "@cv/auth"; 2 1 import { BaseEntity } from "@cv/system"; 3 2 import type { Company } from "@/modules/job-experience/company/company.entity"; 4 3 import type { Level } from "@/modules/job-experience/level/level.entity"; ··· 6 5 import type { Skill } from "@/modules/job-experience/skill/skill.entity"; 7 6 8 7 export class UserJobExperience extends BaseEntity { 9 - userId: string; 8 + profileId: string; 10 9 startDate: Date; 11 10 endDate?: Date; 12 11 description?: string; ··· 16 15 role: Role; 17 16 level: Level; 18 17 skills?: Skill[]; 19 - user?: User; 20 18 21 19 constructor( 22 20 id: string, 23 - userId: string, 21 + profileId: string, 24 22 startDate: Date, 25 23 createdAt: Date, 26 24 updatedAt: Date, ··· 30 28 endDate?: Date, 31 29 description?: string, 32 30 skills?: Skill[], 33 - user?: User, 34 31 ) { 35 32 super(id, createdAt, updatedAt); 36 - this.userId = userId; 33 + this.profileId = profileId; 37 34 this.startDate = startDate; 38 35 this.company = company; 39 36 this.role = role; ··· 46 43 } 47 44 if (skills !== undefined) { 48 45 this.skills = skills; 49 - } 50 - if (user !== undefined) { 51 - this.user = user; 52 46 } 53 47 } 54 48 }
+3 -24
apps/server/src/modules/job-experience/employment/user-job-experience.mapper.ts
··· 1 - import { UserMapper } from "@cv/auth"; 2 1 import type { BaseMapper } from "@cv/system"; 3 2 import { Injectable } from "@nestjs/common"; 4 3 import type { 5 4 Company as PrismaCompany, 6 5 Level as PrismaLevel, 6 + Profile as PrismaProfile, 7 7 Role as PrismaRole, 8 8 Skill as PrismaSkill, 9 - User as PrismaUser, 10 9 UserJobExperience as PrismaUserJobExperience, 11 10 } from "@prisma/client"; 12 11 import { CompanyMapper } from "@/modules/job-experience/company/company.mapper"; ··· 23 22 role: PrismaRole; 24 23 level: PrismaLevel; 25 24 skills?: PrismaSkill[]; 26 - user?: 27 - | (PrismaUser & { 28 - credentials: { 29 - id: string; 30 - userId: string; 31 - email: string; 32 - password: string; 33 - emailVerifiedAt: Date | null; 34 - emailVerificationToken: string | null; 35 - emailVerificationTokenExpiresAt: Date | null; 36 - passwordResetToken: string | null; 37 - passwordResetTokenExpiresAt: Date | null; 38 - createdAt: Date; 39 - updatedAt: Date; 40 - } | null; 41 - }) 42 - | null; 25 + profile?: PrismaProfile | null; 43 26 }; 44 27 45 28 /** ··· 54 37 private roleMapper: RoleMapper, 55 38 private levelMapper: LevelMapper, 56 39 private skillMapper: SkillMapper, 57 - private userMapper: UserMapper, 58 40 ) {} 59 41 /** 60 42 * Maps a Prisma UserJobExperience entity to a domain UserJobExperience entity ··· 76 58 77 59 return new UserJobExperience( 78 60 prismaExperience.id, 79 - prismaExperience.userId, 61 + prismaExperience.profileId, 80 62 prismaExperience.startDate, 81 63 prismaExperience.createdAt, 82 64 prismaExperience.updatedAt, ··· 87 69 prismaExperience.description ?? undefined, 88 70 prismaExperience.skills 89 71 ? this.skillMapper.mapToDomain(prismaExperience.skills) 90 - : undefined, 91 - prismaExperience.user 92 - ? this.userMapper.toDomain(prismaExperience.user) 93 72 : undefined, 94 73 ); 95 74 }
+7 -2
apps/server/src/modules/job-experience/employment/user-job-experience.policy.ts
··· 1 - import { Policy, UserOwnedResourcePolicy } from "@cv/auth"; 1 + import { Policy, ProfileOwnedResourcePolicy } from "@cv/auth"; 2 + import { PrismaService } from "@cv/system"; 2 3 import { Injectable } from "@nestjs/common"; 3 4 import { UserJobExperience } from "./user-job-experience.entity"; 4 5 5 6 @Injectable() 6 7 @Policy(UserJobExperience) 7 - export class UserJobExperiencePolicy extends UserOwnedResourcePolicy<UserJobExperience> {} 8 + export class UserJobExperiencePolicy extends ProfileOwnedResourcePolicy<UserJobExperience> { 9 + constructor(prisma: PrismaService) { 10 + super(prisma); 11 + } 12 + }
+30 -27
apps/server/src/modules/job-experience/employment/user-job-experience.service.ts
··· 10 10 import { UserJobExperience } from "./user-job-experience.entity"; 11 11 import { UserJobExperienceMapper } from "./user-job-experience.mapper"; 12 12 13 - // Proper types for Prisma operations 14 13 type PrismaUserJobExperienceCreateData = { 15 - userId: string; 16 - companyId: string; 17 - roleId: string; 18 - levelId: string; 14 + profile: { connect: { id: string } }; 15 + company: { connect: { id: string } }; 16 + role: { connect: { id: string } }; 17 + level: { connect: { id: string } }; 19 18 startDate: Date; 20 19 endDate?: Date; 21 20 description?: string; ··· 25 24 }; 26 25 27 26 type PrismaUserJobExperienceUpdateData = { 28 - companyId?: string; 29 - roleId?: string; 30 - levelId?: string; 27 + company?: { connect: { id: string } }; 28 + role?: { connect: { id: string } }; 29 + level?: { connect: { id: string } }; 31 30 startDate?: Date; 32 31 endDate?: Date; 33 32 description?: string; ··· 39 38 @Injectable() 40 39 export class UserJobExperienceService { 41 40 private readonly userJobExperienceInclude = { 42 - user: { 43 - include: { 44 - credentials: true, 45 - }, 46 - }, 41 + profile: true, 47 42 company: true, 48 43 role: true, 49 44 level: true, ··· 60 55 createUserJobExperienceDto: CreateUserJobExperienceDto, 61 56 ): Promise<UserJobExperience> { 62 57 const createData: PrismaUserJobExperienceCreateData = { 63 - userId: createUserJobExperienceDto.user.id, 64 - companyId: createUserJobExperienceDto.company.id, 65 - roleId: createUserJobExperienceDto.role.id, 66 - levelId: createUserJobExperienceDto.level.id, 58 + profile: { connect: { id: createUserJobExperienceDto.profileId } }, 59 + company: { connect: { id: createUserJobExperienceDto.company.id } }, 60 + role: { connect: { id: createUserJobExperienceDto.role.id } }, 61 + level: { connect: { id: createUserJobExperienceDto.level.id } }, 67 62 startDate: createUserJobExperienceDto.startDate, 68 63 }; 69 64 ··· 89 84 } 90 85 91 86 async findMany( 92 - userId?: string, 87 + profileId?: string, 93 88 options: PaginationOptions = {}, 94 89 ): Promise<PaginationResult<UserJobExperience>> { 95 - const where: Prisma.UserJobExperienceWhereInput = userId ? { userId } : {}; 90 + const where: Prisma.UserJobExperienceWhereInput = profileId 91 + ? { profileId } 92 + : {}; 96 93 const queryOptions = this.paginationService.buildQueryOptions( 97 94 where, 98 95 { startDate: "desc" }, ··· 115 112 ); 116 113 } 117 114 118 - async findForUser(user: { id: string }): Promise<UserJobExperience[]> { 119 - const result = await this.findMany(user.id); 115 + async findForProfile(profileId: string): Promise<UserJobExperience[]> { 116 + const result = await this.findMany(profileId); 120 117 return result.edges.map((edge) => edge.node); 121 118 } 122 119 123 - async findManyForUser( 124 - userId: string, 120 + async findManyForProfile( 121 + profileId: string, 125 122 options: PaginationOptions = {}, 126 123 ): Promise<PaginationResult<UserJobExperience>> { 127 - return this.findMany(userId, options); 124 + return this.findMany(profileId, options); 128 125 } 129 126 130 127 async findById(id: string): Promise<UserJobExperience | null> { ··· 147 144 const updateData: PrismaUserJobExperienceUpdateData = {}; 148 145 149 146 if (updateUserJobExperienceDto.company !== undefined) { 150 - updateData.companyId = updateUserJobExperienceDto.company.id; 147 + updateData.company = { 148 + connect: { id: updateUserJobExperienceDto.company.id }, 149 + }; 151 150 } 152 151 if (updateUserJobExperienceDto.role !== undefined) { 153 - updateData.roleId = updateUserJobExperienceDto.role.id; 152 + updateData.role = { 153 + connect: { id: updateUserJobExperienceDto.role.id }, 154 + }; 154 155 } 155 156 if (updateUserJobExperienceDto.level !== undefined) { 156 - updateData.levelId = updateUserJobExperienceDto.level.id; 157 + updateData.level = { 158 + connect: { id: updateUserJobExperienceDto.level.id }, 159 + }; 157 160 } 158 161 if (updateUserJobExperienceDto.startDate !== undefined) { 159 162 updateData.startDate = updateUserJobExperienceDto.startDate;