lastfm-nodejs-client 1.2.4 → 1.4.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,5 +1,6 @@
1
- LASTFM_API_BASE_URL="https://ws.audioscrobbler.com/2.0/"
2
- LASTFM_API_KEY="abcdefghijkhlmnopqrstuvwxyz"
3
- LASTFM_APPNAME="your app name"
4
- LASTFM_SHARED_SECRET="xxxxxxxxxxxxxxxxxxxxx"
5
- LASTFM_USER="your username"
1
+ LASTFM_API_BASE_URL=https://ws.audioscrobbler.com/2.0/
2
+ LASTFM_API_KEY=f7177932c78b9723d54e617d0d5695ee
3
+ LASTFM_APPNAME=music-wall
4
+ LASTFM_SHARED_SECRET=bcffbbc0ba4af16fc00415c94b138c74
5
+ LASTFM_USER=mannuelf
6
+ LASTFM_REGISTERTO=mannuelf
package/@types/index.d.ts CHANGED
@@ -108,7 +108,7 @@ export type Artist = {
108
108
  rank: number;
109
109
  };
110
110
  cover: ArtistImage;
111
- image?: string;
111
+ image?: Image[];
112
112
  mbid: string;
113
113
  name: string;
114
114
  playcount: number;
@@ -278,7 +278,7 @@ export interface WeeklyTrackChartAttr2 {
278
278
  }
279
279
 
