rename internal types in domain models

This commit is contained in:
jeffvli
2025-11-03 20:38:18 -08:00
parent 76bf4ae825
commit 427f808180
23 changed files with 162 additions and 168 deletions
+8 -11
View File
@@ -1,4 +1,3 @@
import { nanoid } from 'nanoid';
import { z } from 'zod';
import { jfType } from '/@/shared/api/jellyfin/jellyfin-types';
@@ -228,6 +227,8 @@ const normalizeSong = (
}
return {
_serverId: server?.id || '',
_serverType: ServerType.JELLYFIN,
album: item.Album,
albumArtists: item.AlbumArtists?.map((entry) => ({
id: entry.Id,
@@ -290,13 +291,10 @@ const normalizeSong = (
: null,
releaseYear: item.ProductionYear ? String(item.ProductionYear) : null,
sampleRate,
serverId: server?.id || '',
serverType: ServerType.JELLYFIN,
size,
streamUrl,
tags: getTags(item),
trackNumber: item.IndexNumber,
uniqueId: nanoid(),
updatedAt: item.DateCreated,
userFavorite: (item.UserData && item.UserData.IsFavorite) || false,
userRating: null,
@@ -309,6 +307,8 @@ const normalizeAlbum = (
imageSize?: number,
): Album => {
return {
_serverId: server?.id || '',
_serverType: ServerType.JELLYFIN,
albumArtist: item.AlbumArtist,
albumArtists:
item.AlbumArtists.map((entry) => ({
@@ -351,13 +351,10 @@ const normalizeAlbum = (
releaseDate: item.PremiereDate?.split('T')[0] || null,
releaseTypes: [],
releaseYear: item.ProductionYear || null,
serverId: server?.id || '',
serverType: ServerType.JELLYFIN,
size: null,
songCount: item?.ChildCount || null,
songs: item.Songs?.map((song) => normalizeSong(song, server, '', imageSize)),
tags: getTags(item),
uniqueId: nanoid(),
updatedAt: item?.DateLastMediaAdded || item.DateCreated,
userFavorite: item.UserData?.IsFavorite || false,
userRating: null,
@@ -386,6 +383,8 @@ const normalizeAlbumArtist = (
) || [];
return {
_serverId: server?.id || '',
_serverType: ServerType.JELLYFIN,
albumCount: item.AlbumCount ?? null,
backgroundImageUrl: null,
biography: item.Overview || null,
@@ -407,8 +406,6 @@ const normalizeAlbumArtist = (
mbz: item.ProviderIds?.MusicBrainzArtist || null,
name: item.Name,
playCount: item.UserData?.PlayCount || 0,
serverId: server?.id || '',
serverType: ServerType.JELLYFIN,
similarArtists,
songCount: item.SongCount ?? null,
userFavorite: item.UserData?.IsFavorite || false,
@@ -430,6 +427,8 @@ const normalizePlaylist = (
const imagePlaceholderUrl = null;
return {
_serverId: server?.id || '',
_serverType: ServerType.JELLYFIN,
description: item.Overview || null,
duration: item.RunTimeTicks / 10000,
genres: item.GenreItems?.map((entry) => ({
@@ -447,8 +446,6 @@ const normalizePlaylist = (
ownerId: null,
public: null,
rules: null,
serverId: server?.id || '',
serverType: ServerType.JELLYFIN,
size: null,
songCount: item?.ChildCount || null,
sync: null,
@@ -1,4 +1,3 @@
import { nanoid } from 'nanoid';
import z from 'zod';
import { ndType } from '/@/shared/api/navidrome/navidrome-types';
@@ -152,6 +151,8 @@ const normalizeSong = (
album: item.album,
albumId: item.albumId,
...getArtists(item),
_serverId: server?.id || 'unknown',
_serverType: ServerType.NAVIDROME,
artistName: item.artist,
bitDepth: item.bitDepth || null,
bitRate: item.bitRate,
@@ -204,13 +205,10 @@ const normalizeSong = (
).toISOString(),
releaseYear: String(item.year),
sampleRate: item.sampleRate || null,
serverId: server?.id || 'unknown',
serverType: ServerType.NAVIDROME,
size: item.size,
streamUrl: `${server?.url}/rest/stream.view?id=${id}&v=1.13.0&c=Feishin&${server?.credential}`,
tags: item.tags || null,
trackNumber: item.trackNumber,
uniqueId: nanoid(),
updatedAt: item.updatedAt,
userFavorite: item.starred || false,
userRating: item.rating || null,
@@ -280,6 +278,8 @@ const normalizeAlbum = (
return {
...parseAlbumTags(item),
...getArtists(item),
_serverId: server?.id || 'unknown',
_serverType: ServerType.NAVIDROME,
albumArtist: item.albumArtist,
backdropImageUrl: imageBackdropUrl,
comment: item.comment || null,
@@ -301,9 +301,9 @@ const normalizeAlbum = (
imagePlaceholderUrl,
imageUrl,
isCompilation: item.compilation,
itemType: LibraryItem.ALBUM,
lastPlayedAt: normalizePlayDate(item),
mbzId: item.mbzAlbumId || null,
name: item.name,
originalDate: item.originalDate
@@ -317,12 +317,9 @@ const normalizeAlbum = (
: new Date(Date.UTC(item.minYear, 0, 1))
).toISOString(),
releaseYear: item.minYear,
serverId: server?.id || 'unknown',
serverType: ServerType.NAVIDROME,
size: item.size,
songCount: item.songCount,
songs: item.songs ? item.songs.map((song) => normalizeSong(song, server)) : undefined,
uniqueId: nanoid(),
updatedAt: item.updatedAt,
userFavorite: item.starred,
userRating: item.rating || null,
@@ -365,6 +362,8 @@ const normalizeAlbumArtist = (
}
return {
_serverId: server?.id || 'unknown',
_serverType: ServerType.NAVIDROME,
albumCount,
backgroundImageUrl: null,
biography: item.biography || null,
@@ -382,8 +381,6 @@ const normalizeAlbumArtist = (
mbz: item.mbzArtistId || null,
name: item.name,
playCount: item.playCount || 0,
serverId: server?.id || 'unknown',
serverType: ServerType.NAVIDROME,
similarArtists:
item.similarArtists?.map((artist) => ({
id: artist.id,
@@ -412,6 +409,8 @@ const normalizePlaylist = (
const imagePlaceholderUrl = null;
return {
_serverId: server?.id || 'unknown',
_serverType: ServerType.NAVIDROME,
description: item.comment,
duration: item.duration * 1000,
genres: [],
@@ -424,8 +423,6 @@ const normalizePlaylist = (
ownerId: item.ownerId,
public: item.public,
rules: item?.rules || null,
serverId: server?.id || 'unknown',
serverType: ServerType.NAVIDROME,
size: item.size,
songCount: item.songCount,
sync: item.sync,
+10 -13
View File
@@ -1,4 +1,3 @@
import { nanoid } from 'nanoid';
import { z } from 'zod';
import { ssType } from '/@/shared/api/subsonic/subsonic-types';
@@ -9,10 +8,10 @@ import {
Genre,
LibraryItem,
Playlist,
QueueSong,
RelatedArtist,
ServerListItemWithCredential,
ServerType,
Song,
} from '/@/shared/types/domain-types';
const getCoverArtUrl = (args: {
@@ -119,7 +118,7 @@ const normalizeSong = (
item: z.infer<typeof ssType._response.song>,
server?: null | ServerListItemWithCredential,
size?: number,
): QueueSong => {
): Song => {
const imageUrl =
getCoverArtUrl({
baseUrl: server?.url,
@@ -131,6 +130,8 @@ const normalizeSong = (
const streamUrl = `${server?.url}/rest/stream.view?id=${item.id}&v=1.13.0&c=Feishin&${server?.credential}`;
return {
_serverId: server?.id || 'unknown',
_serverType: ServerType.SUBSONIC,
album: item.album || '',
albumArtists: getArtistList(item.albumArtists, item.artistId, item.artist),
albumId: item.albumId?.toString() || '',
@@ -183,13 +184,10 @@ const normalizeSong = (
releaseDate: null,
releaseYear: item.year ? String(item.year) : null,
sampleRate: item.samplingRate || null,
serverId: server?.id || 'unknown',
serverType: ServerType.SUBSONIC,
size: item.size,
streamUrl,
tags: null,
trackNumber: item.track || 1,
uniqueId: nanoid(),
updatedAt: '',
userFavorite: item.starred || false,
userRating: item.userRating || null,
@@ -212,6 +210,8 @@ const normalizeAlbumArtist = (
}) || null;
return {
_serverId: server?.id || 'unknown',
_serverType: ServerType.SUBSONIC,
albumCount: item.albumCount ? Number(item.albumCount) : 0,
backgroundImageUrl: null,
biography: null,
@@ -224,8 +224,6 @@ const normalizeAlbumArtist = (
mbz: null,
name: item.name,
playCount: null,
serverId: server?.id || 'unknown',
serverType: ServerType.SUBSONIC,
similarArtists: [],
songCount: null,
userFavorite: false,
@@ -247,6 +245,8 @@ const normalizeAlbum = (
}) || null;
return {
_serverId: server?.id || 'unknown',
_serverType: ServerType.SUBSONIC,
albumArtist: item.artist,
albumArtists: getArtistList(item.artists, item.artistId, item.artist),
artists: [],
@@ -276,8 +276,6 @@ const normalizeAlbum = (
releaseDate: item.year ? new Date(Date.UTC(item.year, 0, 1)).toISOString() : null,
releaseTypes: item.releaseTypes || [],
releaseYear: item.year ? Number(item.year) : null,
serverId: server?.id || 'unknown',
serverType: ServerType.SUBSONIC,
size: null,
songCount: item.songCount,
songs:
@@ -285,7 +283,6 @@ const normalizeAlbum = (
normalizeSong(song, server),
) || [],
tags: null,
uniqueId: nanoid(),
updatedAt: item.created,
userFavorite: item.starred || false,
userRating: item.userRating || null,
@@ -300,6 +297,8 @@ const normalizePlaylist = (
server?: null | ServerListItemWithCredential,
): Playlist => {
return {
_serverId: server?.id || 'unknown',
_serverType: ServerType.SUBSONIC,
description: item.comment || null,
duration: item.duration * 1000,
genres: [],
@@ -316,8 +315,6 @@ const normalizePlaylist = (
owner: item.owner,
ownerId: item.owner,
public: item.public,
serverId: server?.id || 'unknown',
serverType: ServerType.SUBSONIC,
size: null,
songCount: item.songCount,
};