lastfm-nodejs-client 1.4.4 → 1.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,309 @@
1
+ export interface AuthResponse {
2
+ token: string;
3
+ }
4
+
5
+ export interface LovedTracksResponse {
6
+ lovedtracks: LovedTracks;
7
+ }
8
+
9
+ export interface LovedTracks {
10
+ track: Track[];
11
+ '@attr': AttrNowPlaying;
12
+ }
13
+ export interface TopAlbumsResponse {
14
+ topalbums: TopAlbums;
15
+ }
16
+
17
+ export interface TopTrackResponse {
18
+ toptracks: TopTracks;
19
+ }
20
+
21
+ export interface TopTracks {
22
+ track: Track[];
23
+ '@attr': AttrLimit;
24
+ }
25
+
26
+ export interface UserResponse {
27
+ user: User;
28
+ }
29
+
30
+ export interface RecentTracksResponse {
31
+ recenttracks: RecentTracks;
32
+ }
33
+
34
+ export interface RecentTracks {
35
+ track: Track[];
36
+ '@attr': AttrLimit;
37
+ }
38
+
39
+ export interface TagsResponse {
40
+ tag: Tag[];
41
+ '@attr': Attr;
42
+ }
43
+
44
+ export interface Tag {
45
+ name: string;
46
+ url: string;
47
+ reach: string;
48
+ taggings: string;
49
+ streamable: string;
50
+ wiki: Wiki;
51
+ }
52
+
53
+ export interface Wiki {}
54
+
55
+ export interface LoveTracksResponse {
56
+ lovedtracks: LovedTracks;
57
+ }
58
+
59
+ export interface LovedTracks {
60
+ track: Track[];
61
+ '@attr': AttrNowPlaying;
62
+ }
63
+ export interface FriendsResponse {
64
+ friends: Friends;
65
+ }
66
+
67
+ export interface Friends {
68
+ '@attr': AttrNowPlaying;
69
+ user: User[];
70
+ }
71
+
72
+ export interface ChartTopArtistRepsonse {
73
+ artists: Artist[];
74
+ '@attr': AttributesPage;
75
+ }
76
+ export interface TopArtistsResponse {
77
+ topartists: TopArtists;
78
+ }
79
+
80
+ export interface TopArtists {
81
+ artist: Artist[];
82
+ '@attr': AttrLimit;
83
+ }
84
+
85
+ export interface WeeklyArtistChartResponse {
86
+ weeklyartistchart: WeeklyArtistChart;
87
+ }
88
+
89
+ export interface WeeklyArtistChart {
90
+ artist: Artist[];
91
+ '@attr': AttrLimit;
92
+ }
93
+
94
+ export interface WeeklyAlbumChartResponse {
95
+ weeklyalbumchart: WeeklyAlbumChart;
96
+ }
97
+
98
+ export interface WeeklyAlbumChart {
99
+ album: WeeklyAlbum[];
100
+ '@attr': WeeklyalbumChartAttr;
101
+ }
102
+
103
+ export interface WeeklyAlbum {
104
+ artist: {
105
+ mbid: string;
106
+ '#text': string;
107
+ };
108
+ mbid: string;
109
+ url: string;
110
+ name: string;
111
+ '@attr': { rank: string };
112
+ playcount: string;
113
+ image?: string;
114
+ }
115
+
116
+ export interface WeeklyalbumChartAttr {
117
+ from: string;
118
+ to: string;
119
+ user: string;
120
+ }
121
+
122
+ export interface AlbumAttr {
123
+ rank: string;
124
+ }
125
+
126
+ export type Artist = {
127
+ '@attr': {
128
+ rank: number;
129
+ };
130
+ cover: ArtistImage;
131
+ image?: Image[];
132
+ mbid: string;
133
+ name: string;
134
+ playcount: number;
135
+ streamable: number;
136
+ url: string;
137
+ '#text': string;
138
+ };
139
+
140
+ export interface AttributesPage {
141
+ page: number;
142
+ perPage: number;
143
+ user: string;
144
+ total: number;
145
+ totalPages: number;
146
+ }
147
+
148
+ export interface ArtistImage {
149
+ name: string;
150
+ photo: string;
151
+ attribution: string;
152
+ playcount: number;
153
+ }
154
+
155
+ export interface Album extends Track {
156
+ album: Album;
157
+ artist: Artist;
158
+ name: string;
159
+ url: string;
160
+ }
161
+
162
+ export interface AttrNowPlaying {
163
+ nowplaying: string;
164
+ }
165
+
166
+ export interface Date {
167
+ uts: string;
168
+ '#text': string;
169
+ }
170
+
171
+ export interface Track {
172
+ '@attr'?: AttrRank;
173
+ album: Album;
174
+ artist: Artist;
175
+ date?: Date;
176
+ duration?: string;
177
+ image?: Image[];
178
+ mbid: string;
179
+ name: string;
180
+ playcount?: string;
181
+ streamable?: string;
182
+ url: string;
183
+ }
184
+
185
+ export interface AttrLimit {
186
+ user?: string;
187
+ totalPages: string;
188
+ page: string;
189
+ perPage: string;
190
+ total: string;
191
+ }
192
+
193
+ export interface RecentTracks {
194
+ track: Track[];
195
+ '@attr': AttrLimit;
196
+ }
197
+
198
+ export interface Image {
199
+ size: string;
200
+ '#text': string;
201
+ }
202
+
203
+ export interface Registered {
204
+ unixtime: string;
205
+ '#text': number;
206
+ }
207
+
208
+ export interface User {
209
+ name: string;
210
+ age: string;
211
+ subscriber: string;
212
+ realname: string;
213
+ bootstrap: string;
214
+ playcount: string;
215
+ artist_count: string;
216
+ playlists: string;
217
+ track_count: string;
218
+ album_count: string;
219
+ image: Image[];
220
+ registered: Registered;
221
+ country: string;
222
+ gender: string;
223
+ url: string;
224
+ type: string;
225
+ }
226
+
227
+ export interface TopAlbums {
228
+ album: Album[];
229
+ '@attr': AttrLimit;
230
+ }
231
+
232
+ export interface WeeklyArtistChartResponse {
233
+ weeklyartistchart: WeeklyArtistChart;
234
+ }
235
+
236
+ export interface WeeklyArtistChart {
237
+ artist: Artist[];
238
+ '@attr': AttrLimit;
239
+ }
240
+
241
+ export interface AttrRank {
242
+ rank?: string;
243
+ }
244
+
245
+ export interface AttrLimit {
246
+ from: string;
247
+ user: string;
248
+ to: string;
249
+ }
250
+
251
+ export interface WeeklyChartListResponse {
252
+ weeklychartlist: WeeklyChartList;
253
+ }
254
+
255
+ export interface WeeklyChartList {
256
+ chart: WeeklyChartListChart[];
257
+ '@attr': WeeklyChartListAttr;
258
+ }
259
+
260
+ export interface WeeklyChartListChart {
261
+ '#text': string;
262
+ from: string;
263
+ to: string;
264
+ }
265
+
266
+ export interface WeeklyChartListAttr {
267
+ user: string;
268
+ }
269
+
270
+ export interface WeeklyTrackChartResponse {
271
+ weeklytrackchart: WeeklyTrackChart;
272
+ }
273
+
274
+ export interface WeeklyTrackChart {
275
+ track: Track[];
276
+ '@attr': AttrLimit;
277
+ }
278
+
279
+ export interface WeeklyTrackChartTrack {
280
+ artist: WeeklyTrackChartArtist;
281
+ image: Image[];
282
+ mbid: string;
283
+ url: string;
284
+ name: string;
285
+ '@attr': AttrNowPlaying;
286
+ playcount: string;
287
+ }
288
+
289
+ export interface WeeklyTrackChartArtist {
290
+ mbid: string;
291
+ '#text': string;
292
+ }
293
+
294
+ export enum ErrorResponse {
295
+ InvalidService = 2,
296
+ InvalidMethod = 3,
297
+ AuthenticationFailed = 4,
298
+ InvalidFormat = 5,
299
+ InvalidParameters = 6,
300
+ InvalidResource = 7,
301
+ OperationFailed = 8,
302
+ InvalidSessionKey = 9,
303
+ InvalidAPIKey = 10,
304
+ ServiceOffline = 11,
305
+ InvalidMethodSignature = 13,
306
+ TemporaryError = 16,
307
+ SuspendedAPIKey = 26,
308
+ RateLimitExceeded = 29,
309
+ }
@@ -1,4 +1,4 @@
1
- import { type TopAlbumsResponse } from '../@types';
1
+ import { type TopAlbumsResponse } from "../@types";
2
2
  /**
3
3
  * GET: Top Albums - LastFM
4
4
  *
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getTopAlbums = void 0;
7
- const createOptions_1 = require("./createOptions");
8
7
  const request_1 = __importDefault(require("./request"));
8
+ const createOptions_1 = require("./createOptions");
9
9
  /**
10
10
  * GET: Top Albums - LastFM
11
11
  *
package/dist/cjs/index.js CHANGED
@@ -16,6 +16,7 @@ const method_1 = require("./method");
16
16
  const topTags_1 = require("./chart/topTags");
17
17
  const topTracks_1 = require("./chart/topTracks");
18
18
  const topArtists_1 = require("./chart/topArtists");
19
+ console.log('LastFmApi init>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>');
19
20
  function LastFmApi() {
20
21
  return {
21
22
  auth: auth_1.auth,
@@ -48,7 +48,11 @@ const request = async (options) => {
48
48
  }
49
49
  switch (res.status) {
50
50
  case 200: {
51
- return await res.json();
51
+ if (res.headers.get('content-type').includes('json')) {
52
+ const body = await res.json();
53
+ return body;
54
+ }
55
+ break;
52
56
  }
53
57
  case 400: {
54
58
  throw new Error('Bad request');
@@ -1,4 +1,4 @@
1
- import { type TopAlbumsResponse } from '../@types';
1
+ import { type TopAlbumsResponse } from "../@types";
2
2
  /**
3
3
  * GET: Top Albums - LastFM
4
4
  *
@@ -1,5 +1,5 @@
1
- import { createOptions } from './createOptions';
2
- import request from './request';
1
+ import request from "./request";
2
+ import { createOptions } from "./createOptions";
3
3
  /**
4
4
  * GET: Top Albums - LastFM
5
5
  *
package/dist/mjs/index.js CHANGED
@@ -14,6 +14,7 @@ import { method } from './method';
14
14
  import { chartTopTags } from './chart/topTags';
15
15
  import { chartTopTracks } from './chart/topTracks';
16
16
  import { chartTopArtists } from './chart/topArtists';
17
+ console.log('LastFmApi init>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>');
17
18
  export default function LastFmApi() {
18
19
  return {
19
20
  auth,
@@ -43,7 +43,11 @@ const request = async (options) => {
43
43
  }
44
44
  switch (res.status) {
45
45
  case 200: {
46
- return await res.json();
46
+ if (res.headers.get('content-type').includes('json')) {
47
+ const body = await res.json();
48
+ return body;
49
+ }
50
+ break;
47
51
  }
48
52
  case 400: {
49
53
  throw new Error('Bad request');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lastfm-nodejs-client",
3
- "version": "1.4.4",
3
+ "version": "1.4.6",
4
4
  "description": "A NodeJS wrapper client for LastFm API. Fetching public data by username using the LastFm public API",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/mjs/index.js",
@@ -22,7 +22,7 @@
22
22
  }
23
23
  },
24
24
  "scripts": {
25
- "build": "rm -fr dist/* && tsc -p tsconfig.json && tsc -p tsconfig.cjs.json && bash ./generate-package-json-files.sh",
25
+ "build": "rm -fr dist/* && tsc -p tsconfig.json && tsc -p tsconfig.cjs.json && bash ./generate-package-json-files.sh && mkdir dist/@types && cp -a @types/* dist/@types",
26
26
  "lint": "eslint src",
27
27
  "lint-fix": "eslint src --fix",
28
28
  "prepare": "npm run build",