diff --git a/src/renderer/api/jellyfin/jellyfin-controller.ts b/src/renderer/api/jellyfin/jellyfin-controller.ts index 8e02105b..fd54c5c4 100644 --- a/src/renderer/api/jellyfin/jellyfin-controller.ts +++ b/src/renderer/api/jellyfin/jellyfin-controller.ts @@ -2,9 +2,8 @@ import chunk from 'lodash/chunk'; import { z } from 'zod'; import { jfApiClient } from '/@/renderer/api/jellyfin/jellyfin-api'; -import { JFSongListSort, JFSortOrder } from '/@/shared/api/jellyfin.types'; import { jfNormalize } from '/@/shared/api/jellyfin/jellyfin-normalize'; -import { jfType } from '/@/shared/api/jellyfin/jellyfin-types'; +import { JFSongListSort, JFSortOrder, jfType } from '/@/shared/api/jellyfin/jellyfin-types'; import { getFeatures, hasFeature, VersionInfo } from '/@/shared/api/utils'; import { albumArtistListSortMap, diff --git a/src/renderer/api/navidrome/navidrome-controller.ts b/src/renderer/api/navidrome/navidrome-controller.ts index 4755926e..b2803e48 100644 --- a/src/renderer/api/navidrome/navidrome-controller.ts +++ b/src/renderer/api/navidrome/navidrome-controller.ts @@ -1,8 +1,8 @@ import { ndApiClient } from '/@/renderer/api/navidrome/navidrome-api'; import { ssApiClient } from '/@/renderer/api/subsonic/subsonic-api'; import { SubsonicController } from '/@/renderer/api/subsonic/subsonic-controller'; -import { NDSongListSort } from '/@/shared/api/navidrome.types'; import { ndNormalize } from '/@/shared/api/navidrome/navidrome-normalize'; +import { NDSongListSort } from '/@/shared/api/navidrome/navidrome-types'; import { ssNormalize } from '/@/shared/api/subsonic/subsonic-normalize'; import { getFeatures, hasFeature, VersionInfo } from '/@/shared/api/utils'; import { diff --git a/src/renderer/features/albums/components/navidrome-album-filters.tsx b/src/renderer/features/albums/components/navidrome-album-filters.tsx index 250cb376..1ed1315b 100644 --- a/src/renderer/features/albums/components/navidrome-album-filters.tsx +++ b/src/renderer/features/albums/components/navidrome-album-filters.tsx @@ -16,7 +16,7 @@ import { useListStoreActions, useListStoreByKey, } from '/@/renderer/store'; -import { NDSongQueryFields } from '/@/shared/api/navidrome.types'; +import { NDSongQueryFields } from '/@/shared/api/navidrome/navidrome-types'; import { hasFeature } from '/@/shared/api/utils'; import { Divider } from '/@/shared/components/divider/divider'; import { Group } from '/@/shared/components/group/group'; diff --git a/src/renderer/features/playlists/components/playlist-query-builder.tsx b/src/renderer/features/playlists/components/playlist-query-builder.tsx index c9983b6c..ae0bddb4 100644 --- a/src/renderer/features/playlists/components/playlist-query-builder.tsx +++ b/src/renderer/features/playlists/components/playlist-query-builder.tsx @@ -23,7 +23,7 @@ import { NDSongQueryNumberOperators, NDSongQueryPlaylistOperators, NDSongQueryStringOperators, -} from '/@/shared/api/navidrome.types'; +} from '/@/shared/api/navidrome/navidrome-types'; import { ActionIcon } from '/@/shared/components/action-icon/action-icon'; import { Button } from '/@/shared/components/button/button'; import { DropdownMenu } from '/@/shared/components/dropdown-menu/dropdown-menu'; diff --git a/src/renderer/features/playlists/utils.ts b/src/renderer/features/playlists/utils.ts index 792cbda3..823cd24b 100644 --- a/src/renderer/features/playlists/utils.ts +++ b/src/renderer/features/playlists/utils.ts @@ -1,6 +1,6 @@ import { nanoid } from 'nanoid/non-secure'; -import { NDSongQueryFields } from '/@/shared/api/navidrome.types'; +import { NDSongQueryFields } from '/@/shared/api/navidrome/navidrome-types'; import { QueryBuilderGroup } from '/@/shared/types/types'; export const parseQueryBuilderChildren = (groups: QueryBuilderGroup[], data: any[]) => { diff --git a/src/renderer/features/songs/components/navidrome-song-filters.tsx b/src/renderer/features/songs/components/navidrome-song-filters.tsx index 0e1a1821..4472a9ab 100644 --- a/src/renderer/features/songs/components/navidrome-song-filters.tsx +++ b/src/renderer/features/songs/components/navidrome-song-filters.tsx @@ -15,7 +15,7 @@ import { useListFilterByKey, useListStoreActions, } from '/@/renderer/store'; -import { NDSongQueryFields } from '/@/shared/api/navidrome.types'; +import { NDSongQueryFields } from '/@/shared/api/navidrome/navidrome-types'; import { hasFeature } from '/@/shared/api/utils'; import { Divider } from '/@/shared/components/divider/divider'; import { Group } from '/@/shared/components/group/group'; diff --git a/src/shared/api/jellyfin.types.ts b/src/shared/api/jellyfin.types.ts deleted file mode 100644 index 216011db..00000000 --- a/src/shared/api/jellyfin.types.ts +++ /dev/null @@ -1,639 +0,0 @@ -export enum JFAlbumArtistListSort { - ALBUM = 'Album,SortName', - DURATION = 'Runtime,AlbumArtist,Album,SortName', - NAME = 'SortName,Name', - RANDOM = 'Random,SortName', - RECENTLY_ADDED = 'DateCreated,SortName', - RELEASE_DATE = 'PremiereDate,AlbumArtist,Album,SortName', -} - -export enum JFAlbumListSort { - ALBUM_ARTIST = 'AlbumArtist,SortName', - COMMUNITY_RATING = 'CommunityRating,SortName', - CRITIC_RATING = 'CriticRating,SortName', - NAME = 'SortName', - PLAY_COUNT = 'PlayCount', - RANDOM = 'Random,SortName', - RECENTLY_ADDED = 'DateCreated,SortName', - RELEASE_DATE = 'ProductionYear,PremiereDate,SortName', -} - -export enum JFArtistListSort { - ALBUM = 'Album,SortName', - DURATION = 'Runtime,AlbumArtist,Album,SortName', - NAME = 'SortName,Name', - RANDOM = 'Random,SortName', - RECENTLY_ADDED = 'DateCreated,SortName', - RELEASE_DATE = 'PremiereDate,AlbumArtist,Album,SortName', -} - -export enum JFCollectionType { - MUSIC = 'music', - PLAYLISTS = 'playlists', -} - -export enum JFExternalType { - MUSICBRAINZ = 'MusicBrainz', - THEAUDIODB = 'TheAudioDb', -} - -export enum JFGenreListSort { - NAME = 'SortName', -} - -export enum JFImageType { - LOGO = 'Logo', - PRIMARY = 'Primary', -} - -export enum JFItemType { - AUDIO = 'Audio', - MUSICALBUM = 'MusicAlbum', -} - -export enum JFPlaylistListSort { - ALBUM_ARTIST = 'AlbumArtist,SortName', - DURATION = 'Runtime', - NAME = 'SortName', - RECENTLY_ADDED = 'DateCreated,SortName', - SONG_COUNT = 'ChildCount', -} - -export enum JFSongListSort { - ALBUM = 'Album,SortName', - ALBUM_ARTIST = 'AlbumArtist,Album,SortName', - ARTIST = 'Artist,Album,SortName', - COMMUNITY_RATING = 'CommunityRating,SortName', - DURATION = 'Runtime,AlbumArtist,Album,SortName', - NAME = 'Name', - PLAY_COUNT = 'PlayCount,SortName', - RANDOM = 'Random,SortName', - RECENTLY_ADDED = 'DateCreated,SortName', - RECENTLY_PLAYED = 'DatePlayed,SortName', - RELEASE_DATE = 'PremiereDate,AlbumArtist,Album,SortName', -} - -export enum JFSortOrder { - ASC = 'Ascending', - DESC = 'Descending', -} - -export type JFAddToPlaylist = null; - -export type JFAddToPlaylistParams = { - ids: string[]; - userId: string; -}; - -export type JFAddToPlaylistResponse = { - added: number; -}; - -export type JFAlbum = { - AlbumArtist: string; - AlbumArtists: JFGenericItem[]; - AlbumPrimaryImageTag: string; - ArtistItems: JFGenericItem[]; - Artists: string[]; - ChannelId: null; - ChildCount?: number; - DateCreated: string; - DateLastMediaAdded?: string; - ExternalUrls: ExternalURL[]; - GenreItems: JFGenericItem[]; - Genres: string[]; - Id: string; - ImageBlurHashes: ImageBlurHashes; - ImageTags: ImageTags; - IsFolder: boolean; - LocationType: string; - Name: string; - ParentLogoImageTag: string; - ParentLogoItemId: string; - PremiereDate?: string; - ProductionYear: number; - RunTimeTicks: number; - ServerId: string; - Type: string; - UserData?: UserData; -} & { - songs?: JFSong[]; -}; - -export type JFAlbumArtist = { - BackdropImageTags: string[]; - ChannelId: null; - DateCreated: string; - ExternalUrls: ExternalURL[]; - GenreItems: GenreItem[]; - Genres: string[]; - Id: string; - ImageBlurHashes: any; - ImageTags: ImageTags; - LocationType: string; - Name: string; - Overview?: string; - RunTimeTicks: number; - ServerId: string; - Type: string; - UserData: { - IsFavorite: boolean; - Key: string; - PlaybackPositionTicks: number; - PlayCount: number; - Played: boolean; - }; -} & { - similarArtists: { - items: JFAlbumArtist[]; - }; -}; - -export type JFAlbumArtistDetail = JFAlbumArtistDetailResponse; - -export type JFAlbumArtistDetailResponse = JFAlbumArtist; - -export type JFAlbumArtistList = { - items: JFAlbumArtist[]; - startIndex: number; - totalRecordCount: number; -}; - -export type JFAlbumArtistListParams = JFBaseParams & - JFPaginationParams & { - filters?: string; - genres?: string; - sortBy?: JFAlbumArtistListSort; - years?: string; - }; - -export interface JFAlbumArtistListResponse extends JFBasePaginatedResponse { - Items: JFAlbumArtist[]; -} - -export type JFAlbumDetail = JFAlbum & { songs?: JFSong[] }; - -export type JFAlbumDetailResponse = JFAlbum; - -export type JFAlbumList = { - items: JFAlbum[]; - startIndex: number; - totalRecordCount: number; -}; - -export type JFAlbumListParams = JFBaseParams & - JFPaginationParams & { - albumArtistIds?: string; - artistIds?: string; - filters?: string; - genreIds?: string; - genres?: string; - includeItemTypes: 'MusicAlbum'; - isFavorite?: boolean; - searchTerm?: string; - sortBy?: JFAlbumListSort; - tags?: string; - years?: string; - }; - -export interface JFAlbumListResponse extends JFBasePaginatedResponse { - Items: JFAlbum[]; -} - -export type JFArtist = { - BackdropImageTags: string[]; - ChannelId: null; - DateCreated: string; - ExternalUrls: ExternalURL[]; - GenreItems: GenreItem[]; - Genres: string[]; - Id: string; - ImageBlurHashes: any; - ImageTags: string[]; - LocationType: string; - Name: string; - Overview?: string; - RunTimeTicks: number; - ServerId: string; - Type: string; -}; - -export type JFArtistList = JFArtistListResponse; - -export type JFArtistListParams = JFBaseParams & - JFPaginationParams & { - filters?: string; - genres?: string; - sortBy?: JFArtistListSort; - years?: string; - }; - -export interface JFArtistListResponse extends JFBasePaginatedResponse { - Items: JFAlbumArtist[]; -} - -export interface JFAuthenticate { - AccessToken: string; - ServerId: string; - SessionInfo: SessionInfo; - User: User; -} - -export type JFBasePaginatedResponse = { - StartIndex: number; - TotalRecordCount: number; -}; - -export type JFCreatePlaylist = JFCreatePlaylistResponse; - -export type JFCreatePlaylistResponse = { - Id: string; -}; - -export type JFGenericItem = { - Id: string; - Name: string; -}; - -export type JFGenre = { - BackdropImageTags: any[]; - ChannelId: null; - Id: string; - ImageBlurHashes: any; - ImageTags: ImageTags; - LocationType: string; - Name: string; - ServerId: string; - Type: string; -}; - -export type JFGenreList = JFGenreListResponse; - -export interface JFGenreListResponse extends JFBasePaginatedResponse { - Items: JFGenre[]; -} - -export type JFMusicFolder = { - BackdropImageTags: string[]; - ChannelId: null; - CollectionType: string; - Id: string; - ImageBlurHashes: ImageBlurHashes; - ImageTags: ImageTags; - IsFolder: boolean; - LocationType: string; - Name: string; - ServerId: string; - Type: string; - UserData: UserData; -}; - -export type JFMusicFolderList = JFMusicFolder[]; - -export interface JFMusicFolderListResponse extends JFBasePaginatedResponse { - Items: JFMusicFolder[]; -} - -export type JFPlaylist = { - BackdropImageTags: string[]; - ChannelId: null; - ChildCount?: number; - DateCreated: string; - GenreItems: GenreItem[]; - Genres: string[]; - Id: string; - ImageBlurHashes: ImageBlurHashes; - ImageTags: ImageTags; - IsFolder: boolean; - LocationType: string; - MediaType: string; - Name: string; - Overview?: string; - RunTimeTicks: number; - ServerId: string; - Type: string; - UserData: UserData; -}; - -export type JFPlaylistDetail = JFPlaylist & { songs?: JFSong[] }; - -export type JFPlaylistDetailResponse = JFPlaylist; - -export type JFPlaylistList = { - items: JFPlaylist[]; - startIndex: number; - totalRecordCount: number; -}; - -export interface JFPlaylistListResponse extends JFBasePaginatedResponse { - Items: JFPlaylist[]; -} - -export type JFRemoveFromPlaylist = null; - -export type JFRemoveFromPlaylistParams = { - entryIds: string[]; -}; - -export type JFRemoveFromPlaylistResponse = null; - -export type JFRequestParams = { - albumArtistIds?: string; - artistIds?: string; - enableImageTypes?: string; - enableTotalRecordCount?: boolean; - enableUserData?: boolean; - excludeItemTypes?: string; - fields?: string; - imageTypeLimit?: number; - includeItemTypes?: string; - isFavorite?: boolean; - limit?: number; - parentId?: string; - recursive?: boolean; - searchTerm?: string; - sortBy?: string; - sortOrder?: 'Ascending' | 'Descending'; - startIndex?: number; - userId?: string; -}; - -export type JFSong = { - Album: string; - AlbumArtist: string; - AlbumArtists: JFGenericItem[]; - AlbumId: string; - AlbumPrimaryImageTag: string; - ArtistItems: JFGenericItem[]; - Artists: string[]; - BackdropImageTags: string[]; - ChannelId: null; - DateCreated: string; - ExternalUrls: ExternalURL[]; - GenreItems: JFGenericItem[]; - Genres: string[]; - Id: string; - ImageBlurHashes: ImageBlurHashes; - ImageTags: ImageTags; - IndexNumber: number; - IsFolder: boolean; - LocationType: string; - MediaSources: MediaSources[]; - MediaType: string; - Name: string; - ParentIndexNumber: number; - PlaylistItemId?: string; - PremiereDate?: string; - ProductionYear: number; - RunTimeTicks: number; - ServerId: string; - SortName: string; - Type: string; - UserData?: UserData; -}; - -export type JFSongList = { - items: JFSong[]; - startIndex: number; - totalRecordCount: number; -}; - -export type JFSongListParams = JFBaseParams & - JFPaginationParams & { - albumArtistIds?: string; - albumIds?: string; - artistIds?: string; - contributingArtistIds?: string; - filters?: string; - genreIds?: string; - genres?: string; - ids?: string; - includeItemTypes: 'Audio'; - searchTerm?: string; - sortBy?: JFSongListSort; - years?: string; - }; - -export interface JFSongListResponse extends JFBasePaginatedResponse { - Items: JFSong[]; -} - -type Capabilities = { - PlayableMediaTypes: any[]; - SupportedCommands: any[]; - SupportsContentUploading: boolean; - SupportsMediaControl: boolean; - SupportsPersistentIdentifier: boolean; - SupportsSync: boolean; -}; - -type Configuration = { - DisplayCollectionsView: boolean; - DisplayMissingEpisodes: boolean; - EnableLocalPassword: boolean; - EnableNextEpisodeAutoPlay: boolean; - GroupedFolders: any[]; - HidePlayedInLatest: boolean; - LatestItemsExcludes: any[]; - MyMediaExcludes: any[]; - OrderedViews: any[]; - PlayDefaultAudioTrack: boolean; - RememberAudioSelections: boolean; - RememberSubtitleSelections: boolean; - SubtitleLanguagePreference: string; - SubtitleMode: string; -}; - -type ExternalURL = { - Name: string; - Url: string; -}; - -type GenreItem = { - Id: string; - Name: string; -}; - -type ImageBlurHashes = { - Backdrop?: any; - Logo?: any; - Primary?: any; -}; - -type ImageTags = { - Logo?: string; - Primary?: string; -}; - -type JFBaseParams = { - enableImageTypes?: JFImageType[]; - fields?: string; - imageTypeLimit?: number; - parentId?: string; - recursive?: boolean; - searchTerm?: string; - userId?: string; -}; - -type JFPaginationParams = { - limit?: number; - nameStartsWith?: string; - sortOrder?: JFSortOrder; - startIndex?: number; -}; - -type MediaSources = { - Bitrate: number; - Container: string; - DefaultAudioStreamIndex: number; - ETag: string; - Formats: any[]; - GenPtsInput: boolean; - Id: string; - IgnoreDts: boolean; - IgnoreIndex: boolean; - IsInfiniteStream: boolean; - IsRemote: boolean; - MediaAttachments: any[]; - MediaStreams: MediaStream[]; - Name: string; - Path: string; - Protocol: string; - ReadAtNativeFramerate: boolean; - RequiredHttpHeaders: any; - RequiresClosing: boolean; - RequiresLooping: boolean; - RequiresOpening: boolean; - RunTimeTicks: number; - Size: number; - SupportsDirectPlay: boolean; - SupportsDirectStream: boolean; - SupportsProbing: boolean; - SupportsTranscoding: boolean; - Type: string; -}; - -type MediaStream = { - AspectRatio?: string; - BitDepth?: number; - BitRate?: number; - ChannelLayout?: string; - Channels?: number; - Codec: string; - CodecTimeBase: string; - ColorSpace?: string; - Comment?: string; - DisplayTitle?: string; - Height?: number; - Index: number; - IsDefault: boolean; - IsExternal: boolean; - IsForced: boolean; - IsInterlaced: boolean; - IsTextSubtitleStream: boolean; - Level: number; - PixelFormat?: string; - Profile?: string; - RealFrameRate?: number; - RefFrames?: number; - SampleRate?: number; - SupportsExternalStream: boolean; - TimeBase: string; - Type: string; - Width?: number; -}; - -type PlayState = { - CanSeek: boolean; - IsMuted: boolean; - IsPaused: boolean; - RepeatMode: string; -}; - -type Policy = { - AccessSchedules: any[]; - AuthenticationProviderId: string; - BlockedChannels: any[]; - BlockedMediaFolders: any[]; - BlockedTags: any[]; - BlockUnratedItems: any[]; - EnableAllChannels: boolean; - EnableAllDevices: boolean; - EnableAllFolders: boolean; - EnableAudioPlaybackTranscoding: boolean; - EnableContentDeletion: boolean; - EnableContentDeletionFromFolders: any[]; - EnableContentDownloading: boolean; - EnabledChannels: any[]; - EnabledDevices: any[]; - EnabledFolders: any[]; - EnableLiveTvAccess: boolean; - EnableLiveTvManagement: boolean; - EnableMediaConversion: boolean; - EnableMediaPlayback: boolean; - EnablePlaybackRemuxing: boolean; - EnablePublicSharing: boolean; - EnableRemoteAccess: boolean; - EnableRemoteControlOfOtherUsers: boolean; - EnableSharedDeviceControl: boolean; - EnableSyncTranscoding: boolean; - EnableUserPreferenceAccess: boolean; - EnableVideoPlaybackTranscoding: boolean; - ForceRemoteSourceTranscoding: boolean; - InvalidLoginAttemptCount: number; - IsAdministrator: boolean; - IsDisabled: boolean; - IsHidden: boolean; - LoginAttemptsBeforeLockout: number; - MaxActiveSessions: number; - PasswordResetProviderId: string; - RemoteClientBitrateLimit: number; - SyncPlayAccess: string; -}; - -type SessionInfo = { - AdditionalUsers: any[]; - ApplicationVersion: string; - Capabilities: Capabilities; - Client: string; - DeviceId: string; - DeviceName: string; - HasCustomDeviceName: boolean; - Id: string; - IsActive: boolean; - LastActivityDate: string; - LastPlaybackCheckIn: string; - NowPlayingQueue: any[]; - NowPlayingQueueFullItems: any[]; - PlayableMediaTypes: any[]; - PlayState: PlayState; - RemoteEndPoint: string; - ServerId: string; - SupportedCommands: any[]; - SupportsMediaControl: boolean; - SupportsRemoteControl: boolean; - UserId: string; - UserName: string; -}; - -type User = { - Configuration: Configuration; - EnableAutoLogin: boolean; - HasConfiguredEasyPassword: boolean; - HasConfiguredPassword: boolean; - HasPassword: boolean; - Id: string; - LastActivityDate: string; - LastLoginDate: string; - Name: string; - Policy: Policy; - ServerId: string; -}; - -type UserData = { - IsFavorite: boolean; - Key: string; - PlaybackPositionTicks: number; - PlayCount: number; - Played: boolean; -}; diff --git a/src/shared/api/jellyfin/jellyfin-normalize.ts b/src/shared/api/jellyfin/jellyfin-normalize.ts index 36a23842..0fc1bf52 100644 --- a/src/shared/api/jellyfin/jellyfin-normalize.ts +++ b/src/shared/api/jellyfin/jellyfin-normalize.ts @@ -1,7 +1,6 @@ import { nanoid } from 'nanoid'; import { z } from 'zod'; -import { JFAlbum, JFGenre, JFMusicFolder, JFPlaylist } from '/@/shared/api/jellyfin.types'; import { jfType } from '/@/shared/api/jellyfin/jellyfin-types'; import { Album, @@ -59,7 +58,11 @@ const getAlbumArtistCoverArtUrl = (args: { ); }; -const getAlbumCoverArtUrl = (args: { baseUrl: string; item: JFAlbum; size: number }) => { +const getAlbumCoverArtUrl = (args: { + baseUrl: string; + item: z.infer; + size: number; +}) => { const size = args.size ? args.size : 300; if (!args.item.ImageTags?.Primary && !args.item?.AlbumPrimaryImageTag) { @@ -109,7 +112,11 @@ const getSongCoverArtUrl = (args: { return null; }; -const getPlaylistCoverArtUrl = (args: { baseUrl: string; item: JFPlaylist; size: number }) => { +const getPlaylistCoverArtUrl = (args: { + baseUrl: string; + item: z.infer; + size: number; +}) => { const size = args.size ? args.size : 300; if (!args.item.ImageTags?.Primary) { @@ -448,7 +455,7 @@ const normalizePlaylist = ( }; }; -const normalizeMusicFolder = (item: JFMusicFolder): MusicFolder => { +const normalizeMusicFolder = (item: z.infer): MusicFolder => { return { id: item.Id, name: item.Name, @@ -495,7 +502,10 @@ const getGenreCoverArtUrl = (args: { ); }; -const normalizeGenre = (item: JFGenre, server: null | ServerListItem): Genre => { +const normalizeGenre = ( + item: z.infer, + server: null | ServerListItem, +): Genre => { return { albumCount: undefined, id: item.Id, diff --git a/src/shared/api/jellyfin/jellyfin-types.ts b/src/shared/api/jellyfin/jellyfin-types.ts index b7a61f05..d0fef9a9 100644 --- a/src/shared/api/jellyfin/jellyfin-types.ts +++ b/src/shared/api/jellyfin/jellyfin-types.ts @@ -1,5 +1,65 @@ import { z } from 'zod'; +export enum JFAlbumArtistListSort { + ALBUM = 'Album,SortName', + DURATION = 'Runtime,AlbumArtist,Album,SortName', + NAME = 'SortName,Name', + RANDOM = 'Random,SortName', + RECENTLY_ADDED = 'DateCreated,SortName', + RELEASE_DATE = 'PremiereDate,AlbumArtist,Album,SortName', +} + +export enum JFAlbumListSort { + ALBUM_ARTIST = 'AlbumArtist,SortName', + COMMUNITY_RATING = 'CommunityRating,SortName', + CRITIC_RATING = 'CriticRating,SortName', + NAME = 'SortName', + PLAY_COUNT = 'PlayCount', + RANDOM = 'Random,SortName', + RECENTLY_ADDED = 'DateCreated,SortName', + RELEASE_DATE = 'ProductionYear,PremiereDate,SortName', +} + +export enum JFArtistListSort { + ALBUM = 'Album,SortName', + DURATION = 'Runtime,AlbumArtist,Album,SortName', + NAME = 'SortName,Name', + RANDOM = 'Random,SortName', + RECENTLY_ADDED = 'DateCreated,SortName', + RELEASE_DATE = 'PremiereDate,AlbumArtist,Album,SortName', +} + +export enum JFGenreListSort { + NAME = 'SortName', +} + +export enum JFPlaylistListSort { + ALBUM_ARTIST = 'AlbumArtist,SortName', + DURATION = 'Runtime', + NAME = 'SortName', + RECENTLY_ADDED = 'DateCreated,SortName', + SONG_COUNT = 'ChildCount', +} + +export enum JFSongListSort { + ALBUM = 'Album,SortName', + ALBUM_ARTIST = 'AlbumArtist,Album,SortName', + ARTIST = 'Artist,Album,SortName', + COMMUNITY_RATING = 'CommunityRating,SortName', + DURATION = 'Runtime,AlbumArtist,Album,SortName', + NAME = 'Name', + PLAY_COUNT = 'PlayCount,SortName', + RANDOM = 'Random,SortName', + RECENTLY_ADDED = 'DateCreated,SortName', + RECENTLY_PLAYED = 'DatePlayed,SortName', + RELEASE_DATE = 'PremiereDate,AlbumArtist,Album,SortName', +} + +export enum JFSortOrder { + ASC = 'Ascending', + DESC = 'Descending', +} + const sortOrderValues = ['Ascending', 'Descending'] as const; const jfExternal = { @@ -762,6 +822,7 @@ export const jfType = { genreList, lyrics, moveItem, + musicFolder, musicFolderList, playlist, playlistList, diff --git a/src/shared/api/navidrome.types.ts b/src/shared/api/navidrome.types.ts index 2cfb83be..e69de29b 100644 --- a/src/shared/api/navidrome.types.ts +++ b/src/shared/api/navidrome.types.ts @@ -1,535 +0,0 @@ -import { SSArtistInfo } from '/@/shared/api/subsonic.types'; - -export enum NDAlbumArtistListSort { - ALBUM_COUNT = 'albumCount', - FAVORITED = 'starred_at', - NAME = 'name', - PLAY_COUNT = 'playCount', - RATING = 'rating', - SONG_COUNT = 'songCount', -} - -export enum NDAlbumListSort { - ALBUM_ARTIST = 'album_artist', - ARTIST = 'artist', - DURATION = 'duration', - EXPLICIT_STATUS = 'explicitStatus', - NAME = 'name', - PLAY_COUNT = 'play_count', - PLAY_DATE = 'play_date', - RANDOM = 'random', - RATING = 'rating', - RECENTLY_ADDED = 'recently_added', - SONG_COUNT = 'songCount', - STARRED = 'starred_at', - YEAR = 'max_year', -} - -export enum NDGenreListSort { - NAME = 'name', -} - -export enum NDPlaylistListSort { - DURATION = 'duration', - NAME = 'name', - OWNER = 'owner_name', - PUBLIC = 'public', - SONG_COUNT = 'songCount', - UPDATED_AT = 'updatedAt', -} - -export enum NDSongListSort { - ALBUM = 'album', - ALBUM_ARTIST = 'order_album_artist_name', - ALBUM_SONGS = 'album', - ARTIST = 'artist', - BPM = 'bpm', - CHANNELS = 'channels', - COMMENT = 'comment', - DURATION = 'duration', - EXPLICIT_STATUS = 'explicitStatus', - FAVORITED = 'starred_at', - GENRE = 'genre', - ID = 'id', - PLAY_COUNT = 'playCount', - PLAY_DATE = 'playDate', - RANDOM = 'random', - RATING = 'rating', - RECENTLY_ADDED = 'createdAt', - TITLE = 'title', - TRACK = 'track', - YEAR = 'year', -} - -export enum NDSortOrder { - ASC = 'ASC', - DESC = 'DESC', -} - -export type NDAddToPlaylist = null; - -export type NDAddToPlaylistBody = { - ids: string[]; -}; - -export type NDAddToPlaylistResponse = { - added: number; -}; - -export type NDAlbum = { - albumArtist: string; - albumArtistId: string; - allArtistIds: string; - artist: string; - artistId: string; - compilation: boolean; - coverArtId?: string; // Removed after v0.48.0 - coverArtPath?: string; // Removed after v0.48.0 - createdAt: string; - duration: number; - fullText: string; - genre: string; - genres: NDGenre[]; - id: string; - maxYear: number; - mbzAlbumArtistId: string; - mbzAlbumId: string; - minYear: number; - name: string; - orderAlbumArtistName: string; - orderAlbumName: string; - playCount: number; - playDate: string; - rating: number; - size: number; - songCount: number; - sortAlbumArtistName: string; - sortArtistName: string; - starred: boolean; - starredAt: string; - updatedAt: string; -} & { songs?: NDSong[] }; - -export type NDAlbumArtist = { - albumCount: number; - biography: string; - externalInfoUpdatedAt: string; - externalUrl: string; - fullText: string; - genres: NDGenre[]; - id: string; - largeImageUrl?: string; - mbzArtistId: string; - mediumImageUrl?: string; - name: string; - orderArtistName: string; - playCount: number; - playDate: string; - rating: number; - size: number; - smallImageUrl?: string; - songCount: number; - starred: boolean; - starredAt: string; -} & { - similarArtists?: SSArtistInfo['similarArtist']; -}; - -export type NDAlbumArtistDetail = NDAlbumArtist; - -export type NDAlbumArtistDetailResponse = NDAlbumArtist; - -export type NDAlbumArtistList = { - items: NDAlbumArtist[]; - startIndex: number; - totalRecordCount: number; -}; - -export type NDAlbumArtistListParams = NDOrder & - NDPagination & { - _sort?: NDAlbumArtistListSort; - genre_id?: string; - starred?: boolean; - }; - -export type NDAlbumDetail = NDAlbum & { songs?: NDSongListResponse }; - -export type NDAlbumDetailResponse = NDAlbum; - -export type NDAlbumList = { - items: NDAlbum[]; - startIndex: number; - totalRecordCount: number; -}; - -export type NDAlbumListParams = NDOrder & - NDPagination & { - _sort?: NDAlbumListSort; - album_id?: string; - artist_id?: string; - compilation?: boolean; - genre_id?: string; - has_rating?: boolean; - id?: string; - name?: string; - recently_played?: boolean; - starred?: boolean; - year?: number; - }; - -export type NDAlbumListResponse = NDAlbum[]; - -export type NDArtistListResponse = NDAlbumArtist[]; - -export type NDAuthenticate = { - id: string; - isAdmin: boolean; - name: string; - subsonicSalt: string; - subsonicToken: string; - token: string; - username: string; -}; - -export type NDAuthenticationResponse = NDAuthenticate; - -export type NDCreatePlaylist = NDCreatePlaylistResponse; - -export type NDCreatePlaylistParams = { - comment?: string; - name: string; - public?: boolean; - rules?: null | Record; -}; - -export type NDCreatePlaylistResponse = { - id: string; -}; - -export type NDDeletePlaylist = NDDeletePlaylistResponse; - -export type NDDeletePlaylistParams = { - id: string; -}; - -export type NDDeletePlaylistResponse = null; - -export type NDGenre = { - id: string; - name: string; -}; - -export type NDGenreList = NDGenre[]; - -export type NDGenreListParams = NDOrder & - NDPagination & { - _sort?: NDGenreListSort; - id?: string; - }; - -export type NDGenreListResponse = NDGenre[]; - -export type NDOrder = { - _order?: NDSortOrder; -}; - -export type NDPagination = { - _end?: number; - _start?: number; -}; - -export type NDPlaylist = { - comment: string; - createdAt: string; - duration: number; - evaluatedAt: string; - id: string; - name: string; - ownerId: string; - ownerName: string; - path: string; - public: boolean; - rules: null | Record; - size: number; - songCount: number; - sync: boolean; - updatedAt: string; -}; - -export type NDPlaylistDetail = NDPlaylist; - -export type NDPlaylistDetailResponse = NDPlaylist; - -export type NDPlaylistList = { - items: NDPlaylist[]; - startIndex: number; - totalRecordCount: number; -}; - -export type NDPlaylistListParams = NDOrder & - NDPagination & { - _sort?: NDPlaylistListSort; - owner_id?: string; - }; - -export type NDPlaylistListResponse = NDPlaylist[]; - -export type NDPlaylistSong = NDSong & { - mediaFileId: string; - playlistId: string; -}; - -export type NDPlaylistSongList = { - items: NDPlaylistSong[]; - startIndex: number; - totalRecordCount: number; -}; - -export type NDPlaylistSongListResponse = NDPlaylistSong[]; - -export type NDRemoveFromPlaylist = null; - -export type NDRemoveFromPlaylistParams = { - id: string[]; -}; - -export type NDRemoveFromPlaylistResponse = { - ids: string[]; -}; - -export type NDSong = { - album: string; - albumArtist: string; - albumArtistId: string; - albumId: string; - artist: string; - artistId: string; - bitRate: number; - bookmarkPosition: number; - bpm?: number; - channels?: number; - comment?: string; - compilation: boolean; - createdAt: string; - discNumber: number; - duration: number; - fullText: string; - genre: string; - genres: NDGenre[]; - hasCoverArt: boolean; - id: string; - lyrics?: string; - mbzAlbumArtistId: string; - mbzAlbumId: string; - mbzArtistId: string; - mbzTrackId: string; - orderAlbumArtistName: string; - orderAlbumName: string; - orderArtistName: string; - orderTitle: string; - path: string; - playCount: number; - playDate: string; - rating: number; - size: number; - sortAlbumArtistName: string; - sortArtistName: string; - starred: boolean; - starredAt: string; - suffix: string; - title: string; - trackNumber: number; - updatedAt: string; - year: number; -}; - -export type NDSongDetail = NDSong; - -export type NDSongDetailResponse = NDSong; - -export type NDSongList = { - items: NDSong[]; - startIndex: number; - totalRecordCount: number; -}; - -export type NDSongListParams = NDOrder & - NDPagination & { - _sort?: NDSongListSort; - album_id?: string[]; - artist_id?: string[]; - genre_id?: string; - starred?: boolean; - }; - -export type NDSongListResponse = NDSong[]; - -export type NDUpdatePlaylistParams = Partial; - -export type NDUpdatePlaylistResponse = NDPlaylist; - -export type NDUser = { - createdAt: string; - email: string; - id: string; - isAdmin: boolean; - lastAccessAt: string; - lastLoginAt: string; - name: string; - updatedAt: string; - userName: string; -}; - -export const NDSongQueryFields = [ - { label: 'Album', type: 'string', value: 'album' }, - { label: 'Album Artist', type: 'string', value: 'albumartist' }, - { label: 'Album Artists', type: 'string', value: 'albumartists' }, - { label: 'Album Comment', type: 'string', value: 'albumcomment' }, - { label: 'Album Type', type: 'string', value: 'albumtype' }, - { label: 'Album Version', type: 'string', value: 'albumversion' }, - { label: 'Arranger', type: 'string', value: 'arranger' }, - { label: 'Artist', type: 'string', value: 'artist' }, - { label: 'Artists', type: 'string', value: 'artists' }, - { label: 'Barcode', type: 'string', value: 'barcode' }, - { label: 'Bitrate', type: 'number', value: 'bitrate' }, - { label: 'BPM', type: 'number', value: 'bpm' }, - { label: 'Catalog Number', type: 'string', value: 'catalognumber' }, - { label: 'Channels', type: 'number', value: 'channels' }, - { label: 'Comment', type: 'string', value: 'comment' }, - { label: 'Composer', type: 'string', value: 'composer' }, - { label: 'Conductor', type: 'string', value: 'conductor' }, - { label: 'Copyright', type: 'string', value: 'copyright' }, - { label: 'Date Added', type: 'date', value: 'dateadded' }, - { label: 'Date Favorited', type: 'date', value: 'dateloved' }, - { label: 'Date Last Played', type: 'date', value: 'lastplayed' }, - { label: 'Date Modified', type: 'date', value: 'datemodified' }, - { label: 'DJ Mixer', type: 'string', value: 'djmixer' }, - { label: 'Director', type: 'string', value: 'director' }, - { label: 'Disc Number', type: 'number', value: 'discnumber' }, - { label: 'Disc Subtitle', type: 'string', value: 'discsubtitle' }, - { label: 'Disc Total', type: 'number', value: 'disctotal' }, - { label: 'Duration', type: 'number', value: 'duration' }, - { label: 'Encoded By', type: 'string', value: 'encodedby' }, - { label: 'Encoder Settings', type: 'string', value: 'encodersettings' }, - { label: 'Engineer', type: 'string', value: 'engineer' }, - { label: 'Explicit Status', type: 'string', value: 'explicitstatus' }, - { label: 'File Path', type: 'string', value: 'filepath' }, - { label: 'File Type', type: 'string', value: 'filetype' }, - { label: 'Genre', type: 'string', value: 'genre' }, - { label: 'Grouping', type: 'string', value: 'grouping' }, - { label: 'Has CoverArt', type: 'boolean', value: 'hascoverart' }, - { label: 'Is Compilation', type: 'boolean', value: 'compilation' }, - { label: 'Is Favorite', type: 'boolean', value: 'loved' }, - { label: 'ISRC', type: 'string', value: 'isrc' }, - { label: 'Key', type: 'string', value: 'key' }, - { label: 'Language', type: 'string', value: 'language' }, - { label: 'License', type: 'string', value: 'license' }, - { label: 'Lyricist', type: 'string', value: 'lyricist' }, - { label: 'Lyrics', type: 'string', value: 'lyrics' }, - { label: 'Media', type: 'string', value: 'media' }, - { label: 'Mixer', type: 'string', value: 'mixer' }, - { label: 'Mood', type: 'string', value: 'mood' }, - { label: 'Movement', type: 'string', value: 'movement' }, - { label: 'Movement Name', type: 'string', value: 'movementname' }, - { label: 'Movement Total', type: 'number', value: 'movementtotal' }, - { label: 'MusicBrainz Artist Id', type: 'string', value: 'musicbrainz_artistid' }, - { label: 'MusicBrainz Album Artist Id', type: 'string', value: 'musicbrainz_albumartistid' }, - { label: 'MusicBrainz Album Id', type: 'string', value: 'musicbrainz_albumid' }, - { label: 'MusicBrainz Disc Id', type: 'string', value: 'musicbrainz_discid' }, - { label: 'MusicBrainz Recording Id', type: 'string', value: 'musicbrainz_recordingid' }, - { label: 'MusicBrainz Release Group Id', type: 'string', value: 'musicbrainz_releasegroupid' }, - { label: 'MusicBrainz Track Id', type: 'string', value: 'musicbrainz_trackid' }, - { label: 'MusicBrainz Work Id', type: 'string', value: 'musicbrainz_workid' }, - { label: 'Name', type: 'string', value: 'title' }, - { label: 'Original Date', type: 'date', value: 'originaldate' }, - { label: 'Performer', type: 'string', value: 'performer' }, - { label: 'Play Count', type: 'number', value: 'playcount' }, - { label: 'Playlist', type: 'playlist', value: 'id' }, - { label: 'Producer', type: 'string', value: 'producer' }, - { label: 'R128 Album Gain', type: 'number', value: 'r128_album_gain' }, - { label: 'R128 Track Gain', type: 'number', value: 'r128_track_gain' }, - { label: 'Rating', type: 'number', value: 'rating' }, - { label: 'Record Label', type: 'string', value: 'recordlabel' }, - { label: 'Recording Date', type: 'date', value: 'recordingdate' }, - { label: 'Release Country', type: 'string', value: 'releasecountry' }, - { label: 'Release Date', type: 'date', value: 'releasedate' }, - { label: 'Release Status', type: 'string', value: 'releasestatus' }, - { label: 'Release Type', type: 'string', value: 'releasetype' }, - { label: 'ReplayGain Album Gain', type: 'number', value: 'replaygain_album_gain' }, - { label: 'ReplayGain Album Peak', type: 'number', value: 'replaygain_album_peak' }, - { label: 'ReplayGain Track Gain', type: 'number', value: 'replaygain_track_gain' }, - { label: 'ReplayGain Track Peak', type: 'number', value: 'replaygain_track_peak' }, - { label: 'Remixer', type: 'string', value: 'remixer' }, - { label: 'Script', type: 'string', value: 'script' }, - { label: 'Size', type: 'number', value: 'size' }, - { label: 'Sort Album', type: 'string', value: 'albumsort' }, - { label: 'Sort Album Artist', type: 'string', value: 'albumartistsort' }, - { label: 'Sort Album Artists', type: 'string', value: 'albumartistssort' }, - { label: 'Sort Artist', type: 'string', value: 'artistsort' }, - { label: 'Sort Artists', type: 'string', value: 'artistssort' }, - { label: 'Sort Composer', type: 'string', value: 'composersort' }, - { label: 'Sort Lyricist', type: 'string', value: 'lyricistsort' }, - { label: 'Sort Name', type: 'string', value: 'titlesort' }, - { label: 'Subtitle', type: 'string', value: 'subtitle' }, - { label: 'Track Number', type: 'number', value: 'track' }, - { label: 'Track Total', type: 'number', value: 'tracktotal' }, - { label: 'Year', type: 'number', value: 'year' }, - { label: 'Website', type: 'string', value: 'website' }, - { label: 'Work', type: 'string', value: 'work' }, -]; - -export const NDSongQueryPlaylistOperators = [ - { label: 'is in', value: 'inPlaylist' }, - { label: 'is not in', value: 'notInPlaylist' }, -]; - -export const NDSongQueryDateOperators = [ - { label: 'is', value: 'is' }, - { label: 'is not', value: 'isNot' }, - { label: 'is before', value: 'before' }, - { label: 'is after', value: 'after' }, - { label: 'is in the last', value: 'inTheLast' }, - { label: 'is not in the last', value: 'notInTheLast' }, - { label: 'is in the range', value: 'inTheRange' }, -]; - -export const NDSongQueryStringOperators = [ - { label: 'is', value: 'is' }, - { label: 'is not', value: 'isNot' }, - { label: 'contains', value: 'contains' }, - { label: 'does not contain', value: 'notContains' }, - { label: 'starts with', value: 'startsWith' }, - { label: 'ends with', value: 'endsWith' }, -]; - -export const NDSongQueryBooleanOperators = [ - { label: 'is', value: 'is' }, - { label: 'is not', value: 'isNot' }, -]; - -export const NDSongQueryNumberOperators = [ - { label: 'is', value: 'is' }, - { label: 'is not', value: 'isNot' }, - { label: 'contains', value: 'contains' }, - { label: 'does not contain', value: 'notContains' }, - { label: 'is greater than', value: 'gt' }, - { label: 'is less than', value: 'lt' }, - { label: 'is in the range', value: 'inTheRange' }, -]; - -export enum NDUserListSort { - NAME = 'name', -} - -export type NDUserList = { - items: NDUser[]; - startIndex: number; - totalRecordCount: number; -}; - -export type NDUserListParams = NDOrder & - NDPagination & { - _sort?: NDUserListSort; - }; - -export type NDUserListResponse = NDUser[]; diff --git a/src/shared/api/navidrome/navidrome-normalize.ts b/src/shared/api/navidrome/navidrome-normalize.ts index bcfe0045..602f56cd 100644 --- a/src/shared/api/navidrome/navidrome-normalize.ts +++ b/src/shared/api/navidrome/navidrome-normalize.ts @@ -1,7 +1,6 @@ import { nanoid } from 'nanoid'; import z from 'zod'; -import { NDGenre } from '/@/shared/api/navidrome.types'; import { ndType } from '/@/shared/api/navidrome/navidrome-types'; import { ssType } from '/@/shared/api/subsonic/subsonic-types'; import { @@ -433,7 +432,7 @@ const normalizePlaylist = ( }; }; -const normalizeGenre = (item: NDGenre): Genre => { +const normalizeGenre = (item: z.infer): Genre => { return { albumCount: undefined, id: item.id, diff --git a/src/shared/api/navidrome/navidrome-types.ts b/src/shared/api/navidrome/navidrome-types.ts index 914903d2..a26f1d10 100644 --- a/src/shared/api/navidrome/navidrome-types.ts +++ b/src/shared/api/navidrome/navidrome-types.ts @@ -1,11 +1,211 @@ import { z } from 'zod'; -import { - NDAlbumArtistListSort, - NDAlbumListSort, - NDPlaylistListSort, - NDSongListSort, -} from '/@/shared/api/navidrome.types'; +export enum NDAlbumArtistListSort { + ALBUM_COUNT = 'albumCount', + FAVORITED = 'starred_at', + NAME = 'name', + PLAY_COUNT = 'playCount', + RATING = 'rating', + SONG_COUNT = 'songCount', +} + +export enum NDAlbumListSort { + ALBUM_ARTIST = 'album_artist', + ARTIST = 'artist', + DURATION = 'duration', + EXPLICIT_STATUS = 'explicitStatus', + NAME = 'name', + PLAY_COUNT = 'play_count', + PLAY_DATE = 'play_date', + RANDOM = 'random', + RATING = 'rating', + RECENTLY_ADDED = 'recently_added', + SONG_COUNT = 'songCount', + STARRED = 'starred_at', + YEAR = 'max_year', +} + +export enum NDGenreListSort { + NAME = 'name', +} + +export enum NDPlaylistListSort { + DURATION = 'duration', + NAME = 'name', + OWNER = 'owner_name', + PUBLIC = 'public', + SONG_COUNT = 'songCount', + UPDATED_AT = 'updatedAt', +} + +export enum NDSongListSort { + ALBUM = 'album', + ALBUM_ARTIST = 'order_album_artist_name', + ALBUM_SONGS = 'album', + ARTIST = 'artist', + BPM = 'bpm', + CHANNELS = 'channels', + COMMENT = 'comment', + DURATION = 'duration', + EXPLICIT_STATUS = 'explicitStatus', + FAVORITED = 'starred_at', + GENRE = 'genre', + ID = 'id', + PLAY_COUNT = 'playCount', + PLAY_DATE = 'playDate', + RANDOM = 'random', + RATING = 'rating', + RECENTLY_ADDED = 'createdAt', + TITLE = 'title', + TRACK = 'track', + YEAR = 'year', +} + +export enum NDSortOrder { + ASC = 'ASC', + DESC = 'DESC', +} + +export const NDSongQueryFields = [ + { label: 'Album', type: 'string', value: 'album' }, + { label: 'Album Artist', type: 'string', value: 'albumartist' }, + { label: 'Album Artists', type: 'string', value: 'albumartists' }, + { label: 'Album Comment', type: 'string', value: 'albumcomment' }, + { label: 'Album Type', type: 'string', value: 'albumtype' }, + { label: 'Album Version', type: 'string', value: 'albumversion' }, + { label: 'Arranger', type: 'string', value: 'arranger' }, + { label: 'Artist', type: 'string', value: 'artist' }, + { label: 'Artists', type: 'string', value: 'artists' }, + { label: 'Barcode', type: 'string', value: 'barcode' }, + { label: 'Bitrate', type: 'number', value: 'bitrate' }, + { label: 'BPM', type: 'number', value: 'bpm' }, + { label: 'Catalog Number', type: 'string', value: 'catalognumber' }, + { label: 'Channels', type: 'number', value: 'channels' }, + { label: 'Comment', type: 'string', value: 'comment' }, + { label: 'Composer', type: 'string', value: 'composer' }, + { label: 'Conductor', type: 'string', value: 'conductor' }, + { label: 'Copyright', type: 'string', value: 'copyright' }, + { label: 'Date Added', type: 'date', value: 'dateadded' }, + { label: 'Date Favorited', type: 'date', value: 'dateloved' }, + { label: 'Date Last Played', type: 'date', value: 'lastplayed' }, + { label: 'Date Modified', type: 'date', value: 'datemodified' }, + { label: 'DJ Mixer', type: 'string', value: 'djmixer' }, + { label: 'Director', type: 'string', value: 'director' }, + { label: 'Disc Number', type: 'number', value: 'discnumber' }, + { label: 'Disc Subtitle', type: 'string', value: 'discsubtitle' }, + { label: 'Disc Total', type: 'number', value: 'disctotal' }, + { label: 'Duration', type: 'number', value: 'duration' }, + { label: 'Encoded By', type: 'string', value: 'encodedby' }, + { label: 'Encoder Settings', type: 'string', value: 'encodersettings' }, + { label: 'Engineer', type: 'string', value: 'engineer' }, + { label: 'Explicit Status', type: 'string', value: 'explicitstatus' }, + { label: 'File Path', type: 'string', value: 'filepath' }, + { label: 'File Type', type: 'string', value: 'filetype' }, + { label: 'Genre', type: 'string', value: 'genre' }, + { label: 'Grouping', type: 'string', value: 'grouping' }, + { label: 'Has CoverArt', type: 'boolean', value: 'hascoverart' }, + { label: 'Is Compilation', type: 'boolean', value: 'compilation' }, + { label: 'Is Favorite', type: 'boolean', value: 'loved' }, + { label: 'ISRC', type: 'string', value: 'isrc' }, + { label: 'Key', type: 'string', value: 'key' }, + { label: 'Language', type: 'string', value: 'language' }, + { label: 'License', type: 'string', value: 'license' }, + { label: 'Lyricist', type: 'string', value: 'lyricist' }, + { label: 'Lyrics', type: 'string', value: 'lyrics' }, + { label: 'Media', type: 'string', value: 'media' }, + { label: 'Mixer', type: 'string', value: 'mixer' }, + { label: 'Mood', type: 'string', value: 'mood' }, + { label: 'Movement', type: 'string', value: 'movement' }, + { label: 'Movement Name', type: 'string', value: 'movementname' }, + { label: 'Movement Total', type: 'number', value: 'movementtotal' }, + { label: 'MusicBrainz Artist Id', type: 'string', value: 'musicbrainz_artistid' }, + { label: 'MusicBrainz Album Artist Id', type: 'string', value: 'musicbrainz_albumartistid' }, + { label: 'MusicBrainz Album Id', type: 'string', value: 'musicbrainz_albumid' }, + { label: 'MusicBrainz Disc Id', type: 'string', value: 'musicbrainz_discid' }, + { label: 'MusicBrainz Recording Id', type: 'string', value: 'musicbrainz_recordingid' }, + { label: 'MusicBrainz Release Group Id', type: 'string', value: 'musicbrainz_releasegroupid' }, + { label: 'MusicBrainz Track Id', type: 'string', value: 'musicbrainz_trackid' }, + { label: 'MusicBrainz Work Id', type: 'string', value: 'musicbrainz_workid' }, + { label: 'Name', type: 'string', value: 'title' }, + { label: 'Original Date', type: 'date', value: 'originaldate' }, + { label: 'Performer', type: 'string', value: 'performer' }, + { label: 'Play Count', type: 'number', value: 'playcount' }, + { label: 'Playlist', type: 'playlist', value: 'id' }, + { label: 'Producer', type: 'string', value: 'producer' }, + { label: 'R128 Album Gain', type: 'number', value: 'r128_album_gain' }, + { label: 'R128 Track Gain', type: 'number', value: 'r128_track_gain' }, + { label: 'Rating', type: 'number', value: 'rating' }, + { label: 'Record Label', type: 'string', value: 'recordlabel' }, + { label: 'Recording Date', type: 'date', value: 'recordingdate' }, + { label: 'Release Country', type: 'string', value: 'releasecountry' }, + { label: 'Release Date', type: 'date', value: 'releasedate' }, + { label: 'Release Status', type: 'string', value: 'releasestatus' }, + { label: 'Release Type', type: 'string', value: 'releasetype' }, + { label: 'ReplayGain Album Gain', type: 'number', value: 'replaygain_album_gain' }, + { label: 'ReplayGain Album Peak', type: 'number', value: 'replaygain_album_peak' }, + { label: 'ReplayGain Track Gain', type: 'number', value: 'replaygain_track_gain' }, + { label: 'ReplayGain Track Peak', type: 'number', value: 'replaygain_track_peak' }, + { label: 'Remixer', type: 'string', value: 'remixer' }, + { label: 'Script', type: 'string', value: 'script' }, + { label: 'Size', type: 'number', value: 'size' }, + { label: 'Sort Album', type: 'string', value: 'albumsort' }, + { label: 'Sort Album Artist', type: 'string', value: 'albumartistsort' }, + { label: 'Sort Album Artists', type: 'string', value: 'albumartistssort' }, + { label: 'Sort Artist', type: 'string', value: 'artistsort' }, + { label: 'Sort Artists', type: 'string', value: 'artistssort' }, + { label: 'Sort Composer', type: 'string', value: 'composersort' }, + { label: 'Sort Lyricist', type: 'string', value: 'lyricistsort' }, + { label: 'Sort Name', type: 'string', value: 'titlesort' }, + { label: 'Subtitle', type: 'string', value: 'subtitle' }, + { label: 'Track Number', type: 'number', value: 'track' }, + { label: 'Track Total', type: 'number', value: 'tracktotal' }, + { label: 'Year', type: 'number', value: 'year' }, + { label: 'Website', type: 'string', value: 'website' }, + { label: 'Work', type: 'string', value: 'work' }, +]; + +export const NDSongQueryPlaylistOperators = [ + { label: 'is in', value: 'inPlaylist' }, + { label: 'is not in', value: 'notInPlaylist' }, +]; + +export const NDSongQueryDateOperators = [ + { label: 'is', value: 'is' }, + { label: 'is not', value: 'isNot' }, + { label: 'is before', value: 'before' }, + { label: 'is after', value: 'after' }, + { label: 'is in the last', value: 'inTheLast' }, + { label: 'is not in the last', value: 'notInTheLast' }, + { label: 'is in the range', value: 'inTheRange' }, +]; + +export const NDSongQueryStringOperators = [ + { label: 'is', value: 'is' }, + { label: 'is not', value: 'isNot' }, + { label: 'contains', value: 'contains' }, + { label: 'does not contain', value: 'notContains' }, + { label: 'starts with', value: 'startsWith' }, + { label: 'ends with', value: 'endsWith' }, +]; + +export const NDSongQueryBooleanOperators = [ + { label: 'is', value: 'is' }, + { label: 'is not', value: 'isNot' }, +]; + +export const NDSongQueryNumberOperators = [ + { label: 'is', value: 'is' }, + { label: 'is not', value: 'isNot' }, + { label: 'contains', value: 'contains' }, + { label: 'does not contain', value: 'notContains' }, + { label: 'is greater than', value: 'gt' }, + { label: 'is less than', value: 'lt' }, + { label: 'is in the range', value: 'inTheRange' }, +]; + +export enum NDUserListSort { + NAME = 'name', +} const sortOrderValues = ['ASC', 'DESC'] as const; diff --git a/src/shared/api/subsonic.types.ts b/src/shared/api/subsonic.types.ts deleted file mode 100644 index 803450df..00000000 --- a/src/shared/api/subsonic.types.ts +++ /dev/null @@ -1,224 +0,0 @@ -export type SSAlbum = SSAlbumListEntry & { - song: SSSong[]; -}; - -export type SSAlbumArtistDetail = SSAlbumArtistListEntry & { album: SSAlbumListEntry[] }; - -export type SSAlbumArtistDetailParams = { - id: string; -}; - -export type SSAlbumArtistDetailResponse = { - artist: SSAlbumArtistListEntry & { - album: SSAlbumListEntry[]; - }; -}; - -export type SSAlbumArtistList = { - items: SSAlbumArtistListEntry[]; - startIndex: number; - totalRecordCount: null | number; -}; - -export type SSAlbumArtistListEntry = { - albumCount: string; - artistImageUrl?: string; - coverArt?: string; - id: string; - name: string; -}; - -export type SSAlbumArtistListParams = { - musicFolderId?: string; -}; - -export type SSAlbumArtistListResponse = { - artists: { - ignoredArticles: string; - index: SSArtistIndex[]; - lastModified: number; - }; -}; - -export type SSAlbumDetail = Omit & { songs: SSSong[] }; - -export type SSAlbumDetailResponse = { - album: SSAlbum; -}; - -export type SSAlbumList = { - items: SSAlbumListEntry[]; - startIndex: number; - totalRecordCount: null | number; -}; - -export type SSAlbumListEntry = { - album: string; - artist: string; - artistId: string; - coverArt: string; - created: string; - duration: number; - genre?: string; - id: string; - isDir: boolean; - isVideo: boolean; - name: string; - parent: string; - songCount: number; - starred?: boolean; - title: string; - userRating?: number; - year: number; -}; - -export type SSAlbumListParams = { - fromYear?: number; - genre?: string; - musicFolderId?: string; - offset?: number; - size?: number; - toYear?: number; - type: string; -}; - -export type SSAlbumListResponse = { - albumList2: { - album: SSAlbumListEntry[]; - }; -}; - -export type SSArtistIndex = { - artist: SSAlbumArtistListEntry[]; - name: string; -}; - -export type SSArtistInfo = { - biography: string; - largeImageUrl?: string; - lastFmUrl?: string; - mediumImageUrl?: string; - musicBrainzId?: string; - similarArtist?: { - albumCount: string; - artistImageUrl?: string; - coverArt?: string; - id: string; - name: string; - }[]; - smallImageUrl?: string; -}; - -export type SSArtistInfoParams = { - count?: number; - id: string; - includeNotPresent?: boolean; -}; - -export type SSArtistInfoResponse = { - artistInfo2: SSArtistInfo; -}; - -export type SSBaseResponse = { - serverVersion?: 'string'; - status: 'string'; - type?: 'string'; - version: 'string'; -}; - -export type SSFavorite = null; - -export type SSFavoriteParams = { - albumId?: string; - artistId?: string; - id?: string; -}; - -export type SSFavoriteResponse = null; - -export type SSGenre = { - albumCount?: number; - songCount?: number; - value: string; -}; - -export type SSGenreList = SSGenre[]; - -export type SSGenreListResponse = { - genres: { - genre: SSGenre[]; - }; -}; - -export type SSMusicFolder = { - id: number; - name: string; -}; - -export type SSMusicFolderList = SSMusicFolder[]; - -export type SSMusicFolderListResponse = { - musicFolders: { - musicFolder: SSMusicFolder[]; - }; -}; - -export type SSRating = null; - -export type SSRatingParams = { - id: string; - rating: number; -}; - -export type SSRatingResponse = null; - -export type SSScrobbleParams = { - id: string; - submission?: boolean; - time?: number; -}; - -export type SSSong = { - album: string; - albumId: string; - artist: string; - artistId?: string; - bitRate: number; - contentType: string; - coverArt: string; - created: string; - discNumber?: number; - duration: number; - genre: string; - id: string; - isDir: boolean; - isVideo: boolean; - parent: string; - path: string; - playCount: number; - size: number; - starred?: boolean; - suffix: string; - title: string; - track: number; - type: string; - userRating?: number; - year: number; -}; - -export type SSTopSongList = { - items: SSSong[]; - startIndex: number; - totalRecordCount: null | number; -}; - -export type SSTopSongListParams = { - artist: string; - count?: number; -}; - -export type SSTopSongListResponse = { - topSongs: { - song: SSSong[]; - }; -}; diff --git a/src/shared/types/domain-types.ts b/src/shared/types/domain-types.ts index 29a95e8b..3850e076 100644 --- a/src/shared/types/domain-types.ts +++ b/src/shared/types/domain-types.ts @@ -12,19 +12,18 @@ import { JFPlaylistListSort, JFSongListSort, JFSortOrder, -} from '/@/shared/api/jellyfin.types'; -import { jfType } from '/@/shared/api/jellyfin/jellyfin-types'; + jfType, +} from '/@/shared/api/jellyfin/jellyfin-types'; import { NDAlbumArtistListSort, NDAlbumListSort, NDGenreListSort, - NDOrder, NDPlaylistListSort, NDSongListSort, NDSortOrder, + ndType, NDUserListSort, -} from '/@/shared/api/navidrome.types'; -import { ndType } from '/@/shared/api/navidrome/navidrome-types'; +} from '/@/shared/api/navidrome/navidrome-types'; import { ServerFeatures } from '/@/shared/types/features-types'; import { PlayerStatus } from '/@/shared/types/types'; @@ -288,7 +287,7 @@ export type GenreListResponse = BasePaginatedResponse; export type GenresResponse = Genre[]; -export type ListSortOrder = JFSortOrder | NDOrder; +export type ListSortOrder = 'asc' | 'desc'; export type MusicFolder = { id: string;