mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-07-25 01:15:26 +10:00
62f8270b3e
commit b2b0470a1d9267d042ec0ac66523c6635bf5b199
Author: Amruth Pillai <im.amruth@gmail.com>
Date: Tue May 19 13:13:38 2026 +0200
chore: update .gitignore to include .vite-hooks and modify pnpm-lock.yaml for dependencies
commit d28fadb5cd8706c874e616102878b4a394ec84c1
Author: Amruth Pillai <im.amruth@gmail.com>
Date: Tue May 19 13:08:04 2026 +0200
fix: remove timestamp conflict guard
commit c6998d9dbab19d09d3c8054feef1d2e4117555eb
Author: Amruth Pillai <im.amruth@gmail.com>
Date: Tue May 19 12:11:51 2026 +0200
chore(release): v5.1.5
commit f33d168711804880e1f12e88d24290aae16cc258
Author: Amruth Pillai <im.amruth@gmail.com>
Date: Tue May 19 11:58:35 2026 +0200
revert: compose.yml
commit d961e6535811a10c335525fb33a08d03e737278d
Author: Amruth Pillai <im.amruth@gmail.com>
Date: Tue May 19 11:58:08 2026 +0200
refactor(agent): replace 'revert' terminology with 'restore' for clarity, resolves #3086
commit 17f351171be218e33f01c469d95e4164d4c8dc57
Author: Amruth Pillai <im.amruth@gmail.com>
Date: Tue May 19 11:10:41 2026 +0200
refactor(pdf): simplify sidebar section filtering and update summary feature logic
commit d55179b9d76879e3204de185e8b53fadd0a107ed
Author: Amruth Pillai <im.amruth@gmail.com>
Date: Tue May 19 09:53:37 2026 +0200
chore: update pnpm-lock.yaml and turbo.json
commit 7cade6980e1a04352536bd44ef773f338c4ef599
Author: Amruth Pillai <im.amruth@gmail.com>
Date: Tue May 19 09:38:30 2026 +0200
fix(polyfill): add tested polyfill for Map Upsert methods
commit 26d175bb9c53d93225d1e907678445252c13d660
Merge: 1cf33dc6c 5b1297fa2
Author: Amruth Pillai <im.amruth@gmail.com>
Date: Tue May 19 09:23:29 2026 +0200
Merge remote-tracking branch 'origin/main' into feat/explore-hono-orpc-migration
# Conflicts:
# packages/api/src/services/agent-url.ts
# packages/runtime-externals/package.json
commit 1cf33dc6c9d81735730ad656e16dab6501c6d6a1
Author: Amruth Pillai <im.amruth@gmail.com>
Date: Tue May 19 09:22:12 2026 +0200
chore: preserve branch changes before main sync
commit b380a4b00fdbcdd81ff4f8ef72b330fd027ccda5
Author: Amruth Pillai <im.amruth@gmail.com>
Date: Mon May 18 07:50:28 2026 +0200
chore: lot of fixes for monorepo migration
commit 8fcf0ec64e1c29572ebaff494338368bfcf75760
Author: Amruth Pillai <im.amruth@gmail.com>
Date: Fri May 15 13:57:17 2026 +0200
chore: update knip version and refine web app routing with new SEO endpoints
commit 234e68086ff15610a93877354c98e2c020364533
Author: Amruth Pillai <im.amruth@gmail.com>
Date: Fri May 15 12:10:06 2026 +0200
refactor(auth): update OAuth routes to include API prefix and remove unused schema endpoint
commit 91c84b9a8496b0ce21d71cae9f8b2a027638c9ac
Author: Amruth Pillai <im.amruth@gmail.com>
Date: Fri May 15 11:54:29 2026 +0200
chore: update dependencies and enhance PWA metadata in web app
commit 150117d4a5a9dd6cd92c64891aad8cae90f6a7af
Author: Amruth Pillai <im.amruth@gmail.com>
Date: Fri May 15 11:12:35 2026 +0200
docs: revise manifest-only pwa testing scope
commit 6b939a55661aec9dd8122b184e4b60a5c7325fb5
Author: Amruth Pillai <im.amruth@gmail.com>
Date: Fri May 15 11:11:33 2026 +0200
docs: add manifest-only pwa design
commit 1422e1fc96c400948b273210a1067251087d15d4
Author: Amruth Pillai <im.amruth@gmail.com>
Date: Fri May 15 11:05:04 2026 +0200
chore(dev): simplify server proxy config
commit bc2ff5a9f6fda41e6c40333c8f163aa23a6c5e48
Author: Amruth Pillai <im.amruth@gmail.com>
Date: Fri May 15 11:04:50 2026 +0200
docs: add unsafe oauth redirect plan
commit 445359ebe9b96c1515bf1c4c3f73ba8a8448ec12
Author: Amruth Pillai <im.amruth@gmail.com>
Date: Fri May 15 11:04:34 2026 +0200
feat(auth): add unsafe oauth redirect flag
commit 73fffdd24598e56b2793f7657919bc794835892e
Author: Amruth Pillai <im.amruth@gmail.com>
Date: Fri May 15 10:55:02 2026 +0200
docs: design unsafe oauth redirect flag
commit c0066aa19c15fc8a4c8e5179ed49889c117519f4
Author: Amruth Pillai <im.amruth@gmail.com>
Date: Fri May 15 10:22:04 2026 +0200
chore: update translation source paths
commit 9033da082418d252aafd6c2eed72f71f014be3d9
Author: Amruth Pillai <im.amruth@gmail.com>
Date: Fri May 15 10:09:25 2026 +0200
refactor(arch): react spa + hono migration
commit 6f27936c11bda895977dc63ee550c3346d4ce24b
Author: Amruth Pillai <im.amruth@gmail.com>
Date: Fri May 15 01:10:47 2026 +0200
docs: add docker nightly tagging design
commit ecc1fd9a88a0ee1dca2f1977dfc17f74527fe1da
Author: Amruth Pillai <im.amruth@gmail.com>
Date: Thu May 14 20:05:44 2026 +0200
feat: migrate to hono spa server
451 lines
13 KiB
TypeScript
451 lines
13 KiB
TypeScript
import type { ResumeData } from "@reactive-resume/schema/resume/data";
|
|
import { flattenError, ZodError, z } from "zod";
|
|
import { getNetworkIcon } from "@reactive-resume/resume/icons";
|
|
import { resumeDataSchema } from "@reactive-resume/schema/resume/data";
|
|
import { defaultResumeData } from "@reactive-resume/schema/resume/default";
|
|
import { formatPeriod, formatSingleDate } from "@reactive-resume/utils/date";
|
|
import { arrayToHtmlList, toHtmlDescription } from "@reactive-resume/utils/html";
|
|
import { parseLevel } from "@reactive-resume/utils/level";
|
|
import { generateId } from "@reactive-resume/utils/string";
|
|
import { createUrl } from "@reactive-resume/utils/url";
|
|
|
|
const createItemWebsite = (url?: string, label?: string) => ({
|
|
...createUrl(url, label),
|
|
inlineLink: false,
|
|
});
|
|
|
|
// Custom ISO 8601 date pattern that allows partial dates (year only, year-month, or full date)
|
|
const iso8601 = z
|
|
.string()
|
|
.regex(
|
|
/^([1-2][0-9]{3}-[0-1][0-9]-[0-3][0-9]|[1-2][0-9]{3}-[0-1][0-9]|[1-2][0-9]{3})$/,
|
|
"Must be a valid ISO 8601 date (YYYY, YYYY-MM, or YYYY-MM-DD)",
|
|
);
|
|
|
|
const locationSchema = z.looseObject({
|
|
address: z.string().optional(),
|
|
postalCode: z.string().optional(),
|
|
city: z.string().optional(),
|
|
countryCode: z.string().optional(),
|
|
region: z.string().optional(),
|
|
});
|
|
|
|
const profileSchema = z.looseObject({
|
|
network: z.string().optional(),
|
|
username: z.string().optional(),
|
|
url: z.url().optional(),
|
|
});
|
|
|
|
const basicsSchema = z.looseObject({
|
|
name: z.string().optional(),
|
|
label: z.string().optional(),
|
|
image: z.string().optional(),
|
|
email: z.email().optional(),
|
|
phone: z.string().optional(),
|
|
url: z.url().optional(),
|
|
summary: z.string().optional(),
|
|
location: locationSchema.optional(),
|
|
profiles: z.array(profileSchema).optional(),
|
|
});
|
|
|
|
const workSchema = z.looseObject({
|
|
name: z.string().optional(),
|
|
location: z.string().optional(),
|
|
description: z.string().optional(),
|
|
position: z.string().optional(),
|
|
url: z.url().optional(),
|
|
startDate: iso8601.optional(),
|
|
endDate: iso8601.optional(),
|
|
summary: z.string().optional(),
|
|
highlights: z.array(z.string()).optional(),
|
|
});
|
|
|
|
const volunteerSchema = z.looseObject({
|
|
organization: z.string().optional(),
|
|
position: z.string().optional(),
|
|
url: z.url().optional(),
|
|
startDate: iso8601.optional(),
|
|
endDate: iso8601.optional(),
|
|
summary: z.string().optional(),
|
|
highlights: z.array(z.string()).optional(),
|
|
});
|
|
|
|
const educationSchema = z.looseObject({
|
|
institution: z.string().optional(),
|
|
url: z.url().optional(),
|
|
area: z.string().optional(),
|
|
studyType: z.string().optional(),
|
|
startDate: iso8601.optional(),
|
|
endDate: iso8601.optional(),
|
|
score: z.string().optional(),
|
|
courses: z.array(z.string()).optional(),
|
|
});
|
|
|
|
const awardSchema = z.looseObject({
|
|
title: z.string().optional(),
|
|
date: iso8601.optional(),
|
|
awarder: z.string().optional(),
|
|
summary: z.string().optional(),
|
|
});
|
|
|
|
const certificateSchema = z.looseObject({
|
|
name: z.string().optional(),
|
|
date: iso8601.optional(),
|
|
url: z.url().optional(),
|
|
issuer: z.string().optional(),
|
|
});
|
|
|
|
const publicationSchema = z.looseObject({
|
|
name: z.string().optional(),
|
|
publisher: z.string().optional(),
|
|
releaseDate: iso8601.optional(),
|
|
url: z.url().optional(),
|
|
summary: z.string().optional(),
|
|
});
|
|
|
|
const skillSchema = z.looseObject({
|
|
name: z.string().optional(),
|
|
level: z.string().optional(),
|
|
keywords: z.array(z.string()).optional(),
|
|
});
|
|
|
|
const languageSchema = z.looseObject({
|
|
language: z.string().optional(),
|
|
fluency: z.string().optional(),
|
|
});
|
|
|
|
const interestSchema = z.looseObject({
|
|
name: z.string().optional(),
|
|
keywords: z.array(z.string()).optional(),
|
|
});
|
|
|
|
const referenceSchema = z.looseObject({
|
|
name: z.string().optional(),
|
|
reference: z.string().optional(),
|
|
});
|
|
|
|
const projectSchema = z.looseObject({
|
|
name: z.string().optional(),
|
|
description: z.string().optional(),
|
|
highlights: z.array(z.string()).optional(),
|
|
keywords: z.array(z.string()).optional(),
|
|
startDate: iso8601.optional(),
|
|
endDate: iso8601.optional(),
|
|
url: z.url().optional(),
|
|
roles: z.array(z.string()).optional(),
|
|
entity: z.string().optional(),
|
|
type: z.string().optional(),
|
|
});
|
|
|
|
const metaSchema = z.looseObject({
|
|
canonical: z.url().optional(),
|
|
version: z.string().optional(),
|
|
lastModified: z.string().optional(),
|
|
});
|
|
|
|
const jsonResumeSchema = z.looseObject({
|
|
$schema: z.url().optional(),
|
|
basics: basicsSchema.optional(),
|
|
work: z.array(workSchema).optional(),
|
|
volunteer: z.array(volunteerSchema).optional(),
|
|
education: z.array(educationSchema).optional(),
|
|
awards: z.array(awardSchema).optional(),
|
|
certificates: z.array(certificateSchema).optional(),
|
|
publications: z.array(publicationSchema).optional(),
|
|
skills: z.array(skillSchema).optional(),
|
|
languages: z.array(languageSchema).optional(),
|
|
interests: z.array(interestSchema).optional(),
|
|
references: z.array(referenceSchema).optional(),
|
|
projects: z.array(projectSchema).optional(),
|
|
meta: metaSchema.optional(),
|
|
});
|
|
|
|
type JSONResume = z.infer<typeof jsonResumeSchema>;
|
|
type JSONResumeLocation = z.infer<typeof locationSchema>;
|
|
|
|
// Helper function to format location object to string
|
|
function formatLocation(location?: JSONResumeLocation): string {
|
|
if (!location) return "";
|
|
|
|
const parts: string[] = [];
|
|
if (location.city) parts.push(location.city);
|
|
if (location.region) parts.push(location.region);
|
|
if (location.countryCode) parts.push(location.countryCode);
|
|
|
|
return parts.join(", ");
|
|
}
|
|
|
|
export class JSONResumeImporter {
|
|
convert(jsonResume: JSONResume): ResumeData {
|
|
const result: ResumeData = {
|
|
...defaultResumeData,
|
|
};
|
|
|
|
// Map basics
|
|
if (jsonResume.basics) {
|
|
const basics = jsonResume.basics;
|
|
result.basics = {
|
|
name: basics.name || "",
|
|
headline: basics.label || "",
|
|
email: basics.email || "",
|
|
phone: basics.phone || "",
|
|
location: basics.location ? formatLocation(basics.location) : "",
|
|
website: createUrl(basics.url),
|
|
customFields: [],
|
|
};
|
|
|
|
// Map image to picture
|
|
if (basics.image) {
|
|
result.picture = {
|
|
...defaultResumeData.picture,
|
|
url: basics.image,
|
|
hidden: false,
|
|
};
|
|
}
|
|
}
|
|
|
|
// Map summary
|
|
if (jsonResume.basics?.summary) {
|
|
result.summary = {
|
|
...defaultResumeData.summary,
|
|
content: `<p>${jsonResume.basics.summary}</p>`,
|
|
hidden: false,
|
|
};
|
|
}
|
|
|
|
// Map work to experience
|
|
if (jsonResume.work && jsonResume.work.length > 0) {
|
|
result.sections.experience = {
|
|
...defaultResumeData.sections.experience,
|
|
items: jsonResume.work
|
|
.filter((work) => work.name || work.position)
|
|
.map((work) => ({
|
|
id: generateId(),
|
|
hidden: false,
|
|
company: work.name || "",
|
|
position: work.position || "",
|
|
location: work.location || "",
|
|
period: formatPeriod(work.startDate, work.endDate),
|
|
website: createItemWebsite(work.url),
|
|
roles: [],
|
|
description: toHtmlDescription(work.summary, work.highlights),
|
|
})),
|
|
};
|
|
}
|
|
|
|
// Map education
|
|
if (jsonResume.education && jsonResume.education.length > 0) {
|
|
result.sections.education = {
|
|
...defaultResumeData.sections.education,
|
|
items: jsonResume.education
|
|
.filter((edu) => edu.institution)
|
|
.map((edu) => ({
|
|
id: generateId(),
|
|
hidden: false,
|
|
school: edu.institution || "",
|
|
degree: [edu.studyType, edu.area].filter(Boolean).join(" in ") || "",
|
|
area: edu.area || "",
|
|
grade: edu.score || "",
|
|
location: "",
|
|
period: formatPeriod(edu.startDate, edu.endDate),
|
|
website: createItemWebsite(edu.url),
|
|
description: edu.courses && edu.courses.length > 0 ? arrayToHtmlList(edu.courses) : "",
|
|
})),
|
|
};
|
|
}
|
|
|
|
// Map projects
|
|
if (jsonResume.projects && jsonResume.projects.length > 0) {
|
|
result.sections.projects = {
|
|
...defaultResumeData.sections.projects,
|
|
items: jsonResume.projects
|
|
.filter((project) => project.name)
|
|
.map((project) => ({
|
|
id: generateId(),
|
|
hidden: false,
|
|
name: project.name || "",
|
|
period: formatPeriod(project.startDate, project.endDate),
|
|
website: createItemWebsite(project.url),
|
|
description: toHtmlDescription(project.description, project.highlights),
|
|
})),
|
|
};
|
|
}
|
|
|
|
// Map skills
|
|
if (jsonResume.skills && jsonResume.skills.length > 0) {
|
|
result.sections.skills = {
|
|
...defaultResumeData.sections.skills,
|
|
items: jsonResume.skills
|
|
.filter((skill) => skill.name)
|
|
.map((skill) => ({
|
|
id: generateId(),
|
|
hidden: false,
|
|
icon: "star",
|
|
iconColor: "",
|
|
name: skill.name || "",
|
|
proficiency: skill.level || "",
|
|
level: parseLevel(skill.level),
|
|
keywords: skill.keywords || [],
|
|
})),
|
|
};
|
|
}
|
|
|
|
// Map languages
|
|
if (jsonResume.languages && jsonResume.languages.length > 0) {
|
|
result.sections.languages = {
|
|
...defaultResumeData.sections.languages,
|
|
items: jsonResume.languages
|
|
.filter((lang) => lang.language)
|
|
.map((lang) => ({
|
|
id: generateId(),
|
|
hidden: false,
|
|
language: lang.language || "",
|
|
fluency: lang.fluency || "",
|
|
level: parseLevel(lang.fluency),
|
|
})),
|
|
};
|
|
}
|
|
|
|
// Map interests
|
|
if (jsonResume.interests && jsonResume.interests.length > 0) {
|
|
result.sections.interests = {
|
|
...defaultResumeData.sections.interests,
|
|
items: jsonResume.interests
|
|
.filter((interest) => interest.name)
|
|
.map((interest) => ({
|
|
id: generateId(),
|
|
hidden: false,
|
|
icon: "star",
|
|
iconColor: "",
|
|
name: interest.name || "",
|
|
keywords: interest.keywords || [],
|
|
})),
|
|
};
|
|
}
|
|
|
|
// Map awards
|
|
if (jsonResume.awards && jsonResume.awards.length > 0) {
|
|
result.sections.awards = {
|
|
...defaultResumeData.sections.awards,
|
|
items: jsonResume.awards
|
|
.filter((award) => award.title)
|
|
.map((award) => ({
|
|
id: generateId(),
|
|
hidden: false,
|
|
title: award.title || "",
|
|
awarder: award.awarder || "",
|
|
date: formatSingleDate(award.date),
|
|
website: createItemWebsite(),
|
|
description: award.summary ? `<p>${award.summary}</p>` : "",
|
|
})),
|
|
};
|
|
}
|
|
|
|
// Map certificates
|
|
if (jsonResume.certificates && jsonResume.certificates.length > 0) {
|
|
result.sections.certifications = {
|
|
...defaultResumeData.sections.certifications,
|
|
items: jsonResume.certificates
|
|
.filter((cert) => cert.name)
|
|
.map((cert) => ({
|
|
id: generateId(),
|
|
hidden: false,
|
|
title: cert.name || "",
|
|
issuer: cert.issuer || "",
|
|
date: formatSingleDate(cert.date),
|
|
website: createItemWebsite(cert.url),
|
|
description: "",
|
|
})),
|
|
};
|
|
}
|
|
|
|
// Map publications
|
|
if (jsonResume.publications && jsonResume.publications.length > 0) {
|
|
result.sections.publications = {
|
|
...defaultResumeData.sections.publications,
|
|
items: jsonResume.publications
|
|
.filter((pub) => pub.name)
|
|
.map((pub) => ({
|
|
id: generateId(),
|
|
hidden: false,
|
|
title: pub.name || "",
|
|
publisher: pub.publisher || "",
|
|
date: formatSingleDate(pub.releaseDate),
|
|
website: createItemWebsite(pub.url),
|
|
description: pub.summary ? `<p>${pub.summary}</p>` : "",
|
|
})),
|
|
};
|
|
}
|
|
|
|
// Map volunteer
|
|
if (jsonResume.volunteer && jsonResume.volunteer.length > 0) {
|
|
result.sections.volunteer = {
|
|
...defaultResumeData.sections.volunteer,
|
|
items: jsonResume.volunteer
|
|
.filter((vol) => vol.organization)
|
|
.map((vol) => ({
|
|
id: generateId(),
|
|
hidden: false,
|
|
organization: vol.organization || "",
|
|
location: "",
|
|
period: formatPeriod(vol.startDate, vol.endDate),
|
|
website: createItemWebsite(vol.url),
|
|
description: toHtmlDescription(vol.summary, vol.highlights),
|
|
})),
|
|
};
|
|
}
|
|
|
|
// Map references
|
|
if (jsonResume.references && jsonResume.references.length > 0) {
|
|
result.sections.references = {
|
|
...defaultResumeData.sections.references,
|
|
items: jsonResume.references
|
|
.filter((ref) => ref.name || ref.reference)
|
|
.map((ref) => ({
|
|
id: generateId(),
|
|
hidden: false,
|
|
name: ref.name || "",
|
|
position: "",
|
|
website: createItemWebsite(),
|
|
phone: "",
|
|
description: ref.reference ? `<p>${ref.reference}</p>` : "",
|
|
})),
|
|
};
|
|
}
|
|
|
|
// Map profiles (from basics.profiles) to profiles section
|
|
if (jsonResume.basics?.profiles && jsonResume.basics.profiles.length > 0) {
|
|
result.sections.profiles = {
|
|
...defaultResumeData.sections.profiles,
|
|
items: jsonResume.basics.profiles
|
|
.filter((profile) => profile.network)
|
|
.map((profile) => ({
|
|
id: generateId(),
|
|
hidden: false,
|
|
icon: getNetworkIcon(profile.network),
|
|
iconColor: "",
|
|
network: profile.network || "",
|
|
username: profile.username || "",
|
|
website: createItemWebsite(profile.url, profile.username || profile.network),
|
|
})),
|
|
};
|
|
}
|
|
|
|
return resumeDataSchema.parse(result);
|
|
}
|
|
|
|
parse(json: string): ResumeData {
|
|
try {
|
|
const jsonResume = jsonResumeSchema.parse(JSON.parse(json));
|
|
return this.convert(jsonResume);
|
|
} catch (error) {
|
|
if (error instanceof ZodError) {
|
|
const errors = flattenError(error);
|
|
throw new Error(JSON.stringify(errors));
|
|
}
|
|
|
|
throw error;
|
|
}
|
|
}
|
|
}
|