import { Controller, Get, Param, Query } from '@nestjs/common'; import { ApiBearerAuth, ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger'; import { CurrentUser } from '@edr/api-common'; import type { TCurrentUser } from '@tria-plc/api-common/modules/auth/types/current-user.type'; import { BookingView } from '../../common/booking-guards'; import { UserTradeAccessService } from '../user-trade-access/user-trade-access.service'; import { ReportQueryDto } from './dto/report-query.dto'; import { ReportResultDto } from './dto/report-result.dto'; import { ReportsService } from './reports.service'; @ApiTags('Reports') @ApiBearerAuth() @Controller('reports') export class ReportsController { constructor( private readonly reportsService: ReportsService, private readonly userTradeAccessService: UserTradeAccessService, ) {} @Get(':key') @BookingView() @ApiOperation({ summary: 'Run a canned report by key with optional filters' }) @ApiOkResponse({ type: ReportResultDto }) async run( @Param('key') key: string, @Query() query: ReportQueryDto, @CurrentUser() user: TCurrentUser, ): Promise { const allowed = await this.userTradeAccessService.resolveAllowedDirections(user); return this.reportsService.run(key, query, allowed); } }