mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-08 04:50:12 +02:00
use tags list for Navidrome genres to support counts
This commit is contained in:
@@ -442,18 +442,18 @@ const normalizePlaylist = (
|
||||
};
|
||||
|
||||
const normalizeGenre = (
|
||||
item: z.infer<typeof ndType._response.genre>,
|
||||
item: z.infer<typeof ndType._response.genre> & { albumCount?: number; songCount?: number },
|
||||
server: null | ServerListItem,
|
||||
): Genre => {
|
||||
return {
|
||||
_itemType: LibraryItem.GENRE,
|
||||
_serverId: server?.id || 'unknown',
|
||||
_serverType: ServerType.NAVIDROME,
|
||||
albumCount: null,
|
||||
albumCount: item.albumCount ?? null,
|
||||
id: item.id,
|
||||
imageUrl: null,
|
||||
name: item.name,
|
||||
songCount: null,
|
||||
songCount: item.songCount ?? null,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -235,6 +235,8 @@ const paginationParameters = z.object({
|
||||
_start: z.number().optional(),
|
||||
});
|
||||
|
||||
const optionalPaginationParameters = paginationParameters.partial();
|
||||
|
||||
const authenticate = z.object({
|
||||
id: z.string(),
|
||||
isAdmin: z.boolean(),
|
||||
@@ -578,7 +580,18 @@ const tag = z.object({
|
||||
tagValue: z.string(),
|
||||
});
|
||||
|
||||
const tags = z.array(tag);
|
||||
const tagList = z.array(tag);
|
||||
|
||||
export enum NDTagListSort {
|
||||
TAG_VALUE = 'tagValue',
|
||||
}
|
||||
|
||||
const tagListParameters = optionalPaginationParameters.extend({
|
||||
_sort: z.nativeEnum(NDTagListSort).optional(),
|
||||
library_id: z.array(z.string()).optional(),
|
||||
tag_name: z.string().optional(),
|
||||
tag_value: z.string().optional(), // Search
|
||||
});
|
||||
|
||||
export const ndType = {
|
||||
_enum: {
|
||||
@@ -587,6 +600,7 @@ export const ndType = {
|
||||
genreList: genreListSort,
|
||||
playlistList: NDPlaylistListSort,
|
||||
songList: NDSongListSort,
|
||||
tagList: NDTagListSort,
|
||||
userList: ndUserListSort,
|
||||
},
|
||||
_parameters: {
|
||||
@@ -601,6 +615,7 @@ export const ndType = {
|
||||
removeFromPlaylist: removeFromPlaylistParameters,
|
||||
shareItem: shareItemParameters,
|
||||
songList: songListParameters,
|
||||
tagList: tagListParameters,
|
||||
updatePlaylist: updatePlaylistParameters,
|
||||
userList: userListParameters,
|
||||
},
|
||||
@@ -625,7 +640,7 @@ export const ndType = {
|
||||
shareItem,
|
||||
song,
|
||||
songList,
|
||||
tags,
|
||||
tagList,
|
||||
updatePlaylist,
|
||||
user,
|
||||
userList,
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
NDPlaylistListSort,
|
||||
NDSongListSort,
|
||||
NDSortOrder,
|
||||
NDTagListSort,
|
||||
NDUserListSort,
|
||||
} from '/@/shared/api/navidrome/navidrome-types';
|
||||
import { ServerFeatures } from '/@/shared/types/features-types';
|
||||
@@ -159,6 +160,10 @@ export enum ImageType {
|
||||
SCREENSHOT = 'SCREENSHOT',
|
||||
}
|
||||
|
||||
export enum TagListSort {
|
||||
TAG_VALUE = 'tagValue',
|
||||
}
|
||||
|
||||
export type Album = {
|
||||
_itemType: LibraryItem.ALBUM;
|
||||
_serverId: string;
|
||||
@@ -399,6 +404,24 @@ export const genreListSortMap: GenreListSortMap = {
|
||||
},
|
||||
};
|
||||
|
||||
type TagListSortMap = {
|
||||
jellyfin: Record<TagListSort, undefined>;
|
||||
navidrome: Record<TagListSort, NDTagListSort | undefined>;
|
||||
subsonic: Record<TagListSort, undefined>;
|
||||
};
|
||||
|
||||
export const tagListSortMap: TagListSortMap = {
|
||||
jellyfin: {
|
||||
tagValue: undefined,
|
||||
},
|
||||
navidrome: {
|
||||
tagValue: NDTagListSort.TAG_VALUE,
|
||||
},
|
||||
subsonic: {
|
||||
tagValue: undefined,
|
||||
},
|
||||
};
|
||||
|
||||
export enum AlbumListSort {
|
||||
ALBUM_ARTIST = 'albumArtist',
|
||||
ARTIST = 'artist',
|
||||
@@ -1224,7 +1247,7 @@ export type ControllerEndpoint = {
|
||||
getSongListCount: (args: SongListCountArgs) => Promise<number>;
|
||||
getStreamUrl: (args: StreamArgs) => string;
|
||||
getStructuredLyrics?: (args: StructuredLyricsArgs) => Promise<StructuredLyric[]>;
|
||||
getTags?: (args: TagArgs) => Promise<TagsResponse>;
|
||||
getTagList?: (args: TagListArgs) => Promise<TagListResponse>;
|
||||
getTopSongs: (args: TopSongListArgs) => Promise<TopSongListResponse>;
|
||||
getUserList?: (args: UserListArgs) => Promise<UserListResponse>;
|
||||
movePlaylistItem?: (args: MoveItemArgs) => Promise<void>;
|
||||
@@ -1316,7 +1339,7 @@ export type InternalControllerEndpoint = {
|
||||
getStructuredLyrics?: (
|
||||
args: ReplaceApiClientProps<StructuredLyricsArgs>,
|
||||
) => Promise<StructuredLyric[]>;
|
||||
getTags?: (args: ReplaceApiClientProps<TagArgs>) => Promise<TagsResponse>;
|
||||
getTagList?: (args: ReplaceApiClientProps<TagListArgs>) => Promise<TagListResponse>;
|
||||
getTopSongs: (args: ReplaceApiClientProps<TopSongListArgs>) => Promise<TopSongListResponse>;
|
||||
getUserList?: (args: ReplaceApiClientProps<UserListArgs>) => Promise<UserListResponse>;
|
||||
movePlaylistItem?: (args: ReplaceApiClientProps<MoveItemArgs>) => Promise<void>;
|
||||
@@ -1413,16 +1436,17 @@ export type Tag = {
|
||||
options: { id: string; name: string }[];
|
||||
};
|
||||
|
||||
export type TagArgs = BaseEndpointArgs & {
|
||||
query: TagQuery;
|
||||
export type TagListArgs = BaseEndpointArgs & {
|
||||
query: TagListQuery;
|
||||
};
|
||||
|
||||
export type TagQuery = {
|
||||
export type TagListQuery = {
|
||||
folder?: string;
|
||||
tagName?: string;
|
||||
type: LibraryItem.ALBUM | LibraryItem.SONG;
|
||||
};
|
||||
|
||||
export type TagsResponse = {
|
||||
export type TagListResponse = {
|
||||
boolTags?: string[];
|
||||
enumTags?: { name: string; options: { id: string; name: string }[] }[];
|
||||
excluded: {
|
||||
|
||||
Reference in New Issue
Block a user