refactor(v4.0.0-alpha): beginning of a new era

This commit is contained in:
Amruth Pillai
2023-11-05 12:31:42 +01:00
parent 0ba6a444e2
commit 22933bd412
505 changed files with 81829 additions and 0 deletions

View File

@ -0,0 +1,25 @@
import { z } from "zod";
import { defaultItem, defaultUrl, itemSchema, urlSchema } from "../shared";
// Schema
export const awardSchema = itemSchema.extend({
title: z.string().min(1),
awarder: z.string(),
date: z.string(),
summary: z.string(),
url: urlSchema,
});
// Type
export type Award = z.infer<typeof awardSchema>;
// Defaults
export const defaultAward: Award = {
...defaultItem,
title: "",
awarder: "",
date: "",
summary: "",
url: defaultUrl,
};

View File

@ -0,0 +1,25 @@
import { z } from "zod";
import { defaultItem, defaultUrl, itemSchema, urlSchema } from "../shared";
// Schema
export const certificationSchema = itemSchema.extend({
name: z.string().min(1),
issuer: z.string(),
date: z.string(),
summary: z.string(),
url: urlSchema,
});
// Type
export type Certification = z.infer<typeof certificationSchema>;
// Defaults
export const defaultCertification: Certification = {
...defaultItem,
name: "",
issuer: "",
date: "",
summary: "",
url: defaultUrl,
};

View File

@ -0,0 +1,29 @@
import { z } from "zod";
import { defaultItem, defaultUrl, itemSchema, urlSchema } from "../shared";
// Schema
export const customSectionSchema = itemSchema.extend({
name: z.string(),
description: z.string(),
date: z.string(),
level: z.number().min(0).max(5).default(0),
summary: z.string(),
keywords: z.array(z.string()).default([]),
url: urlSchema,
});
// Type
export type CustomSection = z.infer<typeof customSectionSchema>;
// Defaults
export const defaultCustomSection: CustomSection = {
...defaultItem,
name: "",
description: "",
date: "",
level: 0,
summary: "",
keywords: [],
url: defaultUrl,
};

View File

@ -0,0 +1,30 @@
import { z } from "zod";
import { defaultItem, defaultUrl, itemSchema, urlSchema } from "../shared";
// Schema
export const educationSchema = itemSchema.extend({
institution: z.string().min(1),
studyType: z.string(),
area: z.string(),
score: z.string(),
date: z.string(),
summary: z.string(),
url: urlSchema,
});
// Type
export type Education = z.infer<typeof educationSchema>;
// Defaults
export const defaultEducation: Education = {
...defaultItem,
id: "",
institution: "",
studyType: "",
area: "",
score: "",
date: "",
summary: "",
url: defaultUrl,
};

View File

@ -0,0 +1,27 @@
import { z } from "zod";
import { defaultItem, defaultUrl, itemSchema, urlSchema } from "../shared";
// Schema
export const experienceSchema = itemSchema.extend({
company: z.string().min(1),
position: z.string(),
location: z.string(),
date: z.string(),
summary: z.string(),
url: urlSchema,
});
// Type
export type Experience = z.infer<typeof experienceSchema>;
// Defaults
export const defaultExperience: Experience = {
...defaultItem,
company: "",
position: "",
location: "",
date: "",
summary: "",
url: defaultUrl,
};

View File

@ -0,0 +1,134 @@
import { FilterKeys } from "@reactive-resume/utils";
import { z } from "zod";
import { idSchema } from "../shared";
import { awardSchema } from "./award";
import { certificationSchema } from "./certification";
import { customSectionSchema } from "./custom-section";
import { educationSchema } from "./education";
import { experienceSchema } from "./experience";
import { interestSchema } from "./interest";
import { languageSchema } from "./language";
import { profileSchema } from "./profile";
import { projectSchema } from "./project";
import { publicationSchema } from "./publication";
import { referenceSchema } from "./reference";
import { skillSchema } from "./skill";
import { volunteerSchema } from "./volunteer";
// Schema
export const sectionSchema = z.object({
name: z.string(),
columns: z.number().min(1).max(5).default(1),
visible: z.boolean().default(true),
});
// Schema
export const customSchema = sectionSchema.extend({
id: idSchema,
items: z.array(customSectionSchema),
});
export const sectionsSchema = z.object({
summary: sectionSchema.extend({
id: z.literal("summary"),
content: z.string().default(""),
}),
awards: sectionSchema.extend({
id: z.literal("awards"),
items: z.array(awardSchema),
}),
certifications: sectionSchema.extend({
id: z.literal("certifications"),
items: z.array(certificationSchema),
}),
education: sectionSchema.extend({
id: z.literal("education"),
items: z.array(educationSchema),
}),
experience: sectionSchema.extend({
id: z.literal("experience"),
items: z.array(experienceSchema),
}),
volunteer: sectionSchema.extend({
id: z.literal("volunteer"),
items: z.array(volunteerSchema),
}),
interests: sectionSchema.extend({
id: z.literal("interests"),
items: z.array(interestSchema),
}),
languages: sectionSchema.extend({
id: z.literal("languages"),
items: z.array(languageSchema),
}),
profiles: sectionSchema.extend({
id: z.literal("profiles"),
items: z.array(profileSchema),
}),
projects: sectionSchema.extend({
id: z.literal("projects"),
items: z.array(projectSchema),
}),
publications: sectionSchema.extend({
id: z.literal("publications"),
items: z.array(publicationSchema),
}),
references: sectionSchema.extend({
id: z.literal("references"),
items: z.array(referenceSchema),
}),
skills: sectionSchema.extend({
id: z.literal("skills"),
items: z.array(skillSchema),
}),
custom: z.record(z.string(), customSchema),
});
// Detailed Types
export type Section = z.infer<typeof sectionSchema>;
export type Sections = z.infer<typeof sectionsSchema>;
export type SectionKey = "basics" | keyof Sections | `custom.${string}`;
export type SectionWithItem<T = unknown> = Sections[FilterKeys<Sections, { items: T[] }>];
export type SectionItem = SectionWithItem["items"][number];
export type CustomSection = z.infer<typeof customSchema>;
export type CustomSectionItem = CustomSection["items"][number];
// Defaults
export const defaultSection: Section = {
name: "",
columns: 1,
visible: true,
};
export const defaultSections: Sections = {
summary: { ...defaultSection, id: "summary", name: "Summary", content: "" },
awards: { ...defaultSection, id: "awards", name: "Awards", items: [] },
certifications: { ...defaultSection, id: "certifications", name: "Certifications", items: [] },
education: { ...defaultSection, id: "education", name: "Education", items: [] },
experience: { ...defaultSection, id: "experience", name: "Experience", items: [] },
volunteer: { ...defaultSection, id: "volunteer", name: "Volunteering", items: [] },
interests: { ...defaultSection, id: "interests", name: "Interests", items: [] },
languages: { ...defaultSection, id: "languages", name: "Languages", items: [] },
profiles: { ...defaultSection, id: "profiles", name: "Profiles", items: [] },
projects: { ...defaultSection, id: "projects", name: "Projects", items: [] },
publications: { ...defaultSection, id: "publications", name: "Publications", items: [] },
references: { ...defaultSection, id: "references", name: "References", items: [] },
skills: { ...defaultSection, id: "skills", name: "Skills", items: [] },
custom: {},
};
export * from "./award";
export * from "./certification";
export * from "./custom-section";
export * from "./education";
export * from "./experience";
export * from "./interest";
export * from "./language";
export * from "./profile";
export * from "./project";
export * from "./publication";
export * from "./reference";
export * from "./skill";
export * from "./volunteer";

View File

@ -0,0 +1,19 @@
import { z } from "zod";
import { defaultItem, itemSchema } from "../shared";
// Schema
export const interestSchema = itemSchema.extend({
name: z.string().min(1),
keywords: z.array(z.string()).default([]),
});
// Type
export type Interest = z.infer<typeof interestSchema>;
// Defaults
export const defaultInterest: Interest = {
...defaultItem,
name: "",
keywords: [],
};

