because I got bored of customising my CV for every job
1import type { User as DomainUser } from "@cv/auth";
2import { JwtAuthGuard } from "@cv/auth";
3import { UseGuards } from "@nestjs/common";
4import { Args, Mutation, Resolver } from "@nestjs/graphql";
5import { CurrentUser } from "../current-user/current-user.decorator";
6import { CVParserService } from "./cv-parser.service";
7import {
8 DraftEducationType,
9 DraftJobExperienceType,
10 ParsedCVDataWithResolutionType,
11} from "./types/draft.types";
12
13@Resolver()
14export class CVParserResolver {
15 constructor(private readonly cvParserService: CVParserService) {}
16
17 /**
18 * Parse story text and resolve entities to existing database records
19 * Returns draft data with entity IDs where matches were found
20 */
21 @Mutation(() => ParsedCVDataWithResolutionType)
22 @UseGuards(JwtAuthGuard)
23 async parseStory(
24 @CurrentUser() user: DomainUser,
25 @Args("storyText") storyText: string,
26 ): Promise<ParsedCVDataWithResolutionType> {
27 const resolved = await this.cvParserService.parseStoryWithResolution(
28 user,
29 storyText,
30 );
31
32 return new ParsedCVDataWithResolutionType(
33 resolved.jobExperiences.map(DraftJobExperienceType.fromResolved),
34 resolved.education.map(DraftEducationType.fromResolved),
35 );
36 }
37}