mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 07:51:13 -05:00
65 lines
1.6 KiB
TypeScript
65 lines
1.6 KiB
TypeScript
import { z } from 'zod';
|
|
import type { NotificationPreferences } from '@/types/notifications';
|
|
|
|
/**
|
|
* Schema for channel preferences
|
|
*/
|
|
export const channelPreferencesSchema = z.object({
|
|
in_app: z.boolean(),
|
|
email: z.boolean(),
|
|
push: z.boolean(),
|
|
sms: z.boolean()
|
|
});
|
|
|
|
/**
|
|
* Schema for workflow preferences (dynamic keys)
|
|
*/
|
|
export const workflowPreferencesSchema = z.record(z.string(), z.boolean());
|
|
|
|
/**
|
|
* Schema for frequency settings
|
|
*/
|
|
export const frequencySettingsSchema = z.object({
|
|
digest: z.enum(['realtime', 'hourly', 'daily', 'weekly'] as const),
|
|
max_per_hour: z.number().int().min(1).max(999)
|
|
});
|
|
|
|
/**
|
|
* Complete notification preferences schema
|
|
*/
|
|
export const notificationPreferencesSchema = z.object({
|
|
channelPreferences: channelPreferencesSchema,
|
|
workflowPreferences: workflowPreferencesSchema,
|
|
frequencySettings: frequencySettingsSchema
|
|
});
|
|
|
|
/**
|
|
* Schema for subscriber data
|
|
*/
|
|
export const subscriberDataSchema = z.object({
|
|
subscriberId: z.string().uuid('Invalid subscriber ID'),
|
|
email: z.string().email('Invalid email').optional(),
|
|
firstName: z.string().max(100).optional(),
|
|
lastName: z.string().max(100).optional(),
|
|
phone: z.string().max(20).optional(),
|
|
avatar: z.string().url('Invalid avatar URL').optional(),
|
|
data: z.record(z.string(), z.any()).optional()
|
|
});
|
|
|
|
/**
|
|
* Default notification preferences for new users
|
|
*/
|
|
export const DEFAULT_NOTIFICATION_PREFERENCES: NotificationPreferences = {
|
|
channelPreferences: {
|
|
in_app: true,
|
|
email: true,
|
|
push: false,
|
|
sms: false
|
|
},
|
|
workflowPreferences: {},
|
|
frequencySettings: {
|
|
digest: 'daily',
|
|
max_per_hour: 10
|
|
}
|
|
};
|