UNPKG

@kkbox/kkbox-js-sdk

Version:

KKBOX Open API developer SDK for JavaScript. Use it to easily access KKBOX open API to get various metadata about KKBOX's tracks, albums, artists, playlists and stations.

1,705 lines (1,704 loc) 308 kB
{ "type": "File", "start": 0, "end": 3101, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 96, "column": 1 } }, "program": { "type": "Program", "start": 0, "end": 3101, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 96, "column": 1 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 37, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 37 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 7, "end": 17, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 17 } }, "local": { "type": "Identifier", "start": 7, "end": 17, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 17 }, "identifierName": "HttpClient" }, "name": "HttpClient" } } ], "source": { "type": "StringLiteral", "start": 23, "end": 37, "loc": { "start": { "line": 1, "column": 23 }, "end": { "line": 1, "column": 37 } }, "extra": { "rawValue": "./HttpClient", "raw": "'./HttpClient'" }, "value": "./HttpClient" } }, { "type": "ImportDeclaration", "start": 38, "end": 81, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 43 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 45, "end": 58, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 20 } }, "local": { "type": "Identifier", "start": 45, "end": 58, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 20 }, "identifierName": "SearchFetcher" }, "name": "SearchFetcher" } } ], "source": { "type": "StringLiteral", "start": 64, "end": 81, "loc": { "start": { "line": 2, "column": 26 }, "end": { "line": 2, "column": 43 } }, "extra": { "rawValue": "./SearchFetcher", "raw": "'./SearchFetcher'" }, "value": "./SearchFetcher" } }, { "type": "ImportDeclaration", "start": 82, "end": 123, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 41 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 89, "end": 101, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 19 } }, "local": { "type": "Identifier", "start": 89, "end": 101, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 19 }, "identifierName": "TrackFetcher" }, "name": "TrackFetcher" } } ], "source": { "type": "StringLiteral", "start": 107, "end": 123, "loc": { "start": { "line": 3, "column": 25 }, "end": { "line": 3, "column": 41 } }, "extra": { "rawValue": "./TrackFetcher", "raw": "'./TrackFetcher'" }, "value": "./TrackFetcher" } }, { "type": "ImportDeclaration", "start": 124, "end": 165, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 41 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 131, "end": 143, "loc": { "start": { "line": 4, "column": 7 }, "end": { "line": 4, "column": 19 } }, "local": { "type": "Identifier", "start": 131, "end": 143, "loc": { "start": { "line": 4, "column": 7 }, "end": { "line": 4, "column": 19 }, "identifierName": "AlbumFetcher" }, "name": "AlbumFetcher" } } ], "source": { "type": "StringLiteral", "start": 149, "end": 165, "loc": { "start": { "line": 4, "column": 25 }, "end": { "line": 4, "column": 41 } }, "extra": { "rawValue": "./AlbumFetcher", "raw": "'./AlbumFetcher'" }, "value": "./AlbumFetcher" } }, { "type": "ImportDeclaration", "start": 166, "end": 209, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 5, "column": 43 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 173, "end": 186, "loc": { "start": { "line": 5, "column": 7 }, "end": { "line": 5, "column": 20 } }, "local": { "type": "Identifier", "start": 173, "end": 186, "loc": { "start": { "line": 5, "column": 7 }, "end": { "line": 5, "column": 20 }, "identifierName": "ArtistFetcher" }, "name": "ArtistFetcher" } } ], "source": { "type": "StringLiteral", "start": 192, "end": 209, "loc": { "start": { "line": 5, "column": 26 }, "end": { "line": 5, "column": 43 } }, "extra": { "rawValue": "./ArtistFetcher", "raw": "'./ArtistFetcher'" }, "value": "./ArtistFetcher" } }, { "type": "ImportDeclaration", "start": 210, "end": 273, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 6, "column": 63 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 217, "end": 240, "loc": { "start": { "line": 6, "column": 7 }, "end": { "line": 6, "column": 30 } }, "local": { "type": "Identifier", "start": 217, "end": 240, "loc": { "start": { "line": 6, "column": 7 }, "end": { "line": 6, "column": 30 }, "identifierName": "FeaturedPlaylistFetcher" }, "name": "FeaturedPlaylistFetcher" } } ], "source": { "type": "StringLiteral", "start": 246, "end": 273, "loc": { "start": { "line": 6, "column": 36 }, "end": { "line": 6, "column": 63 } }, "extra": { "rawValue": "./FeaturedPlaylistFetcher", "raw": "'./FeaturedPlaylistFetcher'" }, "value": "./FeaturedPlaylistFetcher" } }, { "type": "ImportDeclaration", "start": 274, "end": 353, "loc": { "start": { "line": 7, "column": 0 }, "end": { "line": 7, "column": 79 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 281, "end": 312, "loc": { "start": { "line": 7, "column": 7 }, "end": { "line": 7, "column": 38 } }, "local": { "type": "Identifier", "start": 281, "end": 312, "loc": { "start": { "line": 7, "column": 7 }, "end": { "line": 7, "column": 38 }, "identifierName": "FeaturedPlaylistCategoryFetcher" }, "name": "FeaturedPlaylistCategoryFetcher" } } ], "source": { "type": "StringLiteral", "start": 318, "end": 353, "loc": { "start": { "line": 7, "column": 44 }, "end": { "line": 7, "column": 79 } }, "extra": { "rawValue": "./FeaturedPlaylistCategoryFetcher", "raw": "'./FeaturedPlaylistCategoryFetcher'" }, "value": "./FeaturedPlaylistCategoryFetcher" } }, { "type": "ImportDeclaration", "start": 354, "end": 421, "loc": { "start": { "line": 8, "column": 0 }, "end": { "line": 8, "column": 67 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 361, "end": 386, "loc": { "start": { "line": 8, "column": 7 }, "end": { "line": 8, "column": 32 } }, "local": { "type": "Identifier", "start": 361, "end": 386, "loc": { "start": { "line": 8, "column": 7 }, "end": { "line": 8, "column": 32 }, "identifierName": "NewReleaseCategoryFetcher" }, "name": "NewReleaseCategoryFetcher" } } ], "source": { "type": "StringLiteral", "start": 392, "end": 421, "loc": { "start": { "line": 8, "column": 38 }, "end": { "line": 8, "column": 67 } }, "extra": { "rawValue": "./NewReleaseCategoryFetcher", "raw": "'./NewReleaseCategoryFetcher'" }, "value": "./NewReleaseCategoryFetcher" } }, { "type": "ImportDeclaration", "start": 422, "end": 483, "loc": { "start": { "line": 9, "column": 0 }, "end": { "line": 9, "column": 61 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 429, "end": 451, "loc": { "start": { "line": 9, "column": 7 }, "end": { "line": 9, "column": 29 } }, "local": { "type": "Identifier", "start": 429, "end": 451, "loc": { "start": { "line": 9, "column": 7 }, "end": { "line": 9, "column": 29 }, "identifierName": "NewHitsPlaylistFetcher" }, "name": "NewHitsPlaylistFetcher" } } ], "source": { "type": "StringLiteral", "start": 457, "end": 483, "loc": { "start": { "line": 9, "column": 35 }, "end": { "line": 9, "column": 61 } }, "extra": { "rawValue": "./NewHitsPlaylistFetcher", "raw": "'./NewHitsPlaylistFetcher'" }, "value": "./NewHitsPlaylistFetcher" } }, { "type": "ImportDeclaration", "start": 484, "end": 539, "loc": { "start": { "line": 10, "column": 0 }, "end": { "line": 10, "column": 55 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 491, "end": 510, "loc": { "start": { "line": 10, "column": 7 }, "end": { "line": 10, "column": 26 } }, "local": { "type": "Identifier", "start": 491, "end": 510, "loc": { "start": { "line": 10, "column": 7 }, "end": { "line": 10, "column": 26 }, "identifierName": "GenreStationFetcher" }, "name": "GenreStationFetcher" } } ], "source": { "type": "StringLiteral", "start": 516, "end": 539, "loc": { "start": { "line": 10, "column": 32 }, "end": { "line": 10, "column": 55 } }, "extra": { "rawValue": "./GenreStationFetcher", "raw": "'./GenreStationFetcher'" }, "value": "./GenreStationFetcher" } }, { "type": "ImportDeclaration", "start": 540, "end": 593, "loc": { "start": { "line": 11, "column": 0 }, "end": { "line": 11, "column": 53 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 547, "end": 565, "loc": { "start": { "line": 11, "column": 7 }, "end": { "line": 11, "column": 25 } }, "local": { "type": "Identifier", "start": 547, "end": 565, "loc": { "start": { "line": 11, "column": 7 }, "end": { "line": 11, "column": 25 }, "identifierName": "MoodStationFetcher" }, "name": "MoodStationFetcher" } } ], "source": { "type": "StringLiteral", "start": 571, "end": 593, "loc": { "start": { "line": 11, "column": 31 }, "end": { "line": 11, "column": 53 } }, "extra": { "rawValue": "./MoodStationFetcher", "raw": "'./MoodStationFetcher'" }, "value": "./MoodStationFetcher" } }, { "type": "ImportDeclaration", "start": 594, "end": 635, "loc": { "start": { "line": 12, "column": 0 }, "end": { "line": 12, "column": 41 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 601, "end": 613, "loc": { "start": { "line": 12, "column": 7 }, "end": { "line": 12, "column": 19 } }, "local": { "type": "Identifier", "start": 601, "end": 613, "loc": { "start": { "line": 12, "column": 7 }, "end": { "line": 12, "column": 19 }, "identifierName": "ChartFetcher" }, "name": "ChartFetcher" } } ], "source": { "type": "StringLiteral", "start": 619, "end": 635, "loc": { "start": { "line": 12, "column": 25 }, "end": { "line": 12, "column": 41 } }, "extra": { "rawValue": "./ChartFetcher", "raw": "'./ChartFetcher'" }, "value": "./ChartFetcher", "leadingComments": null, "trailingComments": null }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Fetch KKBOX resources.\n ", "start": 637, "end": 670, "loc": { "start": { "line": 14, "column": 0 }, "end": { "line": 16, "column": 3 } } } ] }, { "type": "ExportDefaultDeclaration", "start": 671, "end": 3101, "loc": { "start": { "line": 17, "column": 0 }, "end": { "line": 96, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 686, "end": 3101, "loc": { "start": { "line": 17, "column": 15 }, "end": { "line": 96, "column": 1 } }, "id": { "type": "Identifier", "start": 692, "end": 695, "loc": { "start": { "line": 17, "column": 21 }, "end": { "line": 17, "column": 24 }, "identifierName": "Api" }, "name": "Api", "leadingComments": null }, "superClass": null, "body": { "type": "ClassBody", "start": 696, "end": 3101, "loc": { "start": { "line": 17, "column": 25 }, "end": { "line": 96, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 984, "end": 1136, "loc": { "start": { "line": 26, "column": 4 }, "end": { "line": 30, "column": 5 } }, "computed": false, "key": { "type": "Identifier", "start": 984, "end": 995, "loc": { "start": { "line": 26, "column": 4 }, "end": { "line": 26, "column": 15 }, "identifierName": "constructor" }, "name": "constructor", "leadingComments": null }, "static": false, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 996, "end": 1001, "loc": { "start": { "line": 26, "column": 16 }, "end": { "line": 26, "column": 21 }, "identifierName": "token" }, "name": "token" }, { "type": "AssignmentPattern", "start": 1003, "end": 1019, "loc": { "start": { "line": 26, "column": 23 }, "end": { "line": 26, "column": 39 } }, "left": { "type": "Identifier", "start": 1003, "end": 1012, "loc": { "start": { "line": 26, "column": 23 }, "end": { "line": 26, "column": 32 }, "identifierName": "territory" }, "name": "territory" }, "right": { "type": "StringLiteral", "start": 1015, "end": 1019, "loc": { "start": { "line": 26, "column": 35 }, "end": { "line": 26, "column": 39 } }, "extra": { "rawValue": "TW", "raw": "'TW'" }, "value": "TW" } } ], "body": { "type": "BlockStatement", "start": 1021, "end": 1136, "loc": { "start": { "line": 26, "column": 41 }, "end": { "line": 30, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 1039, "end": 1065, "loc": { "start": { "line": 27, "column": 8 }, "end": { "line": 27, "column": 34 } }, "expression": { "type": "AssignmentExpression", "start": 1039, "end": 1065, "loc": { "start": { "line": 27, "column": 8 }, "end": { "line": 27, "column": 34 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 1039, "end": 1053, "loc": { "start": { "line": 27, "column": 8 }, "end": { "line": 27, "column": 22 } }, "object": { "type": "ThisExpression", "start": 1039, "end": 1043, "loc": { "start": { "line": 27, "column": 8 }, "end": { "line": 27, "column": 12 } } }, "property": { "type": "Identifier", "start": 1044, "end": 1053, "loc": { "start": { "line": 27, "column": 13 }, "end": { "line": 27, "column": 22 }, "identifierName": "territory" }, "name": "territory" }, "computed": false }, "right": { "type": "Identifier", "start": 1056, "end": 1065, "loc": { "start": { "line": 27, "column": 25 }, "end": { "line": 27, "column": 34 }, "identifierName": "territory" }, "name": "territory" } } }, { "type": "ExpressionStatement", "start": 1074, "end": 1101, "loc": { "start": { "line": 28, "column": 8 }, "end": { "line": 28, "column": 35 } }, "expression": { "type": "AssignmentExpression", "start": 1074, "end": 1101, "loc": { "start": { "line": 28, "column": 8 }, "end": { "line": 28, "column": 35 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 1074, "end": 1089, "loc": { "start": { "line": 28, "column": 8 }, "end": { "line": 28, "column": 23 } }, "object": { "type": "ThisExpression", "start": 1074, "end": 1078, "loc": { "start": { "line": 28, "column": 8 }, "end": { "line": 28, "column": 12 } } }, "property": { "type": "Identifier", "start": 1079, "end": 1089, "loc": { "start": { "line": 28, "column": 13 }, "end": { "line": 28, "column": 23 }, "identifierName": "httpClient" }, "name": "httpClient" }, "computed": false }, "right": { "type": "Identifier", "start": 1092, "end": 1101, "loc": { "start": { "line": 28, "column": 26 }, "end": { "line": 28, "column": 35 }, "identifierName": "undefined" }, "name": "undefined" } } }, { "type": "ExpressionStatement", "start": 1110, "end": 1130, "loc": { "start": { "line": 29, "column": 8 }, "end": { "line": 29, "column": 28 } }, "expression": { "type": "CallExpression", "start": 1110, "end": 1130, "loc": { "start": { "line": 29, "column": 8 }, "end": { "line": 29, "column": 28 } }, "callee": { "type": "MemberExpression", "start": 1110, "end": 1123, "loc": { "start": { "line": 29, "column": 8 }, "end": { "line": 29, "column": 21 } }, "object": { "type": "ThisExpression", "start": 1110, "end": 1114, "loc": { "start": { "line": 29, "column": 8 }, "end": { "line": 29, "column": 12 } } }, "property": { "type": "Identifier", "start": 1115, "end": 1123, "loc": { "start": { "line": 29, "column": 13 }, "end": { "line": 29, "column": 21 }, "identifierName": "setToken" }, "name": "setToken" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 1124, "end": 1129, "loc": { "start": { "line": 29, "column": 22 }, "end": { "line": 29, "column": 27 }, "identifierName": "token" }, "name": "token" } ] } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * Need access token to initialize.\n *\n * @param {string} token - Get via Auth.\n * @param {string} [territory = 'TW'] - ['TW', 'HK', 'SG', 'MY', 'JP'] The territory for the fetcher.\n * @example new Api(token)\n * @example new Api(token, 'TW')\n ", "start": 702, "end": 979, "loc": { "start": { "line": 18, "column": 4 }, "end": { "line": 25, "column": 7 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Set new token and create fetchers with the new token.\n *\n * @param {string} token - Get via Auth.\n * @example api.setToken(token)\n ", "start": 1142, "end": 1302, "loc": { "start": { "line": 32, "column": 4 }, "end": { "line": 37, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 1307, "end": 3099, "loc": { "start": { "line": 38, "column": 4 }, "end": { "line": 95, "column": 5 } }, "computed": false, "key": { "type": "Identifier", "start": 1307, "end": 1315, "loc": { "start": { "line": 38, "column": 4 }, "end": { "line": 38, "column": 12 }, "identifierName": "setToken" }, "name": "setToken", "leadingComments": null }, "static": false, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 1316, "end": 1321, "loc": { "start": { "line": 38, "column": 13 }, "end": { "line": 38, "column": 18 }, "identifierName": "token" }, "name": "token" } ], "body": { "type": "BlockStatement", "start": 1323, "end": 3099, "loc": { "start": { "line": 38, "column": 20 }, "end": { "line": 95, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 1333, "end": 1372, "loc": { "start": { "line": 39, "column": 8 }, "end": { "line": 39, "column": 47 } }, "expression": { "type": "AssignmentExpression", "start": 1333, "end": 1372, "loc": { "start": { "line": 39, "column": 8 }, "end": { "line": 39, "column": 47 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 1333, "end": 1348, "loc": { "start": { "line": 39, "column": 8 }, "end": { "line": 39, "column": 23 } }, "object": { "type": "ThisExpression", "start": 1333, "end": 1337, "loc": { "start": { "line": 39, "column": 8 }, "end": { "line": 39, "column": 12 } } }, "property": { "type": "Identifier", "start": 1338, "end": 1348, "loc": { "start": { "line": 39, "column": 13 }, "end": { "line": 39, "column": 23 }, "identifierName": "httpClient" }, "name": "httpClient" }, "computed": false }, "right": { "type": "NewExpression", "start": 1351, "end": 1372, "loc": { "start": { "line": 39, "column": 26 }, "end": { "line": 39, "column": 47 } }, "callee": { "type": "Identifier", "start": 1355, "end": 1365, "loc": { "start": { "line": 39, "column": 30 }, "end": { "line": 39, "column": 40 }, "identifierName": "HttpClient" }, "name": "HttpClient" }, "arguments": [ { "type": "Identifier", "start": 1366, "end": 1371, "loc": { "start": { "line": 39, "column": 41 }, "end": { "line": 39, "column": 46 }, "identifierName": "token" }, "name": "token" } ], "trailingComments": null }, "trailingComments": null }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * @type {SearchFetcher}\n ", "start": 1382, "end": 1430, "loc": { "start": { "line": 41, "column": 8 }, "end": { "line": 43, "column": 11 } } } ] }, { "type": "ExpressionStatement", "start": 1439, "end": 1510, "loc": { "start": { "line": 44, "column": 8 }, "end": { "line": 44, "column": 79 } }, "expression": { "type": "AssignmentExpression", "start": 1439, "end": 1510, "loc": { "start": { "line": 44, "column": 8 }, "end": { "line": 44, "column": 79 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 1439, "end": 1457, "loc": { "start": { "line": 44, "column": 8 }, "end": { "line": 44, "column": 26 } }, "object": { "type": "ThisExpression", "start": 1439, "end": 1443, "loc": { "start": { "line": 44, "column": 8 }, "end": { "line": 44, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 1444, "end": 1457, "loc": { "start": { "line": 44, "column": 13 }, "end": { "line": 44, "column": 26 }, "identifierName": "searchFetcher" }, "name": "searchFetcher" }, "computed": false, "leadingComments": null }, "right": { "type": "NewExpression", "start": 1460, "end": 1510, "loc": { "start": { "line": 44,