280
280
  export const LastFmApi: () => {
281
- auth: (method: string, user: string, period: string, limit: number) => Promise<AuthResponse>;
281
+ auth: (method: string, user: string) => Promise<AuthResponse>;
282
282
  config: {
283
283
  api_key: string;
284
284
  app_name: string;
@@ -290,7 +290,7 @@ export const LastFmApi: () => {
290
290
  share_secret: string;
291
291
  username: string;
292
292
  };
293
- getInfo: (method: string, user: string, period: string, limit: number) => Promise<UserResponse>;
293
+ getInfo: (method: string, user: string) => Promise<UserResponse>;
294
294
  getLovedTracks: (
295
295
  method: string,
296
296
  user: string,
@@ -374,19 +374,19 @@ export interface method {
374
374
  };
375
375
  }
376
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
- }
377
+ export enum ErrorResponse {
378
+ InvalidService = 2,
379
+ InvalidMethod = 3,
380
+ AuthenticationFailed = 4,
381
+ InvalidFormat = 5,
382
+ InvalidParameters = 6,
383
+ InvalidResource = 7,
384
+ OperationFailed = 8,
385
+ InvalidSessionKey = 9,
386
+ InvalidAPIKey = 10,
387
+ ServiceOffline = 11,
388
+ InvalidMethodSignature = 13,
389
+ TemporaryError = 16,
390
+ SuspendedAPIKey = 26,
391
+ RateLimitExceeded = 29
392
+ }
package/CHANGELOG.md CHANGED
@@ -1,15 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.4.0
4
+
5
+ - update all api functions from snake case to camel case.
6
+
7
+ ## 1.3.0
8
+
9
+ - Updates npm dependencies.
10
+ - refactors request with new error handling and responses.
11
+ - updates getInfo, removes hte un-required params.
12
+
3
13
  ## 1.2.4
4
14
 
5
- - Updates npm dependencies
15
+ - Updates npm dependencies.
6
16
  - Refactors request methods options and updates all callsites.
7
17
  - Add nvmrc file for easy switching node version.
8
18
 
9
19
  ## 1.2.3
10
20
 
11
- - Adds tests, using Playwright
12
- - Adds dotenv npm module as a new dependency
21
+ - Adds tests, using Playwright.
22
+ - Adds dotenv npm module as a new dependency.
13
23
 
14
24
  ## 1.2.2
15
25
 
@@ -17,7 +27,7 @@
17
27
 
18
28
  ## 1.2.1
19
29
 
20
- - Tidy up, removes console logs
30
+ - Tidy up, removes console logs.
21
31
 
22
32
  ## 1.2.0
23
33
 
@@ -25,15 +35,15 @@
25
35
 
26
36
  ## 1.1.5
27
37
 
28
- - Fix incorrect type on request method
38
+ - Fix incorrect type on request method.
29
39
 
30
40
  ## 1.1.4
31
41
 
32
- - Fix incorrect type on request method
42
+ - Fix incorrect type on request method.
33
43
 
34
44
  ## 1.1.3
35
45
 
36
- - Fix incorrect type import
46
+ - Fix incorrect type import.
37
47
 
38
48
  ## 1.1.2
39
49
 
@@ -41,44 +51,44 @@
41
51
 
42
52
  ## 1.1.1
43
53
 
44
- - update function declaration
45
- - re-add type declartion files for source code
54
+ - update function declaration.
55
+ - re-add type declartion files for source code.
46
56
 
47
57
  ## 1.1.0
48
58
 
49
- - Downgrade node-fetch to v2.6.7
50
- - Do not ship separate declaration files
51
- - TS now exports to CommonJs modules for better support older consumers
59
+ - Downgrade node-fetch to v2.6.7.
60
+ - Do not ship separate declaration files.
61
+ - TS now exports to CommonJs modules for better support older consumers.
52
62
 
53
63
  ## 1.0.6
54
64
 
55
- - Forking repo README update
65
+ - Forking repo README update.
56
66
 
57
67
  ## 1.0.5
58
68
 
59
- - Fix local types
60
- - Update readme with current way of using the types
61
- - adds screenshot of it in use
69
+ - Fix local types.
70
+ - Update readme with current way of using the types.
71
+ - adds screenshot of it in use.
62
72
 
63
73
  ## 1.0.4
64
74
 
65
- - Export types
75
+ - Export types.
66
76
 
67
77
  ## 1.0.3
68
78
 
69
- - Adds types file to distribution
70
- - Updates readme with types imports
79
+ - Adds types file to distribution.
80
+ - Updates readme with types imports.
71
81
 
72
82
  ## 1.0.2
73
83
 
74
- - Refactors types.d.ts to types.ts so can ship them with package and consumers can import them in their projects
84
+ - Refactors types.d.ts to types.ts so can ship them with package and consumers can import them in their projects.
75
85
 
76
86
  ## 1.0.1
77
87
 
78
- - Refactors config and methods to own modules
79
- - tsconfig, generate types to allow shipping types in one package, no need to DefinitleyTyped right now
80
- - update docs with new way of interacting with API
88
+ - Refactors config and methods to own modules.
89
+ - tsconfig, generate types to allow shipping types in one package, no need to DefinitleyTyped right now.
90
+ - update docs with new way of interacting with API.
81
91
 
82
92
  ## 1.0.0
83
93
 
84
- - Initial project setup
94
+ - Initial project setup.
package/README.md CHANGED
@@ -110,3 +110,7 @@ pnpm build
110
110
  ### Why I built this?
111
111
 
112
112
  I was building a scrobbles page [https://mannuelferreira.com/scrobbles](https://mannuelferreira.com/scrobbles) and I thought others might want it to.
113
+
114
+ ### TODO
115
+
116
+ - move types into [DefinitelyTyped](https://github.com/mannuelf/DefinitelyTyped)
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;
package/dist/config.js CHANGED
@@ -23,9 +23,20 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.config = void 0;
26
27
  const dotenv = __importStar(require("dotenv"));
27
28
  dotenv.config();
28
- exports.default = {
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 = {
29
40
  api_key: `${process.env.LASTFM_API_KEY}`,
30
41
  app_name: `${process.env.LASTFM_APPNAME}`,
31
42
  base_url: `${process.env.LASTFM_API_BASE_URL}`,
@@ -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,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,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,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,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,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,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,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,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,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,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;