File size: 4,628 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
import { z } from "zod";
import type { FilterKeys } from "../shared";
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),
separateLinks: z.boolean().default(true),
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 CustomSectionGroup = z.infer<typeof customSchema>;
// Defaults
export const defaultSection: Section = {
name: "",
columns: 1,
separateLinks: true,
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";
|