mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
feat: endpoint descriptions (#23813)
This commit is contained in:
parent
896665bca9
commit
edde0f93ae
76 changed files with 4193 additions and 1663 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { Body, Controller, Get, HttpCode, HttpStatus, Post, Query } from '@nestjs/common';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
import { AssetResponseDto } from 'src/dtos/asset-response.dto';
|
||||
import { AuthDto } from 'src/dtos/auth.dto';
|
||||
import { PersonResponseDto } from 'src/dtos/person.dto';
|
||||
|
|
@ -17,11 +17,11 @@ import {
|
|||
SmartSearchDto,
|
||||
StatisticsSearchDto,
|
||||
} from 'src/dtos/search.dto';
|
||||
import { Permission } from 'src/enum';
|
||||
import { ApiTag, Permission } from 'src/enum';
|
||||
import { Auth, Authenticated } from 'src/middleware/auth.guard';
|
||||
import { SearchService } from 'src/services/search.service';
|
||||
|
||||
@ApiTags('Search')
|
||||
@ApiTags(ApiTag.Search)
|
||||
@Controller('search')
|
||||
export class SearchController {
|
||||
constructor(private service: SearchService) {}
|
||||
|
|
@ -29,6 +29,10 @@ export class SearchController {
|
|||
@Post('metadata')
|
||||
@Authenticated({ permission: Permission.AssetRead })
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@ApiOperation({
|
||||
summary: 'Search assets by metadata',
|
||||
description: 'Search for assets based on various metadata criteria.',
|
||||
})
|
||||
searchAssets(@Auth() auth: AuthDto, @Body() dto: MetadataSearchDto): Promise<SearchResponseDto> {
|
||||
return this.service.searchMetadata(auth, dto);
|
||||
}
|
||||
|
|
@ -36,6 +40,10 @@ export class SearchController {
|
|||
@Post('statistics')
|
||||
@Authenticated({ permission: Permission.AssetStatistics })
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@ApiOperation({
|
||||
summary: 'Search asset statistics',
|
||||
description: 'Retrieve statistical data about assets based on search criteria, such as the total matching count.',
|
||||
})
|
||||
searchAssetStatistics(@Auth() auth: AuthDto, @Body() dto: StatisticsSearchDto): Promise<SearchStatisticsResponseDto> {
|
||||
return this.service.searchStatistics(auth, dto);
|
||||
}
|
||||
|
|
@ -43,6 +51,10 @@ export class SearchController {
|
|||
@Post('random')
|
||||
@Authenticated({ permission: Permission.AssetRead })
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@ApiOperation({
|
||||
summary: 'Search random assets',
|
||||
description: 'Retrieve a random selection of assets based on the provided criteria.',
|
||||
})
|
||||
searchRandom(@Auth() auth: AuthDto, @Body() dto: RandomSearchDto): Promise<AssetResponseDto[]> {
|
||||
return this.service.searchRandom(auth, dto);
|
||||
}
|
||||
|
|
@ -50,6 +62,10 @@ export class SearchController {
|
|||
@Post('large-assets')
|
||||
@Authenticated({ permission: Permission.AssetRead })
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@ApiOperation({
|
||||
summary: 'Search large assets',
|
||||
description: 'Search for assets that are considered large based on specified criteria.',
|
||||
})
|
||||
searchLargeAssets(@Auth() auth: AuthDto, @Query() dto: LargeAssetSearchDto): Promise<AssetResponseDto[]> {
|
||||
return this.service.searchLargeAssets(auth, dto);
|
||||
}
|
||||
|
|
@ -57,36 +73,62 @@ export class SearchController {
|
|||
@Post('smart')
|
||||
@Authenticated({ permission: Permission.AssetRead })
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@ApiOperation({
|
||||
summary: 'Smart asset search',
|
||||
description: 'Perform a smart search for assets by using machine learning vectors to determine relevance.',
|
||||
})
|
||||
searchSmart(@Auth() auth: AuthDto, @Body() dto: SmartSearchDto): Promise<SearchResponseDto> {
|
||||
return this.service.searchSmart(auth, dto);
|
||||
}
|
||||
|
||||
@Get('explore')
|
||||
@Authenticated({ permission: Permission.AssetRead })
|
||||
@ApiOperation({
|
||||
summary: 'Retrieve explore data',
|
||||
description: 'Retrieve data for the explore section, such as popular people and places.',
|
||||
})
|
||||
getExploreData(@Auth() auth: AuthDto): Promise<SearchExploreResponseDto[]> {
|
||||
return this.service.getExploreData(auth);
|
||||
}
|
||||
|
||||
@Get('person')
|
||||
@Authenticated({ permission: Permission.PersonRead })
|
||||
@ApiOperation({
|
||||
summary: 'Search people',
|
||||
description: 'Search for people by name.',
|
||||
})
|
||||
searchPerson(@Auth() auth: AuthDto, @Query() dto: SearchPeopleDto): Promise<PersonResponseDto[]> {
|
||||
return this.service.searchPerson(auth, dto);
|
||||
}
|
||||
|
||||
@Get('places')
|
||||
@Authenticated({ permission: Permission.AssetRead })
|
||||
@ApiOperation({
|
||||
summary: 'Search places',
|
||||
description: 'Search for places by name.',
|
||||
})
|
||||
searchPlaces(@Query() dto: SearchPlacesDto): Promise<PlacesResponseDto[]> {
|
||||
return this.service.searchPlaces(dto);
|
||||
}
|
||||
|
||||
@Get('cities')
|
||||
@Authenticated({ permission: Permission.AssetRead })
|
||||
@ApiOperation({
|
||||
summary: 'Retrieve assets by city',
|
||||
description:
|
||||
'Retrieve a list of assets with each asset belonging to a different city. This endpoint is used on the places pages to show a single thumbnail for each city the user has assets in.',
|
||||
})
|
||||
getAssetsByCity(@Auth() auth: AuthDto): Promise<AssetResponseDto[]> {
|
||||
return this.service.getAssetsByCity(auth);
|
||||
}
|
||||
|
||||
@Get('suggestions')
|
||||
@Authenticated({ permission: Permission.AssetRead })
|
||||
@ApiOperation({
|
||||
summary: 'Retrieve search suggestions',
|
||||
description:
|
||||
'Retrieve search suggestions based on partial input. This endpoint is used for typeahead search features.',
|
||||
})
|
||||
getSearchSuggestions(@Auth() auth: AuthDto, @Query() dto: SearchSuggestionRequestDto): Promise<string[]> {
|
||||
// TODO fix open api generation to indicate that results can be nullable
|
||||
return this.service.getSearchSuggestions(auth, dto) as Promise<string[]>;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue