import type { WorkOSUser } from './workos'
import type { User } from '../user'

/**
 * Transform WorkOS User to internal User format
 */
export function transformWorkOSUser(workosUser: WorkOSUser): User {
  return {
    id: workosUser.id,
    email: workosUser.email,
    firstName: workosUser.firstName,
    lastName: workosUser.lastName,
    emailVerified: workosUser.emailVerified,
    profilePictureUrl: workosUser.profilePictureUrl,
    lastSignInAt: workosUser.lastSignInAt ? new Date(workosUser.lastSignInAt) : undefined,
    externalId: workosUser.externalId,
    metadata: workosUser.metadata || {},
    createdAt: new Date(workosUser.createdAt),
    updatedAt: new Date(workosUser.updatedAt)
  }
}
