lastfm-nodejs-client 1.4.1 → 1.4.3

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.
Files changed (52) hide show
  1. package/@types/index.d.ts +32 -135
  2. package/CHANGELOG.md +8 -0
  3. package/dist/auth.d.ts +13 -0
  4. package/dist/auth.d.ts.map +1 -0
  5. package/dist/auth.js +23 -0
  6. package/dist/config.d.ts +21 -0
  7. package/dist/config.d.ts.map +1 -0
  8. package/dist/config.js +49 -0
  9. package/dist/createOptions.d.ts +7 -0
  10. package/dist/createOptions.d.ts.map +1 -0
  11. package/dist/createOptions.js +12 -0
  12. package/dist/getInfo.d.ts +9 -0
  13. package/dist/getInfo.d.ts.map +1 -0
  14. package/dist/getInfo.js +19 -0
  15. package/dist/getLovedTracks.d.ts +9 -0
  16. package/dist/getLovedTracks.d.ts.map +1 -0
  17. package/dist/getLovedTracks.js +19 -0
  18. package/dist/getRecentTracks.d.ts +9 -0
  19. package/dist/getRecentTracks.d.ts.map +1 -0
  20. package/dist/getRecentTracks.js +19 -0
  21. package/dist/getTopAlbums.d.ts +9 -0
  22. package/dist/getTopAlbums.d.ts.map +1 -0
  23. package/dist/getTopAlbums.js +19 -0
  24. package/dist/getTopArtists.d.ts +9 -0
  25. package/dist/getTopArtists.d.ts.map +1 -0
  26. package/dist/getTopArtists.js +19 -0
  27. package/dist/getTopTracks.d.ts +9 -0
  28. package/dist/getTopTracks.d.ts.map +1 -0
  29. package/dist/getTopTracks.js +19 -0
  30. package/dist/getWeeklyAlbumChart.d.ts +9 -0
  31. package/dist/getWeeklyAlbumChart.d.ts.map +1 -0
  32. package/dist/getWeeklyAlbumChart.js +19 -0
  33. package/dist/getWeeklyArtistChart.d.ts +9 -0
  34. package/dist/getWeeklyArtistChart.d.ts.map +1 -0
  35. package/dist/getWeeklyArtistChart.js +19 -0
  36. package/dist/getWeeklyChartList.d.ts +9 -0
  37. package/dist/getWeeklyChartList.d.ts.map +1 -0
  38. package/dist/getWeeklyChartList.js +19 -0
  39. package/dist/getWeeklyTrackChart.d.ts +9 -0
  40. package/dist/getWeeklyTrackChart.d.ts.map +1 -0
  41. package/dist/getWeeklyTrackChart.js +19 -0
  42. package/dist/index.d.ts +52 -0
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +31 -0
  45. package/dist/method.d.ts +33 -0
  46. package/dist/method.d.ts.map +1 -0
  47. package/dist/method.js +20 -0
  48. package/dist/request.d.ts +9 -0
  49. package/dist/request.d.ts.map +1 -0
  50. package/dist/request.js +132 -0
  51. package/package.json +2 -2
  52. package/tsconfig.json +14 -14
