/**
 * Zod schema for DeviceList
 *
 * This schema provides runtime validation and type inference.
 *  * Serializer for listing TOTP devices.
 *  */
import { z } from 'zod'
import * as Enums from '../../enums'

/**
 * Serializer for listing TOTP devices.
 */
export const DeviceListSchema = z.object({
  id: z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
  name: z.string(),
  is_primary: z.boolean(),
  status: z.nativeEnum(Enums.DeviceListStatus),
  created_at: z.iso.datetime(),
  confirmed_at: z.iso.datetime().nullable(),
  last_used_at: z.iso.datetime().nullable(),
})

/**
 * Infer TypeScript type from Zod schema
 */
export type DeviceList = z.infer<typeof DeviceListSchema>