From 9e1e9b1fbfc0ced99f6729d425e483bd3945fe82 Mon Sep 17 00:00:00 2001
From: Jason Rasmussen <jason@rasm.me>
Date: Wed, 20 Nov 2024 14:47:25 -0500
Subject: [PATCH] refactor: rename searchMetadata to searchAssets (#14151)

---
 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                      | Bin 32074 -> 32070 bytes
 mobile/openapi/lib/api/search_api.dart        | Bin 14927 -> 14921 bytes
 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, 28 insertions(+), 28 deletions(-)

diff --git a/e2e/src/api/specs/library.e2e-spec.ts b/e2e/src/api/specs/library.e2e-spec.ts
index bf0bd4a9c6..3f910fa1e3 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 0bfc0ec19b..f86f38ab61 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 619ef601e2..14225ff063 100644
--- a/e2e/src/utils.ts
+++ b/e2e/src/utils.ts
@@ -27,7 +27,7 @@ import {
   getAssetInfo,
   getConfigDefaults,
   login,
-  searchMetadata,
+  searchAssets,
   setBaseUrl,
   signUpAdmin,
   tagAssets,
@@ -405,8 +405,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 54d57c4dfc..f4fcd8a6dd 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 3dd0106c09..14e53c3ce4 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 755ffe03f121a48e1274264c5c5420131741f11f..77809359023ba5fb9585545f3f20beb7cb360230 100644
GIT binary patch
delta 29
lcmX^0i}Bbm#tq@RY>vgnsU^je59-QHE)*2mJW+S2KLE$9408Yg

delta 36
mcmX^1i}BPi#tq@R9KNX~i7AOCiIZb>WjJ!7oXz#R$Nd2wXb#%|

diff --git a/mobile/openapi/lib/api/search_api.dart b/mobile/openapi/lib/api/search_api.dart
index 985029f106d275bb686ce3bbc958dd4d11f9043c..70af3ab0a393ae48eb64bc0c53f98781aa0584cb 100644
GIT binary patch
delta 42
mcmX?Ka<XKDgCv_{adB!%@n#Rn^Gs0oWO<nYm~gqw4Oswa<q$If

delta 48
pcmX?Ea=v7PgCvJ<YDr>BVoBm=H_7u%aNcBTnE*IvbD_))SpdyO5;p(<

diff --git a/open-api/immich-openapi-specs.json b/open-api/immich-openapi-specs.json
index 1770a4a024..4674232139 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 df83dfcede..ddec0f2421 100644
--- a/open-api/typescript-sdk/src/fetch-client.ts
+++ b/open-api/typescript-sdk/src/fetch-client.ts
@@ -2483,7 +2483,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 9fdb2746fc..367c39dae9 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<SearchResponseDto> {
+  searchAssets(@Auth() auth: AuthDto, @Body() dto: MetadataSearchDto): Promise<SearchResponseDto> {
     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 65a20b5e97..c800dd7014 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
@@ -24,8 +24,8 @@
   import { shortcut } from '$lib/actions/shortcut';
   import {
     type AssetResponseDto,
+    searchAssets,
     searchSmart,
-    searchMetadata,
     getPerson,
     type SmartSearchDto,
     type MetadataSearchDto,
@@ -156,7 +156,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);