package/@types/index.d.ts CHANGED
@@ -8,7 +8,7 @@ export interface LovedTracksResponse {
8
8
 
9
9
  export interface LovedTracks {
10
10
  track: Track[];
11
- '@attr': Attr;
11
+ '@attr': AttrNowPlaying;
12
12
  }
13
13
  export interface TopAlbumsResponse {
14
14
  topalbums: TopAlbums;
@@ -20,7 +20,7 @@ export interface TopTrackResponse {
20
20
 
21
21
  export interface TopTracks {
22
22
  track: Track[];
23
- '@attr': Attr2;
23
+ '@attr': AttrLimit;
24
24
  }
25
25
 
26
26
  export interface UserResponse {
@@ -33,7 +33,7 @@ export interface RecentTracksResponse {
33
33
 
34
34
  export interface RecentTracks {
35
35
  track: Track[];
36
- '@attr': Attr2;
36
+ '@attr': AttrLimit;
37
37
  }
38
38
 
39
39
  export interface LoveTracksResponse {
@@ -42,14 +42,14 @@ export interface LoveTracksResponse {
42
42
 
43
43
  export interface LovedTracks {
44
44
  track: Track[];
45
- '@attr': Attr;
45
+ '@attr': AttrNowPlaying;
46
46
  }
47
47
  export interface FriendsResponse {
48
48
  friends: Friends;
49
49
  }
50
50
 
51
51
  export interface Friends {
52
- '@attr': Attr;
52
+ '@attr': AttrNowPlaying;
53
53
  user: User[];
54
54
  }
55
55
 
@@ -59,7 +59,7 @@ export interface TopArtistsResponse {
59
59
 
60
60
  export interface TopArtists {
61
61
  artist: Artist[];
62
- '@attr': Attr2;
62
+ '@attr': AttrLimit;
63
63
  }
64
64
 
65
65
  export interface WeeklyArtistChartResponse {
@@ -68,7 +68,7 @@ export interface WeeklyArtistChartResponse {
68
68
 
69
69
  export interface WeeklyArtistChart {
70
70
  artist: Artist[];
71
- '@attr': Attr2;
71
+ '@attr': AttrLimit;
72
72
  }
73
73
 
74
74
  export interface WeeklyAlbumChartResponse {
@@ -80,7 +80,7 @@ export interface WeeklyAlbumChart {
80
80
  '@attr': WeeklyalbumChartAttr;
81
81
  }
82
82
 
83
- export type WeeklyAlbum = {
83
+ export interface WeeklyAlbum {
84
84
  artist: {
85
85
  mbid: string;
86
86
  '#text': string;
@@ -132,12 +132,14 @@ export interface ArtistImage {
132
132
  playcount: number;
133
133
  }
134
134
 
135
- export interface Album {
136
- mbid: string;
137
- '#text': string;
138
- }
135
+ export interface Album extends Track {
136
+ album: Album;
137
+ artist: Artist;
138
+ name: string;
139
+ url: string
140
+ };
139
141
 
140
- export interface Attr {
142
+ export interface AttrNowPlaying {
141
143
  nowplaying: string;
142
144
  }
143
145
 
@@ -147,18 +149,20 @@ export interface Date {
147
149
  }
148
150
 
149
151
  export interface Track {
150
- artist: Artist;
151
- streamable: string;
152
- image: Image[];
153
- mbid: string;
152
+ '@attr'?: AttrRank;
154
153
  album: Album;
154
+ artist: Artist;
155
+ date?: Date;
156
+ duration?: string;
157
+ image?: Image[];
158
+ mbid: string;
155
159
  name: string;
156
- '@attr': Attr;
160
+ playcount?: string;
161
+ streamable?: string;
157
162
  url: string;
158
- date: Date;
159
163
  }
160
164
 
161
- export interface Attr2 {
165
+ export interface AttrLimit {
162
166
  user: string;
163
167
  totalPages: string;
164
168
  page: string;
@@ -168,7 +172,7 @@ export interface Attr2 {
168
172
 
169
173
  export interface RecentTracks {
170
174
  track: Track[];
171
- '@attr': Attr2;
175
+ '@attr': AttrLimit;
172
176
  }
173
177
 
174
178
  export interface Image {
@@ -202,7 +206,7 @@ export interface User {
202
206
 
203
207
  export interface TopAlbums {
204
208
  album: Album[];
205
- '@attr': Attr2;
209
+ '@attr': AttrLimit;
206
210
  }
207
211
 
208
212
  export interface WeeklyArtistChartResponse {
@@ -211,14 +215,14 @@ export interface WeeklyArtistChartResponse {
211
215
 
212
216
  export interface WeeklyArtistChart {
213
217
  artist: Artist[];
214
- '@attr': Attr2;
218
+ '@attr': AttrLimit;
215
219
  }
216
220
 
217
- export interface Attr1 {
218
- rank: string;
221
+ export interface AttrRank {
222
+ rank?: string;
219
223
  }
220
224
 
221
- export interface Attr2 {
225
+ export interface AttrLimit {
222
226
  from: string;
223
227
  user: string;
224
228
  to: string;
@@ -249,7 +253,7 @@ export interface WeeklyTrackChartResponse {
249
253
 
250
254
  export interface WeeklyTrackChart {
251
255
  track: Track[];
252
- '@attr': WeeklyTrackChartAttr2;
256
+ '@attr': AttrLimit;
253
257
  }
254
258
 
255
259
  export interface WeeklyTrackChartTrack {
@@ -258,7 +262,7 @@ export interface WeeklyTrackChartTrack {
258
262
  mbid: string;
259
263
  url: string;
260
264
  name: string;
261
- '@attr': Attr;
265
+ '@attr': AttrNowPlaying;
262
266
  playcount: string;
263
267
  }
264
268
 
@@ -267,113 +271,6 @@ export interface WeeklyTrackChartArtist {
267
271
  '#text': string;
268
272
  }
269
273
 
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) => Promise<AuthResponse>;
282
- config: {
283
- api_key: string;
284
- app_name: string;
285
- base_url: string;
286
- format: {
287
- json: string;
288
- xml: string;
289
- };
290
- share_secret: string;
291
- username: string;
292
- };
293
- getInfo: (method: string, user: string) => 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>;
348
- };
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
274
  export enum ErrorResponse {
378
275
  InvalidService = 2,
379
276
  InvalidMethod = 3,
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.4.3
4
+
5
+ - fix missmatched types for Album and Track, added some optionals pity, but it works, that just how they give us the data.
6
+
7
+ ## 1.4.2
8
+
9
+ - bug, release dist
10
+
3
11
  ## 1.4.1
4
12
 
5
13
  - export esm modules modern js only.
package/dist/auth.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ import { AuthResponse } from '../@types';
2
+ /**
3
+ * POST: Auth - LastFM
4
+ *
5
+ * https://www.last.fm/api/show/auth.getToken
6
+ *
7
+ * Authentication tokens are API account specific.
8
+ * They are valid for 60 minutes from the moment they are granted.
9
+ * Can only used once (they are consumed when a session is created).
10
+ * @returns Auth token
11
+ */
12
+ export declare function auth(method: string, user: string, period: string, limit: string): Promise<AuthResponse>;
13
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAIzC;;;;;;;;;EASE;AACF,wBAAgB,IAAI,CAClB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,YAAY,CAAC,CAGvB"}
package/dist/auth.js ADDED
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.auth = void 0;
7
+ const createOptions_1 = require("./createOptions");
8
+ const request_1 = __importDefault(require("./request"));
9
+ /**
10
+ * POST: Auth - LastFM
11
+ *
12
+ * https://www.last.fm/api/show/auth.getToken
13
+ *
14
+ * Authentication tokens are API account specific.
15
+ * They are valid for 60 minutes from the moment they are granted.
16
+ * Can only used once (they are consumed when a session is created).
17
+ * @returns Auth token
18
+ */
19
+ function auth(method, user, period, limit) {
20
+ const options = (0, createOptions_1.createOptions)(method, user, period, limit);
21
+ return (0, request_1.default)(options);
22
+ }
23
+ exports.auth = auth;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @description Stores the Last.fm API key, app name, base url, format, shared secret, and username.
3
+ * Simply add a .env file to the root of the project and add the following:
4
+ * LASTFM_API_KEY=your_api_key
5
+ * LASTFM_APPNAME=your_app_name
6
+ * LASTFM_API_BASE_URL=your_base_url
7
+ * LASTFM_SHARED_SECRET=your_shared_secret
8
+ * LASTFM_USER=your_username
9
+ */
10
+ export declare const config: {
11
+ api_key: string;
12
+ app_name: string;
13
+ base_url: string;
14
+ format: {
15
+ json: string;
16
+ xml: string;
17
+ };
18
+ share_secret: string;
19
+ username: string;
20
+ };
21
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAcA;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;CAUD,CAAC"}
package/dist/config.js ADDED
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.config = void 0;
27
+ const dotenv = __importStar(require("dotenv"));
28
+ dotenv.config();
29
+ ;
30
+ /**
31
+ * @description Stores the Last.fm API key, app name, base url, format, shared secret, and username.
32
+ * Simply add a .env file to the root of the project and add the following:
33
+ * LASTFM_API_KEY=your_api_key
34
+ * LASTFM_APPNAME=your_app_name
35
+ * LASTFM_API_BASE_URL=your_base_url
36
+ * LASTFM_SHARED_SECRET=your_shared_secret
37
+ * LASTFM_USER=your_username
38
+ */
39
+ exports.config = {
40
+ api_key: `${process.env.LASTFM_API_KEY}`,
41
+ app_name: `${process.env.LASTFM_APPNAME}`,
42
+ base_url: `${process.env.LASTFM_API_BASE_URL}`,
43
+ format: {
44
+ json: 'json',
45
+ xml: 'xml',
46
+ },
47
+ share_secret: `${process.env.LASTFM_SHARED_SECRET}`,
48
+ username: `${process.env.LASTFM_USER}`,
49
+ };
@@ -0,0 +1,7 @@
1
+ export declare function createOptions(method: string, user: string, period?: string, limit?: string): {
2
+ method: string;
3
+ user: string;
4
+ period: string | undefined;
5
+ limit: string | undefined;
6
+ };
7
+ //# sourceMappingURL=createOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createOptions.d.ts","sourceRoot":"","sources":["../src/createOptions.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM;;;;;EAOf"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createOptions = void 0;
4
+ function createOptions(method, user, period, limit) {
5
+ return {
6
+ method,
7
+ user,
8
+ period,
9
+ limit,
10
+ };
11
+ }
12
+ exports.createOptions = createOptions;
@@ -0,0 +1,9 @@
1
+ import { UserResponse } from '../@types';
2
+ /**
3
+ * GET: User profile information - LastFM
4
+ *
5
+ * https://www.last.fm/api/show/user.getInfo
6
+ * @returns User profile information
7
+ */
8
+ export declare function getInfo(method: string, user: string): Promise<UserResponse>;
9
+ //# sourceMappingURL=getInfo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getInfo.d.ts","sourceRoot":"","sources":["../src/getInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAIzC;;;;;GAKG;AACH,wBAAgB,OAAO,CACrB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,YAAY,CAAC,CAGvB"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getInfo = void 0;
7
+ const createOptions_1 = require("./createOptions");
8
+ const request_1 = __importDefault(require("./request"));
9
+ /**
10
+ * GET: User profile information - LastFM
11
+ *
12
+ * https://www.last.fm/api/show/user.getInfo
13
+ * @returns User profile information
14
+ */
15
+ function getInfo(method, user) {
16
+ const options = (0, createOptions_1.createOptions)(method, user);
17
+ return (0, request_1.default)(options);
18
+ }
19
+ exports.getInfo = getInfo;
@@ -0,0 +1,9 @@
1
+ import { LovedTracksResponse } from '../@types';
2
+ /**
3
+ * GET: Love Tracks - LastFM
4
+ *
5
+ * https://www.last.fm/api/show/user.getLovedTracks
6
+ * @returns Loved Tracks;
7
+ */
8
+ export declare function getLovedTracks(method: string, user: string, period: string, limit: string): Promise<LovedTracksResponse>;
9
+ //# sourceMappingURL=getLovedTracks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getLovedTracks.d.ts","sourceRoot":"","sources":["../src/getLovedTracks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAIhD;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,mBAAmB,CAAC,CAG9B"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getLovedTracks = void 0;
7
+ const createOptions_1 = require("./createOptions");
8
+ const request_1 = __importDefault(require("./request"));
9
+ /**
10
+ * GET: Love Tracks - LastFM
11
+ *
12
+ * https://www.last.fm/api/show/user.getLovedTracks
13
+ * @returns Loved Tracks;
14
+ */
15
+ function getLovedTracks(method, user, period, limit) {
16
+ const options = (0, createOptions_1.createOptions)(method, user, period, limit);
17
+ return (0, request_1.default)(options);
18
+ }
19
+ exports.getLovedTracks = getLovedTracks;
@@ -0,0 +1,9 @@
1
+ import { RecentTracksResponse } from '../@types';
2
+ /**
3
+ * GET: Recent Tracks - LastFM
4
+ *
5
+ * https://www.last.fm/api/show/user.getRecentTracks
6
+ * @returns Recent Tracks
7
+ */
8
+ export declare function getRecentTracks(method: string, user: string, period: string, limit: string): Promise<RecentTracksResponse>;
9
+ //# sourceMappingURL=getRecentTracks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRecentTracks.d.ts","sourceRoot":"","sources":["../src/getRecentTracks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAIjD;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,oBAAoB,CAAC,CAG/B"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getRecentTracks = void 0;
7
+ const createOptions_1 = require("./createOptions");
8
+ const request_1 = __importDefault(require("./request"));
9
+ /**
10
+ * GET: Recent Tracks - LastFM
11
+ *
12
+ * https://www.last.fm/api/show/user.getRecentTracks
13
+ * @returns Recent Tracks
14
+ */
15
+ function getRecentTracks(method, user, period, limit) {
16
+ const options = (0, createOptions_1.createOptions)(method, user, period, limit);
17
+ return (0, request_1.default)(options);
18
+ }
19
+ exports.getRecentTracks = getRecentTracks;
@@ -0,0 +1,9 @@
1
+ import { TopAlbumsResponse } from '../@types';
2
+ /**
3
+ * GET: Top Albums - LastFM
4
+ *
5
+ * https://www.last.fm/api/show/user.getTopAlbums
6
+ * @returns Top Albums
7
+ */
8
+ export declare function getTopAlbums(method: string, user: string, period: string, limit: string): Promise<TopAlbumsResponse>;
9
+ //# sourceMappingURL=getTopAlbums.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTopAlbums.d.ts","sourceRoot":"","sources":["../src/getTopAlbums.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAI9C;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,iBAAiB,CAAC,CAG5B"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getTopAlbums = void 0;
7
+ const createOptions_1 = require("./createOptions");
8
+ const request_1 = __importDefault(require("./request"));
9
+ /**
10
+ * GET: Top Albums - LastFM
11
+ *
12
+ * https://www.last.fm/api/show/user.getTopAlbums
13
+ * @returns Top Albums
14
+ */
15
+ function getTopAlbums(method, user, period, limit) {
16
+ const options = (0, createOptions_1.createOptions)(method, user, period, limit);
17
+ return (0, request_1.default)(options);
18
+ }
19
+ exports.getTopAlbums = getTopAlbums;
@@ -0,0 +1,9 @@
1
+ import { TopArtistsResponse } from '../@types';
2
+ /**
3
+ * GET: Top Artist - LastFM
4
+ *
5
+ * https://www.last.fm/api/show/user.getTopArtists
6
+ * @returns Top Artists
7
+ */
8
+ export declare function getTopArtists(method: string, user: string, period: string, limit: string): Promise<TopArtistsResponse>;
9
+ //# sourceMappingURL=getTopArtists.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTopArtists.d.ts","sourceRoot":"","sources":["../src/getTopArtists.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAI/C;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,kBAAkB,CAAC,CAG7B"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getTopArtists = void 0;
7
+ const createOptions_1 = require("./createOptions");
8
+ const request_1 = __importDefault(require("./request"));
9
+ /**
10
+ * GET: Top Artist - LastFM
11
+ *
12
+ * https://www.last.fm/api/show/user.getTopArtists
13
+ * @returns Top Artists
14
+ */
15
+ function getTopArtists(method, user, period, limit) {
16
+ const options = (0, createOptions_1.createOptions)(method, user, period, limit);
17
+ return (0, request_1.default)(options);
18
+ }
19
+ exports.getTopArtists = getTopArtists;
@@ -0,0 +1,9 @@
1
+ import { TopTrackResponse } from '../@types';
2
+ /**
3
+ * GET: Top Tracks - LastFM
4
+ *
5
+ * https://www.last.fm/api/show/user.getTopTracks
6
+ * @returns Top Tracks
7
+ */
8
+ export declare function getTopTracks(method: string, user: string, period: string, limit: string): Promise<TopTrackResponse>;
9
+ //# sourceMappingURL=getTopTracks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTopTracks.d.ts","sourceRoot":"","sources":["../src/getTopTracks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAI7C;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,gBAAgB,CAAC,CAG3B"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getTopTracks = void 0;
7
+ const createOptions_1 = require("./createOptions");
8
+ const request_1 = __importDefault(require("./request"));
9
+ /**
10
+ * GET: Top Tracks - LastFM
11
+ *
12
+ * https://www.last.fm/api/show/user.getTopTracks
13
+ * @returns Top Tracks
14
+ */
15
+ function getTopTracks(method, user, period, limit) {
16
+ const options = (0, createOptions_1.createOptions)(method, user, period, limit);
17
+ return (0, request_1.default)(options);
18
+ }
19
+ exports.getTopTracks = getTopTracks;
@@ -0,0 +1,9 @@
1
+ import { WeeklyAlbumChartResponse } from '../@types';
2
+ /**
3
+ * GET: Weekly album chart - LastFM
4
+ *
5
+ * https://www.last.fm/api/show/user.getWeeklyAlbumChart
6
+ * @returns Weekly album chart
7
+ */
8
+ export declare function getWeeklyAlbumChart(method: string, user: string, period: string, limit: string): Promise<WeeklyAlbumChartResponse>;
9
+ //# sourceMappingURL=getWeeklyAlbumChart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getWeeklyAlbumChart.d.ts","sourceRoot":"","sources":["../src/getWeeklyAlbumChart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAIrD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,wBAAwB,CAAC,CAGnC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getWeeklyAlbumChart = void 0;
7
+ const createOptions_1 = require("./createOptions");
8
+ const request_1 = __importDefault(require("./request"));
9
+ /**
10
+ * GET: Weekly album chart - LastFM
11
+ *
12
+ * https://www.last.fm/api/show/user.getWeeklyAlbumChart
13
+ * @returns Weekly album chart
14
+ */
15
+ function getWeeklyAlbumChart(method, user, period, limit) {
16
+ const options = (0, createOptions_1.createOptions)(method, user, period, limit);
17
+ return (0, request_1.default)(options);
18
+ }
19
+ exports.getWeeklyAlbumChart = getWeeklyAlbumChart;
@@ -0,0 +1,9 @@
1
+ import { WeeklyArtistChartResponse } from '../@types';
2
+ /**
3
+ * GET: Weekly artist chart - LastFM
4
+ *
5
+ * https://www.last.fm/api/show/user.getWeeklyArtistChart
6
+ * @returns Weekly artist chart
7
+ */
8
+ export declare function getWeeklyArtistChart(method: string, user: string, period: string, limit: string): Promise<WeeklyArtistChartResponse>;
9
+ //# sourceMappingURL=getWeeklyArtistChart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getWeeklyArtistChart.d.ts","sourceRoot":"","sources":["../src/getWeeklyArtistChart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAItD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,yBAAyB,CAAC,CAGpC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getWeeklyArtistChart = void 0;
7
+ const createOptions_1 = require("./createOptions");
8
+ const request_1 = __importDefault(require("./request"));
9
+ /**
10
+ * GET: Weekly artist chart - LastFM
11
+ *
12
+ * https://www.last.fm/api/show/user.getWeeklyArtistChart
13
+ * @returns Weekly artist chart
14
+ */
15
+ function getWeeklyArtistChart(method, user, period, limit) {
16
+ const options = (0, createOptions_1.createOptions)(method, user, period, limit);
17
+ return (0, request_1.default)(options);
18
+ }
19
+ exports.getWeeklyArtistChart = getWeeklyArtistChart;
@@ -0,0 +1,9 @@
1
+ import { WeeklyChartListResponse } from '../@types';
2
+ /**
3
+ * GET: Weekly chart list - LastFM
4
+ *
5
+ * https://www.last.fm/api/show/user.getWeeklyChartList
6
+ * @returns Weekly chart list
7
+ */
8
+ export declare function getWeeklyChartList(method: string, user: string, period: string, limit: string): Promise<WeeklyChartListResponse>;
9
+ //# sourceMappingURL=getWeeklyChartList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getWeeklyChartList.d.ts","sourceRoot":"","sources":["../src/getWeeklyChartList.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAIpD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,uBAAuB,CAAC,CAGlC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getWeeklyChartList = void 0;
7
+ const createOptions_1 = require("./createOptions");
8
+ const request_1 = __importDefault(require("./request"));
9
+ /**
10
+ * GET: Weekly chart list - LastFM
11
+ *
12
+ * https://www.last.fm/api/show/user.getWeeklyChartList
13
+ * @returns Weekly chart list
14
+ */
15
+ function getWeeklyChartList(method, user, period, limit) {
16
+ const options = (0, createOptions_1.createOptions)(method, user, period, limit);
17
+ return (0, request_1.default)(options);
18
+ }
19
+ exports.getWeeklyChartList = getWeeklyChartList;
@@ -0,0 +1,9 @@
1
+ import { WeeklyTrackChartResponse } from '../@types';
2
+ /**
3
+ * GET: Weekly track chart - LastFM
4
+ *
5
+ * https://www.last.fm/api/show/user.getWeeklyTrackChart
6
+ * @returns Weekly track chart
7
+ */
8
+ export declare function getWeeklyTrackChart(method: string, user: string, period: string, limit: string): Promise<WeeklyTrackChartResponse>;
9
+ //# sourceMappingURL=getWeeklyTrackChart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getWeeklyTrackChart.d.ts","sourceRoot":"","sources":["../src/getWeeklyTrackChart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAKrD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,wBAAwB,CAAC,CAGnC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getWeeklyTrackChart = void 0;
7
+ const createOptions_1 = require("./createOptions");
8
+ const request_1 = __importDefault(require("./request"));
9
+ /**
10
+ * GET: Weekly track chart - LastFM
11
+ *
12
+ * https://www.last.fm/api/show/user.getWeeklyTrackChart
13
+ * @returns Weekly track chart
14
+ */
15
+ function getWeeklyTrackChart(method, user, period, limit) {
16
+ const options = (0, createOptions_1.createOptions)(method, user, period, limit);
17
+ return (0, request_1.default)(options);
18
+ }
19
+ exports.getWeeklyTrackChart = getWeeklyTrackChart;
@@ -0,0 +1,52 @@
1
+ import { auth } from './auth';
2
+ import { getInfo } from './getInfo';
3
+ import { getLovedTracks } from './getLovedTracks';
4
+ import { getRecentTracks } from './getRecentTracks';
5
+ import { getTopAlbums } from './getTopAlbums';
6
+ import { getTopArtists } from './getTopArtists';
7
+ import { getTopTracks } from './getTopTracks';
8
+ import { getWeeklyAlbumChart } from './getWeeklyAlbumChart';
9
+ import { getWeeklyArtistChart } from './getWeeklyArtistChart';
10
+ import { getWeeklyChartList } from './getWeeklyChartList';
11
+ import { getWeeklyTrackChart } from './getWeeklyTrackChart';
12
+ declare const LastFmApi: () => {
13
+ auth: typeof auth;
14
+ config: {
15
+ api_key: string;
16
+ app_name: string;
17
+ base_url: string;
18
+ format: {
19
+ json: string;
20
+ xml: string;
21
+ };
22
+ share_secret: string;
23
+ username: string;
24
+ };
25
+ getInfo: typeof getInfo;
26
+ getLovedTracks: typeof getLovedTracks;
27
+ getRecentTracks: typeof getRecentTracks;
28
+ getTopAlbums: typeof getTopAlbums;
29
+ getTopArtists: typeof getTopArtists;
30
+ getTopTracks: typeof getTopTracks;
31
+ getWeeklyAlbumChart: typeof getWeeklyAlbumChart;
32
+ getWeeklyArtistChart: typeof getWeeklyArtistChart;
33
+ getWeeklyChartList: typeof getWeeklyChartList;
34
+ getWeeklyTrackChart: typeof getWeeklyTrackChart;
35
+ method: {
36
+ auth: string;
37
+ user: {
38
+ getInfo: string;
39
+ getLovedTracks: string;
40
+ getRecentTracks: string;
41
+ getTopAlbums: string;
42
+ getTopArtists: string;
43
+ getTopTracks: string;
44
+ getWeeklyAlbumChart: string;
45
+ getWeeklyArtistChart: string;
46
+ getWeeklyChartList: string;
47
+ getWeeklyTrackChart: string;
48
+ };
49
+ };
50
+ };
51
+ export default LastFmApi;
52
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,QAAA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAcb,CAAA;AAEF,eAAe,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const auth_1 = require("./auth");
4
+ const config_1 = require("./config");
5
+ const getInfo_1 = require("./getInfo");
6
+ const getLovedTracks_1 = require("./getLovedTracks");
7
+ const getRecentTracks_1 = require("./getRecentTracks");
8
+ const getTopAlbums_1 = require("./getTopAlbums");
9
+ const getTopArtists_1 = require("./getTopArtists");
10
+ const getTopTracks_1 = require("./getTopTracks");
11
+ const getWeeklyAlbumChart_1 = require("./getWeeklyAlbumChart");
12
+ const getWeeklyArtistChart_1 = require("./getWeeklyArtistChart");
13
+ const getWeeklyChartList_1 = require("./getWeeklyChartList");
14
+ const getWeeklyTrackChart_1 = require("./getWeeklyTrackChart");
15
+ const method_1 = require("./method");
16
+ const LastFmApi = () => ({
17
+ auth: auth_1.auth,
18
+ config: config_1.config,
19
+ getInfo: getInfo_1.getInfo,
20
+ getLovedTracks: getLovedTracks_1.getLovedTracks,
21
+ getRecentTracks: getRecentTracks_1.getRecentTracks,
22
+ getTopAlbums: getTopAlbums_1.getTopAlbums,
23
+ getTopArtists: getTopArtists_1.getTopArtists,
24
+ getTopTracks: getTopTracks_1.getTopTracks,
25
+ getWeeklyAlbumChart: getWeeklyAlbumChart_1.getWeeklyAlbumChart,
26
+ getWeeklyArtistChart: getWeeklyArtistChart_1.getWeeklyArtistChart,
27
+ getWeeklyChartList: getWeeklyChartList_1.getWeeklyChartList,
28
+ getWeeklyTrackChart: getWeeklyTrackChart_1.getWeeklyTrackChart,
29
+ method: method_1.method,
30
+ });
31
+ exports.default = LastFmApi;
@@ -0,0 +1,33 @@
1
+ interface UserMethod {
2
+ getInfo: string;
3
+ getLovedTracks: string;
4
+ getRecentTracks: string;
5
+ getTopAlbums: string;
6
+ getTopArtists: string;
7
+ getTopTracks: string;
8
+ getWeeklyAlbumChart: string;
9
+ getWeeklyArtistChart: string;
10
+ getWeeklyChartList: string;
11
+ getWeeklyTrackChart: string;
12
+ }
13
+ export interface Method {
14
+ auth: string;
15
+ user: UserMethod;
16
+ }
17
+ export declare const method: {
18
+ auth: string;
19
+ user: {
20
+ getInfo: string;
21
+ getLovedTracks: string;
22
+ getRecentTracks: string;
23
+ getTopAlbums: string;
24
+ getTopArtists: string;
25
+ getTopTracks: string;
26
+ getWeeklyAlbumChart: string;
27
+ getWeeklyArtistChart: string;
28
+ getWeeklyChartList: string;
29
+ getWeeklyTrackChart: string;
30
+ };
31
+ };
32
+ export {};
33
+ //# sourceMappingURL=method.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"method.d.ts","sourceRoot":"","sources":["../src/method.ts"],"names":[],"mappings":"AAAA,UAAU,UAAU;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,eAAO,MAAM,MAAM;;;;;;;;;;;;;;CAcD,CAAC"}
package/dist/method.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.method = void 0;
4
+ ;
5
+ ;
6
+ exports.method = {
7
+ auth: 'auth.getToken',
8
+ user: {
9
+ getInfo: 'user.getInfo',
10
+ getLovedTracks: 'user.getLovedTracks',
11
+ getRecentTracks: 'user.getRecentTracks',
12
+ getTopAlbums: 'user.getTopAlbums',
13
+ getTopArtists: 'user.getTopArtists',
14
+ getTopTracks: 'user.getTopTracks',
15
+ getWeeklyAlbumChart: 'user.getWeeklyAlbumChart',
16
+ getWeeklyArtistChart: 'user.getWeeklyArtistChart',
17
+ getWeeklyChartList: 'user.getWeeklyChartList',
18
+ getWeeklyTrackChart: 'user.getWeeklyTrackChart',
19
+ },
20
+ };
@@ -0,0 +1,9 @@
1
+ interface RequestOptions {
2
+ method: string;
3
+ user?: string;
4
+ period?: string;
5
+ limit?: string;
6
+ }
7
+ declare const request: <Response_1>(options: RequestOptions) => Promise<Response_1>;
8
+ export default request;
9
+ //# sourceMappingURL=request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAGA,UAAU,cAAc;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAkCD,QAAA,MAAM,OAAO,wBAA6B,cAAc,wBAwFvD,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const cross_fetch_1 = __importDefault(require("cross-fetch"));
16
+ const config_1 = require("./config");
17
+ var ErrorResponse;
18
+ (function (ErrorResponse) {
19
+ ErrorResponse[ErrorResponse["InvalidService"] = 2] = "InvalidService";
20
+ ErrorResponse[ErrorResponse["InvalidMethod"] = 3] = "InvalidMethod";
21
+ ErrorResponse[ErrorResponse["AuthenticationFailed"] = 4] = "AuthenticationFailed";
22
+ ErrorResponse[ErrorResponse["InvalidFormat"] = 5] = "InvalidFormat";
23
+ ErrorResponse[ErrorResponse["InvalidParameters"] = 6] = "InvalidParameters";
24
+ ErrorResponse[ErrorResponse["InvalidResource"] = 7] = "InvalidResource";
25
+ ErrorResponse[ErrorResponse["OperationFailed"] = 8] = "OperationFailed";
26
+ ErrorResponse[ErrorResponse["InvalidSessionKey"] = 9] = "InvalidSessionKey";
27
+ ErrorResponse[ErrorResponse["InvalidAPIKey"] = 10] = "InvalidAPIKey";
28
+ ErrorResponse[ErrorResponse["ServiceOffline"] = 11] = "ServiceOffline";
29
+ ErrorResponse[ErrorResponse["InvalidMethodSignature"] = 13] = "InvalidMethodSignature";
30
+ ErrorResponse[ErrorResponse["TemporaryError"] = 16] = "TemporaryError";
31
+ ErrorResponse[ErrorResponse["SuspendedAPIKey"] = 26] = "SuspendedAPIKey";
32
+ ErrorResponse[ErrorResponse["RateLimitExceeded"] = 29] = "RateLimitExceeded";
33
+ })(ErrorResponse || (ErrorResponse = {}));
34
+ const buildUrl = (options) => {
35
+ const params = new URLSearchParams();
36
+ params.append('method', options.method);
37
+ if (options.user)
38
+ params.append('user', options.user);
39
+ if (options.period)
40
+ params.append('period', options.period);
41
+ if (options.limit)
42
+ params.append('limit', options.limit);
43
+ params.append('api_key', config_1.config.api_key);
44
+ params.append('format', config_1.config.format.json);
45
+ return `${config_1.config.base_url}?${params.toString()}`;
46
+ };
47
+ const request = (options) => __awaiter(void 0, void 0, void 0, function* () {
48
+ const url = buildUrl(options);
49
+ return (yield (0, cross_fetch_1.default)(url, {
50
+ headers: {
51
+ 'Content-Type': 'application/json',
52
+ },
53
+ })
54
+ .then((res) => {
55
+ if (!res.ok) {
56
+ throw new Error(res.statusText);
57
+ }
58
+ switch (res.status) {
59
+ case 200: {
60
+ return res.json();
61
+ }
62
+ case 400: {
63
+ throw new Error('Bad request');
64
+ }
65
+ case 401: {
66
+ throw new Error('Unauthorized');
67
+ }
68
+ case 403: {
69
+ throw new Error('Forbidden');
70
+ }
71
+ case 404: {
72
+ throw new Error('Not found');
73
+ }
74
+ case 500: {
75
+ throw new Error('Internal server error');
76
+ }
77
+ case 503: {
78
+ throw new Error('Service unavailable');
79
+ }
80
+ case ErrorResponse.InvalidAPIKey: {
81
+ throw new Error('Invalid API key');
82
+ }
83
+ case ErrorResponse.InvalidMethod: {
84
+ throw new Error('Invalid method');
85
+ }
86
+ case ErrorResponse.InvalidParameters: {
87
+ throw new Error('Invalid parameters');
88
+ }
89
+ case ErrorResponse.InvalidResource: {
90
+ throw new Error('Invalid resource');
91
+ }
92
+ case ErrorResponse.InvalidSessionKey: {
93
+ throw new Error('Invalid session key');
94
+ }
95
+ case ErrorResponse.InvalidService: {
96
+ throw new Error('Invalid service');
97
+ }
98
+ case ErrorResponse.OperationFailed: {
99
+ throw new Error('Operation failed');
100
+ }
101
+ case ErrorResponse.RateLimitExceeded: {
102
+ throw new Error('Rate limit exceeded');
103
+ }
104
+ case ErrorResponse.ServiceOffline: {
105
+ throw new Error('Service offline');
106
+ }
107
+ case ErrorResponse.SuspendedAPIKey: {
108
+ throw new Error('Suspended API key');
109
+ }
110
+ case ErrorResponse.TemporaryError: {
111
+ throw new Error('Temporary error');
112
+ }
113
+ case ErrorResponse.AuthenticationFailed: {
114
+ throw new Error('Authentication failed');
115
+ }
116
+ case ErrorResponse.InvalidFormat: {
117
+ throw new Error('Invalid format');
118
+ }
119
+ case ErrorResponse.InvalidMethodSignature: {
120
+ throw new Error('Invalid method signature');
121
+ }
122
+ default: {
123
+ throw new Error('Unknown error');
124
+ }
125
+ }
126
+ })
127
+ .then((json) => json)
128
+ .catch((error) => {
129
+ console.log('🚨 error:', error);
130
+ }));
131
+ });
132
+ exports.default = request;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lastfm-nodejs-client",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "description": "A NodeJS wrapper client for LastFm API. Fetching public data by username using the LastFm public API",
5
5
  "main": "./dist",
6
6
  "keywords": [
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "homepage": "https://github.com/mannuelf/lastfm-nodejs-client#readme",
36
36
  "scripts": {
37
- "build": "rimraf dist && tsc && cp -r @types/ dist/@types/",
37
+ "build": "rimraf dist && tsc",
38
38
  "clean": "rimraf dist",
39
39
  "dev": "npm run clean && tsc --watch --project tsconfig.dev.json",
40
40
  "test": "npx playwright test --reporter=list"
package/tsconfig.json CHANGED
@@ -12,8 +12,8 @@
12
12
  // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
13
13
 
14
14
  /* Language and Environment */
15
- "target": "ES6" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
16
- "lib": ["DOM", "ESNext"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
15
+ "target": "ES6" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
16
+ "lib": ["DOM", "ESNext"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
17
17
  // "jsx": "preserve", /* Specify what JSX code is generated. */
18
18
  // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
19
19
  // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
@@ -26,9 +26,9 @@
26
26
  // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
27
27
 
28
28
  /* Modules */
29
- "module": "NodeNext" /* Specify what module code is generated. */,
30
- "rootDir": "./src" /* Specify the root folder within your source files. */,
31
- "moduleResolution": "NodeNext" /* Specify how TypeScript looks up a file from a given module specifier. */,
29
+ "module": "NodeNext" /* Specify what module code is generated. */,
30
+ "rootDir": "./src" /* Specify the root folder within your source files. */,
31
+ "moduleResolution": "NodeNext" /* Specify how TypeScript looks up a file from a given module specifier. */,
32
32
  // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
33
33
  // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
34
34
  // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
@@ -46,7 +46,7 @@
46
46
 
47
47
  /* Emit */
48
48
  "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
49
- "declarationMap": true, /* Create sourcemaps for d.ts files. */
49
+ "declarationMap": true, /* Create sourcemaps for d.ts files. */
50
50
  // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
51
51
  // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
52
52
  // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
@@ -77,16 +77,16 @@
77
77
  "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
78
78
 
79
79
  /* Type Checking */
80
- "strict": true /* Enable all strict type-checking options. */,
81
- "noImplicitAny": true /* Enable error reporting for expressions and declarations with an implied 'any' type. */,
82
- "strictNullChecks": true /* When type checking, take into account 'null' and 'undefined'. */,
80
+ "strict": true /* Enable all strict type-checking options. */,
81
+ "noImplicitAny": true /* Enable error reporting for expressions and declarations with an implied 'any' type. */,
82
+ "strictNullChecks": true /* When type checking, take into account 'null' and 'undefined'. */,
83
83
  // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
84
84
  // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
85
85
  // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
86
86
  // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
87
- // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
88
- // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
89
- // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
87
+ "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
88
+ "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
89
+ "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
90
90
  // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
91
91
  // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
92
92
  // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
@@ -98,7 +98,7 @@
98
98
  // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
99
99
 
100
100
  /* Completeness */
101
- "skipDefaultLibCheck": true /* Skip type checking .d.ts files that are included with TypeScript. */,
102
- "skipLibCheck": true /* Skip type checking all .d.ts files. */
101
+ "skipDefaultLibCheck": true /* Skip type checking .d.ts files that are included with TypeScript. */,
102
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
103
103
  }
104
104
  }