mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-01 10:23:33 +00:00
refactor navidrome-types
This commit is contained in:
parent
6eecc3c0fd
commit
22e4974191
2 changed files with 15 additions and 63 deletions
|
|
@ -224,7 +224,7 @@ const getAlbumDetail = async (args: AlbumDetailArgs): Promise<AlbumDetailRespons
|
||||||
query: {
|
query: {
|
||||||
_end: 0,
|
_end: 0,
|
||||||
_order: 'ASC',
|
_order: 'ASC',
|
||||||
_sort: 'album',
|
_sort: NDSongListSort.ALBUM,
|
||||||
_start: 0,
|
_start: 0,
|
||||||
album_id: [query.id],
|
album_id: [query.id],
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,10 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
import {
|
||||||
|
NDAlbumArtistListSort,
|
||||||
|
NDAlbumListSort,
|
||||||
|
NDPlaylistListSort,
|
||||||
|
NDSongListSort,
|
||||||
|
} from '/@/renderer/api/navidrome.types';
|
||||||
|
|
||||||
const sortOrderValues = ['ASC', 'DESC'] as const;
|
const sortOrderValues = ['ASC', 'DESC'] as const;
|
||||||
|
|
||||||
|
|
@ -89,17 +95,8 @@ const albumArtist = z.object({
|
||||||
|
|
||||||
const albumArtistList = z.array(albumArtist);
|
const albumArtistList = z.array(albumArtist);
|
||||||
|
|
||||||
const ndAlbumArtistListSort = {
|
|
||||||
ALBUM_COUNT: 'albumCount',
|
|
||||||
FAVORITED: 'starred ASC, starredAt ASC',
|
|
||||||
NAME: 'name',
|
|
||||||
PLAY_COUNT: 'playCount',
|
|
||||||
RATING: 'rating',
|
|
||||||
SONG_COUNT: 'songCount',
|
|
||||||
} as const;
|
|
||||||
|
|
||||||
const albumArtistListParameters = paginationParameters.extend({
|
const albumArtistListParameters = paginationParameters.extend({
|
||||||
_sort: z.nativeEnum(ndAlbumArtistListSort).optional(),
|
_sort: z.nativeEnum(NDAlbumArtistListSort).optional(),
|
||||||
genre_id: z.string().optional(),
|
genre_id: z.string().optional(),
|
||||||
name: z.string().optional(),
|
name: z.string().optional(),
|
||||||
starred: z.boolean().optional(),
|
starred: z.boolean().optional(),
|
||||||
|
|
@ -145,23 +142,8 @@ const album = z.object({
|
||||||
|
|
||||||
const albumList = z.array(album);
|
const albumList = z.array(album);
|
||||||
|
|
||||||
const ndAlbumListSort = {
|
|
||||||
ALBUM_ARTIST: 'albumArtist',
|
|
||||||
ARTIST: 'artist',
|
|
||||||
DURATION: 'duration',
|
|
||||||
NAME: 'name',
|
|
||||||
PLAY_COUNT: 'playCount',
|
|
||||||
PLAY_DATE: 'play_date',
|
|
||||||
RANDOM: 'random',
|
|
||||||
RATING: 'rating',
|
|
||||||
RECENTLY_ADDED: 'recently_added',
|
|
||||||
SONG_COUNT: 'songCount',
|
|
||||||
STARRED: 'starred',
|
|
||||||
YEAR: 'max_year',
|
|
||||||
} as const;
|
|
||||||
|
|
||||||
const albumListParameters = paginationParameters.extend({
|
const albumListParameters = paginationParameters.extend({
|
||||||
_sort: z.nativeEnum(ndAlbumListSort).optional(),
|
_sort: z.nativeEnum(NDAlbumListSort).optional(),
|
||||||
album_id: z.string().optional(),
|
album_id: z.string().optional(),
|
||||||
artist_id: z.string().optional(),
|
artist_id: z.string().optional(),
|
||||||
compilation: z.boolean().optional(),
|
compilation: z.boolean().optional(),
|
||||||
|
|
@ -237,29 +219,8 @@ const song = z.object({
|
||||||
|
|
||||||
const songList = z.array(song);
|
const songList = z.array(song);
|
||||||
|
|
||||||
const ndSongListSort = {
|
|
||||||
ALBUM: 'album, order_album_artist_name, disc_number, track_number, title',
|
|
||||||
ALBUM_ARTIST: 'order_album_artist_name, album, disc_number, track_number, title',
|
|
||||||
ALBUM_SONGS: 'album, discNumber, trackNumber',
|
|
||||||
ARTIST: 'artist',
|
|
||||||
BPM: 'bpm',
|
|
||||||
CHANNELS: 'channels',
|
|
||||||
COMMENT: 'comment',
|
|
||||||
DURATION: 'duration',
|
|
||||||
FAVORITED: 'starred ASC, starredAt ASC',
|
|
||||||
GENRE: 'genre',
|
|
||||||
ID: 'id',
|
|
||||||
PLAY_COUNT: 'playCount',
|
|
||||||
PLAY_DATE: 'playDate',
|
|
||||||
RATING: 'rating',
|
|
||||||
RECENTLY_ADDED: 'createdAt',
|
|
||||||
TITLE: 'title',
|
|
||||||
TRACK: 'track',
|
|
||||||
YEAR: 'year, album, discNumber, trackNumber',
|
|
||||||
};
|
|
||||||
|
|
||||||
const songListParameters = paginationParameters.extend({
|
const songListParameters = paginationParameters.extend({
|
||||||
_sort: z.nativeEnum(ndSongListSort).optional(),
|
_sort: z.nativeEnum(NDSongListSort).optional(),
|
||||||
album_artist_id: z.array(z.string()).optional(),
|
album_artist_id: z.array(z.string()).optional(),
|
||||||
album_id: z.array(z.string()).optional(),
|
album_id: z.array(z.string()).optional(),
|
||||||
artist_id: z.array(z.string()).optional(),
|
artist_id: z.array(z.string()).optional(),
|
||||||
|
|
@ -290,17 +251,8 @@ const playlist = z.object({
|
||||||
|
|
||||||
const playlistList = z.array(playlist);
|
const playlistList = z.array(playlist);
|
||||||
|
|
||||||
const ndPlaylistListSort = {
|
|
||||||
DURATION: 'duration',
|
|
||||||
NAME: 'name',
|
|
||||||
OWNER: 'ownerName',
|
|
||||||
PUBLIC: 'public',
|
|
||||||
SONG_COUNT: 'songCount',
|
|
||||||
UPDATED_AT: 'updatedAt',
|
|
||||||
} as const;
|
|
||||||
|
|
||||||
const playlistListParameters = paginationParameters.extend({
|
const playlistListParameters = paginationParameters.extend({
|
||||||
_sort: z.nativeEnum(ndPlaylistListSort).optional(),
|
_sort: z.nativeEnum(NDPlaylistListSort).optional(),
|
||||||
owner_id: z.string().optional(),
|
owner_id: z.string().optional(),
|
||||||
q: z.string().optional(),
|
q: z.string().optional(),
|
||||||
smart: z.boolean().optional(),
|
smart: z.boolean().optional(),
|
||||||
|
|
@ -367,11 +319,11 @@ const moveItem = z.null();
|
||||||
|
|
||||||
export const ndType = {
|
export const ndType = {
|
||||||
_enum: {
|
_enum: {
|
||||||
albumArtistList: ndAlbumArtistListSort,
|
albumArtistList: NDAlbumArtistListSort,
|
||||||
albumList: ndAlbumListSort,
|
albumList: NDAlbumListSort,
|
||||||
genreList: genreListSort,
|
genreList: genreListSort,
|
||||||
playlistList: ndPlaylistListSort,
|
playlistList: NDPlaylistListSort,
|
||||||
songList: ndSongListSort,
|
songList: NDSongListSort,
|
||||||
userList: ndUserListSort,
|
userList: ndUserListSort,
|
||||||
},
|
},
|
||||||
_parameters: {
|
_parameters: {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue