lastfm-nodejs-client 1.0.6 → 1.1.0

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.
package/.env.example CHANGED
@@ -1,4 +1,5 @@
1
1
  LASTFM_API_BASE_URL=""
2
2
  LASTFM_API_KEY=""
3
3
  LASTFM_APPNAME=""
4
- LASTFM_USER=""
4
+ LASTFM_SHARED_SECRET=""
5
+ LASTFM_USER=""
@@ -0,0 +1,6 @@
1
+ semi: true
2
+ trailingComma: all
3
+ singleQuote: true
4
+ jsxSingleQuote: true
5
+ printWidth: 100
6
+ tabWidth: 2
@@ -0,0 +1,402 @@
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': Attr;
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': Attr2;
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': Attr2;
37
+ }
38
+
39
+ export interface LoveTracksResponse {
40
+ lovedtracks: LovedTracks;
41
+ }
42
+
43
+ export interface LovedTracks {
44
+ track: Track[];
45
+ '@attr': Attr;
46
+ }
47
+ export interface FriendsResponse {
48
+ friends: Friends;
49
+ }
50
+
51
+ export interface Friends {
52
+ '@attr': Attr;
53
+ user: User[];
54
+ }
55
+
56
+ export interface TopArtistsResponse {
57
+ topartists: TopArtists;
58
+ }
59
+
60
+ export interface TopArtists {
61
+ artist: Artist[];
62
+ '@attr': Attr2;
63
+ }
64
+
65
+ export interface WeeklyArtistChartResponse {
66
+ weeklyartistchart: WeeklyArtistChart;
67
+ }
68
+
69
+ export interface WeeklyArtistChart {
70
+ artist: Artist[];
71
+ '@attr': Attr2;
72
+ }
73
+
74
+ export interface WeeklyAlbumChartResponse {
75
+ weeklyalbumchart: WeeklyAlbumChart;
76
+ }
77
+
78
+ export interface WeeklyAlbumChart {
79
+ album: WeeklyAlbum[];
80
+ '@attr': WeeklyalbumChartAttr;
81
+ }
82
+
83
+ export type WeeklyAlbum = {
84
+ artist: {
85
+ mbid: string;
86
+ '#text': string;
87
+ };
88
+ mbid: string;
89
+ url: string;
90
+ name: string;
91
+ '@attr': { rank: string };
92
+ playcount: string;
93
+ image?: string;
94
+ };
95
+
96
+ export interface WeeklyalbumChartAttr {
97
+ from: string;
98
+ to: string;
99
+ user: string;
100
+ }
101
+
102
+ export interface AlbumAttr {
103
+ rank: string;
104
+ }
105
+
106
+ export type Artist = {
107
+ '@attr': {
108
+ rank: number;
109
+ };
110
+ cover: ArtistImage;
111
+ image?: string;
112
+ mbid: string;
113
+ name: string;
114
+ playcount: number;
115
+ streamable: number;
116
+ url: string;
117
+ '#text': string;
118
+ };
119
+
120
+ export interface Attribs {
121
+ page: number;
122
+ perPage: number;
123
+ user: string;
124
+ total: number;
125
+ totalPages: number;
126
+ }
127
+
128
+ export interface ArtistImage {
129
+ name: string;
130
+ photo: string;
131
+ attribution: string;
132
+ playcount: number;
133
+ }
134
+
135
+ export interface Album {
136
+ mbid: string;
137
+ '#text': string;
138
+ }
139
+
140
+ export interface Attr {
141
+ nowplaying: string;
142
+ }
143
+
144
+ export interface Date {
145
+ uts: string;
146
+ '#text': string;
147
+ }
148
+
149
+ export interface Track {
150
+ artist: Artist;
151
+ streamable: string;
152
+ image: '';
153
+ mbid: string;
154
+ album: Album;
155
+ name: string;
156
+ '@attr': Attr;
157
+ url: string;
158
+ date: Date;
159
+ }
160
+
161
+ export interface Attr2 {
162
+ user: string;
163
+ totalPages: string;
164
+ page: string;
165
+ perPage: string;
166
+ total: string;
167
+ }
168
+
169
+ export interface RecentTracks {
170
+ track: Track[];
171
+ '@attr': Attr2;
172
+ }
173
+
174
+ export interface Image {
175
+ size: string;
176
+ '#text': string;
177
+ }
178
+
179
+ export interface Registered {
180
+ unixtime: string;
181
+ '#text': number;
182
+ }
183
+
184
+ export interface User {
185
+ name: string;
186
+ age: string;
187
+ subscriber: string;
188
+ realname: string;
189
+ bootstrap: string;
190
+ playcount: string;
191
+ artist_count: string;
192
+ playlists: string;
193
+ track_count: string;
194
+ album_count: string;
195
+ image: Image[];
196
+ registered: Registered;
197
+ country: string;
198
+ gender: string;
199
+ url: string;
200
+ type: string;
201
+ }
202
+
203
+ export interface TopAlbums {
204
+ album: Album[];
205
+ '@attr': Attr2;
206
+ }
207
+
208
+ export interface WeeklyArtistChartResponse {
209
+ weeklyartistchart: WeeklyArtistChart;
210
+ }
211
+
212
+ export interface WeeklyArtistChart {
213
+ artist: Artist[];
214
+ '@attr': Attr2;
215
+ }
216
+
217
+ export interface Attr1 {
218
+ rank: string;
219
+ }
220
+
221
+ export interface Attr2 {
222
+ from: string;
223
+ user: string;
224
+ to: string;
225
+ }
226
+
227
+ export interface WeeklyChartListResponse {
228
+ weeklychartlist: WeeklyChartList;
229
+ }
230
+
231
+ export interface WeeklyChartList {
232
+ chart: WeeklyChartListChart[];
233
+ '@attr': WeeklyChartListAttr;
234
+ }
235
+
236
+ export interface WeeklyChartListChart {
237
+ '#text': string;
238
+ from: string;
239
+ to: string;
240
+ }
241
+
242
+ export interface WeeklyChartListAttr {
243
+ user: string;
244
+ }
245
+
246
+ export interface WeeklyTrackChartResponse {
247
+ weeklytrackchart: WeeklyTrackChart;
248
+ }
249
+
250
+ export interface WeeklyTrackChart {
251
+ track: Track[];
252
+ '@attr': WeeklyTrackChartAttr2;
253
+ }
254
+
255
+ export interface WeeklyTrackChartTrack {
256
+ artist: WeeklyTrackChartArtist;
257
+ image: Image[];
258
+ mbid: string;
259
+ url: string;
260
+ name: string;
261
+ '@attr': Attr;
262
+ playcount: string;
263
+ }
264
+
265
+ export interface WeeklyTrackChartArtist {
266
+ mbid: string;
267
+ '#text': string;
268
+ }
269
+
270
+ export interface WeeklyTrackChartAttr {
271
+ rank: string;
272
+ }
273
+
274
+ export interface WeeklyTrackChartAttr2 {
275
+ from: string;
276
+ user: string;
277
+ to: string;
278
+ }
279
+
280
+ export const LastFmApi: () => {
281
+ auth: (
282
+ method: string,
283
+ user: string,
284
+ period: string,
285
+ limit: number
286
+ ) => Promise<AuthResponse>;
287
+ config: {
288
+ api_key: string;
289
+ app_name: string;
290
+ base_url: string;
291
+ format: {
292
+ json: string;
293
+ xml: string;
294
+ };
295
+ share_secret: string;
296
+ username: string;
297
+ };
298
+ getInfo: (
299
+ method: string,
300
+ user: string,
301
+ period: string,
302
+ limit: number
303
+ ) => Promise<UserResponse>;
304
+ getLovedTracks: (
305
+ method: string,
306
+ user: string,
307
+ period: string,
308
+ limit: number
309
+ ) => Promise<LovedTracksResponse>;
310
+ getRecentTracks: (
311
+ method: string,
312
+ user: string,
313
+ period: string,
314
+ limit: number
315
+ ) => Promise<RecentTracksResponse>;
316
+ getTopAlbums: (
317
+ method: string,
318
+ user: string,
319
+ period: string,
320
+ limit: number
321
+ ) => Promise<TopAlbumsResponse>;
322
+ getTopArtists: (
323
+ method: string,
324
+ user: string,
325
+ period: string,
326
+ limit: number
327
+ ) => Promise<TopArtistsResponse>;
328
+ getTopTracks: (
329
+ method: string,
330
+ user: string,
331
+ period: string,
332
+ limit: number
333
+ ) => Promise<TopTrackResponse>;
334
+ getWeeklyAlbumChart: (
335
+ method: string,
336
+ user: string,
337
+ period: string,
338
+ limit: number
339
+ ) => Promise<WeeklyAlbumChartResponse>;
340
+ getWeeklyArtistChart: (
341
+ method: string,
342
+ user: string,
343
+ period: string,
344
+ limit: number
345
+ ) => Promise<WeeklyArtistChartResponse>;
346
+ getWeeklyChartList: (
347
+ method: string,
348
+ user: string,
349
+ period: string,
350
+ limit: number
351
+ ) => Promise<WeeklyChartListResponse>;
352
+ getWeeklyTrackChart: (
353
+ method: string,
354
+ user: string,
355
+ period: string,
356
+ limit: number
357
+ ) => Promise<WeeklyTrackChartResponse>;
358
+ };
359
+ export interface config {
360
+ api_key: string;
361
+ app_name: string;
362
+ base_url: string;
363
+ format: {
364
+ json: string;
365
+ xml: string;
366
+ };
367
+ share_secret: string;
368
+ username: string;
369
+ }
370
+
371
+ export interface method {
372
+ auth: string;
373
+ user: {
374
+ getInfo: string;
375
+ loved_tracks: string;
376
+ recent_tracks: string;
377
+ top_albums: string;
378
+ top_artists: string;
379
+ top_tracks: string;
380
+ weekly_album_chart: string;
381
+ weekly_artist_chart: string;
382
+ weekly_chart_list: string;
383
+ weekly_track_chart: string;
384
+ };
385
+ }
386
+
387
+ export enum Errors {
388
+ 'InvalidService' = 2,
389
+ 'InvalidMethod' = 3,
390
+ 'AuthenticationFailed' = 4,
391
+ 'Invalid format' = 5,
392
+ 'Invalid parameters' = 6,
393
+ 'InvalidResourceSpecified' = 7,
394
+ 'OperationFailed' = 8,
395
+ 'Invalid session key' = 9,
396
+ 'InvalidApiKey' = 10,
397
+ 'ServiceOffline' = 11,
398
+ 'InvalidMethodSignatureSupplied' = 13,
399
+ 'TemporaryErrorRequest' = 16,
400
+ 'SuspendedApiKey' = 26,
401
+ 'RateLimitExceeded' = 29,
402
+ }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.0
4
+
5
+ - Downgrade node-fetch to v2.6.7
6
+ - Do not ship separate declaration files
7
+ - TS now exports to CommonJs modules for better support older consumers
8
+
3
9
  ## 1.0.6
