mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-14 00:32:35 +10:00
refactor(v4.0.0-alpha): beginning of a new era
This commit is contained in:
30
libs/schema/.eslintrc.json
Normal file
30
libs/schema/.eslintrc.json
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"extends": ["../../.eslintrc.json"],
|
||||
"ignorePatterns": ["!**/*"],
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
||||
"rules": {}
|
||||
},
|
||||
{
|
||||
"files": ["*.ts", "*.tsx"],
|
||||
"rules": {}
|
||||
},
|
||||
{
|
||||
"files": ["*.js", "*.jsx"],
|
||||
"rules": {}
|
||||
},
|
||||
{
|
||||
"files": ["*.json"],
|
||||
"parser": "jsonc-eslint-parser",
|
||||
"rules": {
|
||||
"@nx/dependency-checks": [
|
||||
"error",
|
||||
{
|
||||
"ignoredFiles": ["{projectRoot}/vite.config.{js,ts,mjs,mts}"]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
29
libs/schema/.swcrc
Normal file
29
libs/schema/.swcrc
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"jsc": {
|
||||
"target": "es2017",
|
||||
"parser": {
|
||||
"syntax": "typescript",
|
||||
"decorators": true,
|
||||
"dynamicImport": true
|
||||
},
|
||||
"transform": {
|
||||
"decoratorMetadata": true,
|
||||
"legacyDecorator": true
|
||||
},
|
||||
"keepClassNames": true,
|
||||
"externalHelpers": true,
|
||||
"loose": true
|
||||
},
|
||||
"module": {
|
||||
"type": "commonjs"
|
||||
},
|
||||
"sourceMaps": true,
|
||||
"exclude": [
|
||||
"jest.config.ts",
|
||||
".*\\.spec.tsx?$",
|
||||
".*\\.test.tsx?$",
|
||||
"./src/jest-setup.ts$",
|
||||
"./**/jest-setup.ts$",
|
||||
".*.js$"
|
||||
]
|
||||
}
|
||||
17
libs/schema/package.json
Normal file
17
libs/schema/package.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "@reactive-resume/schema",
|
||||
"version": "0.0.1",
|
||||
"private": false,
|
||||
"type": "commonjs",
|
||||
"main": "./src/index.js",
|
||||
"typings": "./src/index.d.ts",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"dependencies": {
|
||||
"@swc/helpers": "~0.5.2",
|
||||
"zod": "^3.22.4",
|
||||
"@reactive-resume/utils": "*",
|
||||
"@paralleldrive/cuid2": "^2.2.2"
|
||||
}
|
||||
}
|
||||
29
libs/schema/pnpm-lock.yaml
generated
Normal file
29
libs/schema/pnpm-lock.yaml
generated
Normal file
@ -0,0 +1,29 @@
|
||||
lockfileVersion: '6.0'
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
dependencies:
|
||||
'@swc/helpers':
|
||||
specifier: ~0.5.2
|
||||
version: 0.5.3
|
||||
zod:
|
||||
specifier: ^3.22.4
|
||||
version: 3.22.4
|
||||
|
||||
packages:
|
||||
|
||||
/@swc/helpers@0.5.3:
|
||||
resolution: {integrity: sha512-FaruWX6KdudYloq1AHD/4nU+UsMTdNE8CKyrseXWEcgjDAbvkwJg2QGPAnfIJLIWsjZOSPLOAykK6fuYp4vp4A==}
|
||||
dependencies:
|
||||
tslib: 2.6.2
|
||||
dev: false
|
||||
|
||||
/tslib@2.6.2:
|
||||
resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==}
|
||||
dev: false
|
||||
|
||||
/zod@3.22.4:
|
||||
resolution: {integrity: sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==}
|
||||
dev: false
|
||||
34
libs/schema/project.json
Normal file
34
libs/schema/project.json
Normal file
@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "schema",
|
||||
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
||||
"sourceRoot": "libs/schema/src",
|
||||
"projectType": "library",
|
||||
"targets": {
|
||||
"build": {
|
||||
"executor": "@nx/js:swc",
|
||||
"outputs": ["{options.outputPath}"],
|
||||
"options": {
|
||||
"outputPath": "dist/libs/schema",
|
||||
"main": "libs/schema/src/index.ts",
|
||||
"tsConfig": "libs/schema/tsconfig.lib.json",
|
||||
"assets": ["libs/schema/*.md"]
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"executor": "@nx/eslint:lint",
|
||||
"outputs": ["{options.outputFile}"],
|
||||
"options": {
|
||||
"lintFilePatterns": ["libs/schema/**/*.ts", "libs/schema/package.json"]
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"executor": "@nx/vite:test",
|
||||
"outputs": ["{options.reportsDirectory}"],
|
||||
"options": {
|
||||
"passWithNoTests": true,
|
||||
"reportsDirectory": "../../coverage/libs/schema"
|
||||
}
|
||||
}
|
||||
},
|
||||
"tags": ["frontend", "backend"]
|
||||
}
|
||||
11
libs/schema/src/basics/custom.ts
Normal file
11
libs/schema/src/basics/custom.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const customFieldSchema = z.object({
|
||||
id: z.string().cuid2(),
|
||||
name: z.string(),
|
||||
value: z.string(),
|
||||
});
|
||||
|
||||
export const customFieldsDefault = [];
|
||||
|
||||
export type CustomField = z.infer<typeof customFieldSchema>;
|
||||
53
libs/schema/src/basics/index.ts
Normal file
53
libs/schema/src/basics/index.ts
Normal file
@ -0,0 +1,53 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { defaultUrl, urlSchema } from "../shared";
|
||||
import { customFieldSchema } from "./custom";
|
||||
|
||||
// Schema
|
||||
export const basicsSchema = z.object({
|
||||
name: z.string(),
|
||||
headline: z.string(),
|
||||
email: z.literal("").or(z.string().email()),
|
||||
phone: z.string(),
|
||||
location: z.string(),
|
||||
url: urlSchema,
|
||||
customFields: z.array(customFieldSchema),
|
||||
picture: z.object({
|
||||
url: z.string(),
|
||||
size: z.number().default(64),
|
||||
aspectRatio: z.number().default(1),
|
||||
borderRadius: z.number().default(0),
|
||||
effects: z.object({
|
||||
hidden: z.boolean().default(false),
|
||||
border: z.boolean().default(false),
|
||||
grayscale: z.boolean().default(false),
|
||||
}),
|
||||
}),
|
||||
});
|
||||
|
||||
// Type
|
||||
export type Basics = z.infer<typeof basicsSchema>;
|
||||
|
||||
// Defaults
|
||||
export const defaultBasics: Basics = {
|
||||
name: "",
|
||||
headline: "",
|
||||
email: "",
|
||||
phone: "",
|
||||
location: "",
|
||||
url: defaultUrl,
|
||||
customFields: [],
|
||||
picture: {
|
||||
url: "",
|
||||
size: 64,
|
||||
aspectRatio: 1,
|
||||
borderRadius: 0,
|
||||
effects: {
|
||||
hidden: false,
|
||||
border: false,
|
||||
grayscale: false,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export * from "./custom";
|
||||
27
libs/schema/src/index.ts
Normal file
27
libs/schema/src/index.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { basicsSchema, defaultBasics } from "./basics";
|
||||
import { defaultMetadata, metadataSchema } from "./metadata";
|
||||
import { defaultSections, sectionsSchema } from "./sections";
|
||||
|
||||
// Schema
|
||||
export const resumeDataSchema = z.object({
|
||||
basics: basicsSchema,
|
||||
sections: sectionsSchema,
|
||||
metadata: metadataSchema,
|
||||
});
|
||||
|
||||
// Type
|
||||
export type ResumeData = z.infer<typeof resumeDataSchema>;
|
||||
|
||||
// Defaults
|
||||
export const defaultResumeData: ResumeData = {
|
||||
basics: defaultBasics,
|
||||
sections: defaultSections,
|
||||
metadata: defaultMetadata,
|
||||
};
|
||||
|
||||
export * from "./basics";
|
||||
export * from "./metadata";
|
||||
export * from "./sections";
|
||||
export * from "./shared";
|
||||
79
libs/schema/src/metadata/index.ts
Normal file
79
libs/schema/src/metadata/index.ts
Normal file
@ -0,0 +1,79 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const defaultLayout = [
|
||||
[
|
||||
["summary", "awards", "certifications", "education", "experience", "volunteer"],
|
||||
["interests", "languages", "profiles", "projects", "publications", "references", "skills"],
|
||||
],
|
||||
];
|
||||
|
||||
// Schema
|
||||
export const metadataSchema = z.object({
|
||||
locale: z.string().default("en"),
|
||||
template: z.string().default("rhyhorn"),
|
||||
layout: z.array(z.array(z.array(z.string()))).default(defaultLayout), // pages -> columns -> sections
|
||||
css: z.object({
|
||||
value: z.string().default(".section {\n\toutline: 1px solid #000;\n\toutline-offset: 4px;\n}"),
|
||||
visible: z.boolean().default(false),
|
||||
}),
|
||||
page: z.object({
|
||||
margin: z.number().default(18),
|
||||
format: z.enum(["a4", "letter"]).default("a4"),
|
||||
options: z.object({
|
||||
breakLine: z.boolean().default(true),
|
||||
pageNumbers: z.boolean().default(true),
|
||||
}),
|
||||
}),
|
||||
theme: z.object({
|
||||
background: z.string().default("#ffffff"),
|
||||
text: z.string().default("#000000"),
|
||||
primary: z.string().default("#000000"),
|
||||
}),
|
||||
typography: z.object({
|
||||
font: z.object({
|
||||
family: z.string().default("IBM Plex Serif"),
|
||||
subset: z.string().default("latin"),
|
||||
variants: z.array(z.string()).default(["regular"]),
|
||||
size: z.number().default(14),
|
||||
}),
|
||||
lineHeight: z.number().default(1.5),
|
||||
underlineLinks: z.boolean().default(true),
|
||||
}),
|
||||
});
|
||||
|
||||
// Type
|
||||
export type Metadata = z.infer<typeof metadataSchema>;
|
||||
|
||||
// Defaults
|
||||
export const defaultMetadata: Metadata = {
|
||||
locale: "en",
|
||||
template: "rhyhorn",
|
||||
layout: defaultLayout,
|
||||
css: {
|
||||
value: ".section {\n\toutline: 1px solid #000;\n\toutline-offset: 4px;\n}",
|
||||
visible: false,
|
||||
},
|
||||
page: {
|
||||
margin: 18,
|
||||
format: "a4",
|
||||
options: {
|
||||
breakLine: true,
|
||||
pageNumbers: true,
|
||||
},
|
||||
},
|
||||
theme: {
|
||||
background: "#ffffff",
|
||||
text: "#000000",
|
||||
primary: "#000000",
|
||||
},
|
||||
typography: {
|
||||
font: {
|
||||
family: "IBM Plex Serif",
|
||||
subset: "latin",
|
||||
variants: ["regular", "italic", "600"],
|
||||
size: 14,
|
||||
},
|
||||
lineHeight: 1.5,
|
||||
underlineLinks: true,
|
||||
},
|
||||
};
|
||||
25
libs/schema/src/sections/award.ts
Normal file
25
libs/schema/src/sections/award.ts
Normal 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,
|
||||
};
|
||||
25
libs/schema/src/sections/certification.ts
Normal file
25
libs/schema/src/sections/certification.ts
Normal 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,
|
||||
};
|
||||
29
libs/schema/src/sections/custom-section.ts
Normal file
29
libs/schema/src/sections/custom-section.ts
Normal 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,
|
||||
};
|
||||
30
libs/schema/src/sections/education.ts
Normal file
30
libs/schema/src/sections/education.ts
Normal 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,
|
||||
};
|
||||
27
libs/schema/src/sections/experience.ts
Normal file
27
libs/schema/src/sections/experience.ts
Normal 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,
|
||||
};
|
||||
134
libs/schema/src/sections/index.ts
Normal file
134
libs/schema/src/sections/index.ts
Normal 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";
|
||||
19
libs/schema/src/sections/interest.ts
Normal file
19
libs/schema/src/sections/interest.ts
Normal 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: [],
|
||||
};
|
||||
21
libs/schema/src/sections/language.ts
Normal file
21
libs/schema/src/sections/language.ts
Normal 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,
|
||||
};
|
||||
27
libs/schema/src/sections/profile.ts
Normal file
27
libs/schema/src/sections/profile.ts
Normal 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,
|
||||
};
|
||||
27
libs/schema/src/sections/project.ts
Normal file
27
libs/schema/src/sections/project.ts
Normal 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,
|
||||
};
|
||||
25
libs/schema/src/sections/publication.ts
Normal file
25
libs/schema/src/sections/publication.ts
Normal 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,
|
||||
};
|
||||
23
libs/schema/src/sections/reference.ts
Normal file
23
libs/schema/src/sections/reference.ts
Normal 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,
|
||||
};
|
||||
23
libs/schema/src/sections/skill.ts
Normal file
23
libs/schema/src/sections/skill.ts
Normal 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: [],
|
||||
};
|
||||
27
libs/schema/src/sections/volunteer.ts
Normal file
27
libs/schema/src/sections/volunteer.ts
Normal 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,
|
||||
};
|
||||
8
libs/schema/src/shared/id.ts
Normal file
8
libs/schema/src/shared/id.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import { createId } from "@paralleldrive/cuid2";
|
||||
import { z } from "zod";
|
||||
|
||||
export const idSchema = z
|
||||
.string()
|
||||
.cuid2()
|
||||
.default(createId())
|
||||
.describe("Unique identifier for the item in Cuid2 format");
|
||||
3
libs/schema/src/shared/index.ts
Normal file
3
libs/schema/src/shared/index.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export * from "./id";
|
||||
export * from "./item";
|
||||
export * from "./url";
|
||||
18
libs/schema/src/shared/item.ts
Normal file
18
libs/schema/src/shared/item.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { idSchema } from "./id";
|
||||
|
||||
// Schema
|
||||
export const itemSchema = z.object({
|
||||
id: idSchema,
|
||||
visible: z.boolean(),
|
||||
});
|
||||
|
||||
// Type
|
||||
export type Item = z.infer<typeof itemSchema>;
|
||||
|
||||
// Defaults
|
||||
export const defaultItem: Item = {
|
||||
id: "",
|
||||
visible: true,
|
||||
};
|
||||
16
libs/schema/src/shared/url.ts
Normal file
16
libs/schema/src/shared/url.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { z } from "zod";
|
||||
|
||||
// Schema
|
||||
export const urlSchema = z.object({
|
||||
label: z.string(),
|
||||
href: z.literal("").or(z.string().url()),
|
||||
});
|
||||
|
||||
// Type
|
||||
export type URL = z.infer<typeof urlSchema>;
|
||||
|
||||
// Defaults
|
||||
export const defaultUrl: URL = {
|
||||
label: "",
|
||||
href: "",
|
||||
};
|
||||
22
libs/schema/tsconfig.json
Normal file
22
libs/schema/tsconfig.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"noImplicitOverride": true,
|
||||
"noPropertyAccessFromIndexSignature": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"files": [],
|
||||
"include": [],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.lib.json"
|
||||
},
|
||||
{
|
||||
"path": "./tsconfig.spec.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
10
libs/schema/tsconfig.lib.json
Normal file
10
libs/schema/tsconfig.lib.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../../dist/out-tsc",
|
||||
"declaration": true,
|
||||
"types": ["node"]
|
||||
},
|
||||
"include": ["src/**/*.ts"],
|
||||
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
|
||||
}
|
||||
19
libs/schema/tsconfig.spec.json
Normal file
19
libs/schema/tsconfig.spec.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../../dist/out-tsc",
|
||||
"types": ["vitest/globals", "vitest/importMeta", "vite/client", "node", "vitest"]
|
||||
},
|
||||
"include": [
|
||||
"vite.config.ts",
|
||||
"src/**/*.test.ts",
|
||||
"src/**/*.spec.ts",
|
||||
"src/**/*.test.tsx",
|
||||
"src/**/*.spec.tsx",
|
||||
"src/**/*.test.js",
|
||||
"src/**/*.spec.js",
|
||||
"src/**/*.test.jsx",
|
||||
"src/**/*.spec.jsx",
|
||||
"src/**/*.d.ts"
|
||||
]
|
||||
}
|
||||
15
libs/schema/vite.config.ts
Normal file
15
libs/schema/vite.config.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { nxViteTsPaths } from "@nx/vite/plugins/nx-tsconfig-paths.plugin";
|
||||
import { defineConfig } from "vite";
|
||||
|
||||
export default defineConfig({
|
||||
cacheDir: "../../node_modules/.vite/schema",
|
||||
|
||||
plugins: [nxViteTsPaths()],
|
||||
|
||||
test: {
|
||||
globals: true,
|
||||
environment: "jsdom",
|
||||
cache: { dir: "../../node_modules/.vitest" },
|
||||
include: ["src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user