@ekwoka/spotify-api
Advanced tools
Comparing version 0.13.2 to 0.14.0
@@ -15,2 +15,3 @@ /** | ||
albums: {}, | ||
playlists: {}, | ||
tracks: {}, | ||
@@ -17,0 +18,0 @@ }, |
@@ -12,2 +12,3 @@ export function spotifyApiClient(token) { | ||
tracks: {}, | ||
playlists: {}, | ||
}, | ||
@@ -14,0 +15,0 @@ }, |
@@ -10,2 +10,3 @@ import { Album } from '../endpoints/albums'; | ||
albums: Record<string, boolean>; | ||
playlists: Record<string, boolean>; | ||
tracks: Record<string, boolean>; | ||
@@ -12,0 +13,0 @@ }; |
@@ -20,2 +20,3 @@ export { albumIsSaved } from './albums/albumIsSaved'; | ||
export { getUsersPlaylists } from './playlists/getUsersPlaylists'; | ||
export { savePlaylists, removePlaylists, } from './playlists/saveOrRemovePlaylist'; | ||
export { search } from './search/search'; | ||
@@ -22,0 +23,0 @@ export { searchString } from './search/searchString'; |
@@ -20,2 +20,3 @@ export { albumIsSaved } from './albums/albumIsSaved'; | ||
export { getUsersPlaylists } from './playlists/getUsersPlaylists'; | ||
export { savePlaylists, removePlaylists, } from './playlists/saveOrRemovePlaylist'; | ||
export { search } from './search/search'; | ||
@@ -22,0 +23,0 @@ export { searchString } from './search/searchString'; |
export { getPlaylist } from './getPlaylist'; | ||
export { getPlaylistItems } from './getPlaylistItems'; | ||
export { getUsersPlaylists } from './getUsersPlaylists'; | ||
export { savePlaylists, removePlaylists } from './saveOrRemovePlaylist'; | ||
export type { Playlist, PlaylistItem, PlaylistStub } from './types'; | ||
//# sourceMappingURL=index.d.ts.map |
export { getPlaylist } from './getPlaylist'; | ||
export { getPlaylistItems } from './getPlaylistItems'; | ||
export { getUsersPlaylists } from './getUsersPlaylists'; | ||
export { savePlaylists, removePlaylists } from './saveOrRemovePlaylist'; |
@@ -1,2 +0,2 @@ | ||
import { batchWrap, spotifyFetch } from '../../utils'; | ||
import { batchWrap, spotifyFetch, createMapper, } from '../../utils'; | ||
/** | ||
@@ -9,3 +9,3 @@ * Adds a track or tracks to the current user's library. Accepts both single | ||
*/ | ||
export const saveTracks = ((ids) => createMap((id, client) => cacheNewTrackState(client, id, true))(ids)); | ||
export const saveTracks = ((ids) => createMapper((id, client) => cacheNewTrackState(client, id, true))(ids)); | ||
/** | ||
@@ -18,6 +18,3 @@ * Removes tracks from the current user's library. Accepts both a single ID | ||
*/ | ||
export const removeTracks = ((ids) => createMap((id, client) => cacheNewTrackState(client, id, false))(ids)); | ||
const createMap = (cb) => (vals) => Array.isArray(vals) | ||
? (client) => Promise.all(vals.map((val) => cb(val, client))) | ||
: (client) => cb(vals, client); | ||
export const removeTracks = ((ids) => createMapper((id, client) => cacheNewTrackState(client, id, false))(ids)); | ||
const cacheNewTrackState = async ({ token, cache }, track, state) => { | ||
@@ -24,0 +21,0 @@ await (state ? batchSaveTrack : batchRemoveTrack)(token, track); |
export { fetchOptions, makeAuthURL, refreshToken, tokensFromCode, } from './auth'; | ||
export { resetCache, setToken, spotifyApiClient } from './core'; | ||
export { albumIsSaved, addToQueue, currentlyPlayingTrack, getAlbum, getAlbums, getAlbumTracks, getArtist, getArtists, getCurrentUser, getFollowedArtists, getPlaylist, getPlaylistItems, getRecommendations, getSavedAlbums, getTopItems, getUserProfile, getUsersPlaylists, newReleases, recentlyPlayedTracks, removeAlbums, removeTracks, saveAlbums, saveTracks, search, trackIsSaved, } from './endpoints'; | ||
export { albumIsSaved, addToQueue, currentlyPlayingTrack, getAlbum, getAlbums, getAlbumTracks, getArtist, getArtists, getCurrentUser, getFollowedArtists, getPlaylist, getPlaylistItems, getRecommendations, getSavedAlbums, getTopItems, getUserProfile, getUsersPlaylists, newReleases, recentlyPlayedTracks, removeAlbums, removePlaylists, removeTracks, saveAlbums, savePlaylists, saveTracks, search, trackIsSaved, } from './endpoints'; | ||
export { spotifyFetch } from './utils/spotifyFetch'; | ||
@@ -5,0 +5,0 @@ export type { RefreshedToken, SpotifyTokens } from './auth'; |
export { fetchOptions, makeAuthURL, refreshToken, tokensFromCode, } from './auth'; | ||
export { resetCache, setToken, spotifyApiClient } from './core'; | ||
export { albumIsSaved, addToQueue, currentlyPlayingTrack, getAlbum, getAlbums, getAlbumTracks, getArtist, getArtists, getCurrentUser, getFollowedArtists, getPlaylist, getPlaylistItems, getRecommendations, getSavedAlbums, getTopItems, getUserProfile, getUsersPlaylists, newReleases, recentlyPlayedTracks, removeAlbums, removeTracks, saveAlbums, saveTracks, search, trackIsSaved, } from './endpoints'; | ||
export { albumIsSaved, addToQueue, currentlyPlayingTrack, getAlbum, getAlbums, getAlbumTracks, getArtist, getArtists, getCurrentUser, getFollowedArtists, getPlaylist, getPlaylistItems, getRecommendations, getSavedAlbums, getTopItems, getUserProfile, getUsersPlaylists, newReleases, recentlyPlayedTracks, removeAlbums, removePlaylists, removeTracks, saveAlbums, savePlaylists, saveTracks, search, trackIsSaved, } from './endpoints'; | ||
export { spotifyFetch } from './utils/spotifyFetch'; |
export { arrayWrap } from './arrayWrap'; | ||
export { batchWrap } from './batchRequests'; | ||
export { chunkArray } from './chunkArray'; | ||
export { createMapper } from './createMapper'; | ||
export { debounce } from './debounce'; | ||
@@ -12,4 +13,5 @@ export { deepFreeze } from './deepFreeze'; | ||
export type { BatchedFunction, BatchCallback } from './batchRequests'; | ||
export type { mappedArguments } from './createMapper'; | ||
export type { Image, SpotifyPageURL, SpotifyAPIURL, UNIXTimeNumber, UNIXTimeString, ISOTimeString, } from './SpotifyUtilityTypes'; | ||
export type { maybeArray } from './types'; | ||
//# sourceMappingURL=index.d.ts.map |
export { arrayWrap } from './arrayWrap'; | ||
export { batchWrap } from './batchRequests'; | ||
export { chunkArray } from './chunkArray'; | ||
export { createMapper } from './createMapper'; | ||
export { debounce } from './debounce'; | ||
@@ -5,0 +6,0 @@ export { deepFreeze } from './deepFreeze'; |
@@ -16,3 +16,3 @@ { | ||
"license": "MIT", | ||
"version": "0.13.2", | ||
"version": "0.14.0", | ||
"description": "Composable Wrapper for the Spotify Web Api and Spotify Web Playback SDK", | ||
@@ -30,6 +30,6 @@ "repository": "github:ekwoka/spotify-api", | ||
"devDependencies": { | ||
"@types/node": "^18.11.7", | ||
"@types/node": "^18.11.8", | ||
"@typescript-eslint/eslint-plugin": "^5.41.0", | ||
"@typescript-eslint/parser": "^5.41.0", | ||
"@vitest/coverage-c8": "^0.24.3", | ||
"@vitest/coverage-c8": "^0.24.4", | ||
"esbuild": "^0.15.12", | ||
@@ -45,4 +45,4 @@ "eslint": "^8.26.0", | ||
"undici": "^5.12.0", | ||
"vite": "^3.2.1", | ||
"vitest": "^0.24.3" | ||
"vite": "^3.2.2", | ||
"vitest": "^0.24.4" | ||
}, | ||
@@ -49,0 +49,0 @@ "prettier": { |
@@ -354,2 +354,4 @@ # ⚡️A tree-shakable, composable, lightweight wrapper for the multiple Spotify APIs🔥 | ||
- `getUsersPlaylists` - Gets playlists created by or saved by the current user | ||
- `savePlaylists` - Puts playlist(s) into user's library | ||
- `removePlaylists` - Deletes playlist(s) from user's library | ||
@@ -408,2 +410,24 @@ #### getPlaylist | ||
#### savePlaylists | ||
Puts playlist ID into the user's library. Returns `true` if successful. Works with single IDs or arrays of IDs. | ||
```js | ||
const isSaved = client(savePlaylists('0skYUMpS0AcbpjcGsAbRGj')); // true | ||
const wasSaved = client( | ||
savePlaylists(['0skYUMpS0AcbpjcGsAbRGj', '60jFaQV7Z4boGC4ob5B5c6']) | ||
); // [true, true] | ||
``` | ||
#### removePlaylists | ||
Deletes playlist ID from the user's library. Returns `true` if successful. Works with single IDs or arrays of IDs. | ||
```js | ||
const isRemoved = client(removePlaylists('0skYUMpS0AcbpjcGsAbRGj')); // true | ||
const wasRemoved = client( | ||
removePlaylists(['0skYUMpS0AcbpjcGsAbRGj', '60jFaQV7Z4boGC4ob5B5c6']) | ||
); // [true, true] | ||
``` | ||
### Search | ||
@@ -495,5 +519,5 @@ | ||
- `trackIsSaved` - Gets whether a provided album id is in the user's library | ||
- `saveTracks` - Put's albums into the user's library | ||
- `removeTracks` - Deletes albums from the user's library | ||
- `trackIsSaved` - Gets whether a provided track id is in the user's library | ||
- `saveTracks` - Put's tracks into the user's library | ||
- `removeTracks` - Deletes tracks from the user's library | ||
@@ -507,32 +531,32 @@ > These 3 all use batching to improve performance, and these 3 all also use a shared cache of in-Library states. | ||
#### albumIsSaved | ||
#### trackIsSaved | ||
Gets whether the provided album IDs are present in the user's library. Works with single IDs or arrays of IDs. | ||
Gets whether the provided track IDs are present in the user's library. Works with single IDs or arrays of IDs. | ||
```js | ||
const isSaved = client(albumIsSaved('0skYUMpS0AcbpjcGsAbRGj')); // true | false | ||
const isSaved = client(trackIsSaved('0skYUMpS0AcbpjcGsAbRGj')); // true | false | ||
const areSaved = client( | ||
albumIsSaved(['0skYUMpS0AcbpjcGsAbRGj', '60jFaQV7Z4boGC4ob5B5c6']) | ||
trackIsSaved(['0skYUMpS0AcbpjcGsAbRGj', '60jFaQV7Z4boGC4ob5B5c6']) | ||
); // [true, false] | ||
``` | ||
#### saveAlbums | ||
#### saveTracks | ||
Puts album ID into the user's library. Returns `true` if successful. Works with single IDs or arrays of IDs. | ||
Puts track ID into the user's library. Returns `true` if successful. Works with single IDs or arrays of IDs. | ||
```js | ||
const isSaved = client(saveAlbums('0skYUMpS0AcbpjcGsAbRGj')); // true | ||
const isSaved = client(saveTracks('0skYUMpS0AcbpjcGsAbRGj')); // true | ||
const wasSaved = client( | ||
saveAlbums(['0skYUMpS0AcbpjcGsAbRGj', '60jFaQV7Z4boGC4ob5B5c6']) | ||
saveTracks(['0skYUMpS0AcbpjcGsAbRGj', '60jFaQV7Z4boGC4ob5B5c6']) | ||
); // [true, true] | ||
``` | ||
#### removeAlbums | ||
#### removeTracks | ||
Deletes album ID from the user's library. Returns `true` if successful. Works with single IDs or arrays of IDs. | ||
Deletes track ID from the user's library. Returns `true` if successful. Works with single IDs or arrays of IDs. | ||
```js | ||
const isRemoved = client(removeAlbums('0skYUMpS0AcbpjcGsAbRGj')); // true | ||
const isRemoved = client(removeTracks('0skYUMpS0AcbpjcGsAbRGj')); // true | ||
const wasRemoved = client( | ||
removeAlbums(['0skYUMpS0AcbpjcGsAbRGj', '60jFaQV7Z4boGC4ob5B5c6']) | ||
removeTracks(['0skYUMpS0AcbpjcGsAbRGj', '60jFaQV7Z4boGC4ob5B5c6']) | ||
); // [true, true] | ||
@@ -539,0 +563,0 @@ ``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
131523
206
1777
687