4
10
 
5
11
  - Forking repo README update
package/README.md CHANGED
@@ -20,15 +20,10 @@ Import module
20
20
  import { lastFm } from 'lastfm-nodejs-client';
21
21
  ```
22
22
 
23
- Import types
23
+ Import as types
24
24
 
25
25
  ```js
26
- import {
27
- Artist,
28
- Track,
29
- User,
30
- WeeklyAlbum,
31
- } from 'lastfm-nodejs-client/dist/types';
26
+ import type { Artist, Track, User, WeeklyAlbum } from 'lastfm-nodejs-client/@types';
32
27
  ```
33
28
 
34
29
  _Working on getting these into [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped)_
@@ -40,12 +35,7 @@ const lastFm = LastFmApi();
40
35
  const { config, method } = lastFm;
41
36
 
42
37
  const getUser = async () => {
43
- const data = await lastFm.getInfo(
44
- method.user.getInfo,
45
- config.username,
46
- 'overall',
47
- 12
48
- );
38
+ const data = await lastFm.getInfo(method.user.getInfo, config.username, 'overall', 12);
49
39
  const { user } = data;
50
40
  return user;
51
41
  };
package/dist/index.d.ts CHANGED
@@ -1,41 +1,392 @@
1
- import { AuthResponse, LovedTracksResponse, RecentTracksResponse, TopAlbumsResponse, TopArtistsResponse, TopTrackResponse, UserResponse, WeeklyAlbumChartResponse, WeeklyArtistChartResponse, WeeklyChartListResponse, WeeklyTrackChartResponse } from './types';
2
- declare const LastFmApi: () => {
3
- auth: (method: string, user: string, period: string, limit: number) => Promise<AuthResponse>;
4
- config: {
5
- api_key: string;
6
- app_name: string;
7
- base_url: string;
8
- format: {
9
- json: string;
10
- xml: string;
11
- };
12
- share_secret: string;
13
- username: string;
14
- };
15
- getInfo: (method: string, user: string, period: string, limit: number) => Promise<UserResponse>;
16
- getLovedTracks: (method: string, user: string, period: string, limit: number) => Promise<LovedTracksResponse>;
17
- getRecentTracks: (method: string, user: string, period: string, limit: number) => Promise<RecentTracksResponse>;
18
- getTopAlbums: (method: string, user: string, period: string, limit: number) => Promise<TopAlbumsResponse>;
19
- getTopArtists: (method: string, user: string, period: string, limit: number) => Promise<TopArtistsResponse>;
20
- getTopTracks: (method: string, user: string, period: string, limit: number) => Promise<TopTrackResponse>;
21
- getWeeklyAlbumChart: (method: string, user: string, period: string, limit: number) => Promise<WeeklyAlbumChartResponse>;
22
- getWeeklyArtistChart: (method: string, user: string, period: string, limit: number) => Promise<WeeklyArtistChartResponse>;
23
- getWeeklyChartList: (method: string, user: string, period: string, limit: number) => Promise<WeeklyChartListResponse>;
24
- getWeeklyTrackChart: (method: string, user: string, period: string, limit: number) => Promise<WeeklyTrackChartResponse>;
25
- method: {
26
- auth: string;
27
- user: {
28
- getInfo: string;
29
- loved_tracks: string;
30
- recent_tracks: string;
31
- top_albums: string;
32
- top_artists: string;
33
- top_tracks: string;
34
- weekly_album_chart: string;
35
- weekly_artist_chart: string;
36
- weekly_chart_list: string;
37
- weekly_track_chart: string;
38
- };
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': Attr;
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': Attr2;
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': Attr2;
37
+ }
38
+
39
+ export interface LoveTracksResponse {
40
+ lovedtracks: LovedTracks;
41
+ }
42
+
43
+ export interface LovedTracks {
44
+ track: Track[];
45
+ '@attr': Attr;
46
+ }
47
+ export interface FriendsResponse {
48
+ friends: Friends;
49
+ }
50
+
51
+ export interface Friends {
52
+ '@attr': Attr;
53
+ user: User[];
54
+ }
55
+
56
+ export interface TopArtistsResponse {
57
+ topartists: TopArtists;
58
+ }
59
+
60
+ export interface TopArtists {
61
+ artist: Artist[];
62
+ '@attr': Attr2;
63
+ }
64
+
65
+ export interface WeeklyArtistChartResponse {
66
+ weeklyartistchart: WeeklyArtistChart;
67
+ }
68
+
69
+ export interface WeeklyArtistChart {
70
+ artist: Artist[];
71
+ '@attr': Attr2;
72
+ }
73
+
74
+ export interface WeeklyAlbumChartResponse {
75
+ weeklyalbumchart: WeeklyAlbumChart;
76
+ }
77
+
78
+ export interface WeeklyAlbumChart {
79
+ album: WeeklyAlbum[];
80
+ '@attr': WeeklyalbumChartAttr;
81
+ }
82
+
83
+ export type WeeklyAlbum = {
84
+ artist: {
85
+ mbid: string;
86
+ '#text': string;
87
+ };
88
+ mbid: string;
89
+ url: string;
90
+ name: string;
91
+ '@attr': { rank: string };
92
+ playcount: string;
93
+ image?: string;
94
+ };
95
+
96
+ export interface WeeklyalbumChartAttr {
97
+ from: string;
98
+ to: string;
99
+ user: string;
100
+ }
101
+
102
+ export interface AlbumAttr {
103
+ rank: string;
104
+ }
105
+
106
+ export type Artist = {
107
+ '@attr': {
108
+ rank: number;
109
+ };
110
+ cover: ArtistImage;
111
+ image?: string;
112
+ mbid: string;
113
+ name: string;
114
+ playcount: number;
115
+ streamable: number;
116
+ url: string;
117
+ '#text': string;
118
+ };
119
+
120
+ export interface Attribs {
121
+ page: number;
122
+ perPage: number;
123
+ user: string;
124
+ total: number;
125
+ totalPages: number;
126
+ }
127
+
128
+ export interface ArtistImage {
129
+ name: string;
130
+ photo: string;
131
+ attribution: string;
132
+ playcount: number;
133
+ }
134
+
135
+ export interface Album {
136
+ mbid: string;
137
+ '#text': string;
138
+ }
139
+
140
+ export interface Attr {
141
+ nowplaying: string;
142
+ }
143
+
144
+ export interface Date {
145
+ uts: string;
146
+ '#text': string;
147
+ }
148
+
149
+ export interface Track {
150
+ artist: Artist;
151
+ streamable: string;
152
+ image: '';
153
+ mbid: string;
154
+ album: Album;
155
+ name: string;
156
+ '@attr': Attr;
157
+ url: string;
158
+ date: Date;
159
+ }
160
+
161
+ export interface Attr2 {
162
+ user: string;
163
+ totalPages: string;
164
+ page: string;
165
+ perPage: string;
166
+ total: string;
167
+ }
168
+
169
+ export interface RecentTracks {
170
+ track: Track[];
171
+ '@attr': Attr2;
172
+ }
173
+
174
+ export interface Image {
175
+ size: string;
176
+ '#text': string;
177
+ }
178
+
179
+ export interface Registered {
180
+ unixtime: string;
181
+ '#text': number;
182
+ }
183
+
184
+ export interface User {
185
+ name: string;
186
+ age: string;
187
+ subscriber: string;
188
+ realname: string;
189
+ bootstrap: string;
190
+ playcount: string;
191
+ artist_count: string;
192
+ playlists: string;
193
+ track_count: string;
194
+ album_count: string;
195
+ image: Image[];
196
+ registered: Registered;
197
+ country: string;
198
+ gender: string;
199
+ url: string;
200
+ type: string;
201
+ }
202
+
203
+ export interface TopAlbums {
204
+ album: Album[];
205
+ '@attr': Attr2;
206
+ }
207
+
208
+ export interface WeeklyArtistChartResponse {
209
+ weeklyartistchart: WeeklyArtistChart;
210
+ }
211
+
212
+ export interface WeeklyArtistChart {
213
+ artist: Artist[];
214
+ '@attr': Attr2;
215
+ }
216
+
217
+ export interface Attr1 {
218
+ rank: string;
219
+ }
220
+
221
+ export interface Attr2 {
222
+ from: string;
223
+ user: string;
224
+ to: string;
225
+ }
226
+
227
+ export interface WeeklyChartListResponse {
228
+ weeklychartlist: WeeklyChartList;
229
+ }
230
+
231
+ export interface WeeklyChartList {
232
+ chart: WeeklyChartListChart[];
233
+ '@attr': WeeklyChartListAttr;
234
+ }
235
+
236
+ export interface WeeklyChartListChart {
237
+ '#text': string;
238
+ from: string;
239
+ to: string;
240
+ }
241
+
242
+ export interface WeeklyChartListAttr {
243
+ user: string;
244
+ }
245
+
246
+ export interface WeeklyTrackChartResponse {
247
+ weeklytrackchart: WeeklyTrackChart;
248
+ }
249
+
250
+ export interface WeeklyTrackChart {
251
+ track: Track[];
252
+ '@attr': WeeklyTrackChartAttr2;
253
+ }
254
+
255
+ export interface WeeklyTrackChartTrack {
256
+ artist: WeeklyTrackChartArtist;
257
+ image: Image[];
258
+ mbid: string;
259
+ url: string;
260
+ name: string;
261
+ '@attr': Attr;
262
+ playcount: string;
263
+ }
264
+
265
+ export interface WeeklyTrackChartArtist {
266
+ mbid: string;
267
+ '#text': string;
268
+ }
269
+
270
+ export interface WeeklyTrackChartAttr {
271
+ rank: string;
272
+ }
273
+
274
+ export interface WeeklyTrackChartAttr2 {
275
+ from: string;
276
+ user: string;
277
+ to: string;
278
+ }
279
+
280
+ export const LastFmApi: () => {
281
+ auth: (method: string, user: string, period: string, limit: number) => Promise<AuthResponse>;
282
+ config: {
283
+ api_key: string;
284
+ app_name: string;
285
+ base_url: string;
286
+ format: {
287
+ json: string;
288
+ xml: string;
39
289
  };
290
+ share_secret: string;
291
+ username: string;
292
+ };
293
+ getInfo: (method: string, user: string, period: string, limit: number) => Promise<UserResponse>;
294
+ getLovedTracks: (
295
+ method: string,
296
+ user: string,
297
+ period: string,
298
+ limit: number,
299
+ ) => Promise<LovedTracksResponse>;
300
+ getRecentTracks: (
301
+ method: string,
302
+ user: string,
303
+ period: string,
304
+ limit: number,
305
+ ) => Promise<RecentTracksResponse>;
306
+ getTopAlbums: (
307
+ method: string,
308
+ user: string,
309
+ period: string,
310
+ limit: number,
311
+ ) => Promise<TopAlbumsResponse>;
312
+ getTopArtists: (
313
+ method: string,
314
+ user: string,
315
+ period: string,
316
+ limit: number,
317
+ ) => Promise<TopArtistsResponse>;
318
+ getTopTracks: (
319
+ method: string,
320
+ user: string,
321
+ period: string,
322
+ limit: number,
323
+ ) => Promise<TopTrackResponse>;
324
+ getWeeklyAlbumChart: (
325
+ method: string,
326
+ user: string,
327
+ period: string,
328
+ limit: number,
329
+ ) => Promise<WeeklyAlbumChartResponse>;
330
+ getWeeklyArtistChart: (
331
+ method: string,
332
+ user: string,
333
+ period: string,
334
+ limit: number,
335
+ ) => Promise<WeeklyArtistChartResponse>;
336
+ getWeeklyChartList: (
337
+ method: string,
338
+ user: string,
339
+ period: string,
340
+ limit: number,
341
+ ) => Promise<WeeklyChartListResponse>;
342
+ getWeeklyTrackChart: (
343
+ method: string,
344
+ user: string,
345
+ period: string,
346
+ limit: number,
347
+ ) => Promise<WeeklyTrackChartResponse>;
40
348
  };
41
- export default LastFmApi;
349
+ export interface config {
350
+ api_key: string;
351
+ app_name: string;
352
+ base_url: string;
353
+ format: {
354
+ json: string;
355
+ xml: string;
356
+ };
357
+ share_secret: string;
358
+ username: string;
359
+ }
360
+
361
+ export interface method {
362
+ auth: string;
363
+ user: {
364
+ getInfo: string;
365
+ loved_tracks: string;
366
+ recent_tracks: string;
367
+ top_albums: string;
368
+ top_artists: string;
369
+ top_tracks: string;
370
+ weekly_album_chart: string;
371
+ weekly_artist_chart: string;
372
+ weekly_chart_list: string;
373
+ weekly_track_chart: string;
374
+ };
375
+ }
376
+
377
+ export enum Errors {
378
+ 'InvalidService' = 2,
379
+ 'InvalidMethod' = 3,
380
+ 'AuthenticationFailed' = 4,
381
+ 'Invalid format' = 5,
382
+ 'Invalid parameters' = 6,
383
+ 'InvalidResourceSpecified' = 7,
384
+ 'OperationFailed' = 8,
385
+ 'Invalid session key' = 9,
386
+ 'InvalidApiKey' = 10,
387
+ 'ServiceOffline' = 11,
388
+ 'InvalidMethodSignatureSupplied' = 13,
389
+ 'TemporaryErrorRequest' = 16,
390
+ 'SuspendedApiKey' = 26,
391
+ 'RateLimitExceeded' = 29,
392
+ }
package/dist/request.js CHANGED
@@ -12,12 +12,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const node_fetch_1 = __importDefault(require("node-fetch"));
16
15
  const config_1 = __importDefault(require("./config"));
17
16
  const request = (method, user, period, limit) => __awaiter(void 0, void 0, void 0, function* () {
18
17
  const url = `
