From 5e9a7b17d9d67d5d70b10c55ed725e02c888090b Mon Sep 17 00:00:00 2001 From: Daniel Dietzler <36593685+danieldietzler@users.noreply.github.com> Date: Fri, 21 Jun 2024 01:02:05 +0200 Subject: [PATCH] fix(server): allow library id to be null in metadata search (#10512) * fix: allow library id to be null in metadata search * chore: open api --- e2e/src/api/specs/search.e2e-spec.ts | 7 +++++++ .../lib/model/metadata_search_dto.dart | Bin 30685 -> 30336 bytes .../openapi/lib/model/smart_search_dto.dart | Bin 22952 -> 22603 bytes open-api/immich-openapi-specs.json | 2 ++ open-api/typescript-sdk/src/fetch-client.ts | 4 ++-- server/src/dtos/search.dto.ts | 4 ++-- server/src/interfaces/search.interface.ts | 2 +- server/src/utils/database.ts | 5 +++++ server/src/validation.ts | 6 +++--- 9 files changed, 22 insertions(+), 8 deletions(-) diff --git a/e2e/src/api/specs/search.e2e-spec.ts b/e2e/src/api/specs/search.e2e-spec.ts index f46c07e0b8..b49dac642e 100644 --- a/e2e/src/api/specs/search.e2e-spec.ts +++ b/e2e/src/api/specs/search.e2e-spec.ts @@ -339,6 +339,13 @@ describe('/search', () => { should: 'should search by model', deferred: () => ({ dto: { model: 'Canon EOS 7D' }, assets: [assetDenali] }), }, + { + should: 'should allow searching the upload library (libraryId: null)', + deferred: () => ({ + dto: { libraryId: null, size: 1 }, + assets: [assetLast], + }), + }, ]; for (const { should, deferred } of searchTests) { diff --git a/mobile/openapi/lib/model/metadata_search_dto.dart b/mobile/openapi/lib/model/metadata_search_dto.dart index 322373ee5815dcbb6b6a3824f2dbeaf85c6a6f48..d77f2e7736c69d6bd0998654eef54c6be646ad33 100644 GIT binary patch delta 13 Ucmccnp0VLA v !== undefined, validationOptions); } -type UUIDOptions = { optional?: boolean; each?: boolean }; +type UUIDOptions = { optional?: boolean; each?: boolean; nullable?: boolean }; export const ValidateUUID = (options?: UUIDOptions) => { - const { optional, each } = { optional: false, each: false, ...options }; + const { optional, each, nullable } = { optional: false, each: false, nullable: false, ...options }; return applyDecorators( IsUUID('4', { each }), ApiProperty({ format: 'uuid' }), - optional ? Optional() : IsNotEmpty(), + optional ? Optional({ nullable }) : IsNotEmpty(), each ? IsArray() : IsString(), ); };