Socket
Socket
Sign inDemoInstall

@musicorum/lastfm

Package Overview
Dependencies
0
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.1 to 0.1.2

dist/packages/Album.d.ts

8

dist/LastClient.d.ts
import { User } from './packages/User.js';
import { Track } from './packages/Track.js';
import { Album } from './packages/Album.js';
import { Artist } from './packages/Artist.js';
import type { GetOriginalResponse, LastfmApiMethod, LastfmResponses } from './types/responses';

@@ -10,2 +13,5 @@ export declare class LastClient {

user: User;
track: Track;
album: Album;
artist: Artist;
constructor(apiKey: string, apiSecret?: string | undefined, sessionToken?: string | undefined, userAgent?: string | undefined);

@@ -17,3 +23,3 @@ onRequestStarted(method: LastfmApiMethod, params: Record<string, string>, internalData: Record<string, never>): void;

*/
request<M extends LastfmApiMethod>(method: M, params?: Record<string, string>): Promise<GetOriginalResponse<LastfmResponses[M]>>;
request<M extends LastfmApiMethod>(method: M, params?: Record<string, string | (string | undefined)>): Promise<GetOriginalResponse<LastfmResponses[M]>>;
}

13

dist/LastClient.js
/* eslint-disable @typescript-eslint/no-unused-vars */
import { LastfmError } from './error/LastfmError.js';
import { User } from './packages/User.js';
import { Track } from './packages/Track.js';
import { Album } from './packages/Album.js';
import { Artist } from './packages/Artist.js';
export class LastClient {

@@ -11,2 +14,5 @@ apiKey;

user = new User(this);
track = new Track(this);
album = new Album(this);
artist = new Artist(this);
constructor(apiKey, apiSecret, sessionToken, userAgent) {

@@ -36,5 +42,6 @@ this.apiKey = apiKey;

};
const queryString = new URLSearchParams(params).toString();
const cleanParams = Object.fromEntries(Object.entries(params).filter(([_, v]) => !!v));
const queryString = new URLSearchParams(cleanParams).toString();
const internalData = {};
this.onRequestStarted(method, params, internalData);
this.onRequestStarted(method, cleanParams, internalData);
const response = await fetch(`${this.apiUrl}?${queryString}`, {

@@ -47,3 +54,3 @@ headers: {

const data = await response.json();
this.onRequestFinished(method, params, internalData, data);
this.onRequestFinished(method, cleanParams, internalData, data);
if (!response.ok)

@@ -50,0 +57,0 @@ throw new LastfmError(data);

@@ -11,2 +11,12 @@ export declare type StringRecord<K extends string> = Record<K, string>;

}
export interface LastfmRawWikiData {
published: string;
summary: string;
content: string;
}
export interface LastfmWikiData {
published: Date;
summary: string;
content: string;
}
export declare type PaginatedResponseAttributes<EXTRA extends string = never> = {

@@ -21,1 +31,2 @@ totalPages: string;

export declare type LastfmDate = StringRecord<'uts' | '#text'>;
export declare type LastfmTag = StringRecord<'name' | 'url'>;

@@ -57,3 +57,3 @@ import type { LastfmDate, LastfmImage, LastfmRawImage, PaginatedResponseAttributes, StringRecord } from './common';

/**
* Extended response includes whether or not the user has loved each track
* Extended response includes whether the user has loved each track
* The API also returns images for the artists of each track, but this is omitted since it defaults to a default image

@@ -60,0 +60,0 @@ */

import type { LastfmOriginalUserInfoResponse, LastfmOriginalUserRecentTracksResponse, LastfmOriginalUserTopArtistsResponse, LastfmUserInfo } from './packages/user';
import { LastfmOriginalTrackInfoResponse, LastfmTrackInfo } from './packages/track';
import { LastfmAlbumInfo, LastfmOriginalAlbumInfoResponse } from './packages/album';
import { LastfmArtistInfo, LastfmOriginalArtistInfoResponse } from './packages/artist';
export interface LastfmErrorResponse {

@@ -16,3 +19,6 @@ error: number;

'user.getTopArtists': LastfmResponse<LastfmOriginalUserTopArtistsResponse>;
'track.getInfo': LastfmResponse<LastfmOriginalTrackInfoResponse, LastfmTrackInfo>;
'album.getInfo': LastfmResponse<LastfmOriginalAlbumInfoResponse, LastfmAlbumInfo>;
'artist.getInfo': LastfmResponse<LastfmOriginalArtistInfoResponse, LastfmArtistInfo>;
};
export declare type LastfmApiMethod = keyof LastfmResponses;
{
"name": "@musicorum/lastfm",
"version": "0.1.1",
"version": "0.1.2",
"description": "",

@@ -5,0 +5,0 @@ "main": "dist/LastClient.js",

/* eslint-disable @typescript-eslint/no-unused-vars */
import { LastfmError } from './error/LastfmError.js'
import { User } from './packages/User.js'
import { Track } from './packages/Track.js'
import { Album } from './packages/Album.js'
import { Artist } from './packages/Artist.js'
import type {

@@ -14,2 +17,5 @@ GetOriginalResponse,

public user = new User(this)
public track = new Track(this)
public album = new Album(this)
public artist = new Artist(this)

@@ -45,3 +51,3 @@ constructor(

method: M,
params?: Record<string, string>
params?: Record<string, string | (string | undefined)>
) {

@@ -54,6 +60,11 @@ params = {

}
const queryString = new URLSearchParams(params).toString()
const cleanParams: { [p: string]: string } = Object.fromEntries(
Object.entries(params).filter(([_, v]) => !!v) as [string, string][]
)
const queryString = new URLSearchParams(cleanParams).toString()
const internalData = {}
this.onRequestStarted(method, params, internalData)
this.onRequestStarted(method, cleanParams, internalData)
const response = await fetch(`${this.apiUrl}?${queryString}`, {

@@ -67,3 +78,3 @@ headers: {

const data = await response.json()
this.onRequestFinished(method, params, internalData, data)
this.onRequestFinished(method, cleanParams, internalData, data)

@@ -70,0 +81,0 @@ if (!response.ok) throw new LastfmError(data)

@@ -20,2 +20,14 @@ export type StringRecord<K extends string> = Record<K, string>

export interface LastfmRawWikiData {
published: string
summary: string
content: string
}
export interface LastfmWikiData {
published: Date
summary: string
content: string
}
export type PaginatedResponseAttributes<EXTRA extends string = never> = {

@@ -29,1 +41,3 @@ totalPages: string

export type LastfmDate = StringRecord<'uts' | '#text'>
export type LastfmTag = StringRecord<'name' | 'url'>

@@ -68,3 +68,3 @@ import type {

/**
* Extended response includes whether or not the user has loved each track
* Extended response includes whether the user has loved each track
* The API also returns images for the artists of each track, but this is omitted since it defaults to a default image

@@ -71,0 +71,0 @@ */

@@ -7,2 +7,14 @@ import type {

} from './packages/user'
import {
LastfmOriginalTrackInfoResponse,
LastfmTrackInfo
} from './packages/track'
import {
LastfmAlbumInfo,
LastfmOriginalAlbumInfoResponse
} from './packages/album'
import {
LastfmArtistInfo,
LastfmOriginalArtistInfoResponse
} from './packages/artist'

@@ -31,4 +43,16 @@ export interface LastfmErrorResponse {

'user.getTopArtists': LastfmResponse<LastfmOriginalUserTopArtistsResponse>
'track.getInfo': LastfmResponse<
LastfmOriginalTrackInfoResponse,
LastfmTrackInfo
>
'album.getInfo': LastfmResponse<
LastfmOriginalAlbumInfoResponse,
LastfmAlbumInfo
>
'artist.getInfo': LastfmResponse<
LastfmOriginalArtistInfoResponse,
LastfmArtistInfo
>
}
export type LastfmApiMethod = keyof LastfmResponses
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc