fix(career): preserve source ids and absent metadata
This commit is contained in:
@@ -34,6 +34,7 @@ export type StructuredCvContact = {
|
||||
};
|
||||
|
||||
export type StructuredCvJob = {
|
||||
id?: string;
|
||||
title?: string;
|
||||
company?: string;
|
||||
location?: string;
|
||||
@@ -45,6 +46,7 @@ export type StructuredCvJob = {
|
||||
};
|
||||
|
||||
export type StructuredCvEducation = {
|
||||
id?: string;
|
||||
qualification?: string;
|
||||
qualificationLevel?: string;
|
||||
institution?: string;
|
||||
@@ -55,6 +57,7 @@ export type StructuredCvEducation = {
|
||||
};
|
||||
|
||||
export type StructuredCvCertification = {
|
||||
id?: string;
|
||||
name?: string;
|
||||
issuer?: string;
|
||||
location?: string;
|
||||
@@ -63,6 +66,7 @@ export type StructuredCvCertification = {
|
||||
};
|
||||
|
||||
export type StructuredCvProject = {
|
||||
id?: string;
|
||||
name?: string;
|
||||
role?: string;
|
||||
location?: string;
|
||||
@@ -211,15 +215,15 @@ export function normalizeStructuredCv(value: unknown): StructuredCvProfile {
|
||||
const normalized: StructuredCvProfile = {
|
||||
version: normalizeString(source.version) ?? "1",
|
||||
metadata: {
|
||||
profileVersion: Number.isFinite(Number(source.metadata?.profileVersion)) ? Number(source.metadata.profileVersion) : undefined,
|
||||
appliedExtractionRunId: Number.isFinite(Number(source.metadata?.appliedExtractionRunId)) ? Number(source.metadata.appliedExtractionRunId) : undefined,
|
||||
profileVersion: source.metadata?.profileVersion != null && Number.isFinite(Number(source.metadata.profileVersion)) ? Number(source.metadata.profileVersion) : undefined,
|
||||
appliedExtractionRunId: source.metadata?.appliedExtractionRunId != null && Number.isFinite(Number(source.metadata.appliedExtractionRunId)) ? Number(source.metadata.appliedExtractionRunId) : undefined,
|
||||
updatedAtUtc: normalizeString(source.metadata?.updatedAtUtc),
|
||||
fields: source.metadata?.fields && typeof source.metadata.fields === "object"
|
||||
? Object.fromEntries(Object.entries(source.metadata.fields as Record<string, any>).map(([key, value]) => [key, {
|
||||
confidence: Number.isFinite(Number(value?.confidence)) ? Number(value.confidence) : undefined,
|
||||
confidence: value?.confidence != null && Number.isFinite(Number(value.confidence)) ? Number(value.confidence) : undefined,
|
||||
method: normalizeString(value?.method),
|
||||
sourceSnippet: normalizeString(value?.sourceSnippet),
|
||||
sourcePage: Number.isFinite(Number(value?.sourcePage)) ? Number(value.sourcePage) : undefined,
|
||||
sourcePage: value?.sourcePage != null && Number.isFinite(Number(value.sourcePage)) ? Number(value.sourcePage) : undefined,
|
||||
sourceBlockId: normalizeString(value?.sourceBlockId),
|
||||
reviewState: normalizeString(value?.reviewState),
|
||||
lastUpdatedAtUtc: normalizeString(value?.lastUpdatedAtUtc),
|
||||
@@ -240,6 +244,7 @@ export function normalizeStructuredCv(value: unknown): StructuredCvProfile {
|
||||
summary: normalizeList(source.summary),
|
||||
jobs: Array.isArray(source.jobs)
|
||||
? source.jobs.map((job: any) => ({
|
||||
id: typeof job?.id === "string" ? job.id : undefined,
|
||||
title: normalizeString(job?.title),
|
||||
company: normalizeString(job?.company),
|
||||
location: normalizeString(job?.location),
|
||||
@@ -252,6 +257,7 @@ export function normalizeStructuredCv(value: unknown): StructuredCvProfile {
|
||||
: [],
|
||||
education: Array.isArray(source.education)
|
||||
? source.education.map((education: any) => ({
|
||||
id: typeof education?.id === "string" ? education.id : undefined,
|
||||
qualification: normalizeString(education?.qualification),
|
||||
qualificationLevel: normalizeString(education?.qualificationLevel),
|
||||
institution: normalizeString(education?.institution),
|
||||
@@ -263,6 +269,7 @@ export function normalizeStructuredCv(value: unknown): StructuredCvProfile {
|
||||
: [],
|
||||
certifications: Array.isArray(source.certifications)
|
||||
? source.certifications.map((certification: any) => ({
|
||||
id: typeof certification?.id === "string" ? certification.id : undefined,
|
||||
name: normalizeString(certification?.name),
|
||||
issuer: normalizeString(certification?.issuer),
|
||||
location: normalizeString(certification?.location),
|
||||
@@ -272,6 +279,7 @@ export function normalizeStructuredCv(value: unknown): StructuredCvProfile {
|
||||
: [],
|
||||
projects: Array.isArray(source.projects)
|
||||
? source.projects.map((project: any) => ({
|
||||
id: typeof project?.id === "string" ? project.id : undefined,
|
||||
name: normalizeString(project?.name),
|
||||
role: normalizeString(project?.role),
|
||||
location: normalizeString(project?.location),
|
||||
|
||||
Reference in New Issue
Block a user