import { Injectable, NotFoundException } from '@nestjs/common'; import { PrismaService } from '../../infrastructure/database/prisma.service'; import { DeviceAuthService } from '../auth/device-auth.service'; import { CurrentAccountResponseDto } from './account.dto'; @Injectable() export class AccountService { constructor( private readonly prismaService: PrismaService, private readonly deviceAuthService: DeviceAuthService, ) {} async getCurrentAccount(): Promise { const authenticatedDevice = this.deviceAuthService.getAuthenticatedDeviceOrThrow(); const account = await this.prismaService.user.findUnique({ where: { id: authenticatedDevice.userId, }, select: { id: true, accountKind: true, accountStatus: true, libraryNamespace: true, }, }); if (!account) { throw new NotFoundException('Account not found'); } return { accountId: account.id, accountKind: account.accountKind, accountStatus: account.accountStatus, libraryNamespace: account.libraryNamespace, currentDeviceId: authenticatedDevice.deviceId, }; } }