From ce851d2502d40d75cd652cdf66902816fae8fb5e Mon Sep 17 00:00:00 2001 From: Jason Rasmussen Date: Thu, 14 Nov 2024 13:34:20 -0500 Subject: [PATCH] refactor: rename searchMetadata to searchAssets --- e2e/src/api/specs/library.e2e-spec.ts | 30 +++++++++---------- e2e/src/api/specs/trash.e2e-spec.ts | 6 ++-- e2e/src/utils.ts | 6 ++-- .../repositories/asset_api.repository.dart | 2 +- mobile/lib/services/search.service.dart | 2 +- mobile/openapi/README.md | 2 +- mobile/openapi/lib/api/search_api.dart | 6 ++-- open-api/immich-openapi-specs.json | 2 +- open-api/typescript-sdk/src/fetch-client.ts | 2 +- server/src/controllers/search.controller.ts | 2 +- .../[[assetId=id]]/+page.svelte | 4 +-- 11 files changed, 32 insertions(+), 32 deletions(-) diff --git a/e2e/src/api/specs/library.e2e-spec.ts b/e2e/src/api/specs/library.e2e-spec.ts index bf0bd4a9c65d7..3f910fa1e3756 100644 --- a/e2e/src/api/specs/library.e2e-spec.ts +++ b/e2e/src/api/specs/library.e2e-spec.ts @@ -299,7 +299,7 @@ describe('/libraries', () => { await utils.waitForQueueFinish(admin.accessToken, 'library'); - const { assets } = await utils.metadataSearch(admin.accessToken, { + const { assets } = await utils.searchAssets(admin.accessToken, { originalPath: `${testAssetDirInternal}/temp/directoryA/assetA.png`, }); expect(assets.count).toBe(1); @@ -320,7 +320,7 @@ describe('/libraries', () => { await utils.waitForQueueFinish(admin.accessToken, 'library'); - const { assets } = await utils.metadataSearch(admin.accessToken, { libraryId: library.id }); + const { assets } = await utils.searchAssets(admin.accessToken, { libraryId: library.id }); expect(assets.count).toBe(1); expect(assets.items[0].originalPath.includes('directoryB')); @@ -340,7 +340,7 @@ describe('/libraries', () => { await utils.waitForQueueFinish(admin.accessToken, 'library'); - const { assets } = await utils.metadataSearch(admin.accessToken, { libraryId: library.id }); + const { assets } = await utils.searchAssets(admin.accessToken, { libraryId: library.id }); expect(assets.count).toBe(2); expect(assets.items.find((asset) => asset.originalPath.includes('directoryA'))).toBeDefined(); @@ -365,7 +365,7 @@ describe('/libraries', () => { await utils.waitForQueueFinish(admin.accessToken, 'library'); - const { assets } = await utils.metadataSearch(admin.accessToken, { libraryId: library.id }); + const { assets } = await utils.searchAssets(admin.accessToken, { libraryId: library.id }); expect(assets.count).toBe(2); expect(assets.items.find((asset) => asset.originalPath.includes('folder, a'))).toBeDefined(); @@ -393,7 +393,7 @@ describe('/libraries', () => { await utils.waitForQueueFinish(admin.accessToken, 'library'); - const { assets } = await utils.metadataSearch(admin.accessToken, { libraryId: library.id }); + const { assets } = await utils.searchAssets(admin.accessToken, { libraryId: library.id }); expect(assets.count).toBe(2); expect(assets.items.find((asset) => asset.originalPath.includes('folder{ a'))).toBeDefined(); @@ -428,7 +428,7 @@ describe('/libraries', () => { await utils.waitForQueueFinish(admin.accessToken, 'metadataExtraction'); utils.removeImageFile(`${testAssetDir}/temp/directoryA/assetB.jpg`); - const { assets } = await utils.metadataSearch(admin.accessToken, { + const { assets } = await utils.searchAssets(admin.accessToken, { libraryId: library.id, model: 'NIKON D750', }); @@ -460,7 +460,7 @@ describe('/libraries', () => { await utils.waitForQueueFinish(admin.accessToken, 'metadataExtraction'); utils.removeImageFile(`${testAssetDir}/temp/directoryA/assetB.jpg`); - const { assets } = await utils.metadataSearch(admin.accessToken, { + const { assets } = await utils.searchAssets(admin.accessToken, { libraryId: library.id, model: 'NIKON D750', }); @@ -478,7 +478,7 @@ describe('/libraries', () => { await scan(admin.accessToken, library.id); await utils.waitForQueueFinish(admin.accessToken, 'library'); - const { assets } = await utils.metadataSearch(admin.accessToken, { libraryId: library.id }); + const { assets } = await utils.searchAssets(admin.accessToken, { libraryId: library.id }); expect(assets.count).toBe(1); utils.removeImageFile(`${testAssetDir}/temp/offline/offline.png`); @@ -495,7 +495,7 @@ describe('/libraries', () => { expect(trashedAsset.originalPath).toBe(`${testAssetDirInternal}/temp/offline/offline.png`); expect(trashedAsset.isOffline).toEqual(true); - const { assets: newAssets } = await utils.metadataSearch(admin.accessToken, { libraryId: library.id }); + const { assets: newAssets } = await utils.searchAssets(admin.accessToken, { libraryId: library.id }); expect(newAssets.items).toEqual([]); }); @@ -510,7 +510,7 @@ describe('/libraries', () => { await scan(admin.accessToken, library.id); await utils.waitForQueueFinish(admin.accessToken, 'library'); - const { assets } = await utils.metadataSearch(admin.accessToken, { libraryId: library.id }); + const { assets } = await utils.searchAssets(admin.accessToken, { libraryId: library.id }); expect(assets.count).toBe(1); utils.createDirectory(`${testAssetDir}/temp/another-path/`); @@ -532,7 +532,7 @@ describe('/libraries', () => { expect(trashedAsset.originalPath).toBe(`${testAssetDirInternal}/temp/offline/offline.png`); expect(trashedAsset.isOffline).toBe(true); - const { assets: newAssets } = await utils.metadataSearch(admin.accessToken, { libraryId: library.id }); + const { assets: newAssets } = await utils.searchAssets(admin.accessToken, { libraryId: library.id }); expect(newAssets.items).toEqual([]); @@ -549,7 +549,7 @@ describe('/libraries', () => { await scan(admin.accessToken, library.id); await utils.waitForQueueFinish(admin.accessToken, 'library'); - const { assets } = await utils.metadataSearch(admin.accessToken, { + const { assets } = await utils.searchAssets(admin.accessToken, { libraryId: library.id, originalFileName: 'assetB.png', }); @@ -568,7 +568,7 @@ describe('/libraries', () => { expect(trashedAsset.originalPath).toBe(`${testAssetDirInternal}/temp/directoryB/assetB.png`); expect(trashedAsset.isOffline).toBe(true); - const { assets: newAssets } = await utils.metadataSearch(admin.accessToken, { libraryId: library.id }); + const { assets: newAssets } = await utils.searchAssets(admin.accessToken, { libraryId: library.id }); expect(newAssets.items).toEqual([ expect.objectContaining({ @@ -586,7 +586,7 @@ describe('/libraries', () => { await scan(admin.accessToken, library.id); await utils.waitForQueueFinish(admin.accessToken, 'library'); - const { assets: assetsBefore } = await utils.metadataSearch(admin.accessToken, { libraryId: library.id }); + const { assets: assetsBefore } = await utils.searchAssets(admin.accessToken, { libraryId: library.id }); expect(assetsBefore.count).toBeGreaterThan(1); const { status } = await request(app) @@ -597,7 +597,7 @@ describe('/libraries', () => { await utils.waitForQueueFinish(admin.accessToken, 'library'); - const { assets } = await utils.metadataSearch(admin.accessToken, { libraryId: library.id }); + const { assets } = await utils.searchAssets(admin.accessToken, { libraryId: library.id }); expect(assets).toEqual(assetsBefore); }); diff --git a/e2e/src/api/specs/trash.e2e-spec.ts b/e2e/src/api/specs/trash.e2e-spec.ts index 0bfc0ec19be21..f86f38ab61d2f 100644 --- a/e2e/src/api/specs/trash.e2e-spec.ts +++ b/e2e/src/api/specs/trash.e2e-spec.ts @@ -84,7 +84,7 @@ describe('/trash', () => { await scan(admin.accessToken, library.id); await utils.waitForQueueFinish(admin.accessToken, 'library'); - const { assets } = await utils.metadataSearch(admin.accessToken, { libraryId: library.id }); + const { assets } = await utils.searchAssets(admin.accessToken, { libraryId: library.id }); expect(assets.items.length).toBe(1); const asset = assets.items[0]; @@ -148,7 +148,7 @@ describe('/trash', () => { await scan(admin.accessToken, library.id); await utils.waitForQueueFinish(admin.accessToken, 'library'); - const { assets } = await utils.metadataSearch(admin.accessToken, { libraryId: library.id }); + const { assets } = await utils.searchAssets(admin.accessToken, { libraryId: library.id }); expect(assets.count).toBe(1); const assetId = assets.items[0].id; @@ -206,7 +206,7 @@ describe('/trash', () => { await scan(admin.accessToken, library.id); await utils.waitForQueueFinish(admin.accessToken, 'library'); - const { assets } = await utils.metadataSearch(admin.accessToken, { libraryId: library.id }); + const { assets } = await utils.searchAssets(admin.accessToken, { libraryId: library.id }); expect(assets.count).toBe(1); const assetId = assets.items[0].id; diff --git a/e2e/src/utils.ts b/e2e/src/utils.ts index 3af44b50b8330..a9b3c9e6ca6db 100644 --- a/e2e/src/utils.ts +++ b/e2e/src/utils.ts @@ -25,7 +25,7 @@ import { getAssetInfo, getConfigDefaults, login, - searchMetadata, + searchAssets, setBaseUrl, signUpAdmin, updateAdminOnboarding, @@ -400,8 +400,8 @@ export const utils = { checkExistingAssets: (accessToken: string, checkExistingAssetsDto: CheckExistingAssetsDto) => checkExistingAssets({ checkExistingAssetsDto }, { headers: asBearerAuth(accessToken) }), - metadataSearch: async (accessToken: string, dto: MetadataSearchDto) => { - return searchMetadata({ metadataSearchDto: dto }, { headers: asBearerAuth(accessToken) }); + searchAssets: async (accessToken: string, dto: MetadataSearchDto) => { + return searchAssets({ metadataSearchDto: dto }, { headers: asBearerAuth(accessToken) }); }, archiveAssets: (accessToken: string, ids: string[]) => diff --git a/mobile/lib/repositories/asset_api.repository.dart b/mobile/lib/repositories/asset_api.repository.dart index 54d57c4dfccf6..f4fcd8a6dd6e0 100644 --- a/mobile/lib/repositories/asset_api.repository.dart +++ b/mobile/lib/repositories/asset_api.repository.dart @@ -34,7 +34,7 @@ class AssetApiRepository extends ApiRepository implements IAssetApiRepository { int currentPage = 1; while (hasNext) { final response = await checkNull( - _searchApi.searchMetadata( + _searchApi.searchAssets( MetadataSearchDto( personIds: personIds, page: currentPage, diff --git a/mobile/lib/services/search.service.dart b/mobile/lib/services/search.service.dart index 3dd0106c09b47..14e53c3ce41af 100644 --- a/mobile/lib/services/search.service.dart +++ b/mobile/lib/services/search.service.dart @@ -77,7 +77,7 @@ class SearchService { ), ); } else { - response = await _apiService.searchApi.searchMetadata( + response = await _apiService.searchApi.searchAssets( MetadataSearchDto( originalFileName: filter.filename != null && filter.filename!.isNotEmpty diff --git a/mobile/openapi/README.md b/mobile/openapi/README.md index 47bbc4be3c925..c86c92df684e5 100644 --- a/mobile/openapi/README.md +++ b/mobile/openapi/README.md @@ -166,7 +166,7 @@ Class | Method | HTTP request | Description *SearchApi* | [**getAssetsByCity**](doc//SearchApi.md#getassetsbycity) | **GET** /search/cities | *SearchApi* | [**getExploreData**](doc//SearchApi.md#getexploredata) | **GET** /search/explore | *SearchApi* | [**getSearchSuggestions**](doc//SearchApi.md#getsearchsuggestions) | **GET** /search/suggestions | -*SearchApi* | [**searchMetadata**](doc//SearchApi.md#searchmetadata) | **POST** /search/metadata | +*SearchApi* | [**searchAssets**](doc//SearchApi.md#searchassets) | **POST** /search/metadata | *SearchApi* | [**searchPerson**](doc//SearchApi.md#searchperson) | **GET** /search/person | *SearchApi* | [**searchPlaces**](doc//SearchApi.md#searchplaces) | **GET** /search/places | *SearchApi* | [**searchRandom**](doc//SearchApi.md#searchrandom) | **POST** /search/random | diff --git a/mobile/openapi/lib/api/search_api.dart b/mobile/openapi/lib/api/search_api.dart index 985029f106d27..70af3ab0a393a 100644 --- a/mobile/openapi/lib/api/search_api.dart +++ b/mobile/openapi/lib/api/search_api.dart @@ -197,7 +197,7 @@ class SearchApi { /// Parameters: /// /// * [MetadataSearchDto] metadataSearchDto (required): - Future searchMetadataWithHttpInfo(MetadataSearchDto metadataSearchDto,) async { + Future searchAssetsWithHttpInfo(MetadataSearchDto metadataSearchDto,) async { // ignore: prefer_const_declarations final path = r'/search/metadata'; @@ -225,8 +225,8 @@ class SearchApi { /// Parameters: /// /// * [MetadataSearchDto] metadataSearchDto (required): - Future searchMetadata(MetadataSearchDto metadataSearchDto,) async { - final response = await searchMetadataWithHttpInfo(metadataSearchDto,); + Future searchAssets(MetadataSearchDto metadataSearchDto,) async { + final response = await searchAssetsWithHttpInfo(metadataSearchDto,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } diff --git a/open-api/immich-openapi-specs.json b/open-api/immich-openapi-specs.json index 5f907340e9612..f79358db4d7dc 100644 --- a/open-api/immich-openapi-specs.json +++ b/open-api/immich-openapi-specs.json @@ -4409,7 +4409,7 @@ }, "/search/metadata": { "post": { - "operationId": "searchMetadata", + "operationId": "searchAssets", "parameters": [], "requestBody": { "content": { diff --git a/open-api/typescript-sdk/src/fetch-client.ts b/open-api/typescript-sdk/src/fetch-client.ts index f47c63a9890d9..5e9cd4c5344a4 100644 --- a/open-api/typescript-sdk/src/fetch-client.ts +++ b/open-api/typescript-sdk/src/fetch-client.ts @@ -2479,7 +2479,7 @@ export function getExploreData(opts?: Oazapfts.RequestOpts) { ...opts })); } -export function searchMetadata({ metadataSearchDto }: { +export function searchAssets({ metadataSearchDto }: { metadataSearchDto: MetadataSearchDto; }, opts?: Oazapfts.RequestOpts) { return oazapfts.ok(oazapfts.fetchJson<{ diff --git a/server/src/controllers/search.controller.ts b/server/src/controllers/search.controller.ts index 9fdb2746fc1d3..367c39dae9db6 100644 --- a/server/src/controllers/search.controller.ts +++ b/server/src/controllers/search.controller.ts @@ -25,7 +25,7 @@ export class SearchController { @Post('metadata') @HttpCode(HttpStatus.OK) @Authenticated() - searchMetadata(@Auth() auth: AuthDto, @Body() dto: MetadataSearchDto): Promise { + searchAssets(@Auth() auth: AuthDto, @Body() dto: MetadataSearchDto): Promise { return this.service.searchMetadata(auth, dto); } diff --git a/web/src/routes/(user)/search/[[photos=photos]]/[[assetId=id]]/+page.svelte b/web/src/routes/(user)/search/[[photos=photos]]/[[assetId=id]]/+page.svelte index 4605a2207eb47..f0c938588fdd5 100644 --- a/web/src/routes/(user)/search/[[photos=photos]]/[[assetId=id]]/+page.svelte +++ b/web/src/routes/(user)/search/[[photos=photos]]/[[assetId=id]]/+page.svelte @@ -22,8 +22,8 @@ import { shortcut } from '$lib/actions/shortcut'; import { type AssetResponseDto, + searchAssets, searchSmart, - searchMetadata, getPerson, type SmartSearchDto, type MetadataSearchDto, @@ -152,7 +152,7 @@ const { albums, assets } = 'query' in searchDto && $featureFlags.smartSearch ? await searchSmart({ smartSearchDto: searchDto }) - : await searchMetadata({ metadataSearchDto: searchDto }); + : await searchAssets({ metadataSearchDto: searchDto }); searchResultAlbums.push(...albums.items); searchResultAssets.push(...assets.items);