From d6886027109af42be2e3ec5d14ad166199add11d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 29 Jul 2021 11:54:38 +0200 Subject: Refactor search query options --- shared/core-utils/utils/object.ts | 4 ++-- shared/models/search/video-channels-search-query.model.ts | 6 ++++++ shared/models/search/video-playlists-search-query.model.ts | 8 ++++++++ shared/models/search/videos-common-query.model.ts | 6 ++++++ shared/models/search/videos-search-query.model.ts | 8 +++++++- 5 files changed, 29 insertions(+), 3 deletions(-) (limited to 'shared') diff --git a/shared/core-utils/utils/object.ts b/shared/core-utils/utils/object.ts index 7b2bb81d0..9a8a98f9b 100644 --- a/shared/core-utils/utils/object.ts +++ b/shared/core-utils/utils/object.ts @@ -1,5 +1,5 @@ -function pick (object: T, keys: (keyof T)[]) { - const result: Partial = {} +function pick (object: O, keys: K[]): Pick { + const result: any = {} for (const key of keys) { if (Object.prototype.hasOwnProperty.call(object, key)) { diff --git a/shared/models/search/video-channels-search-query.model.ts b/shared/models/search/video-channels-search-query.model.ts index 77cea4a59..b68a1e80b 100644 --- a/shared/models/search/video-channels-search-query.model.ts +++ b/shared/models/search/video-channels-search-query.model.ts @@ -10,3 +10,9 @@ export interface VideoChannelsSearchQuery extends SearchTargetQuery { host?: string handles?: string[] } + +export interface VideoChannelsSearchQueryAfterSanitize extends VideoChannelsSearchQuery { + start: number + count: number + sort: string +} diff --git a/shared/models/search/video-playlists-search-query.model.ts b/shared/models/search/video-playlists-search-query.model.ts index 55393c92a..d9027eb5b 100644 --- a/shared/models/search/video-playlists-search-query.model.ts +++ b/shared/models/search/video-playlists-search-query.model.ts @@ -8,5 +8,13 @@ export interface VideoPlaylistsSearchQuery extends SearchTargetQuery { sort?: string host?: string + + // UUIDs or short UUIDs uuids?: string[] } + +export interface VideoPlaylistsSearchQueryAfterSanitize extends VideoPlaylistsSearchQuery { + start: number + count: number + sort: string +} diff --git a/shared/models/search/videos-common-query.model.ts b/shared/models/search/videos-common-query.model.ts index 179266338..2f2e9a934 100644 --- a/shared/models/search/videos-common-query.model.ts +++ b/shared/models/search/videos-common-query.model.ts @@ -25,6 +25,12 @@ export interface VideosCommonQuery { skipCount?: boolean } +export interface VideosCommonQueryAfterSanitize extends VideosCommonQuery { + start: number + count: number + sort: string +} + export interface VideosWithSearchCommonQuery extends VideosCommonQuery { search?: string } diff --git a/shared/models/search/videos-search-query.model.ts b/shared/models/search/videos-search-query.model.ts index 736d89577..a5436879d 100644 --- a/shared/models/search/videos-search-query.model.ts +++ b/shared/models/search/videos-search-query.model.ts @@ -15,6 +15,12 @@ export interface VideosSearchQuery extends SearchTargetQuery, VideosCommonQuery durationMin?: number // seconds durationMax?: number // seconds - // UUIDs or short + // UUIDs or short UUIDs uuids?: string[] } + +export interface VideosSearchQueryAfterSanitize extends VideosSearchQuery { + start: number + count: number + sort: string +} -- cgit v1.2.3