import type { AsyncUseCase } from '@gridpilot/shared/application'; import type { ISocialGraphRepository } from '../../domain/repositories/ISocialGraphRepository'; import type { CurrentUserSocialDTO } from '../dto/CurrentUserSocialDTO'; import type { FriendDTO } from '../dto/FriendDTO'; import type { CurrentUserSocialViewModel, ICurrentUserSocialPresenter, } from '../presenters/ISocialPresenters'; export interface GetCurrentUserSocialParams { driverId: string; } /** * Application-level use case to retrieve the current user's social context. * * Keeps orchestration in the social bounded context while delegating * data access to domain repositories and presenting via a presenter. */ export class GetCurrentUserSocialUseCase implements AsyncUseCase { constructor( private readonly socialGraphRepository: ISocialGraphRepository, public readonly presenter: ICurrentUserSocialPresenter, ) {} async execute(params: GetCurrentUserSocialParams): Promise { const { driverId } = params; const friendsDomain = await this.socialGraphRepository.getFriends(driverId); const friends: FriendDTO[] = friendsDomain.map((friend) => ({ driverId: friend.id, displayName: friend.name, avatarUrl: '', isOnline: false, lastSeen: new Date(), })); const currentUser: CurrentUserSocialDTO = { driverId, displayName: '', avatarUrl: '', countryCode: '', }; const viewModel: CurrentUserSocialViewModel = { currentUser, friends, }; this.presenter.present(viewModel); } }