mirror of
https://github.com/immich-app/immich.git
synced 2025-12-22 17:24:56 +03:00
feat: endpoint descriptions (#23813)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Body, Controller, Delete, Get, Header, HttpCode, HttpStatus, Post, Res } from '@nestjs/common';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
import { Response } from 'express';
|
||||
import { EndpointLifecycle } from 'src/decorators';
|
||||
import { AssetResponseDto } from 'src/dtos/asset-response.dto';
|
||||
import { AuthDto } from 'src/dtos/auth.dto';
|
||||
import {
|
||||
@@ -12,12 +13,12 @@ import {
|
||||
SyncAckSetDto,
|
||||
SyncStreamDto,
|
||||
} from 'src/dtos/sync.dto';
|
||||
import { Permission } from 'src/enum';
|
||||
import { ApiTag, Permission } from 'src/enum';
|
||||
import { Auth, Authenticated } from 'src/middleware/auth.guard';
|
||||
import { GlobalExceptionFilter } from 'src/middleware/global-exception.filter';
|
||||
import { SyncService } from 'src/services/sync.service';
|
||||
|
||||
@ApiTags('Sync')
|
||||
@ApiTags(ApiTag.Sync)
|
||||
@Controller('sync')
|
||||
export class SyncController {
|
||||
constructor(
|
||||
@@ -28,6 +29,11 @@ export class SyncController {
|
||||
@Post('full-sync')
|
||||
@Authenticated()
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@EndpointLifecycle({
|
||||
deprecatedAt: 'v2.0.0',
|
||||
summary: 'Get full sync for user',
|
||||
description: 'Retrieve all assets for a full synchronization for the authenticated user.',
|
||||
})
|
||||
getFullSyncForUser(@Auth() auth: AuthDto, @Body() dto: AssetFullSyncDto): Promise<AssetResponseDto[]> {
|
||||
return this.service.getFullSync(auth, dto);
|
||||
}
|
||||
@@ -35,6 +41,11 @@ export class SyncController {
|
||||
@Post('delta-sync')
|
||||
@Authenticated()
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@EndpointLifecycle({
|
||||
deprecatedAt: 'v2.0.0',
|
||||
summary: 'Get delta sync for user',
|
||||
description: 'Retrieve changed assets since the last sync for the authenticated user.',
|
||||
})
|
||||
getDeltaSync(@Auth() auth: AuthDto, @Body() dto: AssetDeltaSyncDto): Promise<AssetDeltaSyncResponseDto> {
|
||||
return this.service.getDeltaSync(auth, dto);
|
||||
}
|
||||
@@ -43,6 +54,11 @@ export class SyncController {
|
||||
@Authenticated({ permission: Permission.SyncStream })
|
||||
@Header('Content-Type', 'application/jsonlines+json')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@ApiOperation({
|
||||
summary: 'Stream sync changes',
|
||||
description:
|
||||
'Retrieve a JSON lines streamed response of changes for synchronization. This endpoint is used by the mobile app to efficiently stay up to date with changes.',
|
||||
})
|
||||
async getSyncStream(@Auth() auth: AuthDto, @Res() res: Response, @Body() dto: SyncStreamDto) {
|
||||
try {
|
||||
await this.service.stream(auth, res, dto);
|
||||
@@ -54,6 +70,10 @@ export class SyncController {
|
||||
|
||||
@Get('ack')
|
||||
@Authenticated({ permission: Permission.SyncCheckpointRead })
|
||||
@ApiOperation({
|
||||
summary: 'Retrieve acknowledgements',
|
||||
description: 'Retrieve the synchronization acknowledgments for the current session.',
|
||||
})
|
||||
getSyncAck(@Auth() auth: AuthDto): Promise<SyncAckDto[]> {
|
||||
return this.service.getAcks(auth);
|
||||
}
|
||||
@@ -61,6 +81,11 @@ export class SyncController {
|
||||
@Post('ack')
|
||||
@Authenticated({ permission: Permission.SyncCheckpointUpdate })
|
||||
@HttpCode(HttpStatus.NO_CONTENT)
|
||||
@ApiOperation({
|
||||
summary: 'Acknowledge changes',
|
||||
description:
|
||||
'Send a list of synchronization acknowledgements to confirm that the latest changes have been received.',
|
||||
})
|
||||
sendSyncAck(@Auth() auth: AuthDto, @Body() dto: SyncAckSetDto) {
|
||||
return this.service.setAcks(auth, dto);
|
||||
}
|
||||
@@ -68,6 +93,10 @@ export class SyncController {
|
||||
@Delete('ack')
|
||||
@Authenticated({ permission: Permission.SyncCheckpointDelete })
|
||||
@HttpCode(HttpStatus.NO_CONTENT)
|
||||
@ApiOperation({
|
||||
summary: 'Delete acknowledgements',
|
||||
description: 'Delete specific synchronization acknowledgments.',
|
||||
})
|
||||
deleteSyncAck(@Auth() auth: AuthDto, @Body() dto: SyncAckDeleteDto): Promise<void> {
|
||||
return this.service.deleteAcks(auth, dto);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user