Skip to content

Set MaxInt to 51 as the existing logic isn't inclusive #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/endpoints/AlbumsEndpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Page<SimplifiedTrack>>(`albums/${albumId}/tracks${params}`);
}
Expand Down
2 changes: 1 addition & 1 deletion src/endpoints/ArtistsEndpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion src/endpoints/AudiobooksEndpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Page<SimplifiedChapter>>(`audiobooks/${id}/chapters${params}`);
}
Expand Down
8 changes: 4 additions & 4 deletions src/endpoints/BrowseEndpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Categories>(`browse/categories${params}`);
Expand All @@ -15,17 +15,17 @@ export default class BrowseEndpoints extends EndpointsBase {
return this.getRequest<Category>(`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<NewReleases>(`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<FeaturedPlaylists>(`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<FeaturedPlaylists>(`browse/categories/${category_id}/playlists${params}`);
}
Expand Down
18 changes: 9 additions & 9 deletions src/endpoints/CurrentUserEndpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ export default class CurrentUserEndpoints extends EndpointsBase {
}

public topItems(type: "artists" | "tracks"): Promise<Page<Artist>>;
public topItems(type: "artists" | "tracks", time_range?: 'short_term' | 'medium_term' | 'long_term', limit?: MaxInt<50>, offset?: number): Promise<Page<Artist>>;
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<Page<Artist>>;
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<Page<Artist>>(`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<FollowedArtists>(`me/following${params}`);
}
Expand All @@ -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<Page<SavedAlbum>>(`me/albums${params}`);
}
Expand All @@ -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<Page<SimplifiedAudiobook>>(`me/audiobooks${params}`);
}
Expand All @@ -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<Page<SavedEpisode>>(`me/episodes${params}`);
}
Expand All @@ -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<Page<SimplifiedPlaylist>>(`me/playlists${params}`);
}
Expand All @@ -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<Page<SavedShow>>(`me/shows${params}`);
}
Expand All @@ -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<Page<SavedTrack>>(`me/tracks${params}`);
}
Expand Down
2 changes: 1 addition & 1 deletion src/endpoints/PlayerEndpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class PlayerEndpoints extends EndpointsBase {
return this.getRequest<PlaybackState>(`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) {
Expand Down
4 changes: 2 additions & 2 deletions src/endpoints/PlaylistsEndpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default class PlaylistsEndpoints extends EndpointsBase {
return this.getRequest<Playlist>(`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<Page<PlaylistedTrack>>(`playlists/${playlist_id}/tracks${params}`);
Expand Down Expand Up @@ -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<Page<Playlist>>(`users/${user_id}/playlists${params}`);
}
Expand Down
4 changes: 2 additions & 2 deletions src/endpoints/SearchEndpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<SearchResults>;
(q: string, type: ItemTypes[], market?: Market, limit?: MaxInt<51>, offset?: number, include_external?: string): Promise<SearchResults>;
}

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<SearchResults>(`search${params}`);
}
Expand Down
2 changes: 1 addition & 1 deletion src/endpoints/ShowsEndpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Page<SimplifiedEpisode>>(`shows/${id}/episodes${params}`);
}
Expand Down