Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

feat: add team notification type/frequency Zod schemas and defaults

Cursor Agenta7c32951209b
diff --git a/lib/zod/schemas/notifications.ts b/lib/zod/schemas/notifications.ts
index 7c8175c8..3e90c293 100644
--- a/lib/zod/schemas/notifications.ts
+++ b/lib/zod/schemas/notifications.ts
@@ -1,14 +1,27 @@
import { z } from "zod";
-export const NotificationFrequency = z.enum(["instant", "daily", "weekly"]);
-export type NotificationFrequency = z.infer<typeof NotificationFrequency>;
+// --- Viewer notification preferences (external viewers for dataroom change notifications) ---
+
+export const ViewerNotificationFrequency = z.enum([
+ "instant",
+ "daily",
+ "weekly",
+]);
+export type ViewerNotificationFrequency = z.infer<
+ typeof ViewerNotificationFrequency
+>;
+
+/** @deprecated Use ViewerNotificationFrequency instead */
+export const NotificationFrequency = ViewerNotificationFrequency;
+/** @deprecated Use ViewerNotificationFrequency instead */
+export type NotificationFrequency = ViewerNotificationFrequency;
export const ZViewerNotificationPreferencesSchema = z
.object({
dataroom: z.record(
z.object({
enabled: z.boolean(),
- frequency: NotificationFrequency.optional().default("instant"),
+ frequency: ViewerNotificationFrequency.optional().default("instant"),
}),
),
})
@@ -23,3 +36,57 @@ export const ZUserNotificationPreferencesSchema = z
})
.optional()
.default({ yearInReview: { enabled: true } });
+
+// --- Team member notification preferences ---
+
+export const TeamNotificationType = z.enum([
+ "DOCUMENT_VIEW",
+ "DATAROOM_VIEW",
+ "BLOCKED_ACCESS",
+ "DATAROOM_UPLOAD",
+ "CONVERSATION_MESSAGE",
+]);
+export type TeamNotificationType = z.infer<typeof TeamNotificationType>;
+export const TEAM_NOTIFICATION_TYPES = TeamNotificationType.options;
+
+export const TeamNotificationFrequency = z.enum([
+ "IMMEDIATE",
+ "DAILY",
+ "WEEKLY",
+ "NEVER",
+]);
+export type TeamNotificationFrequency = z.infer<
+ typeof TeamNotificationFrequency
+>;
+export const TEAM_NOTIFICATION_FREQUENCIES = TeamNotificationFrequency.options;
+
+export const ZNotificationPreferenceSchema = z.object({
+ type: TeamNotificationType,
+ frequency: TeamNotificationFrequency,
+});
+
+export const ZUpdateNotificationPreferencesSchema = z.object({
+ preferences: z.array(ZNotificationPreferenceSchema).min(1),
+});
+
+export const DEFAULT_ADMIN_PREFERENCES: Record<
+ TeamNotificationType,
+ TeamNotificationFrequency
+> = {
+ DOCUMENT_VIEW: "IMMEDIATE",
+ DATAROOM_VIEW: "IMMEDIATE",
+ BLOCKED_ACCESS: "IMMEDIATE",
+ DATAROOM_UPLOAD: "IMMEDIATE",
+ CONVERSATION_MESSAGE: "IMMEDIATE",
+};
+
+export const DEFAULT_MEMBER_PREFERENCES: Record<
+ TeamNotificationType,
+ TeamNotificationFrequency
+> = {
+ DOCUMENT_VIEW: "IMMEDIATE",
+ DATAROOM_VIEW: "IMMEDIATE",
+ BLOCKED_ACCESS: "IMMEDIATE",
+ DATAROOM_UPLOAD: "IMMEDIATE",
+ CONVERSATION_MESSAGE: "NEVER",
+};