remove limit / startIndex from count query args

This commit is contained in:
jeffvli 2025-09-26 10:43:39 -07:00
parent 78fb9b5ab7
commit abd1d55f23
4 changed files with 30 additions and 11 deletions

View file

@ -4,7 +4,7 @@ import { api } from '/@/renderer/api';
import { queryKeys } from '/@/renderer/api/query-keys'; import { queryKeys } from '/@/renderer/api/query-keys';
import { QueryHookArgs } from '/@/renderer/lib/react-query'; import { QueryHookArgs } from '/@/renderer/lib/react-query';
import { getServerById } from '/@/renderer/store'; import { getServerById } from '/@/renderer/store';
import { AlbumDetailQuery, AlbumListQuery } from '/@/shared/types/domain-types'; import { AlbumDetailQuery, AlbumListQuery, ListCountQuery } from '/@/shared/types/domain-types';
export const albumQueries = { export const albumQueries = {
detail: (args: QueryHookArgs<AlbumDetailQuery>) => { detail: (args: QueryHookArgs<AlbumDetailQuery>) => {
@ -35,7 +35,7 @@ export const albumQueries = {
...args.options, ...args.options,
}); });
}, },
listCount: (args: QueryHookArgs<AlbumListQuery>) => { listCount: (args: QueryHookArgs<ListCountQuery<AlbumListQuery>>) => {
return queryOptions({ return queryOptions({
queryFn: ({ signal }) => { queryFn: ({ signal }) => {
return api.controller.getAlbumListCount({ return api.controller.getAlbumListCount({

View file

@ -8,6 +8,7 @@ import {
AlbumArtistDetailQuery, AlbumArtistDetailQuery,
AlbumArtistListQuery, AlbumArtistListQuery,
ArtistListQuery, ArtistListQuery,
ListCountQuery,
TopSongListQuery, TopSongListQuery,
} from '/@/shared/types/domain-types'; } from '/@/shared/types/domain-types';
@ -36,7 +37,7 @@ export const artistsQueries = {
...args.options, ...args.options,
}); });
}, },
albumArtistListCount: (args: QueryHookArgs<AlbumArtistListQuery>) => { albumArtistListCount: (args: QueryHookArgs<ListCountQuery<AlbumArtistListQuery>>) => {
return queryOptions({ return queryOptions({
queryFn: ({ signal }) => { queryFn: ({ signal }) => {
return api.controller.getAlbumArtistListCount({ return api.controller.getAlbumArtistListCount({
@ -51,7 +52,7 @@ export const artistsQueries = {
...args.options, ...args.options,
}); });
}, },
artistListCount: (args: QueryHookArgs<ArtistListQuery>) => { artistListCount: (args: QueryHookArgs<ListCountQuery<ArtistListQuery>>) => {
return queryOptions({ return queryOptions({
queryFn: ({ signal }) => { queryFn: ({ signal }) => {
return api.controller.getArtistListCount({ return api.controller.getArtistListCount({

View file

@ -5,7 +5,7 @@ import { controller } from '/@/renderer/api/controller';
import { queryKeys } from '/@/renderer/api/query-keys'; import { queryKeys } from '/@/renderer/api/query-keys';
import { QueryHookArgs } from '/@/renderer/lib/react-query'; import { QueryHookArgs } from '/@/renderer/lib/react-query';
import { getServerById } from '/@/renderer/store'; import { getServerById } from '/@/renderer/store';
import { SimilarSongsQuery, SongListQuery } from '/@/shared/types/domain-types'; import { ListCountQuery, SimilarSongsQuery, SongListQuery } from '/@/shared/types/domain-types';
export const songsQueries = { export const songsQueries = {
list: (args: QueryHookArgs<SongListQuery>, imageSize?: number) => { list: (args: QueryHookArgs<SongListQuery>, imageSize?: number) => {
@ -22,7 +22,7 @@ export const songsQueries = {
...args.options, ...args.options,
}); });
}, },
listCount: (args: QueryHookArgs<SongListQuery>) => { listCount: (args: QueryHookArgs<ListCountQuery<SongListQuery>>) => {
return queryOptions({ return queryOptions({
queryFn: ({ signal }) => { queryFn: ({ signal }) => {
const server = getServerById(args.serverId); const server = getServerById(args.serverId);

View file

@ -416,6 +416,8 @@ export enum AlbumListSort {
export type AlbumListArgs = BaseEndpointArgs & { query: AlbumListQuery }; export type AlbumListArgs = BaseEndpointArgs & { query: AlbumListQuery };
export type AlbumListCountArgs = BaseEndpointArgs & { query: ListCountQuery<AlbumListQuery> };
export interface AlbumListQuery extends BaseQuery<AlbumListSort> { export interface AlbumListQuery extends BaseQuery<AlbumListSort> {
_custom?: { _custom?: {
jellyfin?: Partial<z.infer<typeof jfType._parameters.albumList>>; jellyfin?: Partial<z.infer<typeof jfType._parameters.albumList>>;
@ -436,6 +438,8 @@ export interface AlbumListQuery extends BaseQuery<AlbumListSort> {
// Album List // Album List
export type AlbumListResponse = BasePaginatedResponse<Album[]>; export type AlbumListResponse = BasePaginatedResponse<Album[]>;
export type ListCountQuery<TQuery> = Omit<TQuery, 'limit' | 'startIndex'>;
type AlbumListSortMap = { type AlbumListSortMap = {
jellyfin: Record<AlbumListSort, JFAlbumListSort | undefined>; jellyfin: Record<AlbumListSort, JFAlbumListSort | undefined>;
navidrome: Record<AlbumListSort, NDAlbumListSort | undefined>; navidrome: Record<AlbumListSort, NDAlbumListSort | undefined>;
@ -536,6 +540,8 @@ export type AlbumInfo = {
export type SongListArgs = BaseEndpointArgs & { query: SongListQuery }; export type SongListArgs = BaseEndpointArgs & { query: SongListQuery };
export type SongListCountArgs = BaseEndpointArgs & { query: ListCountQuery<SongListQuery> };
export interface SongListQuery extends BaseQuery<SongListSort> { export interface SongListQuery extends BaseQuery<SongListSort> {
_custom?: { _custom?: {
jellyfin?: Partial<z.infer<typeof jfType._parameters.songList>>; jellyfin?: Partial<z.infer<typeof jfType._parameters.songList>>;
@ -647,6 +653,10 @@ export enum AlbumArtistListSort {
export type AlbumArtistListArgs = BaseEndpointArgs & { query: AlbumArtistListQuery }; export type AlbumArtistListArgs = BaseEndpointArgs & { query: AlbumArtistListQuery };
export type AlbumArtistListCountArgs = BaseEndpointArgs & {
query: ListCountQuery<AlbumArtistListQuery>;
};
export interface AlbumArtistListQuery extends BaseQuery<AlbumArtistListSort> { export interface AlbumArtistListQuery extends BaseQuery<AlbumArtistListSort> {
_custom?: { _custom?: {
jellyfin?: Partial<z.infer<typeof jfType._parameters.albumArtistList>>; jellyfin?: Partial<z.infer<typeof jfType._parameters.albumArtistList>>;
@ -740,6 +750,8 @@ export type AlbumArtistDetailResponse = AlbumArtist | null;
export type ArtistListArgs = BaseEndpointArgs & { query: ArtistListQuery }; export type ArtistListArgs = BaseEndpointArgs & { query: ArtistListQuery };
export type ArtistListCountArgs = BaseEndpointArgs & { query: ListCountQuery<ArtistListQuery> };
export interface ArtistListQuery extends BaseQuery<ArtistListSort> { export interface ArtistListQuery extends BaseQuery<ArtistListSort> {
_custom?: { _custom?: {
jellyfin?: Partial<z.infer<typeof jfType._parameters.albumArtistList>>; jellyfin?: Partial<z.infer<typeof jfType._parameters.albumArtistList>>;
@ -872,6 +884,8 @@ export type FavoriteResponse = null | undefined;
export type PlaylistListArgs = BaseEndpointArgs & { query: PlaylistListQuery }; export type PlaylistListArgs = BaseEndpointArgs & { query: PlaylistListQuery };
export type PlaylistListCountArgs = BaseEndpointArgs & { query: ListCountQuery<PlaylistListQuery> };
export interface PlaylistListQuery extends BaseQuery<PlaylistListSort> { export interface PlaylistListQuery extends BaseQuery<PlaylistListSort> {
_custom?: { _custom?: {
jellyfin?: Partial<z.infer<typeof jfType._parameters.playlistList>>; jellyfin?: Partial<z.infer<typeof jfType._parameters.playlistList>>;
@ -1004,6 +1018,10 @@ export type PlaylistDetailResponse = Playlist;
export type PlaylistSongListArgs = BaseEndpointArgs & { query: PlaylistSongListQuery }; export type PlaylistSongListArgs = BaseEndpointArgs & { query: PlaylistSongListQuery };
export type PlaylistSongListCountArgs = BaseEndpointArgs & {
query: ListCountQuery<PlaylistSongListQuery>;
};
export type PlaylistSongListQuery = { export type PlaylistSongListQuery = {
id: string; id: string;
}; };
@ -1207,21 +1225,21 @@ export type ControllerEndpoint = {
deletePlaylist: (args: DeletePlaylistArgs) => Promise<DeletePlaylistResponse>; deletePlaylist: (args: DeletePlaylistArgs) => Promise<DeletePlaylistResponse>;
getAlbumArtistDetail: (args: AlbumArtistDetailArgs) => Promise<AlbumArtistDetailResponse>; getAlbumArtistDetail: (args: AlbumArtistDetailArgs) => Promise<AlbumArtistDetailResponse>;
getAlbumArtistList: (args: AlbumArtistListArgs) => Promise<AlbumArtistListResponse>; getAlbumArtistList: (args: AlbumArtistListArgs) => Promise<AlbumArtistListResponse>;
getAlbumArtistListCount: (args: AlbumArtistListArgs) => Promise<number>; getAlbumArtistListCount: (args: AlbumArtistListCountArgs) => Promise<number>;
getAlbumDetail: (args: AlbumDetailArgs) => Promise<AlbumDetailResponse>; getAlbumDetail: (args: AlbumDetailArgs) => Promise<AlbumDetailResponse>;
getAlbumInfo?: (args: AlbumDetailArgs) => Promise<AlbumInfo>; getAlbumInfo?: (args: AlbumDetailArgs) => Promise<AlbumInfo>;
getAlbumList: (args: AlbumListArgs) => Promise<AlbumListResponse>; getAlbumList: (args: AlbumListArgs) => Promise<AlbumListResponse>;
getAlbumListCount: (args: AlbumListArgs) => Promise<number>; getAlbumListCount: (args: AlbumListCountArgs) => Promise<number>;
// getArtistInfo?: (args: any) => void; // getArtistInfo?: (args: any) => void;
getArtistList: (args: ArtistListArgs) => Promise<ArtistListResponse>; getArtistList: (args: ArtistListArgs) => Promise<ArtistListResponse>;
getArtistListCount: (args: ArtistListArgs) => Promise<number>; getArtistListCount: (args: ArtistListCountArgs) => Promise<number>;
getDownloadUrl: (args: DownloadArgs) => string; getDownloadUrl: (args: DownloadArgs) => string;
getGenreList: (args: GenreListArgs) => Promise<GenreListResponse>; getGenreList: (args: GenreListArgs) => Promise<GenreListResponse>;
getLyrics?: (args: LyricsArgs) => Promise<LyricsResponse>; getLyrics?: (args: LyricsArgs) => Promise<LyricsResponse>;
getMusicFolderList: (args: MusicFolderListArgs) => Promise<MusicFolderListResponse>; getMusicFolderList: (args: MusicFolderListArgs) => Promise<MusicFolderListResponse>;
getPlaylistDetail: (args: PlaylistDetailArgs) => Promise<PlaylistDetailResponse>; getPlaylistDetail: (args: PlaylistDetailArgs) => Promise<PlaylistDetailResponse>;
getPlaylistList: (args: PlaylistListArgs) => Promise<PlaylistListResponse>; getPlaylistList: (args: PlaylistListArgs) => Promise<PlaylistListResponse>;
getPlaylistListCount: (args: PlaylistListArgs) => Promise<number>; getPlaylistListCount: (args: PlaylistListCountArgs) => Promise<number>;
getPlaylistSongList: (args: PlaylistSongListArgs) => Promise<SongListResponse>; getPlaylistSongList: (args: PlaylistSongListArgs) => Promise<SongListResponse>;
getRandomSongList: (args: RandomSongListArgs) => Promise<SongListResponse>; getRandomSongList: (args: RandomSongListArgs) => Promise<SongListResponse>;
getRoles: (args: BaseEndpointArgs) => Promise<Array<string | { label: string; value: string }>>; getRoles: (args: BaseEndpointArgs) => Promise<Array<string | { label: string; value: string }>>;
@ -1229,7 +1247,7 @@ export type ControllerEndpoint = {
getSimilarSongs: (args: SimilarSongsArgs) => Promise<Song[]>; getSimilarSongs: (args: SimilarSongsArgs) => Promise<Song[]>;
getSongDetail: (args: SongDetailArgs) => Promise<SongDetailResponse>; getSongDetail: (args: SongDetailArgs) => Promise<SongDetailResponse>;
getSongList: (args: SongListArgs) => Promise<SongListResponse>; getSongList: (args: SongListArgs) => Promise<SongListResponse>;
getSongListCount: (args: SongListArgs) => Promise<number>; getSongListCount: (args: SongListCountArgs) => Promise<number>;
getStructuredLyrics?: (args: StructuredLyricsArgs) => Promise<StructuredLyric[]>; getStructuredLyrics?: (args: StructuredLyricsArgs) => Promise<StructuredLyric[]>;
getTags?: (args: TagArgs) => Promise<TagResponses>; getTags?: (args: TagArgs) => Promise<TagResponses>;
getTopSongs: (args: TopSongListArgs) => Promise<TopSongListResponse>; getTopSongs: (args: TopSongListArgs) => Promise<TopSongListResponse>;