import type { WorkOSInvitation } from './workos'
import type { Invitation } from '../invitation'

/**
 * Transform WorkOS invitation to internal format
 */
export function transformWorkOSInvitation(workosInvitation: WorkOSInvitation): Invitation {
  return {
    id: workosInvitation.id,
    workosInvitationId: workosInvitation.id,
    email: workosInvitation.email,
    organizationId: workosInvitation.organizationId,
    inviterUserId: workosInvitation.inviterUserId,
    invitationState: workosInvitation.state,
    roleSlug: null, // WorkOS doesn't include role in invitation response
    invitationToken: workosInvitation.token,
    acceptInvitationUrl: workosInvitation.acceptInvitationUrl,
    acceptedAt: workosInvitation.acceptedAt,
    revokedAt: workosInvitation.revokedAt,
    expiresAt: workosInvitation.expiresAt,
    createdAt: workosInvitation.createdAt,
    updatedAt: workosInvitation.updatedAt
  }
}
