import { Body, Controller, Get, Param, Patch } from '@nestjs/common'; import { ApiBearerAuth, ApiTags } from '@nestjs/swagger'; import { RequirePermission } from '../auth/decorators/require-permission.decorator'; import { CurrentUser } from '../auth/decorators/current-user.decorator'; import type { AuthenticatedUser } from '../auth/types/authenticated-user'; import { AutomationService } from './automation.service'; import { UpdateAutomationRuleDto } from './dto/update-automation-rule.dto'; @ApiTags('automation-rules') @ApiBearerAuth() @Controller('automation-rules') export class AutomationController { constructor(private readonly automationService: AutomationService) {} @RequirePermission('automation:read') @Get() findAll() { return this.automationService.findAll(); } @RequirePermission('automation:update') @Patch(':id') update( @Param('id') id: string, @Body() dto: UpdateAutomationRuleDto, @CurrentUser() actor: AuthenticatedUser, ) { return this.automationService.update(id, dto, actor.id); } }