/**
 * Zod schema for OAuthConnection
 *
 * This schema provides runtime validation and type inference.
 *  * Serializer for OAuth connection info (user-facing).
 *  */
import { z } from 'zod'
import * as Enums from '../../enums'

/**
 * Serializer for OAuth connection info (user-facing).
 */
export const OAuthConnectionSchema = z.object({
  id: z.int(),
  provider: z.nativeEnum(Enums.OAuthConnectionProvider),
  provider_display: z.string(),
  provider_username: z.string(),
  provider_email: z.email(),
  provider_avatar_url: z.union([z.url(), z.literal('')]),
  connected_at: z.string().datetime({ offset: true }),
  last_login_at: z.string().datetime({ offset: true }),
})

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