aboutsummaryrefslogtreecommitdiffstats
path: root/packages/shared
diff options
context:
space:
mode:
Diffstat (limited to 'packages/shared')
-rw-r--r--packages/shared/types/highlights.ts31
1 files changed, 31 insertions, 0 deletions
diff --git a/packages/shared/types/highlights.ts b/packages/shared/types/highlights.ts
new file mode 100644
index 00000000..b766c360
--- /dev/null
+++ b/packages/shared/types/highlights.ts
@@ -0,0 +1,31 @@
+import { z } from "zod";
+
+const zHighlightColorSchema = z.enum(["yellow", "red", "green", "blue"]);
+export type ZHighlightColor = z.infer<typeof zHighlightColorSchema>;
+export const SUPPORTED_HIGHLIGHT_COLORS = zHighlightColorSchema.options;
+
+const zHighlightBaseSchema = z.object({
+ bookmarkId: z.string(),
+ startOffset: z.number(),
+ endOffset: z.number(),
+ color: zHighlightColorSchema.default("yellow"),
+ text: z.string().nullable(),
+ note: z.string().nullable(),
+});
+
+export const zHighlightSchema = zHighlightBaseSchema.merge(
+ z.object({
+ id: z.string(),
+ userId: z.string(),
+ createdAt: z.date(),
+ }),
+);
+
+export type ZHighlight = z.infer<typeof zHighlightSchema>;
+
+export const zNewHighlightSchema = zHighlightBaseSchema;
+
+export const zUpdateHighlightSchema = z.object({
+ highlightId: z.string(),
+ color: zHighlightColorSchema.optional(),
+});