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,734 lines (1,733 loc) 344 kB
{ "type": "File", "start": 0, "end": 3198, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 124, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 3198, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 124, "column": 0 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 38, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 38 } }, "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": 39, "end": 83, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 44 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 46, "end": 59, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 20 } }, "local": { "type": "Identifier", "start": 46, "end": 59, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 20 }, "identifierName": "SearchFetcher" }, "name": "SearchFetcher" } } ], "source": { "type": "StringLiteral", "start": 65, "end": 82, "loc": { "start": { "line": 2, "column": 26 }, "end": { "line": 2, "column": 43 } }, "extra": { "rawValue": "./SearchFetcher", "raw": "'./SearchFetcher'" }, "value": "./SearchFetcher" } }, { "type": "ImportDeclaration", "start": 84, "end": 126, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 42 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 91, "end": 103, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 19 } }, "local": { "type": "Identifier", "start": 91, "end": 103, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 19 }, "identifierName": "TrackFetcher" }, "name": "TrackFetcher" } } ], "source": { "type": "StringLiteral", "start": 109, "end": 125, "loc": { "start": { "line": 3, "column": 25 }, "end": { "line": 3, "column": 41 } }, "extra": { "rawValue": "./TrackFetcher", "raw": "'./TrackFetcher'" }, "value": "./TrackFetcher" } }, { "type": "ImportDeclaration", "start": 127, "end": 169, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 42 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 134, "end": 146, "loc": { "start": { "line": 4, "column": 7 }, "end": { "line": 4, "column": 19 } }, "local": { "type": "Identifier", "start": 134, "end": 146, "loc": { "start": { "line": 4, "column": 7 }, "end": { "line": 4, "column": 19 }, "identifierName": "AlbumFetcher" }, "name": "AlbumFetcher" } } ], "source": { "type": "StringLiteral", "start": 152, "end": 168, "loc": { "start": { "line": 4, "column": 25 }, "end": { "line": 4, "column": 41 } }, "extra": { "rawValue": "./AlbumFetcher", "raw": "'./AlbumFetcher'" }, "value": "./AlbumFetcher" } }, { "type": "ImportDeclaration", "start": 170, "end": 214, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 5, "column": 44 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 177, "end": 190, "loc": { "start": { "line": 5, "column": 7 }, "end": { "line": 5, "column": 20 } }, "local": { "type": "Identifier", "start": 177, "end": 190, "loc": { "start": { "line": 5, "column": 7 }, "end": { "line": 5, "column": 20 }, "identifierName": "ArtistFetcher" }, "name": "ArtistFetcher" } } ], "source": { "type": "StringLiteral", "start": 196, "end": 213, "loc": { "start": { "line": 5, "column": 26 }, "end": { "line": 5, "column": 43 } }, "extra": { "rawValue": "./ArtistFetcher", "raw": "'./ArtistFetcher'" }, "value": "./ArtistFetcher" } }, { "type": "ImportDeclaration", "start": 215, "end": 279, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 6, "column": 64 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 222, "end": 245, "loc": { "start": { "line": 6, "column": 7 }, "end": { "line": 6, "column": 30 } }, "local": { "type": "Identifier", "start": 222, "end": 245, "loc": { "start": { "line": 6, "column": 7 }, "end": { "line": 6, "column": 30 }, "identifierName": "FeaturedPlaylistFetcher" }, "name": "FeaturedPlaylistFetcher" } } ], "source": { "type": "StringLiteral", "start": 251, "end": 278, "loc": { "start": { "line": 6, "column": 36 }, "end": { "line": 6, "column": 63 } }, "extra": { "rawValue": "./FeaturedPlaylistFetcher", "raw": "'./FeaturedPlaylistFetcher'" }, "value": "./FeaturedPlaylistFetcher" } }, { "type": "ImportDeclaration", "start": 280, "end": 360, "loc": { "start": { "line": 7, "column": 0 }, "end": { "line": 7, "column": 80 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 287, "end": 318, "loc": { "start": { "line": 7, "column": 7 }, "end": { "line": 7, "column": 38 } }, "local": { "type": "Identifier", "start": 287, "end": 318, "loc": { "start": { "line": 7, "column": 7 }, "end": { "line": 7, "column": 38 }, "identifierName": "FeaturedPlaylistCategoryFetcher" }, "name": "FeaturedPlaylistCategoryFetcher" } } ], "source": { "type": "StringLiteral", "start": 324, "end": 359, "loc": { "start": { "line": 7, "column": 44 }, "end": { "line": 7, "column": 79 } }, "extra": { "rawValue": "./FeaturedPlaylistCategoryFetcher", "raw": "'./FeaturedPlaylistCategoryFetcher'" }, "value": "./FeaturedPlaylistCategoryFetcher" } }, { "type": "ImportDeclaration", "start": 361, "end": 429, "loc": { "start": { "line": 8, "column": 0 }, "end": { "line": 8, "column": 68 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 368, "end": 393, "loc": { "start": { "line": 8, "column": 7 }, "end": { "line": 8, "column": 32 } }, "local": { "type": "Identifier", "start": 368, "end": 393, "loc": { "start": { "line": 8, "column": 7 }, "end": { "line": 8, "column": 32 }, "identifierName": "NewReleaseCategoryFetcher" }, "name": "NewReleaseCategoryFetcher" } } ], "source": { "type": "StringLiteral", "start": 399, "end": 428, "loc": { "start": { "line": 8, "column": 38 }, "end": { "line": 8, "column": 67 } }, "extra": { "rawValue": "./NewReleaseCategoryFetcher", "raw": "'./NewReleaseCategoryFetcher'" }, "value": "./NewReleaseCategoryFetcher" } }, { "type": "ImportDeclaration", "start": 430, "end": 492, "loc": { "start": { "line": 9, "column": 0 }, "end": { "line": 9, "column": 62 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 437, "end": 459, "loc": { "start": { "line": 9, "column": 7 }, "end": { "line": 9, "column": 29 } }, "local": { "type": "Identifier", "start": 437, "end": 459, "loc": { "start": { "line": 9, "column": 7 }, "end": { "line": 9, "column": 29 }, "identifierName": "NewHitsPlaylistFetcher" }, "name": "NewHitsPlaylistFetcher" } } ], "source": { "type": "StringLiteral", "start": 465, "end": 491, "loc": { "start": { "line": 9, "column": 35 }, "end": { "line": 9, "column": 61 } }, "extra": { "rawValue": "./NewHitsPlaylistFetcher", "raw": "'./NewHitsPlaylistFetcher'" }, "value": "./NewHitsPlaylistFetcher" } }, { "type": "ImportDeclaration", "start": 493, "end": 549, "loc": { "start": { "line": 10, "column": 0 }, "end": { "line": 10, "column": 56 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 500, "end": 519, "loc": { "start": { "line": 10, "column": 7 }, "end": { "line": 10, "column": 26 } }, "local": { "type": "Identifier", "start": 500, "end": 519, "loc": { "start": { "line": 10, "column": 7 }, "end": { "line": 10, "column": 26 }, "identifierName": "GenreStationFetcher" }, "name": "GenreStationFetcher" } } ], "source": { "type": "StringLiteral", "start": 525, "end": 548, "loc": { "start": { "line": 10, "column": 32 }, "end": { "line": 10, "column": 55 } }, "extra": { "rawValue": "./GenreStationFetcher", "raw": "'./GenreStationFetcher'" }, "value": "./GenreStationFetcher" } }, { "type": "ImportDeclaration", "start": 550, "end": 604, "loc": { "start": { "line": 11, "column": 0 }, "end": { "line": 11, "column": 54 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 557, "end": 575, "loc": { "start": { "line": 11, "column": 7 }, "end": { "line": 11, "column": 25 } }, "local": { "type": "Identifier", "start": 557, "end": 575, "loc": { "start": { "line": 11, "column": 7 }, "end": { "line": 11, "column": 25 }, "identifierName": "MoodStationFetcher" }, "name": "MoodStationFetcher" } } ], "source": { "type": "StringLiteral", "start": 581, "end": 603, "loc": { "start": { "line": 11, "column": 31 }, "end": { "line": 11, "column": 53 } }, "extra": { "rawValue": "./MoodStationFetcher", "raw": "'./MoodStationFetcher'" }, "value": "./MoodStationFetcher" } }, { "type": "ImportDeclaration", "start": 605, "end": 647, "loc": { "start": { "line": 12, "column": 0 }, "end": { "line": 12, "column": 42 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 612, "end": 624, "loc": { "start": { "line": 12, "column": 7 }, "end": { "line": 12, "column": 19 } }, "local": { "type": "Identifier", "start": 612, "end": 624, "loc": { "start": { "line": 12, "column": 7 }, "end": { "line": 12, "column": 19 }, "identifierName": "ChartFetcher" }, "name": "ChartFetcher" } } ], "source": { "type": "StringLiteral", "start": 630, "end": 646, "loc": { "start": { "line": 12, "column": 25 }, "end": { "line": 12, "column": 41 } }, "extra": { "rawValue": "./ChartFetcher", "raw": "'./ChartFetcher'" }, "value": "./ChartFetcher" } }, { "type": "ImportDeclaration", "start": 648, "end": 708, "loc": { "start": { "line": 13, "column": 0 }, "end": { "line": 13, "column": 60 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 655, "end": 676, "loc": { "start": { "line": 13, "column": 7 }, "end": { "line": 13, "column": 28 } }, "local": { "type": "Identifier", "start": 655, "end": 676, "loc": { "start": { "line": 13, "column": 7 }, "end": { "line": 13, "column": 28 }, "identifierName": "SharedPlaylistFetcher" }, "name": "SharedPlaylistFetcher" } } ], "source": { "type": "StringLiteral", "start": 682, "end": 707, "loc": { "start": { "line": 13, "column": 34 }, "end": { "line": 13, "column": 59 } }, "extra": { "rawValue": "./SharedPlaylistFetcher", "raw": "'./SharedPlaylistFetcher'" }, "value": "./SharedPlaylistFetcher" }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Fetch KKBOX resources.\n ", "start": 710, "end": 743, "loc": { "start": { "line": 15, "column": 0 }, "end": { "line": 17, "column": 3 } } } ] }, { "type": "ExportDefaultDeclaration", "start": 744, "end": 3197, "loc": { "start": { "line": 18, "column": 0 }, "end": { "line": 123, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 759, "end": 3197, "loc": { "start": { "line": 18, "column": 15 }, "end": { "line": 123, "column": 1 } }, "id": { "type": "Identifier", "start": 765, "end": 768, "loc": { "start": { "line": 18, "column": 21 }, "end": { "line": 18, "column": 24 }, "identifierName": "Api" }, "name": "Api", "leadingComments": null }, "superClass": null, "body": { "type": "ClassBody", "start": 769, "end": 3197, "loc": { "start": { "line": 18, "column": 25 }, "end": { "line": 123, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 1041, "end": 1174, "loc": { "start": { "line": 27, "column": 2 }, "end": { "line": 31, "column": 3 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 1041, "end": 1052, "loc": { "start": { "line": 27, "column": 2 }, "end": { "line": 27, "column": 13 }, "identifierName": "constructor" }, "name": "constructor", "leadingComments": null }, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 1053, "end": 1058, "loc": { "start": { "line": 27, "column": 14 }, "end": { "line": 27, "column": 19 }, "identifierName": "token" }, "name": "token" }, { "type": "AssignmentPattern", "start": 1060, "end": 1076, "loc": { "start": { "line": 27, "column": 21 }, "end": { "line": 27, "column": 37 } }, "left": { "type": "Identifier", "start": 1060, "end": 1069, "loc": { "start": { "line": 27, "column": 21 }, "end": { "line": 27, "column": 30 }, "identifierName": "territory" }, "name": "territory" }, "right": { "type": "StringLiteral", "start": 1072, "end": 1076, "loc": { "start": { "line": 27, "column": 33 }, "end": { "line": 27, "column": 37 } }, "extra": { "rawValue": "TW", "raw": "'TW'" }, "value": "TW" } } ], "body": { "type": "BlockStatement", "start": 1078, "end": 1174, "loc": { "start": { "line": 27, "column": 39 }, "end": { "line": 31, "column": 3 } }, "body": [ { "type": "ExpressionStatement", "start": 1084, "end": 1111, "loc": { "start": { "line": 28, "column": 4 }, "end": { "line": 28, "column": 31 } }, "expression": { "type": "AssignmentExpression", "start": 1084, "end": 1110, "loc": { "start": { "line": 28, "column": 4 }, "end": { "line": 28, "column": 30 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 1084, "end": 1098, "loc": { "start": { "line": 28, "column": 4 }, "end": { "line": 28, "column": 18 } }, "object": { "type": "ThisExpression", "start": 1084, "end": 1088, "loc": { "start": { "line": 28, "column": 4 }, "end": { "line": 28, "column": 8 } } }, "property": { "type": "Identifier", "start": 1089, "end": 1098, "loc": { "start": { "line": 28, "column": 9 }, "end": { "line": 28, "column": 18 }, "identifierName": "territory" }, "name": "territory" }, "computed": false }, "right": { "type": "Identifier", "start": 1101, "end": 1110, "loc": { "start": { "line": 28, "column": 21 }, "end": { "line": 28, "column": 30 }, "identifierName": "territory" }, "name": "territory" } } }, { "type": "ExpressionStatement", "start": 1116, "end": 1144, "loc": { "start": { "line": 29, "column": 4 }, "end": { "line": 29, "column": 32 } }, "expression": { "type": "AssignmentExpression", "start": 1116, "end": 1143, "loc": { "start": { "line": 29, "column": 4 }, "end": { "line": 29, "column": 31 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 1116, "end": 1131, "loc": { "start": { "line": 29, "column": 4 }, "end": { "line": 29, "column": 19 } }, "object": { "type": "ThisExpression", "start": 1116, "end": 1120, "loc": { "start": { "line": 29, "column": 4 }, "end": { "line": 29, "column": 8 } } }, "property": { "type": "Identifier", "start": 1121, "end": 1131, "loc": { "start": { "line": 29, "column": 9 }, "end": { "line": 29, "column": 19 }, "identifierName": "httpClient" }, "name": "httpClient" }, "computed": false }, "right": { "type": "Identifier", "start": 1134, "end": 1143, "loc": { "start": { "line": 29, "column": 22 }, "end": { "line": 29, "column": 31 }, "identifierName": "undefined" }, "name": "undefined" } } }, { "type": "ExpressionStatement", "start": 1149, "end": 1170, "loc": { "start": { "line": 30, "column": 4 }, "end": { "line": 30, "column": 25 } }, "expression": { "type": "CallExpression", "start": 1149, "end": 1169, "loc": { "start": { "line": 30, "column": 4 }, "end": { "line": 30, "column": 24 } }, "callee": { "type": "MemberExpression", "start": 1149, "end": 1162, "loc": { "start": { "line": 30, "column": 4 }, "end": { "line": 30, "column": 17 } }, "object": { "type": "ThisExpression", "start": 1149, "end": 1153, "loc": { "start": { "line": 30, "column": 4 }, "end": { "line": 30, "column": 8 } } }, "property": { "type": "Identifier", "start": 1154, "end": 1162, "loc": { "start": { "line": 30, "column": 9 }, "end": { "line": 30, "column": 17 }, "identifierName": "setToken" }, "name": "setToken" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 1163, "end": 1168, "loc": { "start": { "line": 30, "column": 18 }, "end": { "line": 30, "column": 23 }, "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": 773, "end": 1038, "loc": { "start": { "line": 19, "column": 2 }, "end": { "line": 26, "column": 5 } } } ], "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": 1178, "end": 1329, "loc": { "start": { "line": 33, "column": 2 }, "end": { "line": 38, "column": 5 } } } ] }, { "type": "ClassMethod", "start": 1332, "end": 3195, "loc": { "start": { "line": 39, "column": 2 }, "end": { "line": 122, "column": 3 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 1332, "end": 1340, "loc": { "start": { "line": 39, "column": 2 }, "end": { "line": 39, "column": 10 }, "identifierName": "setToken" }, "name": "setToken", "leadingComments": null }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 1341, "end": 1346, "loc": { "start": { "line": 39, "column": 11 }, "end": { "line": 39, "column": 16 }, "identifierName": "token" }, "name": "token" } ], "body": { "type": "BlockStatement", "start": 1348, "end": 3195, "loc": { "start": { "line": 39, "column": 18 }, "end": { "line": 122, "column": 3 } }, "body": [ { "type": "ExpressionStatement", "start": 1354, "end": 1394, "loc": { "start": { "line": 40, "column": 4 }, "end": { "line": 40, "column": 44 } }, "expression": { "type": "AssignmentExpression", "start": 1354, "end": 1393, "loc": { "start": { "line": 40, "column": 4 }, "end": { "line": 40, "column": 43 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 1354, "end": 1369, "loc": { "start": { "line": 40, "column": 4 }, "end": { "line": 40, "column": 19 } }, "object": { "type": "ThisExpression", "start": 1354, "end": 1358, "loc": { "start": { "line": 40, "column": 4 }, "end": { "line": 40, "column": 8 } } }, "property": { "type": "Identifier", "start": 1359, "end": 1369, "loc": { "start": { "line": 40, "column": 9 }, "end": { "line": 40, "column": 19 }, "identifierName": "httpClient" }, "name": "httpClient" }, "computed": false }, "right": { "type": "NewExpression", "start": 1372, "end": 1393, "loc": { "start": { "line": 40, "column": 22 }, "end": { "line": 40, "column": 43 } }, "callee": { "type": "Identifier", "start": 1376, "end": 1386, "loc": { "start": { "line": 40, "column": 26 }, "end": { "line": 40, "column": 36 }, "identifierName": "HttpClient" }, "name": "HttpClient" }, "arguments": [ { "type": "Identifier", "start": 1387, "end": 1392, "loc": { "start": { "line": 40, "column": 37 }, "end": { "line": 40, "column": 42 }, "identifierName": "token" }, "name": "token" } ] } }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * @type {SearchFetcher}\n ", "start": 1400, "end": 1440, "loc": { "start": { "line": 42, "column": 4 }, "end": { "line": 44, "column": 7 } } } ] }, { "type": "ExpressionStatement", "start": 1445, "end": 1517, "loc": { "start": { "line": 45, "column": 4 }, "end": { "line": 45, "column": 76 } }, "expression": { "type": "AssignmentExpression", "start": 1445, "end": 1516, "loc": { "start": { "line": 45, "column": 4 }, "end": { "line": 45, "column": 75 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 1445, "end": 1463, "loc": { "start": { "line": 45, "column": 4 }, "end": { "line": 45, "column": 22 } }, "object": { "type": "ThisExpression", "start": 1445, "end": 1449, "loc": { "start": { "line": 45,