import type { User as DomainUser } from "@cv/auth"; import { JwtAuthGuard } from "@cv/auth"; import { UseGuards } from "@nestjs/common"; import { Args, Mutation, Resolver } from "@nestjs/graphql"; import { CurrentUser } from "../current-user/current-user.decorator"; import { CVParserService } from "./cv-parser.service"; import { DraftEducationType, DraftJobExperienceType, ParsedCVDataWithResolutionType, } from "./types/draft.types"; @Resolver() export class CVParserResolver { constructor(private readonly cvParserService: CVParserService) {} /** * Parse story text and resolve entities to existing database records * Returns draft data with entity IDs where matches were found */ @Mutation(() => ParsedCVDataWithResolutionType) @UseGuards(JwtAuthGuard) async parseStory( @CurrentUser() user: DomainUser, @Args("storyText") storyText: string, ): Promise { const resolved = await this.cvParserService.parseStoryWithResolution( user, storyText, ); return new ParsedCVDataWithResolutionType( resolved.jobExperiences.map(DraftJobExperienceType.fromResolved), resolved.education.map(DraftEducationType.fromResolved), ); } }