19
18
  ${config_1.default.base_url}?method=${method}${user ? '&user=' : ''}${user}${user ? '&user=' : ''}${user}${period ? '&period=' : ''}${period}&${limit ? '&limit=' : ''}${limit}&api_key=${config_1.default.api_key}&format=${config_1.default.format.json}`;
20
- return (yield (0, node_fetch_1.default)(url, {
19
+ return (yield fetch(url, {
21
20
  headers: {
22
21
  'Content-Type': 'application/json',
23
22
  },
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "lastfm-nodejs-client",
3
- "version": "1.0.6",
3
+ "version": "1.1.0",
4
4
  "description": "A client for fetching public data with username using the LastFm public API",
5
- "main": "./dist/index.js",
5
+ "main": "./dist",
6
6
  "scripts": {
7
7
  "build": "rimraf dist && tsc",
8
8
  "dev": "tsc --watch",
@@ -21,7 +21,7 @@
21
21
  ],
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
- "node-fetch": "^3.2.10",
24
+ "node-fetch": "2.6.7",
25
25
  "rimraf": "^3.0.2"
26
26
  },
27
27
  "devDependencies": {
package/src/index.ts CHANGED
@@ -30,7 +30,7 @@ const LastFmApi = function LastFmApi() {
30
30
  method: string,
31
31
  user: string,
32
32
  period: string,
33
- limit: number
33
+ limit: number,
34
34
  ): Promise<AuthResponse> => {
35
35
  return request(method, user, period, limit);
36
36
  };
@@ -45,7 +45,7 @@ const LastFmApi = function LastFmApi() {
45
45
  method: string,
46
46
  user: string,
47
47
  period: string,
48
- limit: number
48
+ limit: number,
49
49
  ): Promise<UserResponse> => {
50
50
  return request(method, user, period, limit);
51
51
  };
@@ -60,7 +60,7 @@ const LastFmApi = function LastFmApi() {
60
60
  method: string,
61
61
  user: string,
62
62
  period: string,
63
- limit: number
63
+ limit: number,
64
64
  ): Promise<LovedTracksResponse> => {
65
65
  return request(method, user, period, limit);
66
66
  };
@@ -75,7 +75,7 @@ const LastFmApi = function LastFmApi() {
75
75
  method: string,
76
76
  user: string,
77
77
  period: string,
78
- limit: number
78
+ limit: number,
79
79
  ): Promise<RecentTracksResponse> => {
80
80
  return request(method, user, period, limit);
81
81
  };
@@ -90,7 +90,7 @@ const LastFmApi = function LastFmApi() {
90
90
  method: string,
91
91
  user: string,
92
92
  period: string,
93
- limit: number
93
+ limit: number,
94
94
  ): Promise<TopAlbumsResponse> => {
95
95
  return request(method, user, period, limit);
96
96
  };
@@ -105,7 +105,7 @@ const LastFmApi = function LastFmApi() {
105
105
  method: string,
106
106
  user: string,
107
107
  period: string,
108
- limit: number
108
+ limit: number,
109
109
  ): Promise<TopArtistsResponse> => {
110
110
  return request(method, user, period, limit);
111
111
  };
@@ -120,7 +120,7 @@ const LastFmApi = function LastFmApi() {
120
120
  method: string,
121
121
  user: string,
122
122
  period: string,
123
- limit: number
123
+ limit: number,
124
124
  ): Promise<TopTrackResponse> => {
125
125
  return request(method, user, period, limit);
126
126
  };
@@ -135,7 +135,7 @@ const LastFmApi = function LastFmApi() {
135
135
  method: string,
136
136
  user: string,
137
137
  period: string,
138
- limit: number
138
+ limit: number,
139
139
  ): Promise<WeeklyAlbumChartResponse> => {
140
140
  return request(method, user, period, limit);
141
141
  };
@@ -150,7 +150,7 @@ const LastFmApi = function LastFmApi() {
150
150
  method: string,
151
151
  user: string,
152
152
  period: string,
153
- limit: number
153
+ limit: number,
154
154
  ): Promise<WeeklyArtistChartResponse> => {
155
155
  return request(method, user, period, limit);
156
156
  };
@@ -165,7 +165,7 @@ const LastFmApi = function LastFmApi() {
165
165
  method: string,
166
166
  user: string,
167
167
  period: string,
168
- limit: number
168
+ limit: number,
169
169
  ): Promise<WeeklyChartListResponse> => {
170
170
  return request(method, user, period, limit);
171
171
  };
@@ -180,7 +180,7 @@ const LastFmApi = function LastFmApi() {
180
180
  method: string,
181
181
  user: string,
182
182
  period: string,
183
- limit: number
183
+ limit: number,
184
184
  ): Promise<WeeklyTrackChartResponse> => {
185
185
  return request(method, user, period, limit);
186
186
  };
package/src/request.ts CHANGED
@@ -1,18 +1,17 @@
1
- import fetch from 'node-fetch';
2
1
  import config from './config';
3
2
 
4
3
  const request = async <Parameters, Response>(
5
4
  method: string,
6
5
  user: string,
7
6
  period?: string,
8
- limit?: number
7
+ limit?: number,
9
8
  ): Promise<Response> => {
10
9
  const url = `
