lastfm-nodejs-client 1.4.3 → 1.4.4
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/README.md +14 -2
- package/dist/cjs/auth.d.ts +12 -0
- package/dist/{auth.js → cjs/auth.js} +11 -11
- package/dist/cjs/chart/topArtists.d.ts +2 -0
- package/dist/cjs/chart/topArtists.js +13 -0
- package/dist/cjs/chart/topTags.d.ts +2 -0
- package/dist/cjs/chart/topTags.js +13 -0
- package/dist/cjs/chart/topTracks.d.ts +2 -0
- package/dist/cjs/chart/topTracks.js +13 -0
- package/dist/{config.d.ts → cjs/config.d.ts} +0 -1
- package/dist/{config.js → cjs/config.js} +0 -1
- package/dist/cjs/createOptions.d.ts +7 -0
- package/dist/{createOptions.js → cjs/createOptions.js} +2 -1
- package/dist/{getInfo.d.ts → cjs/getInfo.d.ts} +1 -2
- package/dist/{getInfo.js → cjs/getInfo.js} +2 -2
- package/dist/{getLovedTracks.d.ts → cjs/getLovedTracks.d.ts} +1 -2
- package/dist/{getLovedTracks.js → cjs/getLovedTracks.js} +2 -2
- package/dist/{getRecentTracks.d.ts → cjs/getRecentTracks.d.ts} +1 -2
- package/dist/{getRecentTracks.js → cjs/getRecentTracks.js} +2 -2
- package/dist/{getTopAlbums.d.ts → cjs/getTopAlbums.d.ts} +1 -2
- package/dist/{getTopAlbums.js → cjs/getTopAlbums.js} +2 -2
- package/dist/{getTopArtists.d.ts → cjs/getTopArtists.d.ts} +1 -2
- package/dist/{getTopArtists.js → cjs/getTopArtists.js} +2 -2
- package/dist/{getTopTracks.d.ts → cjs/getTopTracks.d.ts} +1 -2
- package/dist/{getTopTracks.js → cjs/getTopTracks.js} +2 -2
- package/dist/{getWeeklyAlbumChart.d.ts → cjs/getWeeklyAlbumChart.d.ts} +1 -2
- package/dist/{getWeeklyAlbumChart.js → cjs/getWeeklyAlbumChart.js} +2 -2
- package/dist/{getWeeklyArtistChart.d.ts → cjs/getWeeklyArtistChart.d.ts} +1 -2
- package/dist/{getWeeklyArtistChart.js → cjs/getWeeklyArtistChart.js} +2 -2
- package/dist/{getWeeklyChartList.d.ts → cjs/getWeeklyChartList.d.ts} +1 -2
- package/dist/{getWeeklyChartList.js → cjs/getWeeklyChartList.js} +2 -2
- package/dist/{getWeeklyTrackChart.d.ts → cjs/getWeeklyTrackChart.d.ts} +1 -2
- package/dist/{getWeeklyTrackChart.js → cjs/getWeeklyTrackChart.js} +2 -2
- package/dist/{index.d.ts → cjs/index.d.ts} +14 -3
- package/dist/cjs/index.js +41 -0
- package/dist/{method.d.ts → cjs/method.d.ts} +11 -1
- package/dist/{method.js → cjs/method.js} +5 -2
- package/dist/cjs/package.json +3 -0
- package/dist/{request.d.ts → cjs/request.d.ts} +0 -1
- package/dist/{request.js → cjs/request.js} +7 -15
- package/dist/mjs/auth.d.ts +12 -0
- package/dist/mjs/auth.js +16 -0
- package/dist/mjs/chart/topArtists.d.ts +2 -0
- package/dist/mjs/chart/topArtists.js +6 -0
- package/dist/mjs/chart/topTags.d.ts +2 -0
- package/dist/mjs/chart/topTags.js +6 -0
- package/dist/mjs/chart/topTracks.d.ts +2 -0
- package/dist/mjs/chart/topTracks.js +6 -0
- package/dist/mjs/config.d.ts +20 -0
- package/dist/mjs/config.js +22 -0
- package/dist/mjs/createOptions.d.ts +7 -0
- package/dist/mjs/createOptions.js +9 -0
- package/dist/mjs/getInfo.d.ts +8 -0
- package/dist/mjs/getInfo.js +12 -0
- package/dist/mjs/getLovedTracks.d.ts +8 -0
- package/dist/mjs/getLovedTracks.js +12 -0
- package/dist/mjs/getRecentTracks.d.ts +8 -0
- package/dist/mjs/getRecentTracks.js +12 -0
- package/dist/mjs/getTopAlbums.d.ts +8 -0
- package/dist/mjs/getTopAlbums.js +12 -0
- package/dist/mjs/getTopArtists.d.ts +8 -0
- package/dist/mjs/getTopArtists.js +12 -0
- package/dist/mjs/getTopTracks.d.ts +8 -0
- package/dist/mjs/getTopTracks.js +12 -0
- package/dist/mjs/getWeeklyAlbumChart.d.ts +8 -0
- package/dist/mjs/getWeeklyAlbumChart.js +12 -0
- package/dist/mjs/getWeeklyArtistChart.d.ts +8 -0
- package/dist/mjs/getWeeklyArtistChart.js +12 -0
- package/dist/mjs/getWeeklyChartList.d.ts +8 -0
- package/dist/mjs/getWeeklyChartList.js +12 -0
- package/dist/mjs/getWeeklyTrackChart.d.ts +8 -0
- package/dist/mjs/getWeeklyTrackChart.js +12 -0
- package/dist/mjs/index.d.ts +63 -0
- package/{src/index.ts → dist/mjs/index.js} +25 -18
- package/dist/mjs/method.d.ts +43 -0
- package/dist/mjs/method.js +20 -0
- package/dist/mjs/package.json +3 -0
- package/dist/mjs/request.d.ts +8 -0
- package/dist/mjs/request.js +119 -0
- package/lastfm-nodejs-client/package.json +7 -0
- package/package.json +41 -13
- package/.env.example +0 -6
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/.github/dependabot.yml +0 -11
- package/.github/workflows/codeql.yml +0 -74
- package/.github/workflows/playwright.yml +0 -36
- package/.nvmrc +0 -1
- package/.prettierrc.yaml +0 -6
- package/@types/index.d.ts +0 -289
- package/CHANGELOG.md +0 -108
- package/CODE_OF_CONDUCT.md +0 -128
- package/CONTRIBUTING.md +0 -9
- package/SECURITY.md +0 -13
- package/dist/auth.d.ts +0 -13
- package/dist/auth.d.ts.map +0 -1
- package/dist/config.d.ts.map +0 -1
- package/dist/createOptions.d.ts +0 -7
- package/dist/createOptions.d.ts.map +0 -1
- package/dist/getInfo.d.ts.map +0 -1
- package/dist/getLovedTracks.d.ts.map +0 -1
- package/dist/getRecentTracks.d.ts.map +0 -1
- package/dist/getTopAlbums.d.ts.map +0 -1
- package/dist/getTopArtists.d.ts.map +0 -1
- package/dist/getTopTracks.d.ts.map +0 -1
- package/dist/getWeeklyAlbumChart.d.ts.map +0 -1
- package/dist/getWeeklyArtistChart.d.ts.map +0 -1
- package/dist/getWeeklyChartList.d.ts.map +0 -1
- package/dist/getWeeklyTrackChart.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -31
- package/dist/method.d.ts.map +0 -1
- package/dist/request.d.ts.map +0 -1
- package/playwright.config.ts +0 -37
- package/src/auth.ts +0 -23
- package/src/config.ts +0 -34
- package/src/createOptions.ts +0 -12
- package/src/getInfo.ts +0 -17
- package/src/getLovedTracks.ts +0 -19
- package/src/getRecentTracks.ts +0 -19
- package/src/getTopAlbums.ts +0 -19
- package/src/getTopArtists.ts +0 -19
- package/src/getTopTracks.ts +0 -19
- package/src/getWeeklyAlbumChart.ts +0 -19
- package/src/getWeeklyArtistChart.ts +0 -19
- package/src/getWeeklyChartList.ts +0 -19
- package/src/getWeeklyTrackChart.ts +0 -20
- package/src/method.ts +0 -33
- package/src/request.ts +0 -133
- package/tests/env.spec.ts +0 -21
- package/tsconfig.dev.json +0 -7
- package/tsconfig.json +0 -104
package/README.md
CHANGED
|
@@ -98,7 +98,12 @@ Create them [here](https://www.last.fm/api/account/create).
|
|
|
98
98
|
### Develop
|
|
99
99
|
|
|
100
100
|
```bash
|
|
101
|
-
pnpm
|
|
101
|
+
pnpm test
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
pnpm lint
|
|
106
|
+
pnpm lint-fix
|
|
102
107
|
```
|
|
103
108
|
|
|
104
109
|
### Build
|
|
@@ -107,10 +112,17 @@ pnpm dev
|
|
|
107
112
|
pnpm build
|
|
108
113
|
```
|
|
109
114
|
|
|
115
|
+
### Publish
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
pnpm prepare
|
|
119
|
+
pnpm publish
|
|
120
|
+
```
|
|
121
|
+
|
|
110
122
|
### Why I built this?
|
|
111
123
|
|
|
112
124
|
I was building a scrobbles page [https://mannuelferreira.com/scrobbles](https://mannuelferreira.com/scrobbles) and I thought others might want it to.
|
|
113
125
|
|
|
114
126
|
### TODO
|
|
115
127
|
|
|
116
|
-
- move types into [DefinitelyTyped](https://github.com/mannuelf/DefinitelyTyped)
|
|
128
|
+
- move types into [DefinitelyTyped](https://github.com/mannuelf/DefinitelyTyped)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type 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>;
|
|
@@ -7,17 +7,17 @@ exports.auth = void 0;
|
|
|
7
7
|
const createOptions_1 = require("./createOptions");
|
|
8
8
|
const request_1 = __importDefault(require("./request"));
|
|
9
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) {
|
|
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
|
+
async function auth(method, user, period, limit) {
|
|
20
20
|
const options = (0, createOptions_1.createOptions)(method, user, period, limit);
|
|
21
|
-
return (0, request_1.default)(options);
|
|
21
|
+
return await (0, request_1.default)(options);
|
|
22
22
|
}
|
|
23
23
|
exports.auth = auth;
|
|
@@ -0,0 +1,13 @@
|
|
|
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.chartTopArtists = void 0;
|
|
7
|
+
const createOptions_1 = require("../createOptions");
|
|
8
|
+
const request_1 = __importDefault(require("../request"));
|
|
9
|
+
async function chartTopArtists(method, user, period, page, limit) {
|
|
10
|
+
const options = (0, createOptions_1.createOptions)(method, user, period, page, limit);
|
|
11
|
+
return await (0, request_1.default)(options);
|
|
12
|
+
}
|
|
13
|
+
exports.chartTopArtists = chartTopArtists;
|
|
@@ -0,0 +1,13 @@
|
|
|
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.chartTopTags = void 0;
|
|
7
|
+
const createOptions_1 = require("../createOptions");
|
|
8
|
+
const request_1 = __importDefault(require("../request"));
|
|
9
|
+
async function chartTopTags(method, page) {
|
|
10
|
+
const options = (0, createOptions_1.createOptions)(method, page);
|
|
11
|
+
return await (0, request_1.default)(options);
|
|
12
|
+
}
|
|
13
|
+
exports.chartTopTags = chartTopTags;
|
|
@@ -0,0 +1,13 @@
|
|
|
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.chartTopTracks = void 0;
|
|
7
|
+
const createOptions_1 = require("../createOptions");
|
|
8
|
+
const request_1 = __importDefault(require("../request"));
|
|
9
|
+
async function chartTopTracks(method, page) {
|
|
10
|
+
const options = (0, createOptions_1.createOptions)(method, page);
|
|
11
|
+
return await (0, request_1.default)(options);
|
|
12
|
+
}
|
|
13
|
+
exports.chartTopTracks = chartTopTracks;
|
|
@@ -26,7 +26,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.config = void 0;
|
|
27
27
|
const dotenv = __importStar(require("dotenv"));
|
|
28
28
|
dotenv.config();
|
|
29
|
-
;
|
|
30
29
|
/**
|
|
31
30
|
* @description Stores the Last.fm API key, app name, base url, format, shared secret, and username.
|
|
32
31
|
* Simply add a .env file to the root of the project and add the following:
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createOptions = void 0;
|
|
4
|
-
function createOptions(method, user, period, limit) {
|
|
4
|
+
function createOptions(method, user, period, limit, page) {
|
|
5
5
|
return {
|
|
6
6
|
method,
|
|
7
|
+
page,
|
|
7
8
|
user,
|
|
8
9
|
period,
|
|
9
10
|
limit,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UserResponse } from
|
|
1
|
+
import { type UserResponse } from "../@types";
|
|
2
2
|
/**
|
|
3
3
|
* GET: User profile information - LastFM
|
|
4
4
|
*
|
|
@@ -6,4 +6,3 @@ import { UserResponse } from '../@types';
|
|
|
6
6
|
* @returns User profile information
|
|
7
7
|
*/
|
|
8
8
|
export declare function getInfo(method: string, user: string): Promise<UserResponse>;
|
|
9
|
-
//# sourceMappingURL=getInfo.d.ts.map
|
|
@@ -12,8 +12,8 @@ const request_1 = __importDefault(require("./request"));
|
|
|
12
12
|
* https://www.last.fm/api/show/user.getInfo
|
|
13
13
|
* @returns User profile information
|
|
14
14
|
*/
|
|
15
|
-
function getInfo(method, user) {
|
|
15
|
+
async function getInfo(method, user) {
|
|
16
16
|
const options = (0, createOptions_1.createOptions)(method, user);
|
|
17
|
-
return (0, request_1.default)(options);
|
|
17
|
+
return await (0, request_1.default)(options);
|
|
18
18
|
}
|
|
19
19
|
exports.getInfo = getInfo;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LovedTracksResponse } from '../@types';
|
|
1
|
+
import { type LovedTracksResponse } from '../@types';
|
|
2
2
|
/**
|
|
3
3
|
* GET: Love Tracks - LastFM
|
|
4
4
|
*
|
|
@@ -6,4 +6,3 @@ import { LovedTracksResponse } from '../@types';
|
|
|
6
6
|
* @returns Loved Tracks;
|
|
7
7
|
*/
|
|
8
8
|
export declare function getLovedTracks(method: string, user: string, period: string, limit: string): Promise<LovedTracksResponse>;
|
|
9
|
-
//# sourceMappingURL=getLovedTracks.d.ts.map
|
|
@@ -12,8 +12,8 @@ const request_1 = __importDefault(require("./request"));
|
|
|
12
12
|
* https://www.last.fm/api/show/user.getLovedTracks
|
|
13
13
|
* @returns Loved Tracks;
|
|
14
14
|
*/
|
|
15
|
-
function getLovedTracks(method, user, period, limit) {
|
|
15
|
+
async function getLovedTracks(method, user, period, limit) {
|
|
16
16
|
const options = (0, createOptions_1.createOptions)(method, user, period, limit);
|
|
17
|
-
return (0, request_1.default)(options);
|
|
17
|
+
return await (0, request_1.default)(options);
|
|
18
18
|
}
|
|
19
19
|
exports.getLovedTracks = getLovedTracks;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RecentTracksResponse } from '../@types';
|
|
1
|
+
import { type RecentTracksResponse } from '../@types';
|
|
2
2
|
/**
|
|
3
3
|
* GET: Recent Tracks - LastFM
|
|
4
4
|
*
|
|
@@ -6,4 +6,3 @@ import { RecentTracksResponse } from '../@types';
|
|
|
6
6
|
* @returns Recent Tracks
|
|
7
7
|
*/
|
|
8
8
|
export declare function getRecentTracks(method: string, user: string, period: string, limit: string): Promise<RecentTracksResponse>;
|
|
9
|
-
//# sourceMappingURL=getRecentTracks.d.ts.map
|
|
@@ -12,8 +12,8 @@ const request_1 = __importDefault(require("./request"));
|
|
|
12
12
|
* https://www.last.fm/api/show/user.getRecentTracks
|
|
13
13
|
* @returns Recent Tracks
|
|
14
14
|
*/
|
|
15
|
-
function getRecentTracks(method, user, period, limit) {
|
|
15
|
+
async function getRecentTracks(method, user, period, limit) {
|
|
16
16
|
const options = (0, createOptions_1.createOptions)(method, user, period, limit);
|
|
17
|
-
return (0, request_1.default)(options);
|
|
17
|
+
return await (0, request_1.default)(options);
|
|
18
18
|
}
|
|
19
19
|
exports.getRecentTracks = getRecentTracks;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TopAlbumsResponse } from '../@types';
|
|
1
|
+
import { type TopAlbumsResponse } from '../@types';
|
|
2
2
|
/**
|
|
3
3
|
* GET: Top Albums - LastFM
|
|
4
4
|
*
|
|
@@ -6,4 +6,3 @@ import { TopAlbumsResponse } from '../@types';
|
|
|
6
6
|
* @returns Top Albums
|
|
7
7
|
*/
|
|
8
8
|
export declare function getTopAlbums(method: string, user: string, period: string, limit: string): Promise<TopAlbumsResponse>;
|
|
9
|
-
//# sourceMappingURL=getTopAlbums.d.ts.map
|
|
@@ -12,8 +12,8 @@ const request_1 = __importDefault(require("./request"));
|
|
|
12
12
|
* https://www.last.fm/api/show/user.getTopAlbums
|
|
13
13
|
* @returns Top Albums
|
|
14
14
|
*/
|
|
15
|
-
function getTopAlbums(method, user, period, limit) {
|
|
15
|
+
async function getTopAlbums(method, user, period, limit) {
|
|
16
16
|
const options = (0, createOptions_1.createOptions)(method, user, period, limit);
|
|
17
|
-
return (0, request_1.default)(options);
|
|
17
|
+
return await (0, request_1.default)(options);
|
|
18
18
|
}
|
|
19
19
|
exports.getTopAlbums = getTopAlbums;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TopArtistsResponse } from '../@types';
|
|
1
|
+
import { type TopArtistsResponse } from '../@types';
|
|
2
2
|
/**
|
|
3
3
|
* GET: Top Artist - LastFM
|
|
4
4
|
*
|
|
@@ -6,4 +6,3 @@ import { TopArtistsResponse } from '../@types';
|
|
|
6
6
|
* @returns Top Artists
|
|
7
7
|
*/
|
|
8
8
|
export declare function getTopArtists(method: string, user: string, period: string, limit: string): Promise<TopArtistsResponse>;
|
|
9
|
-
//# sourceMappingURL=getTopArtists.d.ts.map
|
|
@@ -12,8 +12,8 @@ const request_1 = __importDefault(require("./request"));
|
|
|
12
12
|
* https://www.last.fm/api/show/user.getTopArtists
|
|
13
13
|
* @returns Top Artists
|
|
14
14
|
*/
|
|
15
|
-
function getTopArtists(method, user, period, limit) {
|
|
15
|
+
async function getTopArtists(method, user, period, limit) {
|
|
16
16
|
const options = (0, createOptions_1.createOptions)(method, user, period, limit);
|
|
17
|
-
return (0, request_1.default)(options);
|
|
17
|
+
return await (0, request_1.default)(options);
|
|
18
18
|
}
|
|
19
19
|
exports.getTopArtists = getTopArtists;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TopTrackResponse } from '../@types';
|
|
1
|
+
import { type TopTrackResponse } from '../@types';
|
|
2
2
|
/**
|
|
3
3
|
* GET: Top Tracks - LastFM
|
|
4
4
|
*
|
|
@@ -6,4 +6,3 @@ import { TopTrackResponse } from '../@types';
|
|
|
6
6
|
* @returns Top Tracks
|
|
7
7
|
*/
|
|
8
8
|
export declare function getTopTracks(method: string, user: string, period: string, limit: string): Promise<TopTrackResponse>;
|
|
9
|
-
//# sourceMappingURL=getTopTracks.d.ts.map
|
|
@@ -12,8 +12,8 @@ const request_1 = __importDefault(require("./request"));
|
|
|
12
12
|
* https://www.last.fm/api/show/user.getTopTracks
|
|
13
13
|
* @returns Top Tracks
|
|
14
14
|
*/
|
|
15
|
-
function getTopTracks(method, user, period, limit) {
|
|
15
|
+
async function getTopTracks(method, user, period, limit) {
|
|
16
16
|
const options = (0, createOptions_1.createOptions)(method, user, period, limit);
|
|
17
|
-
return (0, request_1.default)(options);
|
|
17
|
+
return await (0, request_1.default)(options);
|
|
18
18
|
}
|
|
19
19
|
exports.getTopTracks = getTopTracks;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WeeklyAlbumChartResponse } from '../@types';
|
|
1
|
+
import { type WeeklyAlbumChartResponse } from '../@types';
|
|
2
2
|
/**
|
|
3
3
|
* GET: Weekly album chart - LastFM
|
|
4
4
|
*
|
|
@@ -6,4 +6,3 @@ import { WeeklyAlbumChartResponse } from '../@types';
|
|
|
6
6
|
* @returns Weekly album chart
|
|
7
7
|
*/
|
|
8
8
|
export declare function getWeeklyAlbumChart(method: string, user: string, period: string, limit: string): Promise<WeeklyAlbumChartResponse>;
|
|
9
|
-
//# sourceMappingURL=getWeeklyAlbumChart.d.ts.map
|
|
@@ -12,8 +12,8 @@ const request_1 = __importDefault(require("./request"));
|
|
|
12
12
|
* https://www.last.fm/api/show/user.getWeeklyAlbumChart
|
|
13
13
|
* @returns Weekly album chart
|
|
14
14
|
*/
|
|
15
|
-
function getWeeklyAlbumChart(method, user, period, limit) {
|
|
15
|
+
async function getWeeklyAlbumChart(method, user, period, limit) {
|
|
16
16
|
const options = (0, createOptions_1.createOptions)(method, user, period, limit);
|
|
17
|
-
return (0, request_1.default)(options);
|
|
17
|
+
return await (0, request_1.default)(options);
|
|
18
18
|
}
|
|
19
19
|
exports.getWeeklyAlbumChart = getWeeklyAlbumChart;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WeeklyArtistChartResponse } from '../@types';
|
|
1
|
+
import { type WeeklyArtistChartResponse } from '../@types';
|
|
2
2
|
/**
|
|
3
3
|
* GET: Weekly artist chart - LastFM
|
|
4
4
|
*
|
|
@@ -6,4 +6,3 @@ import { WeeklyArtistChartResponse } from '../@types';
|
|
|
6
6
|
* @returns Weekly artist chart
|
|
7
7
|
*/
|
|
8
8
|
export declare function getWeeklyArtistChart(method: string, user: string, period: string, limit: string): Promise<WeeklyArtistChartResponse>;
|
|
9
|
-
//# sourceMappingURL=getWeeklyArtistChart.d.ts.map
|
|
@@ -12,8 +12,8 @@ const request_1 = __importDefault(require("./request"));
|
|
|
12
12
|
* https://www.last.fm/api/show/user.getWeeklyArtistChart
|
|
13
13
|
* @returns Weekly artist chart
|
|
14
14
|
*/
|
|
15
|
-
function getWeeklyArtistChart(method, user, period, limit) {
|
|
15
|
+
async function getWeeklyArtistChart(method, user, period, limit) {
|
|
16
16
|
const options = (0, createOptions_1.createOptions)(method, user, period, limit);
|
|
17
|
-
return (0, request_1.default)(options);
|
|
17
|
+
return await (0, request_1.default)(options);
|
|
18
18
|
}
|
|
19
19
|
exports.getWeeklyArtistChart = getWeeklyArtistChart;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WeeklyChartListResponse } from '../@types';
|
|
1
|
+
import { type WeeklyChartListResponse } from '../@types';
|
|
2
2
|
/**
|
|
3
3
|
* GET: Weekly chart list - LastFM
|
|
4
4
|
*
|
|
@@ -6,4 +6,3 @@ import { WeeklyChartListResponse } from '../@types';
|
|
|
6
6
|
* @returns Weekly chart list
|
|
7
7
|
*/
|
|
8
8
|
export declare function getWeeklyChartList(method: string, user: string, period: string, limit: string): Promise<WeeklyChartListResponse>;
|
|
9
|
-
//# sourceMappingURL=getWeeklyChartList.d.ts.map
|
|
@@ -12,8 +12,8 @@ const request_1 = __importDefault(require("./request"));
|
|
|
12
12
|
* https://www.last.fm/api/show/user.getWeeklyChartList
|
|
13
13
|
* @returns Weekly chart list
|
|
14
14
|
*/
|
|
15
|
-
function getWeeklyChartList(method, user, period, limit) {
|
|
15
|
+
async function getWeeklyChartList(method, user, period, limit) {
|
|
16
16
|
const options = (0, createOptions_1.createOptions)(method, user, period, limit);
|
|
17
|
-
return (0, request_1.default)(options);
|
|
17
|
+
return await (0, request_1.default)(options);
|
|
18
18
|
}
|
|
19
19
|
exports.getWeeklyChartList = getWeeklyChartList;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WeeklyTrackChartResponse } from '../@types';
|
|
1
|
+
import { type WeeklyTrackChartResponse } from '../@types';
|
|
2
2
|
/**
|
|
3
3
|
* GET: Weekly track chart - LastFM
|
|
4
4
|
*
|
|
@@ -6,4 +6,3 @@ import { WeeklyTrackChartResponse } from '../@types';
|
|
|
6
6
|
* @returns Weekly track chart
|
|
7
7
|
*/
|
|
8
8
|
export declare function getWeeklyTrackChart(method: string, user: string, period: string, limit: string): Promise<WeeklyTrackChartResponse>;
|
|
9
|
-
//# sourceMappingURL=getWeeklyTrackChart.d.ts.map
|
|
@@ -12,8 +12,8 @@ const request_1 = __importDefault(require("./request"));
|
|
|
12
12
|
* https://www.last.fm/api/show/user.getWeeklyTrackChart
|
|
13
13
|
* @returns Weekly track chart
|
|
14
14
|
*/
|
|
15
|
-
function getWeeklyTrackChart(method, user, period, limit) {
|
|
15
|
+
async function getWeeklyTrackChart(method, user, period, limit) {
|
|
16
16
|
const options = (0, createOptions_1.createOptions)(method, user, period, limit);
|
|
17
|
-
return (0, request_1.default)(options);
|
|
17
|
+
return await (0, request_1.default)(options);
|
|
18
18
|
}
|
|
19
19
|
exports.getWeeklyTrackChart = getWeeklyTrackChart;
|
|
@@ -9,8 +9,16 @@ import { getWeeklyAlbumChart } from './getWeeklyAlbumChart';
|
|
|
9
9
|
import { getWeeklyArtistChart } from './getWeeklyArtistChart';
|
|
10
10
|
import { getWeeklyChartList } from './getWeeklyChartList';
|
|
11
11
|
import { getWeeklyTrackChart } from './getWeeklyTrackChart';
|
|
12
|
-
|
|
12
|
+
import { chartTopTags } from './chart/topTags';
|
|
13
|
+
import { chartTopTracks } from './chart/topTracks';
|
|
14
|
+
import { chartTopArtists } from './chart/topArtists';
|
|
15
|
+
export default function LastFmApi(): {
|
|
13
16
|
auth: typeof auth;
|
|
17
|
+
chart: {
|
|
18
|
+
chartTopArtists: typeof chartTopArtists;
|
|
19
|
+
chartTopTracks: typeof chartTopTracks;
|
|
20
|
+
chartTopTags: typeof chartTopTags;
|
|
21
|
+
};
|
|
14
22
|
config: {
|
|
15
23
|
api_key: string;
|
|
16
24
|
app_name: string;
|
|
@@ -34,6 +42,11 @@ declare const LastFmApi: () => {
|
|
|
34
42
|
getWeeklyTrackChart: typeof getWeeklyTrackChart;
|
|
35
43
|
method: {
|
|
36
44
|
auth: string;
|
|
45
|
+
chart: {
|
|
46
|
+
getTopTracks: string;
|
|
47
|
+
getTopTags: string;
|
|
48
|
+
getTopArtists: string;
|
|
49
|
+
};
|
|
37
50
|
user: {
|
|
38
51
|
getInfo: string;
|
|
39
52
|
getLovedTracks: string;
|
|
@@ -48,5 +61,3 @@ declare const LastFmApi: () => {
|
|
|
48
61
|
};
|
|
49
62
|
};
|
|
50
63
|
};
|
|
51
|
-
export default LastFmApi;
|
|
52
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
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 topTags_1 = require("./chart/topTags");
|
|
17
|
+
const topTracks_1 = require("./chart/topTracks");
|
|
18
|
+
const topArtists_1 = require("./chart/topArtists");
|
|
19
|
+
function LastFmApi() {
|
|
20
|
+
return {
|
|
21
|
+
auth: auth_1.auth,
|
|
22
|
+
chart: {
|
|
23
|
+
chartTopArtists: topArtists_1.chartTopArtists,
|
|
24
|
+
chartTopTracks: topTracks_1.chartTopTracks,
|
|
25
|
+
chartTopTags: topTags_1.chartTopTags,
|
|
26
|
+
},
|
|
27
|
+
config: config_1.config,
|
|
28
|
+
getInfo: getInfo_1.getInfo,
|
|
29
|
+
getLovedTracks: getLovedTracks_1.getLovedTracks,
|
|
30
|
+
getRecentTracks: getRecentTracks_1.getRecentTracks,
|
|
31
|
+
getTopAlbums: getTopAlbums_1.getTopAlbums,
|
|
32
|
+
getTopArtists: getTopArtists_1.getTopArtists,
|
|
33
|
+
getTopTracks: getTopTracks_1.getTopTracks,
|
|
34
|
+
getWeeklyAlbumChart: getWeeklyAlbumChart_1.getWeeklyAlbumChart,
|
|
35
|
+
getWeeklyArtistChart: getWeeklyArtistChart_1.getWeeklyArtistChart,
|
|
36
|
+
getWeeklyChartList: getWeeklyChartList_1.getWeeklyChartList,
|
|
37
|
+
getWeeklyTrackChart: getWeeklyTrackChart_1.getWeeklyTrackChart,
|
|
38
|
+
method: method_1.method,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
exports.default = LastFmApi;
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
interface ChartMethod {
|
|
2
|
+
getTopArtists: string;
|
|
3
|
+
getTopTags: string;
|
|
4
|
+
getTopTracks: string;
|
|
5
|
+
}
|
|
1
6
|
interface UserMethod {
|
|
2
7
|
getInfo: string;
|
|
3
8
|
getLovedTracks: string;
|
|
@@ -12,10 +17,16 @@ interface UserMethod {
|
|
|
12
17
|
}
|
|
13
18
|
export interface Method {
|
|
14
19
|
auth: string;
|
|
20
|
+
chart: ChartMethod;
|
|
15
21
|
user: UserMethod;
|
|
16
22
|
}
|
|
17
23
|
export declare const method: {
|
|
18
24
|
auth: string;
|
|
25
|
+
chart: {
|
|
26
|
+
getTopTracks: string;
|
|
27
|
+
getTopTags: string;
|
|
28
|
+
getTopArtists: string;
|
|
29
|
+
};
|
|
19
30
|
user: {
|
|
20
31
|
getInfo: string;
|
|
21
32
|
getLovedTracks: string;
|
|
@@ -30,4 +41,3 @@ export declare const method: {
|
|
|
30
41
|
};
|
|
31
42
|
};
|
|
32
43
|
export {};
|
|
33
|
-
//# sourceMappingURL=method.d.ts.map
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.method = void 0;
|
|
4
|
-
;
|
|
5
|
-
;
|
|
6
4
|
exports.method = {
|
|
7
5
|
auth: 'auth.getToken',
|
|
6
|
+
chart: {
|
|
7
|
+
getTopTracks: 'chart.getTopTracks',
|
|
8
|
+
getTopTags: 'chart.getTopTags',
|
|
9
|
+
getTopArtists: 'chart.getTopArtists',
|
|
10
|
+
},
|
|
8
11
|
user: {
|
|
9
12
|
getInfo: 'user.getInfo',
|
|
10
13
|
getLovedTracks: 'user.getLovedTracks',
|
|
@@ -1,13 +1,4 @@
|
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -44,20 +35,20 @@ const buildUrl = (options) => {
|
|
|
44
35
|
params.append('format', config_1.config.format.json);
|
|
45
36
|
return `${config_1.config.base_url}?${params.toString()}`;
|
|
46
37
|
};
|
|
47
|
-
const request = (options) =>
|
|
38
|
+
const request = async (options) => {
|
|
48
39
|
const url = buildUrl(options);
|
|
49
|
-
return (
|
|
40
|
+
return (await (0, cross_fetch_1.default)(url, {
|
|
50
41
|
headers: {
|
|
51
42
|
'Content-Type': 'application/json',
|
|
52
43
|
},
|
|
53
44
|
})
|
|
54
|
-
.then((res) => {
|
|
45
|
+
.then(async (res) => {
|
|
55
46
|
if (!res.ok) {
|
|
56
47
|
throw new Error(res.statusText);
|
|
57
48
|
}
|
|
58
49
|
switch (res.status) {
|
|
59
50
|
case 200: {
|
|
60
|
-
return res.json();
|
|
51
|
+
return await res.json();
|
|
61
52
|
}
|
|
62
53
|
case 400: {
|
|
63
54
|
throw new Error('Bad request');
|
|
@@ -126,7 +117,8 @@ const request = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
126
117
|
})
|
|
127
118
|
.then((json) => json)
|
|
128
119
|
.catch((error) => {
|
|
129
|
-
|
|
120
|
+
// eslint-disable-next-line no-console
|
|
121
|
+
console.error('🚨 error:', error);
|
|
130
122
|
}));
|
|
131
|
-
}
|
|
123
|
+
};
|
|
132
124
|
exports.default = request;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type 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>;
|
package/dist/mjs/auth.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createOptions } from "./createOptions";
|
|
2
|
+
import request from "./request";
|
|
3
|
+
/**
|
|
4
|
+
* POST: Auth - LastFM
|
|
5
|
+
*
|
|
6
|
+
* https://www.last.fm/api/show/auth.getToken
|
|
7
|
+
*
|
|
8
|
+
* Authentication tokens are API account specific.
|
|
9
|
+
* They are valid for 60 minutes from the moment they are granted.
|
|
10
|
+
* Can only used once (they are consumed when a session is created).
|
|
11
|
+
* @returns Auth token
|
|
12
|
+
*/
|
|
13
|
+
export async function auth(method, user, period, limit) {
|
|
14
|
+
const options = createOptions(method, user, period, limit);
|
|
15
|
+
return await request(options);
|
|
16
|
+
}
|