Add inferred api types to controller

This commit is contained in:
jeffvli 2023-05-17 17:38:13 -07:00
parent 3fb24d5f64
commit a1072b461f
2 changed files with 14 additions and 59 deletions

View File

@ -270,6 +270,7 @@ const ndPlaylistListSort = {
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(),
smart: z.boolean().optional(),
}); });
const playlistSong = song.extend({ const playlistSong = song.extend({

View File

@ -1,3 +1,4 @@
import { z } from 'zod';
import { import {
JFSortOrder, JFSortOrder,
JFAlbumListSort, JFAlbumListSort,
@ -15,6 +16,8 @@ import {
NDSongListSort, NDSongListSort,
NDUserListSort, NDUserListSort,
} from '/@/renderer/api/navidrome.types'; } from '/@/renderer/api/navidrome.types';
import { ndType } from '/@/renderer/api/navidrome/navidrome-types';
import { jfType } from '/@/renderer/api/jellyfin/jellyfin-types';
export enum LibraryItem { export enum LibraryItem {
ALBUM = 'album', ALBUM = 'album',
@ -313,28 +316,8 @@ export enum AlbumListSort {
export type AlbumListQuery = { export type AlbumListQuery = {
_custom?: { _custom?: {
jellyfin?: { jellyfin?: Partial<z.infer<typeof jfType._parameters.albumList>>;
albumArtistIds?: string; navidrome?: Partial<z.infer<typeof ndType._parameters.albumList>>;
artistIds?: string;
contributingArtistIds?: string;
filters?: string;
genreIds?: string;
genres?: string;
isFavorite?: boolean;
maxYear?: number; // Parses to years
minYear?: number; // Parses to years
tags?: string;
};
navidrome?: {
artist_id?: string;
compilation?: boolean;
genre_id?: string;
has_rating?: boolean;
name?: string;
recently_played?: boolean;
starred?: boolean;
year?: number;
};
}; };
artistIds?: string[]; artistIds?: string[];
limit?: number; limit?: number;
@ -440,29 +423,8 @@ export enum SongListSort {
export type SongListQuery = { export type SongListQuery = {
_custom?: { _custom?: {
jellyfin?: { jellyfin?: Partial<z.infer<typeof jfType._parameters.songList>>;
artistIds?: string; navidrome?: Partial<z.infer<typeof ndType._parameters.songList>>;
contributingArtistIds?: string;
filters?: string;
genreIds?: string;
genres?: string;
includeItemTypes: 'Audio';
isFavorite?: boolean;
maxYear?: number; // Parses to years
minYear?: number; // Parses to years
sortBy?: JFSongListSort;
years?: string;
};
navidrome?: {
album_id?: string[];
artist_id?: string[];
compilation?: boolean;
genre_id?: string;
has_rating?: boolean;
starred?: boolean;
title?: string;
year?: number;
};
}; };
albumIds?: string[]; albumIds?: string[];
artistIds?: string[]; artistIds?: string[];
@ -571,11 +533,8 @@ export enum AlbumArtistListSort {
export type AlbumArtistListQuery = { export type AlbumArtistListQuery = {
_custom?: { _custom?: {
navidrome?: { jellyfin?: Partial<z.infer<typeof jfType._parameters.albumArtistList>>;
genre_id?: string; navidrome?: Partial<z.infer<typeof ndType._parameters.albumArtistList>>;
name?: string;
starred?: boolean;
};
}; };
limit?: number; limit?: number;
musicFolderId?: string; musicFolderId?: string;
@ -662,11 +621,8 @@ export enum ArtistListSort {
export type ArtistListQuery = { export type ArtistListQuery = {
_custom?: { _custom?: {
navidrome?: { jellyfin?: Partial<z.infer<typeof jfType._parameters.albumArtistList>>;
genre_id?: string; navidrome?: Partial<z.infer<typeof ndType._parameters.albumArtistList>>;
name?: string;
starred?: boolean;
};
}; };
limit?: number; limit?: number;
musicFolderId?: string; musicFolderId?: string;
@ -848,10 +804,8 @@ export enum PlaylistListSort {
export type PlaylistListQuery = { export type PlaylistListQuery = {
_custom?: { _custom?: {
navidrome?: { jellyfin?: Partial<z.infer<typeof jfType._parameters.playlistList>>;
owner_id?: string; navidrome?: Partial<z.infer<typeof ndType._parameters.playlistList>>;
smart?: boolean;
};
}; };
limit?: number; limit?: number;
searchTerm?: string; searchTerm?: string;