View File

@ -0,0 +1,21 @@
import { z } from "zod";
import { defaultItem, itemSchema } from "../shared";
// Schema
export const languageSchema = itemSchema.extend({
name: z.string().min(1),
fluency: z.string(),
fluencyLevel: z.number().min(1).max(6),
});
// Type
export type Language = z.infer<typeof languageSchema>;
// Defaults
export const defaultLanguage: Language = {
...defaultItem,
name: "",
fluency: "",
fluencyLevel: 1,
};

View File

@ -0,0 +1,27 @@
import { z } from "zod";
import { defaultItem, defaultUrl, itemSchema, urlSchema } from "../shared";
// Schema
export const profileSchema = itemSchema.extend({
network: z.string().min(1),
username: z.string().min(1),
icon: z
.string()
.describe(
'Slug for the icon from https://simpleicons.org. For example, "github", "linkedin", etc.',
),
url: urlSchema,
});
// Type
export type Profile = z.infer<typeof profileSchema>;
// Defaults
export const defaultProfile: Profile = {
...defaultItem,
network: "",
username: "",
icon: "",
url: defaultUrl,
};

View File

@ -0,0 +1,27 @@
import { z } from "zod";
import { defaultItem, defaultUrl, itemSchema, urlSchema } from "../shared";
// Schema
export const projectSchema = itemSchema.extend({
name: z.string().min(1),
description: z.string(),
date: z.string(),
summary: z.string(),
keywords: z.array(z.string()).default([]),
url: urlSchema,
});
// Type
export type Project = z.infer<typeof projectSchema>;
// Defaults
export const defaultProject: Project = {
...defaultItem,
name: "",
description: "",
date: "",
summary: "",
keywords: [],
url: defaultUrl,
};

View File

@ -0,0 +1,25 @@
import { z } from "zod";
import { defaultItem, defaultUrl, itemSchema, urlSchema } from "../shared";
// Schema
export const publicationSchema = itemSchema.extend({
name: z.string().min(1),
publisher: z.string(),
date: z.string(),
summary: z.string(),
url: urlSchema,
});
// Type
export type Publication = z.infer<typeof publicationSchema>;
// Defaults
export const defaultPublication: Publication = {
...defaultItem,
name: "",
publisher: "",
date: "",
summary: "",
url: defaultUrl,
};

View File

@ -0,0 +1,23 @@
import { z } from "zod";
import { defaultItem, defaultUrl, itemSchema, urlSchema } from "../shared";
// Schema
export const referenceSchema = itemSchema.extend({
name: z.string().min(1),
description: z.string(),
summary: z.string(),
url: urlSchema,
});
// Type
export type Reference = z.infer<typeof referenceSchema>;
// Defaults
export const defaultReference: Reference = {
...defaultItem,
name: "",
description: "",
summary: "",
url: defaultUrl,
};

View File

@ -0,0 +1,23 @@
import { z } from "zod";
import { defaultItem, itemSchema } from "../shared";
// Schema
export const skillSchema = itemSchema.extend({
name: z.string(),
description: z.string(),
level: z.number().min(1).max(5).default(1),
keywords: z.array(z.string()).default([]),
});
// Type
export type Skill = z.infer<typeof skillSchema>;
// Defaults
export const defaultSkill: Skill = {
...defaultItem,
name: "",
description: "",
level: 1,
keywords: [],
};

View File

@ -0,0 +1,27 @@
import { z } from "zod";
import { defaultItem, defaultUrl, itemSchema, urlSchema } from "../shared";
// Schema
export const volunteerSchema = itemSchema.extend({
organization: z.string().min(1),
position: z.string(),
location: z.string(),
date: z.string(),
summary: z.string(),
url: urlSchema,
});
// Type
export type Volunteer = z.infer<typeof volunteerSchema>;
// Defaults
export const defaultVolunteer: Volunteer = {
...defaultItem,
organization: "",
position: "",
location: "",
date: "",
summary: "",
url: defaultUrl,
};