Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@soundify/api

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@soundify/api - npm Package Compare versions

Comparing version 0.0.29 to 0.0.30

esm/endpoints.js

35

esm/client.js

@@ -1,2 +0,5 @@

import { searchParamsFromObj, } from "@soundify/shared";
import { objectToSearchParams, } from "@soundify/shared";
/**
* Client will throw this error if spotify will return error
*/
export class SpotifyError extends Error {

@@ -24,5 +27,5 @@ status;

/**
* Access Token or object that implements `IAuthProvider`
* Access token or object that implements `Accessor`
*/
#authProvider;
#accessor;
#retry5xx = {

@@ -38,8 +41,8 @@ times: 0,

/**
* It is recommended to pass a class that implements `IAuthProvider`
* It is recommended to pass a class that implements `Accessor`
* to automatically update tokens. If you do not need this behavior,
* you can simply pass an access token.
*/
authProvider, opts = {}) {
this.#authProvider = authProvider;
accessor, opts = {}) {
this.#accessor = accessor;
if (opts.retry5xx)

@@ -50,9 +53,9 @@ this.#retry5xx = opts.retry5xx;

}
setAuthProvider(authProvider) {
this.#authProvider = authProvider;
setAccessor(accessor) {
this.#accessor = accessor;
}
async fetch(baseURL, returnType, { body, query, method } = {}) {
async fetch(baseURL, responseType, { body, query, method } = {}) {
const url = new URL("https://api.spotify.com/v1" + baseURL);
if (query) {
url.search = searchParamsFromObj(query).toString();
url.search = objectToSearchParams(query).toString();
}

@@ -63,5 +66,5 @@ const serializedBody = body ? JSON.stringify(body) : undefined;

let retry429 = this.#retry429.times;
let accessToken = typeof this.#authProvider === "string"
? this.#authProvider
: await this.#authProvider.getAccessToken();
let accessToken = typeof this.#accessor === "string"
? this.#accessor
: await this.#accessor.getAccessToken();
const call = async () => {

@@ -79,5 +82,5 @@ const res = await fetch(url, {

return res;
if (res.status === 401 && typeof this.#authProvider !== "string" &&
if (res.status === 401 && typeof this.#accessor !== "string" &&
!isTriedRefresh) {
const newToken = await this.#authProvider.getAccessToken(true);
const newToken = await this.#accessor.getAccessToken(true);
accessToken = newToken;

@@ -111,3 +114,3 @@ isTriedRefresh = true;

const res = await call();
if (returnType === "json") {
if (responseType === "json") {
return await res.json();

@@ -114,0 +117,0 @@ }

@@ -1,17 +0,11 @@

export * from "./album/album.endpoints.js";
export * from "./album/album.types.js";
export * from "./artist/artist.endpoints.js";
export * from "./artist/artist.types.js";
export * from "./category/category.endpoints.js";
export * from "./category/category.types.js";
export * from "./genre/genre.endpoints.js";
export * from "./genre/genre.types.js";
export * from "./market/market.endpoints.js";
export * from "./market/market.types.js";
export * from "./playlist/playlist.endpoints.js";
export * from "./playlist/playlist.types.js";
export * from "./track/track.endpoints.js";
export * from "./track/track.types.js";
export * from "./user/user.endpoints.js";
export * from "./user/user.types.js";
export * from "./general.types.js";
export * from "./endpoints.js";
export * from "./client.js";

@@ -5,7 +5,10 @@ {

"name": "@soundify/api",
"version": "0.0.29",
"version": "0.0.30",
"description": "Modern Spotify api wrapper for Node, Deno, and browser 🎧",
"license": "MIT",
"devDependencies": {},
"devDependencies": {
"@types/node": "latest"
},
"dependencies": {
"@soundify/shared": "0.0.29"
"@soundify/shared": "0.0.30"
},

@@ -22,2 +25,14 @@ "packageManager": "pnpm@7.29.1",

"homepage": "https://github.com/MellKam/soundify/readme",
"keywords": [
"spotify",
"api",
"wrapper",
"music",
"client",
"soundify",
"web",
"js",
"ts",
"deno"
],
"exports": {

@@ -24,0 +39,0 @@ ".": {

@@ -1,6 +0,6 @@

import { HTTPClient, QueryParams } from "@soundify/shared";
import { HTTPClient, SearchParams } from "@soundify/shared";
import { PagingObject } from "../general.types.js";
import { Market } from "../market/market.types.js";
import { Category } from "./category.types.js";
interface GetBrowseCategoriesOpts extends QueryParams {
interface GetBrowseCategoriesOpts extends SearchParams {
/**

@@ -40,3 +40,3 @@ * An ISO 3166-1 alpha-2 country code.

export declare const getBrowseCategories: (client: HTTPClient, opts?: GetBrowseCategoriesOpts) => Promise<PagingObject<Category>>;
interface GetBrowseCategoryOpts extends QueryParams {
interface GetBrowseCategoryOpts extends SearchParams {
/**

@@ -43,0 +43,0 @@ * An ISO 3166-1 alpha-2 country code.

@@ -1,3 +0,3 @@

import { JSONObject } from "@soundify/shared";
import { Image, NonNullableJSON } from "../general.types.js";
import { JSONObject, NonNullableJSON } from "@soundify/shared";
import { Image } from "../general.types.js";
export interface Category extends JSONObject {

@@ -4,0 +4,0 @@ /**

@@ -1,2 +0,2 @@

import { FetchOpts, HTTPClient, IAuthProvider, JSONObject } from "@soundify/shared";
import { Accessor, FetchOpts, HTTPClient, JSONValue } from "@soundify/shared";
type Retry = {

@@ -16,2 +16,5 @@ /**

};
/**
* Client will throw this error if spotify will return error
*/
export declare class SpotifyError extends Error {

@@ -43,18 +46,11 @@ readonly status: number;

/**
* It is recommended to pass a class that implements `IAuthProvider`
* It is recommended to pass a class that implements `Accessor`
* to automatically update tokens. If you do not need this behavior,
* you can simply pass an access token.
*/
authProvider: IAuthProvider | string, opts?: SpotifyClientOpts);
setAuthProvider(authProvider: IAuthProvider | string): void;
/**
* Sends an HTTP request to the Spotify API.
*
* @param baseURL The base URL for the API request. Must begin with "/"
* @param returnType The expected return type of the API response.
* @param opts Optional request options, such as the request body or query parameters.
*/
fetch(baseURL: string, returnType: "void", opts?: FetchOpts): Promise<void>;
fetch<R extends JSONObject = JSONObject>(baseURL: string, returnType: "json", opts?: FetchOpts): Promise<R>;
accessor: Accessor | string, opts?: SpotifyClientOpts);
setAccessor(accessor: Accessor | string): void;
fetch(baseURL: string, responseType: "void", opts?: FetchOpts): Promise<void>;
fetch<R extends JSONValue = JSONValue>(baseURL: string, responseType: "json", opts?: FetchOpts): Promise<R>;
}
export {};

@@ -1,5 +0,2 @@

import { JSONObject, QueryParams } from "@soundify/shared";
export type NonNullableJSON<T extends JSONObject> = {
[K in keyof T]: NonNullable<T[K]>;
};
import { JSONObject, SearchParams } from "@soundify/shared";
export interface PagingObject<T extends JSONObject> extends JSONObject {

@@ -64,3 +61,3 @@ /**

}
export interface PagingOptions extends QueryParams {
export interface PagingOptions extends SearchParams {
/**

@@ -67,0 +64,0 @@ * The maximum number of items to return. Minimum: 1. Maximum: 50.

@@ -1,17 +0,11 @@

export * from "./album/album.endpoints.js";
export * from "./album/album.types.js";
export * from "./artist/artist.endpoints.js";
export * from "./artist/artist.types.js";
export * from "./category/category.endpoints.js";
export * from "./category/category.types.js";
export * from "./genre/genre.endpoints.js";
export * from "./genre/genre.types.js";
export * from "./market/market.endpoints.js";
export * from "./market/market.types.js";
export * from "./playlist/playlist.endpoints.js";
export * from "./playlist/playlist.types.js";
export * from "./track/track.endpoints.js";
export * from "./track/track.types.js";
export * from "./user/user.endpoints.js";
export * from "./user/user.types.js";
export * from "./general.types.js";
export * from "./endpoints.js";
export * from "./client.js";

@@ -1,6 +0,6 @@

import { HTTPClient, JSONObject, QueryParams } from "@soundify/shared";
import { HTTPClient, JSONObject, SearchParams } from "@soundify/shared";
import { Market } from "../market/market.types.js";
import { PagingObject, PagingOptions } from "../general.types.js";
import { Playlist, PlaylistTrack } from "./playlist.types.js";
interface PlaylistFieldsOpts extends QueryParams {
interface PlaylistFieldsOpts extends SearchParams {
/**

@@ -16,3 +16,3 @@ * List of item types that your client supports besides the default track type.

}
interface GetPlaylistOpts extends QueryParams, PlaylistFieldsOpts {
interface GetPlaylistOpts extends SearchParams, PlaylistFieldsOpts {
/**

@@ -60,3 +60,3 @@ * An ISO 3166-1 alpha-2 country code.

export declare const changePlaylistDetails: (client: HTTPClient, playlist_id: string, body: ChangePlaylistDetailsBody) => Promise<void>;
interface GetPlaylistTracksOpts extends QueryParams, PlaylistFieldsOpts, PagingOptions {
interface GetPlaylistTracksOpts extends SearchParams, PlaylistFieldsOpts, PagingOptions {
/**

@@ -63,0 +63,0 @@ * An ISO 3166-1 alpha-2 country code.

@@ -1,2 +0,2 @@

import { JSONObject, QueryParams } from "@soundify/shared";
import { JSONObject, SearchParams } from "@soundify/shared";
import { AlbumSimplified } from "../album/album.types.js";

@@ -444,3 +444,3 @@ import { Artist } from "../artist/artist.types.js";

}
export interface GetRecommendationsOpts extends QueryParams {
export interface GetRecommendationsOpts extends SearchParams {
/**

@@ -447,0 +447,0 @@ * List of Spotify IDs for seed artists. Maximum 5 IDs

@@ -5,3 +5,3 @@ import { Artist } from "../artist/artist.types.js";

import { CursorPagingObject, PagingObject, PagingOptions } from "../general.types.js";
import { HTTPClient, QueryParams } from "@soundify/shared";
import { HTTPClient, SearchParams } from "@soundify/shared";
/**

@@ -13,3 +13,3 @@ * Get detailed profile information about the current user.

export declare const getCurrentUserProfile: (client: HTTPClient) => Promise<UserPrivate>;
interface GetUserTopItemsOpts extends QueryParams, PagingOptions {
interface GetUserTopItemsOpts extends SearchParams, PagingOptions {
/**

@@ -78,3 +78,3 @@ * Over what time frame the affinities are computed.

export declare const unfollowPlaylist: (client: HTTPClient, playlist_id: string) => Promise<void>;
interface GetFollowedArtistsOpts extends QueryParams, Pick<PagingOptions, "limit"> {
interface GetFollowedArtistsOpts extends SearchParams, Pick<PagingOptions, "limit"> {
/**

@@ -81,0 +81,0 @@ * The last artist ID retrieved from the previous request.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc