2024-01-26 11:48:37 -05:00
|
|
|
import { Body, Controller, HttpCode, HttpStatus, Post } from '@nestjs/common';
|
2025-11-13 08:18:43 -05:00
|
|
|
import { ApiTags } from '@nestjs/swagger';
|
|
|
|
|
import { Endpoint, HistoryBuilder } from 'src/decorators';
|
2024-03-20 23:53:07 +01:00
|
|
|
import { BulkIdsDto } from 'src/dtos/asset-ids.response.dto';
|
|
|
|
|
import { AuthDto } from 'src/dtos/auth.dto';
|
2024-09-18 09:57:52 -04:00
|
|
|
import { TrashResponseDto } from 'src/dtos/trash.dto';
|
2025-11-11 17:01:14 -05:00
|
|
|
import { ApiTag, Permission } from 'src/enum';
|
2024-03-20 15:15:01 -05:00
|
|
|
import { Auth, Authenticated } from 'src/middleware/auth.guard';
|
2024-03-21 00:07:30 +01:00
|
|
|
import { TrashService } from 'src/services/trash.service';
|
2024-01-26 11:48:37 -05:00
|
|
|
|
2025-11-11 17:01:14 -05:00
|
|
|
@ApiTags(ApiTag.Trash)
|
2024-01-26 11:48:37 -05:00
|
|
|
@Controller('trash')
|
|
|
|
|
export class TrashController {
|
|
|
|
|
constructor(private service: TrashService) {}
|
|
|
|
|
|
|
|
|
|
@Post('empty')
|
2025-07-15 14:50:13 -04:00
|
|
|
@Authenticated({ permission: Permission.AssetDelete })
|
2025-08-08 15:56:37 -04:00
|
|
|
@HttpCode(HttpStatus.OK)
|
2025-11-13 08:18:43 -05:00
|
|
|
@Endpoint({
|
2025-11-11 17:01:14 -05:00
|
|
|
summary: 'Empty trash',
|
|
|
|
|
description: 'Permanently delete all items in the trash.',
|
2025-11-13 08:18:43 -05:00
|
|
|
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
2025-11-11 17:01:14 -05:00
|
|
|
})
|
2024-09-18 09:57:52 -04:00
|
|
|
emptyTrash(@Auth() auth: AuthDto): Promise<TrashResponseDto> {
|
2024-01-26 11:48:37 -05:00
|
|
|
return this.service.empty(auth);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Post('restore')
|
2025-07-15 14:50:13 -04:00
|
|
|
@Authenticated({ permission: Permission.AssetDelete })
|
2025-08-08 15:56:37 -04:00
|
|
|
@HttpCode(HttpStatus.OK)
|
2025-11-13 08:18:43 -05:00
|
|
|
@Endpoint({
|
2025-11-11 17:01:14 -05:00
|
|
|
summary: 'Restore trash',
|
|
|
|
|
description: 'Restore all items in the trash.',
|
2025-11-13 08:18:43 -05:00
|
|
|
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
2025-11-11 17:01:14 -05:00
|
|
|
})
|
2024-09-18 09:57:52 -04:00
|
|
|
restoreTrash(@Auth() auth: AuthDto): Promise<TrashResponseDto> {
|
2024-01-26 11:48:37 -05:00
|
|
|
return this.service.restore(auth);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Post('restore/assets')
|
2025-07-15 14:50:13 -04:00
|
|
|
@Authenticated({ permission: Permission.AssetDelete })
|
2025-08-08 15:56:37 -04:00
|
|
|
@HttpCode(HttpStatus.OK)
|
2025-11-13 08:18:43 -05:00
|
|
|
@Endpoint({
|
2025-11-11 17:01:14 -05:00
|
|
|
summary: 'Restore assets',
|
|
|
|
|
description: 'Restore specific assets from the trash.',
|
2025-11-13 08:18:43 -05:00
|
|
|
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
2025-11-11 17:01:14 -05:00
|
|
|
})
|
2024-09-18 09:57:52 -04:00
|
|
|
restoreAssets(@Auth() auth: AuthDto, @Body() dto: BulkIdsDto): Promise<TrashResponseDto> {
|
2024-01-26 11:48:37 -05:00
|
|
|
return this.service.restoreAssets(auth, dto);
|
|
|
|
|
}
|
|
|
|
|
}
|