All files / apps/api-gateway/src/gateway/controllers activity.controller.ts

100% Statements 11/11
100% Branches 12/12
100% Functions 2/2
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 492x 2x                 2x 2x 2x                       2x 2x                                 2x     1x      
import { Controller, Get, Query } from '@nestjs/common';
import {
  ApiBearerAuth,
  ApiForbiddenResponse,
  ApiOkResponse,
  ApiOperation,
  ApiQuery,
  ApiTags,
  ApiUnauthorizedResponse,
} from '@nestjs/swagger';
import { Roles } from '../../auth/auth.decorators';
import { ActivityClient } from '../clients/activity.client';
import { ActivityEventDto, ActivityPage, CursorPage } from '../http/api-types';
 
/**
 * Pass-through to the audit service's activity feed. Same rule as the other
 * pass-through routes: query validation lives with the service that owns the
 * data.
 */
@ApiTags('activity')
@ApiBearerAuth()
@ApiUnauthorizedResponse({ description: 'Missing or invalid token' })
@ApiForbiddenResponse({ description: 'Role not allowed on this route' })
@Controller('activity')
export class ActivityController {
  constructor(private readonly activity: ActivityClient) {}
 
  @ApiOperation({
    summary: 'Read the audit activity feed',
    description:
      'Roles: manager. Keyset-paginated, newest first — follow nextCursor for the next page. Each entry names the actor (null for system-initiated events like AI triage).',
  })
  @ApiQuery({ name: 'limit', required: false, example: 20 })
  @ApiQuery({
    name: 'cursor',
    required: false,
    description: 'nextCursor from the previous page',
  })
  @ApiQuery({ name: 'workOrderId', required: false })
  @ApiOkResponse({ type: ActivityPage })
  @Roles('manager')
  @Get()
  list(
    @Query() query: Record<string, string>,
  ): Promise<CursorPage<ActivityEventDto>> {
    return this.activity.list(query);
  }
}