From a5fb98ae6852498ea9267d59ecce9ba20bd50472 Mon Sep 17 00:00:00 2001 From: Luke Mansell Date: Fri, 28 Jul 2023 23:54:34 +1200 Subject: [PATCH] bug: Set MaxInt to 51 as the existing logic isn't inclusive --- src/endpoints/AlbumsEndpoints.ts | 2 +- src/endpoints/ArtistsEndpoints.ts | 2 +- src/endpoints/AudiobooksEndpoints.ts | 2 +- src/endpoints/BrowseEndpoints.ts | 8 ++++---- src/endpoints/CurrentUserEndpoints.ts | 18 +++++++++--------- src/endpoints/PlayerEndpoints.ts | 2 +- src/endpoints/PlaylistsEndpoints.ts | 4 ++-- src/endpoints/SearchEndpoints.ts | 4 ++-- src/endpoints/ShowsEndpoints.ts | 2 +- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/endpoints/AlbumsEndpoints.ts b/src/endpoints/AlbumsEndpoints.ts index 79311e5..e869b45 100644 --- a/src/endpoints/AlbumsEndpoints.ts +++ b/src/endpoints/AlbumsEndpoints.ts @@ -18,7 +18,7 @@ export default class AlbumsEndpoints extends EndpointsBase { return response.albums; } - public tracks(albumId: string, market?: Market, limit?: MaxInt<50>, offset?: number) { + public tracks(albumId: string, market?: Market, limit?: MaxInt<51>, offset?: number) { const params = this.paramsFor({ market, limit, offset }); return this.getRequest>(`albums/${albumId}/tracks${params}`); } diff --git a/src/endpoints/ArtistsEndpoints.ts b/src/endpoints/ArtistsEndpoints.ts index f1e95ca..0fa88ad 100644 --- a/src/endpoints/ArtistsEndpoints.ts +++ b/src/endpoints/ArtistsEndpoints.ts @@ -28,7 +28,7 @@ export default class ArtistsEndpoints extends EndpointsBase { id: string, includeGroups?: string, market?: Market, - limit?: MaxInt<50>, + limit?: MaxInt<51>, offset?: number ) { const params = this.paramsFor({ diff --git a/src/endpoints/AudiobooksEndpoints.ts b/src/endpoints/AudiobooksEndpoints.ts index ceaa646..4c0dd51 100644 --- a/src/endpoints/AudiobooksEndpoints.ts +++ b/src/endpoints/AudiobooksEndpoints.ts @@ -15,7 +15,7 @@ export default class AudiobooksEndpoints extends EndpointsBase { return response.audiobooks; } - public getAudiobookChapters(id: string, market?: Market, limit?: MaxInt<50>, offset?: number) { + public getAudiobookChapters(id: string, market?: Market, limit?: MaxInt<51>, offset?: number) { const params = this.paramsFor({ market, limit, offset }); return this.getRequest>(`audiobooks/${id}/chapters${params}`); } diff --git a/src/endpoints/BrowseEndpoints.ts b/src/endpoints/BrowseEndpoints.ts index ef586ba..baea912 100644 --- a/src/endpoints/BrowseEndpoints.ts +++ b/src/endpoints/BrowseEndpoints.ts @@ -3,7 +3,7 @@ import EndpointsBase from './EndpointsBase.js'; export default class BrowseEndpoints extends EndpointsBase { - public getCategories(country?: CountryCodeA2, locale?: string, limit?: MaxInt<50>, offset?: number) { + public getCategories(country?: CountryCodeA2, locale?: string, limit?: MaxInt<51>, offset?: number) { const params = this.paramsFor({ country, locale, limit, offset }); return this.getRequest(`browse/categories${params}`); @@ -15,17 +15,17 @@ export default class BrowseEndpoints extends EndpointsBase { return this.getRequest(`browse/categories/${categoryId}${params}`); } - public getNewReleases(country?: string, limit?: MaxInt<50>, offset?: number) { + public getNewReleases(country?: string, limit?: MaxInt<51>, offset?: number) { const params = this.paramsFor({ country, limit, offset }); return this.getRequest(`browse/new-releases${params}`); } - public getFeaturedPlaylists(country?: CountryCodeA2, locale?: string, timestamp?: string, limit?: MaxInt<50>, offset?: number) { + public getFeaturedPlaylists(country?: CountryCodeA2, locale?: string, timestamp?: string, limit?: MaxInt<51>, offset?: number) { const params = this.paramsFor({ country, locale, timestamp, limit, offset }); return this.getRequest(`browse/featured-playlists${params}`); } - public getPlaylistsForCategory(category_id: string, country?: CountryCodeA2, limit?: MaxInt<50>, offset?: number) { + public getPlaylistsForCategory(category_id: string, country?: CountryCodeA2, limit?: MaxInt<51>, offset?: number) { const params = this.paramsFor({ country, limit, offset }); return this.getRequest(`browse/categories/${category_id}/playlists${params}`); } diff --git a/src/endpoints/CurrentUserEndpoints.ts b/src/endpoints/CurrentUserEndpoints.ts index ec48cf6..4e3a30c 100644 --- a/src/endpoints/CurrentUserEndpoints.ts +++ b/src/endpoints/CurrentUserEndpoints.ts @@ -26,13 +26,13 @@ export default class CurrentUserEndpoints extends EndpointsBase { } public topItems(type: "artists" | "tracks"): Promise>; - public topItems(type: "artists" | "tracks", time_range?: 'short_term' | 'medium_term' | 'long_term', limit?: MaxInt<50>, offset?: number): Promise>; - public topItems(type: "artists" | "tracks", time_range?: 'short_term' | 'medium_term' | 'long_term', limit?: MaxInt<50>, offset?: number) { + public topItems(type: "artists" | "tracks", time_range?: 'short_term' | 'medium_term' | 'long_term', limit?: MaxInt<51>, offset?: number): Promise>; + public topItems(type: "artists" | "tracks", time_range?: 'short_term' | 'medium_term' | 'long_term', limit?: MaxInt<51>, offset?: number) { const params = this.paramsFor({ time_range, limit, offset }); return this.getRequest>(`me/top/${type}${params}`); } - public followedArtists(after?: string, limit?: MaxInt<50>) { + public followedArtists(after?: string, limit?: MaxInt<51>) { const params = this.paramsFor({ type: "artist", after, limit }); return this.getRequest(`me/following${params}`); } @@ -55,7 +55,7 @@ export default class CurrentUserEndpoints extends EndpointsBase { class CurrentUserAlbumsEndpoints extends EndpointsBase { - public savedAlbums(limit?: MaxInt<50>, offset?: number, market?: Market) { + public savedAlbums(limit?: MaxInt<51>, offset?: number, market?: Market) { const params = this.paramsFor({ limit, offset, market }); return this.getRequest>(`me/albums${params}`); } @@ -75,7 +75,7 @@ class CurrentUserAlbumsEndpoints extends EndpointsBase { } class CurrentUserAudiobooksEndpoints extends EndpointsBase { - public savedAudiobooks(limit?: MaxInt<50>, offset?: number) { + public savedAudiobooks(limit?: MaxInt<51>, offset?: number) { const params = this.paramsFor({ limit, offset }); return this.getRequest>(`me/audiobooks${params}`); } @@ -95,7 +95,7 @@ class CurrentUserAudiobooksEndpoints extends EndpointsBase { } class CurrentUserEpisodesEndpoints extends EndpointsBase { - public savedEpisodes(market?: Market, limit?: MaxInt<50>, offset?: number) { + public savedEpisodes(market?: Market, limit?: MaxInt<51>, offset?: number) { const params = this.paramsFor({ market, limit, offset }); return this.getRequest>(`me/episodes${params}`); } @@ -115,7 +115,7 @@ class CurrentUserEpisodesEndpoints extends EndpointsBase { } class CurrentUserPlaylistsEndpoints extends EndpointsBase { - public playlists(limit?: MaxInt<50>, offset?: number) { + public playlists(limit?: MaxInt<51>, offset?: number) { const params = this.paramsFor({ limit, offset }); return this.getRequest>(`me/playlists${params}`); } @@ -135,7 +135,7 @@ class CurrentUserPlaylistsEndpoints extends EndpointsBase { } class CurrentUserShowsEndpoints extends EndpointsBase { - public savedShows(limit?: MaxInt<50>, offset?: number) { + public savedShows(limit?: MaxInt<51>, offset?: number) { const params = this.paramsFor({ limit, offset }) return this.getRequest>(`me/shows${params}`); } @@ -157,7 +157,7 @@ class CurrentUserShowsEndpoints extends EndpointsBase { } class CurrentUserTracksEndpoints extends EndpointsBase { - public savedTracks(limit?: MaxInt<50>, offset?: number, market?: Market) { + public savedTracks(limit?: MaxInt<51>, offset?: number, market?: Market) { const params = this.paramsFor({ limit, offset, market }); return this.getRequest>(`me/tracks${params}`); } diff --git a/src/endpoints/PlayerEndpoints.ts b/src/endpoints/PlayerEndpoints.ts index 0dd6b4b..513853a 100644 --- a/src/endpoints/PlayerEndpoints.ts +++ b/src/endpoints/PlayerEndpoints.ts @@ -21,7 +21,7 @@ export default class PlayerEndpoints extends EndpointsBase { return this.getRequest(`me/player/currently-playing${params}`); } - public getRecentlyPlayedTracks(limit?: MaxInt<50>, queryRange?: QueryRange) { + public getRecentlyPlayedTracks(limit?: MaxInt<51>, queryRange?: QueryRange) { const paramObj: any = { limit }; if (queryRange) { diff --git a/src/endpoints/PlaylistsEndpoints.ts b/src/endpoints/PlaylistsEndpoints.ts index f79a3ae..cdab0b8 100644 --- a/src/endpoints/PlaylistsEndpoints.ts +++ b/src/endpoints/PlaylistsEndpoints.ts @@ -9,7 +9,7 @@ export default class PlaylistsEndpoints extends EndpointsBase { return this.getRequest(`playlists/${playlist_id}${params}`); } - public getPlaylistItems(playlist_id: string, market?: Market, fields?: string, limit?: MaxInt<50>, offset?: number, additional_types?: string) { + public getPlaylistItems(playlist_id: string, market?: Market, fields?: string, limit?: MaxInt<51>, offset?: number, additional_types?: string) { // TODO: better support for fields const params = this.paramsFor({ market, fields, limit, offset, additional_types }); return this.getRequest>(`playlists/${playlist_id}/tracks${params}`); @@ -39,7 +39,7 @@ export default class PlaylistsEndpoints extends EndpointsBase { await this.deleteRequest(`playlists/${playlist_id}/tracks`, request); } - public getUsersPlaylists(user_id: string, limit?: MaxInt<50>, offset?: number) { + public getUsersPlaylists(user_id: string, limit?: MaxInt<51>, offset?: number) { const params = this.paramsFor({ limit, offset }); return this.getRequest>(`users/${user_id}/playlists${params}`); } diff --git a/src/endpoints/SearchEndpoints.ts b/src/endpoints/SearchEndpoints.ts index b91052e..3c5d25e 100644 --- a/src/endpoints/SearchEndpoints.ts +++ b/src/endpoints/SearchEndpoints.ts @@ -2,11 +2,11 @@ import type { ItemTypes, Market, MaxInt, SearchResults } from '../types.js'; import EndpointsBase from './EndpointsBase.js'; export interface SearchExecutionFunction { - (q: string, type: ItemTypes[], market?: Market, limit?: MaxInt<50>, offset?: number, include_external?: string): Promise; + (q: string, type: ItemTypes[], market?: Market, limit?: MaxInt<51>, offset?: number, include_external?: string): Promise; } export default class SearchEndpoints extends EndpointsBase { - public async execute(q: string, type: ItemTypes[], market?: Market, limit?: MaxInt<50>, offset?: number, include_external?: string) { + public async execute(q: string, type: ItemTypes[], market?: Market, limit?: MaxInt<51>, offset?: number, include_external?: string) { const params = this.paramsFor({ q, type, market, limit, offset, include_external }); return await this.getRequest(`search${params}`); } diff --git a/src/endpoints/ShowsEndpoints.ts b/src/endpoints/ShowsEndpoints.ts index 664c3a6..2355c5d 100644 --- a/src/endpoints/ShowsEndpoints.ts +++ b/src/endpoints/ShowsEndpoints.ts @@ -17,7 +17,7 @@ export default class ShowsEndpoints extends EndpointsBase { return response.shows; } - public episodes(id: string, market?: Market, limit?: MaxInt<50>, offset?: number) { + public episodes(id: string, market?: Market, limit?: MaxInt<51>, offset?: number) { const params = this.paramsFor({ market, limit, offset }) return this.getRequest>(`shows/${id}/episodes${params}`); }