11
10
  ${config.base_url}?method=${method}${user ? '&user=' : ''}${user}${
12
11
  user ? '&user=' : ''
13
- }${user}${period ? '&period=' : ''}${period}&${
14
- limit ? '&limit=' : ''
15
- }${limit}&api_key=${config.api_key}&format=${config.format.json}`;
12
+ }${user}${period ? '&period=' : ''}${period}&${limit ? '&limit=' : ''}${limit}&api_key=${
13
+ config.api_key
14
+ }&format=${config.format.json}`;
16
15
 
17
16
  return (await fetch(url, {
18
17
  headers: {
package/src/types.d.ts CHANGED
@@ -278,12 +278,7 @@ export interface WeeklyTrackChartAttr2 {
278
278
  }
279
279
 
280
280
  export const LastFmApi: () => {
281
- auth: (
282
- method: string,
283
- user: string,
284
- period: string,
285
- limit: number
286
- ) => Promise<AuthResponse>;
281
+ auth: (method: string, user: string, period: string, limit: number) => Promise<AuthResponse>;
287
282
  config: {
288
283
  api_key: string;
289
284
  app_name: string;
@@ -295,65 +290,60 @@ export const LastFmApi: () => {
295
290
  share_secret: string;
296
291
  username: string;
297
292
  };
298
- getInfo: (
299
- method: string,
300
- user: string,
301
- period: string,
302
- limit: number
303
- ) => Promise<UserResponse>;
293
+ getInfo: (method: string, user: string, period: string, limit: number) => Promise<UserResponse>;
304
294
  getLovedTracks: (
305
295
  method: string,
306
296
  user: string,
307
297
  period: string,
308
- limit: number
298
+ limit: number,
309
299
  ) => Promise<LovedTracksResponse>;
310
300
  getRecentTracks: (
311
301
  method: string,
312
302
  user: string,
313
303
  period: string,
314
- limit: number
304
+ limit: number,
315
305
  ) => Promise<RecentTracksResponse>;
316
306
  getTopAlbums: (
317
307
  method: string,
318
308
  user: string,
319
309
  period: string,
320
- limit: number
310
+ limit: number,
321
311
  ) => Promise<TopAlbumsResponse>;
322
312
  getTopArtists: (
323
313
  method: string,
324
314
  user: string,
325
315
  period: string,
326
- limit: number
316
+ limit: number,
327
317
  ) => Promise<TopArtistsResponse>;
328
318
  getTopTracks: (
329
319
  method: string,
330
320
  user: string,
331
321
  period: string,
332
- limit: number
322
+ limit: number,
333
323
  ) => Promise<TopTrackResponse>;
334
324
  getWeeklyAlbumChart: (
335
325
  method: string,
336
326
  user: string,
337
327
  period: string,
338
- limit: number
328
+ limit: number,
339
329
  ) => Promise<WeeklyAlbumChartResponse>;
340
330
  getWeeklyArtistChart: (
341
331
  method: string,
342
332
  user: string,
343
333
  period: string,
344
- limit: number
334
+ limit: number,
345
335
  ) => Promise<WeeklyArtistChartResponse>;
346
336
  getWeeklyChartList: (
347
337
  method: string,
348
338
  user: string,
349
339
  period: string,
350
- limit: number
340
+ limit: number,
351
341
  ) => Promise<WeeklyChartListResponse>;
352
342
  getWeeklyTrackChart: (
353
343
  method: string,
354
344
  user: string,
355
345
  period: string,
356
- limit: number
346
+ limit: number,
357
347
  ) => Promise<WeeklyTrackChartResponse>;
358
348
  };
359
349
  export interface config {
package/tsconfig.json CHANGED
@@ -25,7 +25,7 @@
25
25
  // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
26
26
 
27
27
  /* Modules */
28
- "module": "Node16" /* Specify what module code is generated. */,
28
+ "module": "CommonJS" /* Specify what module code is generated. */,
29
29
  "rootDir": "./src" /* Specify the root folder within your source files. */,
30
30
  "moduleResolution": "node" /* Specify how TypeScript looks up a file from a given module specifier. */,
31
31
  // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
@@ -44,7 +44,7 @@
44
44
  // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
45
45
 
46
46
  /* Emit */
47
- "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
47
+ "declaration": false /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
48
48
  // "declarationMap": true, /* Create sourcemaps for d.ts files. */
49
49
  // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
50
50
  // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
package/dist/config.d.ts DELETED
@@ -1,12 +0,0 @@
1
- declare const _default: {
2
- api_key: string;
3
- app_name: string;
4
- base_url: string;
5
- format: {
6
- json: string;
7
- xml: string;
8
- };
9
- share_secret: string;
10
- username: string;
11
- };
12
- export default _default;
package/dist/method.d.ts DELETED
@@ -1,16 +0,0 @@
1
- declare const _default: {
2
- auth: string;
3
- user: {
4
- getInfo: string;
5
- loved_tracks: string;
6
- recent_tracks: string;
7
- top_albums: string;
8
- top_artists: string;
9
- top_tracks: string;
10
- weekly_album_chart: string;
11
- weekly_artist_chart: string;
12
- weekly_chart_list: string;
13
- weekly_track_chart: string;
14
- };
15
- };
16
- export default _default;
package/dist/request.d.ts DELETED
@@ -1,2 +0,0 @@
1
- declare const request: <Parameters_1, Response_1>(method: string, user: string, period?: string, limit?: number) => Promise<Response_1>;
2
- export default request;