lastfm-nodejs-client 1.0.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 ADDED
@@ -0,0 +1,4 @@
1
+ LASTFM_API_BASE_URL=""
2
+ LASTFM_API_KEY=""
3
+ LASTFM_APPNAME=""
4
+ LASTFM_USER=""
package/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ # 1.0.0
2
+
3
+ - Initial project setup
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Mannuel Ferreira
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,84 @@
1
+ # LastFm NodeJs client
2
+
3
+ A Node JS wrapper client for fetching public data from [LastFm API](https://www.last.fm/api).
4
+
5
+ ## How to use the client
6
+
7
+ Install the npm package in your project.
8
+
9
+ ```bash
10
+ pnpm install
11
+ ```
12
+
13
+ Consider [PNPM](https://pnpm.io/) ▶️
14
+
15
+ ### Import it
16
+
17
+ ```js
18
+ import { lastFm } from 'lastfm-nodejs-client';
19
+ ```
20
+
21
+ ### Use it
22
+
23
+ ```js
24
+ const getUser = async () => {
25
+ const data = await lastFm.getInfo(
26
+ config.method.user.getInfo,
27
+ config.username,
28
+ 'overall',
29
+ 12
30
+ );
31
+ const { user } = data;
32
+ return user;
33
+ };
34
+
35
+ const user = getUser();
36
+
37
+ console.log(user.name);
38
+ ```
39
+
40
+ ## Developing client
41
+
42
+ Written in TypeScript and compiles down to ES2015.
43
+
44
+ ### Postman collections
45
+
46
+ A list of endpoints currently mapped to this client. Still under development, not feature complete.
47
+
48
+ [View collections](https://documenter.getpostman.com/view/4217/2s8YKJELqJ) ▶️
49
+
50
+ Clone repo
51
+
52
+ ```bash
53
+ git clone git@github.com:mannuelf/lastfm-nodejs-client.git
54
+ ```
55
+
56
+ create `.env` file in project root.
57
+ Requirements for environment are:
58
+
59
+ ```bash
60
+ LASTFM_API_BASE_URL=""
61
+ LASTFM_API_KEY=""
62
+ LASTFM_APPNAME=""
63
+ LASTFM_USER=""
64
+ ```
65
+
66
+ Get it [here](https://www.last.fm/api/account/create)
67
+
68
+ Develop
69
+
70
+ ```bash
71
+ pnpm dev
72
+ ```
73
+
74
+ Build
75
+
76
+ ```bash
77
+ pnpm build
78
+ ```
79
+
80
+ ## Testing code
81
+
82
+ ```bash
83
+ pnpm test
84
+ ```
package/dist/config.js ADDED
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const config = {
4
+ api_key: `${process.env.LASTFM_API_KEY}`,
5
+ app_name: `${process.env.LASTFM_APPNAME}`,
6
+ base_url: `${process.env.LASTFM_API_BASE_URL}`,
7
+ format: {
8
+ json: 'json',
9
+ xml: 'xml',
10
+ },
11
+ method: {
12
+ auth: 'auth.getToken',
13
+ user: {
14
+ getInfo: 'user.getInfo',
15
+ loved_tracks: 'user.getLovedTracks',
16
+ recent_tracks: 'user.getRecentTracks',
17
+ top_albums: 'user.getTopAlbums',
18
+ top_artists: 'user.getTopArtists',
19
+ top_tracks: 'user.getTopTracks',
20
+ weekly_album_chart: 'user.getWeeklyAlbumChart',
21
+ weekly_artist_chart: 'user.getWeeklyArtistChart',
22
+ weekly_chart_list: 'user.getWeeklyChartList',
23
+ weekly_track_chart: 'user.getWeeklyTrackChart',
24
+ },
25
+ },
26
+ share_secret: `${process.env.LASTFM_SHARED_SECRET}`,
27
+ username: `${process.env.LASTFM_USER}`,
28
+ };
29
+ exports.default = config;
package/dist/index.js ADDED
@@ -0,0 +1,125 @@
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
+ const request_1 = __importDefault(require("./request"));
7
+ const LastFmApi = function LastFmApi() {
8
+ /**
9
+ * POST: Auth - LastFM
10
+ *
11
+ * https://www.last.fm/api/show/auth.getToken
12
+ *
13
+ * Authentication tokens are API account specific.
14
+ * They are valid for 60 minutes from the moment they are granted.
15
+ * Can only used once (they are consumed when a session is created).
16
+ * @returns Auth token
17
+ */
18
+ const auth = (method, user, period, limit) => {
19
+ return (0, request_1.default)(method, user, period, limit);
20
+ };
21
+ /**
22
+ * GET: User profile information - LastFM
23
+ *
24
+ * https://www.last.fm/api/show/user.getInfo
25
+ * @returns User profile data
26
+ */
27
+ const getInfo = (method, user, period, limit) => {
28
+ return (0, request_1.default)(method, user, period, limit);
29
+ };
30
+ /**
31
+ * GET: Love Tracks - LastFM
32
+ *
33
+ * https://www.last.fm/api/show/user.getLovedTracks
34
+ * @returns Loved Tracks;
35
+ */
36
+ const getLovedTracks = (method, user, period, limit) => {
37
+ return (0, request_1.default)(method, user, period, limit);
38
+ };
39
+ /**
40
+ * GET: Recent Tracks - LastFM
41
+ *
42
+ * https://www.last.fm/api/show/user.getRecentTracks
43
+ * @returns Recent Tracks
44
+ */
45
+ const getRecentTracks = (method, user, period, limit) => {
46
+ return (0, request_1.default)(method, user, period, limit);
47
+ };
48
+ /**
49
+ * GET: Top Albums - LastFM
50
+ *
51
+ * https://www.last.fm/api/show/user.getTopAlbums
52
+ * @returns Top Albums
53
+ */
54
+ const getTopAlbums = (method, user, period, limit) => {
55
+ return (0, request_1.default)(method, user, period, limit);
56
+ };
57
+ /**
58
+ * GET: Top Artist - LastFM
59
+ *
60
+ * https://www.last.fm/api/show/user.getTopArtists
61
+ * @returns Top Artists
62
+ */
63
+ const getTopArtists = (method, user, period, limit) => {
64
+ return (0, request_1.default)(method, user, period, limit);
65
+ };
66
+ /**
67
+ * GET: Top Tracks - LastFM
68
+ *
69
+ * https://www.last.fm/api/show/user.getTopTracks
70
+ * @returns Top Tracks
71
+ */
72
+ const getTopTracks = (method, user, period, limit) => {
73
+ return (0, request_1.default)(method, user, period, limit);
74
+ };
75
+ /**
76
+ * GET: Weekly album chart - LastFM
77
+ *
78
+ * https://www.last.fm/api/show/user.getWeeklyAlbumChart
79
+ * @returns Weekly album chart
80
+ */
81
+ const getWeeklyAlbumChart = (method, user, period, limit) => {
82
+ return (0, request_1.default)(method, user, period, limit);
83
+ };
84
+ /**
85
+ * GET: Weekly artist chart - LastFM
86
+ *
87
+ * https://www.last.fm/api/show/user.getWeeklyArtistChart
88
+ * @returns Weekly artist chart
89
+ */
90
+ const getWeeklyArtistChart = (method, user, period, limit) => {
91
+ return (0, request_1.default)(method, user, period, limit);
92
+ };
93
+ /**
94
+ * GET: Weekly chart list - LastFM
95
+ *
96
+ * https://www.last.fm/api/show/user.getWeeklyChartList
97
+ * @returns Weekly chart list
98
+ */
99
+ const getWeeklyChartList = (method, user, period, limit) => {
100
+ return (0, request_1.default)(method, user, period, limit);
101
+ };
102
+ /**
103
+ * GET: Weekly track chart - LastFM
104
+ *
105
+ * https://www.last.fm/api/show/user.getWeeklyTrackChart
106
+ * @returns Weekly track chart
107
+ */
108
+ const getWeeklyTrackChart = (method, user, period, limit) => {
109
+ return (0, request_1.default)(method, user, period, limit);
110
+ };
111
+ return {
112
+ auth,
113
+ getInfo,
114
+ getLovedTracks,
115
+ getRecentTracks,
116
+ getTopAlbums,
117
+ getTopArtists,
118
+ getTopTracks,
119
+ getWeeklyAlbumChart,
120
+ getWeeklyArtistChart,
121
+ getWeeklyChartList,
122
+ getWeeklyTrackChart,
123
+ };
124
+ };
125
+ exports.default = LastFmApi;
@@ -0,0 +1,29 @@
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 node_fetch_1 = __importDefault(require("node-fetch"));
16
+ const config_1 = __importDefault(require("./config"));
17
+ const request = (method, user, period, limit) => __awaiter(void 0, void 0, void 0, function* () {
18
+ const url = `
19
+ ${config_1.default.base_url}?method=${method}${user ? '&user=' : ''}${user}${user ? '&user=' : ''}${user}${period ? '&period=' : ''}${period}&${limit ? '&limit=' : ''}${limit}&api_key=${config_1.default.api_key}&format=${config_1.default.format.json}`;
20
+ return (yield (0, node_fetch_1.default)(url, {
21
+ headers: {
22
+ 'Content-Type': 'application/json',
23
+ },
24
+ })
25
+ .then((res) => res.json())
26
+ .then((json) => json)
27
+ .catch((error) => console.log('🔥 Uh oh...', error)));
28
+ });
29
+ exports.default = request;
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "lastfm-nodejs-client",
3
+ "version": "1.0.0",
4
+ "description": "A client for fetching public data with username using the LastFm public API",
5
+ "main": "./dist/index.js",
6
+ "scripts": {
7
+ "build": "rimraf dist && tsc",
8
+ "dev": "tsc --watch",
9
+ "test": "echo \"Error: no test specified\" && exit 1"
10
+ },
11
+ "keywords": [
12
+ "client",
13
+ "lastfm",
14
+ "nodejs",
15
+ "typescript"
16
+ ],
17
+ "author": "Mannuel Ferreira",
18
+ "license": "MIT",
19
+ "dependencies": {
20
+ "node-fetch": "^3.2.10",
21
+ "rimraf": "^3.0.2"
22
+ },
23
+ "devDependencies": {
24
+ "@types/node": "^18.11.7",
25
+ "typescript": "^4.8.4"
26
+ },
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/mannuelf/lastfm-nodejs-client.git"
30
+ },
31
+ "bugs": {
32
+ "url": "https://github.com/mannuelf/lastfm-nodejs-client/issues"
33
+ },
34
+ "homepage": "https://github.com/mannuelf/lastfm-nodejs-client#readme"
35
+ }
package/src/config.ts ADDED
@@ -0,0 +1,28 @@
1
+ const config = {
2
+ api_key: `${process.env.LASTFM_API_KEY}`,
3
+ app_name: `${process.env.LASTFM_APPNAME}`,
4
+ base_url: `${process.env.LASTFM_API_BASE_URL}`,
5
+ format: {
6
+ json: 'json',
7
+ xml: 'xml',
8
+ },
9
+ method: {
10
+ auth: 'auth.getToken',
11
+ user: {
12
+ getInfo: 'user.getInfo',
13
+ loved_tracks: 'user.getLovedTracks',
14
+ recent_tracks: 'user.getRecentTracks',
15
+ top_albums: 'user.getTopAlbums',
16
+ top_artists: 'user.getTopArtists',
17
+ top_tracks: 'user.getTopTracks',
18
+ weekly_album_chart: 'user.getWeeklyAlbumChart',
19
+ weekly_artist_chart: 'user.getWeeklyArtistChart',
20
+ weekly_chart_list: 'user.getWeeklyChartList',
21
+ weekly_track_chart: 'user.getWeeklyTrackChart',
22
+ },
23
+ },
24
+ share_secret: `${process.env.LASTFM_SHARED_SECRET}`,
25
+ username: `${process.env.LASTFM_USER}`,
26
+ };
27
+
28
+ export default config;
package/src/index.ts ADDED
@@ -0,0 +1,201 @@
1
+ import {
2
+ AuthResponse,
3
+ LovedTracksResponse,
4
+ RecentTracksResponse,
5
+ TopAlbumsResponse,
6
+ TopArtistsResponse,
7
+ TopTrackResponse,
8
+ UserResponse,
9
+ WeeklyAlbumChartResponse,
10
+ WeeklyArtistChartResponse,
11
+ WeeklyChartListResponse,
12
+ WeeklyTrackChartResponse,
13
+ } from './types';
14
+ import request from './request';
15
+
16
+ const LastFmApi = function LastFmApi() {
17
+ /**
18
+ * POST: Auth - LastFM
19
+ *
20
+ * https://www.last.fm/api/show/auth.getToken
21
+ *
22
+ * Authentication tokens are API account specific.
23
+ * They are valid for 60 minutes from the moment they are granted.
24
+ * Can only used once (they are consumed when a session is created).
25
+ * @returns Auth token
26
+ */
27
+ const auth = (
28
+ method: string,
29
+ user: string,
30
+ period: string,
31
+ limit: number
32
+ ): Promise<AuthResponse> => {
33
+ return request(method, user, period, limit);
34
+ };
35
+
36
+ /**
37
+ * GET: User profile information - LastFM
38
+ *
39
+ * https://www.last.fm/api/show/user.getInfo
40
+ * @returns User profile data
41
+ */
42
+ const getInfo = (
43
+ method: string,
44
+ user: string,
45
+ period: string,
46
+ limit: number
47
+ ): Promise<UserResponse> => {
48
+ return request(method, user, period, limit);
49
+ };
50
+
51
+ /**
52
+ * GET: Love Tracks - LastFM
53
+ *
54
+ * https://www.last.fm/api/show/user.getLovedTracks
55
+ * @returns Loved Tracks;
56
+ */
57
+ const getLovedTracks = (
58
+ method: string,
59
+ user: string,
60
+ period: string,
61
+ limit: number
62
+ ): Promise<LovedTracksResponse> => {
63
+ return request(method, user, period, limit);
64
+ };
65
+
66
+ /**
67
+ * GET: Recent Tracks - LastFM
68
+ *
69
+ * https://www.last.fm/api/show/user.getRecentTracks
70
+ * @returns Recent Tracks
71
+ */
72
+ const getRecentTracks = (
73
+ method: string,
74
+ user: string,
75
+ period: string,
76
+ limit: number
77
+ ): Promise<RecentTracksResponse> => {
78
+ return request(method, user, period, limit);
79
+ };
80
+
81
+ /**
82
+ * GET: Top Albums - LastFM
83
+ *
84
+ * https://www.last.fm/api/show/user.getTopAlbums
85
+ * @returns Top Albums
86
+ */
87
+ const getTopAlbums = (
88
+ method: string,
89
+ user: string,
90
+ period: string,
91
+ limit: number
92
+ ): Promise<TopAlbumsResponse> => {
93
+ return request(method, user, period, limit);
94
+ };
95
+
96
+ /**
97
+ * GET: Top Artist - LastFM
98
+ *
99
+ * https://www.last.fm/api/show/user.getTopArtists
100
+ * @returns Top Artists
101
+ */
102
+ const getTopArtists = (
103
+ method: string,
104
+ user: string,
105
+ period: string,
106
+ limit: number
107
+ ): Promise<TopArtistsResponse> => {
108
+ return request(method, user, period, limit);
109
+ };
110
+
111
+ /**
112
+ * GET: Top Tracks - LastFM
113
+ *
114
+ * https://www.last.fm/api/show/user.getTopTracks
115
+ * @returns Top Tracks
116
+ */
117
+ const getTopTracks = (
118
+ method: string,
119
+ user: string,
120
+ period: string,
121
+ limit: number
122
+ ): Promise<TopTrackResponse> => {
123
+ return request(method, user, period, limit);
124
+ };
125
+
126
+ /**
127
+ * GET: Weekly album chart - LastFM
128
+ *
129
+ * https://www.last.fm/api/show/user.getWeeklyAlbumChart
130
+ * @returns Weekly album chart
131
+ */
132
+ const getWeeklyAlbumChart = (
133
+ method: string,
134
+ user: string,
135
+ period: string,
136
+ limit: number
137
+ ): Promise<WeeklyAlbumChartResponse> => {
138
+ return request(method, user, period, limit);
139
+ };
140
+
141
+ /**
142
+ * GET: Weekly artist chart - LastFM
143
+ *
144
+ * https://www.last.fm/api/show/user.getWeeklyArtistChart
145
+ * @returns Weekly artist chart
146
+ */
147
+ const getWeeklyArtistChart = (
148
+ method: string,
149
+ user: string,
150
+ period: string,
151
+ limit: number
152
+ ): Promise<WeeklyArtistChartResponse> => {
153
+ return request(method, user, period, limit);
154
+ };
155
+
156
+ /**
157
+ * GET: Weekly chart list - LastFM
158
+ *
159
+ * https://www.last.fm/api/show/user.getWeeklyChartList
160
+ * @returns Weekly chart list
161
+ */
162
+ const getWeeklyChartList = (
163
+ method: string,
164
+ user: string,
165
+ period: string,
166
+ limit: number
167
+ ): Promise<WeeklyChartListResponse> => {
168
+ return request(method, user, period, limit);
169
+ };
170
+
171
+ /**
172
+ * GET: Weekly track chart - LastFM
173
+ *
174
+ * https://www.last.fm/api/show/user.getWeeklyTrackChart
175
+ * @returns Weekly track chart
176
+ */
177
+ const getWeeklyTrackChart = (
178
+ method: string,
179
+ user: string,
180
+ period: string,
181
+ limit: number
182
+ ): Promise<WeeklyTrackChartResponse> => {
183
+ return request(method, user, period, limit);
184
+ };
185
+
186
+ return {
187
+ auth,
188
+ getInfo,
189
+ getLovedTracks,
190
+ getRecentTracks,
191
+ getTopAlbums,
192
+ getTopArtists,
193
+ getTopTracks,
194
+ getWeeklyAlbumChart,
195
+ getWeeklyArtistChart,
196
+ getWeeklyChartList,
197
+ getWeeklyTrackChart,
198
+ };
199
+ };
200
+
201
+ export default LastFmApi;
package/src/request.ts ADDED
@@ -0,0 +1,27 @@
1
+ import fetch from 'node-fetch';
2
+ import config from './config';
3
+
4
+ const request = async <Parameters, Response>(
5
+ method: string,
6
+ user: string,
7
+ period?: string,
8
+ limit?: number
9
+ ): Promise<Response> => {
10
+ const url = `
11
+ ${config.base_url}?method=${method}${user ? '&user=' : ''}${user}${
12
+ user ? '&user=' : ''
13
+ }${user}${period ? '&period=' : ''}${period}&${
14
+ limit ? '&limit=' : ''
15
+ }${limit}&api_key=${config.api_key}&format=${config.format.json}`;
16
+
17
+ return (await fetch(url, {
18
+ headers: {
19
+ 'Content-Type': 'application/json',
20
+ },
21
+ })
22
+ .then((res) => res.json())
23
+ .then((json) => json)
24
+ .catch((error) => console.log('🔥 Uh oh...', error))) as Response;
25
+ };
26
+
27
+ export default request;
package/src/types.d.ts ADDED
@@ -0,0 +1,295 @@
1
+ export interface AuthResponse {
2
+ token: string;
3
+ }
4
+
5
+ export interface LovedTracksResponse {
6
+ lovedtracks: LovedTracks;
7
+ }
8
+
9
+ export interface LovedTracks {
10
+ track: Track[];
11
+ '@attr': Attr;
12
+ }
13
+ export interface TopAlbumsResponse {
14
+ topalbums: TopAlbums;
15
+ }
16
+
17
+ export interface TopTrackResponse {
18
+ toptracks: TopTracks;
19
+ }
20
+
21
+ export interface TopTracks {
22
+ track: Track[];
23
+ '@attr': Attr2;
24
+ }
25
+
26
+ export interface UserResponse {
27
+ user: User;
28
+ }
29
+
30
+ export interface RecentTracksResponse {
31
+ recenttracks: RecentTracks;
32
+ }
33
+
34
+ export interface RecentTracks {
35
+ track: Track[];
36
+ '@attr': Attr2;
37
+ }
38
+
39
+ export interface LoveTracksResponse {
40
+ lovedtracks: LovedTracks;
41
+ }
42
+
43
+ export interface LovedTracks {
44
+ track: Track[];
45
+ '@attr': Attr;
46
+ }
47
+ export interface FriendsResponse {
48
+ friends: Friends;
49
+ }
50
+
51
+ export interface Friends {
52
+ '@attr': Attr;
53
+ user: User[];
54
+ }
55
+
56
+ export interface TopArtistsResponse {
57
+ topartists: TopArtists;
58
+ }
59
+
60
+ export interface TopArtists {
61
+ artist: Artist[];
62
+ '@attr': Attr2;
63
+ }
64
+
65
+ export interface WeeklyArtistChartResponse {
66
+ weeklyartistchart: WeeklyArtistChart;
67
+ }
68
+
69
+ export interface WeeklyArtistChart {
70
+ artist: Artist[];
71
+ '@attr': Attr2;
72
+ }
73
+
74
+ export interface WeeklyAlbumChartResponse {
75
+ weeklyalbumchart: WeeklyAlbumChart;
76
+ }
77
+
78
+ export interface WeeklyAlbumChart {
79
+ album: WeeklyAlbum[];
80
+ '@attr': WeeklyalbumChartAttr;
81
+ }
82
+
83
+ export type WeeklyAlbum = {
84
+ artist: {
85
+ mbid: string;
86
+ '#text': string;
87
+ };
88
+ mbid: string;
89
+ url: string;
90
+ name: string;
91
+ '@attr': { rank: string };
92
+ playcount: string;
93
+ image?: string;
94
+ };
95
+
96
+ export interface WeeklyalbumChartAttr {
97
+ from: string;
98
+ to: string;
99
+ user: string;
100
+ }
101
+
102
+ export interface AlbumAttr {
103
+ rank: string;
104
+ }
105
+
106
+ export type Artist = {
107
+ '@attr': {
108
+ rank: number;
109
+ };
110
+ cover: ArtistImage;
111
+ image?: string;
112
+ mbid: string;
113
+ name: string;
114
+ playcount: number;
115
+ streamable: number;
116
+ url: string;
117
+ '#text': string;
118
+ };
119
+
120
+ export interface Attribs {
121
+ page: number;
122
+ perPage: number;
123
+ user: string;
124
+ total: number;
125
+ totalPages: number;
126
+ }
127
+
128
+ export interface ArtistImage {
129
+ name: string;
130
+ photo: string;
131
+ attribution: string;
132
+ playcount: number;
133
+ }
134
+
135
+ export interface Album {
136
+ mbid: string;
137
+ '#text': string;
138
+ }
139
+
140
+ export interface Attr {
141
+ nowplaying: string;
142
+ }
143
+
144
+ export interface Date {
145
+ uts: string;
146
+ '#text': string;
147
+ }
148
+
149
+ export interface Track {
150
+ artist: Artist;
151
+ streamable: string;
152
+ image: '';
153
+ mbid: string;
154
+ album: Album;
155
+ name: string;
156
+ '@attr': Attr;
157
+ url: string;
158
+ date: Date;
159
+ }
160
+
161
+ export interface Attr2 {
162
+ user: string;
163
+ totalPages: string;
164
+ page: string;
165
+ perPage: string;
166
+ total: string;
167
+ }
168
+
169
+ export interface RecentTracks {
170
+ track: Track[];
171
+ '@attr': Attr2;
172
+ }
173
+
174
+ export interface Image {
175
+ size: string;
176
+ '#text': string;
177
+ }
178
+
179
+ export interface Registered {
180
+ unixtime: string;
181
+ '#text': number;
182
+ }
183
+
184
+ export interface User {
185
+ name: string;
186
+ age: string;
187
+ subscriber: string;
188
+ realname: string;
189
+ bootstrap: string;
190
+ playcount: string;
191
+ artist_count: string;
192
+ playlists: string;
193
+ track_count: string;
194
+ album_count: string;
195
+ image: Image[];
196
+ registered: Registered;
197
+ country: string;
198
+ gender: string;
199
+ url: string;
200
+ type: string;
201
+ }
202
+
203
+ export interface TopAlbums {
204
+ album: Album[];
205
+ '@attr': Attr2;
206
+ }
207
+
208
+ export interface WeeklyArtistChartResponse {
209
+ weeklyartistchart: WeeklyArtistChart;
210
+ }
211
+
212
+ export interface WeeklyArtistChart {
213
+ artist: Artist[];
214
+ '@attr': Attr2;
215
+ }
216
+
217
+ export interface Attr1 {
218
+ rank: string;
219
+ }
220
+
221
+ export interface Attr2 {
222
+ from: string;
223
+ user: string;
224
+ to: string;
225
+ }
226
+
227
+ export interface WeeklyChartListResponse {
228
+ weeklychartlist: WeeklyChartList;
229
+ }
230
+
231
+ export interface WeeklyChartList {
232
+ chart: WeeklyChartListChart[];
233
+ '@attr': WeeklyChartListAttr;
234
+ }
235
+
236
+ export interface WeeklyChartListChart {
237
+ '#text': string;
238
+ from: string;
239
+ to: string;
240
+ }
241
+
242
+ export interface WeeklyChartListAttr {
243
+ user: string;
244
+ }
245
+
246
+ export interface WeeklyTrackChartResponse {
247
+ weeklytrackchart: WeeklyTrackChart;
248
+ }
249
+
250
+ export interface WeeklyTrackChart {
251
+ track: Track[];
252
+ '@attr': WeeklyTrackChartAttr2;
253
+ }
254
+
255
+ export interface WeeklyTrackChartTrack {
256
+ artist: WeeklyTrackChartArtist;
257
+ image: Image[];
258
+ mbid: string;
259
+ url: string;
260
+ name: string;
261
+ '@attr': Attr;
262
+ playcount: string;
263
+ }
264
+
265
+ export interface WeeklyTrackChartArtist {
266
+ mbid: string;
267
+ '#text': string;
268
+ }
269
+
270
+ export interface WeeklyTrackChartAttr {
271
+ rank: string;
272
+ }
273
+
274
+ export interface WeeklyTrackChartAttr2 {
275
+ from: string;
276
+ user: string;
277
+ to: string;
278
+ }
279
+
280
+ export enum Errors {
281
+ 'InvalidService' = 2,
282
+ 'InvalidMethod' = 3,
283
+ 'AuthenticationFailed' = 4,
284
+ 'Invalid format' = 5,
285
+ 'Invalid parameters' = 6,
286
+ 'InvalidResourceSpecified' = 7,
287
+ 'OperationFailed' = 8,
288
+ 'Invalid session key' = 9,
289
+ 'InvalidApiKey' = 10,
290
+ 'ServiceOffline' = 11,
291
+ 'InvalidMethodSignatureSupplied' = 13,
292
+ 'TemporaryErrorRequest' = 16,
293
+ 'SuspendedApiKey' = 26,
294
+ 'RateLimitExceeded' = 29,
295
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,103 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Visit https://aka.ms/tsconfig to read more about this file */
4
+
5
+ /* Projects */
6
+ // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
7
+ // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8
+ // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
9
+ // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
10
+ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11
+ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
+
13
+ /* Language and Environment */
14
+ "target": "ES2015" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
15
+ // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
+ // "jsx": "preserve", /* Specify what JSX code is generated. */
17
+ // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
18
+ // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
19
+ // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
20
+ // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
21
+ // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
22
+ // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
23
+ // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
24
+ // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
25
+ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
26
+
27
+ /* Modules */
28
+ "module": "Node16" /* Specify what module code is generated. */,
29
+ "rootDir": "./src" /* Specify the root folder within your source files. */,
30
+ "moduleResolution": "node" /* Specify how TypeScript looks up a file from a given module specifier. */,
31
+ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
32
+ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
33
+ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
34
+ // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
35
+ // "types": [], /* Specify type package names to be included without being referenced in a source file. */
36
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
37
+ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
38
+ // "resolveJsonModule": true, /* Enable importing .json files. */
39
+ // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
40
+
41
+ /* JavaScript Support */
42
+ // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
43
+ // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
44
+ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
45
+
46
+ /* Emit */
47
+ // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
48
+ // "declarationMap": true, /* Create sourcemaps for d.ts files. */
49
+ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
50
+ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
51
+ // "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. */
52
+ "outDir": "./dist" /* Specify an output folder for all emitted files. */,
53
+ // "removeComments": true, /* Disable emitting comments. */
54
+ // "noEmit": true, /* Disable emitting files from a compilation. */
55
+ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
56
+ // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
57
+ // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
58
+ // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
59
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
60
+ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
61
+ // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
62
+ // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
63
+ // "newLine": "crlf", /* Set the newline character for emitting files. */
64
+ // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
65
+ // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
66
+ // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
67
+ // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
68
+ // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
69
+ // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
70
+
71
+ /* Interop Constraints */
72
+ "isolatedModules": true /* Ensure that each file can be safely transpiled without relying on other imports. */,
73
+ // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
74
+ "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
75
+ // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
76
+ "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
77
+
78
+ /* Type Checking */
79
+ "strict": true /* Enable all strict type-checking options. */,
80
+ "noImplicitAny": true /* Enable error reporting for expressions and declarations with an implied 'any' type. */,
81
+ "strictNullChecks": true /* When type checking, take into account 'null' and 'undefined'. */,
82
+ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
83
+ // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
84
+ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
85
+ // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
86
+ // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
87
+ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
88
+ // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
89
+ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
90
+ // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
91
+ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
92
+ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
93
+ // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
94
+ // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
95
+ // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
96
+ // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
97
+ // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
98
+
99
+ /* Completeness */
100
+ "skipDefaultLibCheck": true /* Skip type checking .d.ts files that are included with TypeScript. */,
101
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
102
+ }
103
+ }