mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-12 07:43:10 +10:00
This commit is contained in:
@ -11,6 +11,7 @@
|
||||
"dependencies": {
|
||||
"@reactive-resume/utils": "*",
|
||||
"@reactive-resume/schema": "*",
|
||||
"@sindresorhus/slugify": "^2.2.1",
|
||||
"nestjs-zod": "^3.0.0",
|
||||
"@swc/helpers": "~0.5.11",
|
||||
"zod": "^3.24.1"
|
||||
|
||||
@ -1,10 +1,14 @@
|
||||
import { kebabCase } from "@reactive-resume/utils";
|
||||
import slugify from "@sindresorhus/slugify";
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "zod";
|
||||
|
||||
export const createResumeSchema = z.object({
|
||||
title: z.string().min(1),
|
||||
slug: z.string().min(1).transform(kebabCase).optional(),
|
||||
slug: z
|
||||
.string()
|
||||
.min(1)
|
||||
.transform((value) => slugify(value))
|
||||
.optional(),
|
||||
visibility: z.enum(["public", "private"]).default("private"),
|
||||
});
|
||||
|
||||
|
||||
@ -1,11 +1,15 @@
|
||||
import { resumeDataSchema } from "@reactive-resume/schema";
|
||||
import { kebabCase } from "@reactive-resume/utils";
|
||||
import slugify from "@sindresorhus/slugify";
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "zod";
|
||||
|
||||
export const importResumeSchema = z.object({
|
||||
title: z.string().optional(),
|
||||
slug: z.string().min(1).transform(kebabCase).optional(),
|
||||
slug: z
|
||||
.string()
|
||||
.min(1)
|
||||
.transform((value) => slugify(value))
|
||||
.optional(),
|
||||
visibility: z.enum(["public", "private"]).default("private").optional(),
|
||||
data: resumeDataSchema,
|
||||
});
|
||||
|
||||
@ -30,17 +30,6 @@ export const extractUrl = (string: string) => {
|
||||
return result ? result[0] : null;
|
||||
};
|
||||
|
||||
export const kebabCase = (string?: string | null) => {
|
||||
if (!string) return "";
|
||||
|
||||
return (
|
||||
string
|
||||
.match(/[A-Z]{2,}(?=[A-Z][a-z]+\d*|\b)|[A-Z]?[a-z]+\d*|[A-Z]|\d+/gu)
|
||||
?.join("-")
|
||||
.toLowerCase() ?? ""
|
||||
);
|
||||
};
|
||||
|
||||
export const generateRandomName = () => {
|
||||
return uniqueNamesGenerator({
|
||||
dictionaries: [adjectives, adjectives, animals],
|
||||
|
||||
@ -6,7 +6,6 @@ import {
|
||||
getInitials,
|
||||
isEmptyString,
|
||||
isUrl,
|
||||
kebabCase,
|
||||
processUsername,
|
||||
} from "../string";
|
||||
|
||||
@ -40,16 +39,6 @@ describe("extractUrl", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("kebabCase", () => {
|
||||
it("converts a string to kebab-case", () => {
|
||||
expect(kebabCase("fooBar")).toBe("foo-bar");
|
||||
expect(kebabCase("Foo Bar")).toBe("foo-bar");
|
||||
expect(kebabCase("foo_bar")).toBe("foo-bar");
|
||||
expect(kebabCase("")).toBe("");
|
||||
expect(kebabCase(null)).toBe("");
|
||||
});
|
||||
});
|
||||
|
||||
describe("generateRandomName", () => {
|
||||
it("generates a random name", () => {
|
||||
const name = generateRandomName();
|
||||
|
||||
Reference in New Issue
Block a user