/**
 * Notifications types — device registration + preferences.
 * Ported from Python backend device/notification routes.
 */

import { z } from 'zod';

export interface DeviceDoc {
  id: string;
  productId: string;
  userId: string;
  deviceId: string;
  platform: 'ios' | 'android' | 'macos' | 'windows' | 'web';
  pushToken?: string;
  appVersion?: string;
  osVersion?: string;
  lastSeenAt: string;
  createdAt: string;
  updatedAt: string;
}

export interface NotificationPrefsDoc {
  id: string;
  productId: string;
  userId: string;
  pushEnabled: boolean;
  emailEnabled: boolean;
  categories: Record<string, boolean>;
  createdAt: string;
  updatedAt: string;
}

export const RegisterDeviceSchema = z.object({
  userId: z.string().min(1),
  deviceId: z.string().min(1),
  platform: z.enum(['ios', 'android', 'macos', 'windows', 'web']),
  pushToken: z.string().optional(),
  appVersion: z.string().optional(),
  osVersion: z.string().optional(),
});

export const UpdatePrefsSchema = z.object({
  pushEnabled: z.boolean().optional(),
  emailEnabled: z.boolean().optional(),
  categories: z.record(z.boolean()).optional(),
});

export type RegisterDeviceInput = z.infer<typeof RegisterDeviceSchema>;
export type UpdatePrefsInput = z.infer<typeof UpdatePrefsSchema>;
