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,455 lines (1,454 loc) 125 kB
{ "type": "File", "start": 0, "end": 1865, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 58, "column": 1 } }, "program": { "type": "Program", "start": 0, "end": 1865, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 58, "column": 1 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 58, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 58 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 8, "end": 38, "loc": { "start": { "line": 1, "column": 8 }, "end": { "line": 1, "column": 38 } }, "imported": { "type": "Identifier", "start": 8, "end": 26, "loc": { "start": { "line": 1, "column": 8 }, "end": { "line": 1, "column": 26 }, "identifierName": "NEW_HITS_PLAYLISTS" }, "name": "NEW_HITS_PLAYLISTS" }, "local": { "type": "Identifier", "start": 30, "end": 38, "loc": { "start": { "line": 1, "column": 30 }, "end": { "line": 1, "column": 38 }, "identifierName": "ENDPOINT" }, "name": "ENDPOINT" } } ], "source": { "type": "StringLiteral", "start": 45, "end": 58, "loc": { "start": { "line": 1, "column": 45 }, "end": { "line": 1, "column": 58 } }, "extra": { "rawValue": "../Endpoint", "raw": "'../Endpoint'" }, "value": "../Endpoint" } }, { "type": "ImportDeclaration", "start": 59, "end": 90, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 31 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 66, "end": 73, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 14 } }, "local": { "type": "Identifier", "start": 66, "end": 73, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 14 }, "identifierName": "Fetcher" }, "name": "Fetcher" } } ], "source": { "type": "StringLiteral", "start": 79, "end": 90, "loc": { "start": { "line": 2, "column": 20 }, "end": { "line": 2, "column": 31 } }, "extra": { "rawValue": "./Fetcher", "raw": "'./Fetcher'" }, "value": "./Fetcher", "leadingComments": null, "trailingComments": null }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * List new hits playlists.\n * @see https://kkbox.gelato.io/docs/versions/1.1/resources/new-hits-playlists\n ", "start": 92, "end": 206, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 7, "column": 3 } } } ] }, { "type": "ExportDefaultDeclaration", "start": 207, "end": 1865, "loc": { "start": { "line": 8, "column": 0 }, "end": { "line": 58, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 222, "end": 1865, "loc": { "start": { "line": 8, "column": 15 }, "end": { "line": 58, "column": 1 } }, "id": { "type": "Identifier", "start": 228, "end": 250, "loc": { "start": { "line": 8, "column": 21 }, "end": { "line": 8, "column": 43 }, "identifierName": "NewHitsPlaylistFetcher" }, "name": "NewHitsPlaylistFetcher", "leadingComments": null }, "superClass": { "type": "Identifier", "start": 259, "end": 266, "loc": { "start": { "line": 8, "column": 52 }, "end": { "line": 8, "column": 59 }, "identifierName": "Fetcher" }, "name": "Fetcher" }, "body": { "type": "ClassBody", "start": 267, "end": 1865, "loc": { "start": { "line": 8, "column": 60 }, "end": { "line": 58, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 304, "end": 459, "loc": { "start": { "line": 12, "column": 4 }, "end": { "line": 19, "column": 5 } }, "computed": false, "key": { "type": "Identifier", "start": 304, "end": 315, "loc": { "start": { "line": 12, "column": 4 }, "end": { "line": 12, "column": 15 }, "identifierName": "constructor" }, "name": "constructor", "leadingComments": null }, "static": false, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 316, "end": 320, "loc": { "start": { "line": 12, "column": 16 }, "end": { "line": 12, "column": 20 }, "identifierName": "http" }, "name": "http" }, { "type": "AssignmentPattern", "start": 322, "end": 338, "loc": { "start": { "line": 12, "column": 22 }, "end": { "line": 12, "column": 38 } }, "left": { "type": "Identifier", "start": 322, "end": 331, "loc": { "start": { "line": 12, "column": 22 }, "end": { "line": 12, "column": 31 }, "identifierName": "territory" }, "name": "territory" }, "right": { "type": "StringLiteral", "start": 334, "end": 338, "loc": { "start": { "line": 12, "column": 34 }, "end": { "line": 12, "column": 38 } }, "extra": { "rawValue": "TW", "raw": "'TW'" }, "value": "TW" } } ], "body": { "type": "BlockStatement", "start": 340, "end": 459, "loc": { "start": { "line": 12, "column": 40 }, "end": { "line": 19, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 350, "end": 372, "loc": { "start": { "line": 13, "column": 8 }, "end": { "line": 13, "column": 30 } }, "expression": { "type": "CallExpression", "start": 350, "end": 372, "loc": { "start": { "line": 13, "column": 8 }, "end": { "line": 13, "column": 30 } }, "callee": { "type": "Super", "start": 350, "end": 355, "loc": { "start": { "line": 13, "column": 8 }, "end": { "line": 13, "column": 13 } } }, "arguments": [ { "type": "Identifier", "start": 356, "end": 360, "loc": { "start": { "line": 13, "column": 14 }, "end": { "line": 13, "column": 18 }, "identifierName": "http" }, "name": "http" }, { "type": "Identifier", "start": 362, "end": 371, "loc": { "start": { "line": 13, "column": 20 }, "end": { "line": 13, "column": 29 }, "identifierName": "territory" }, "name": "territory" } ], "trailingComments": null }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * @ignore\n ", "start": 382, "end": 416, "loc": { "start": { "line": 15, "column": 8 }, "end": { "line": 17, "column": 11 } } } ] }, { "type": "ExpressionStatement", "start": 425, "end": 453, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 36 } }, "expression": { "type": "AssignmentExpression", "start": 425, "end": 453, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 36 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 425, "end": 441, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 24 } }, "object": { "type": "ThisExpression", "start": 425, "end": 429, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 430, "end": 441, "loc": { "start": { "line": 18, "column": 13 }, "end": { "line": 18, "column": 24 }, "identifierName": "playlist_id" }, "name": "playlist_id" }, "computed": false, "leadingComments": null }, "right": { "type": "Identifier", "start": 444, "end": 453, "loc": { "start": { "line": 18, "column": 27 }, "end": { "line": 18, "column": 36 }, "identifierName": "undefined" }, "name": "undefined" }, "leadingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * @ignore\n ", "start": 382, "end": 416, "loc": { "start": { "line": 15, "column": 8 }, "end": { "line": 17, "column": 11 } } } ] } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * @ignore\n ", "start": 273, "end": 299, "loc": { "start": { "line": 9, "column": 4 }, "end": { "line": 11, "column": 7 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Fetch all new hits playlists.\n *\n * @param {number} [limit] - The size of one page.\n * @param {number} [offset] - The offset index for first element.\n * @return {Promise}\n * @example api.newHitsPlaylistFetcher.fetchAllNewHitsPlaylists()\n * @see https://kkbox.gelato.io/docs/versions/1.1/resources/new-hits-playlists/endpoints/get-new-hits-playlists\n ", "start": 465, "end": 856, "loc": { "start": { "line": 21, "column": 4 }, "end": { "line": 29, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 861, "end": 1022, "loc": { "start": { "line": 30, "column": 4 }, "end": { "line": 34, "column": 5 } }, "computed": false, "key": { "type": "Identifier", "start": 861, "end": 885, "loc": { "start": { "line": 30, "column": 4 }, "end": { "line": 30, "column": 28 }, "identifierName": "fetchAllNewHitsPlaylists" }, "name": "fetchAllNewHitsPlaylists", "leadingComments": null }, "static": false, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "AssignmentPattern", "start": 886, "end": 903, "loc": { "start": { "line": 30, "column": 29 }, "end": { "line": 30, "column": 46 } }, "left": { "type": "Identifier", "start": 886, "end": 891, "loc": { "start": { "line": 30, "column": 29 }, "end": { "line": 30, "column": 34 }, "identifierName": "limit" }, "name": "limit" }, "right": { "type": "Identifier", "start": 894, "end": 903, "loc": { "start": { "line": 30, "column": 37 }, "end": { "line": 30, "column": 46 }, "identifierName": "undefined" }, "name": "undefined" } }, { "type": "AssignmentPattern", "start": 905, "end": 923, "loc": { "start": { "line": 30, "column": 48 }, "end": { "line": 30, "column": 66 } }, "left": { "type": "Identifier", "start": 905, "end": 911, "loc": { "start": { "line": 30, "column": 48 }, "end": { "line": 30, "column": 54 }, "identifierName": "offset" }, "name": "offset" }, "right": { "type": "Identifier", "start": 914, "end": 923, "loc": { "start": { "line": 30, "column": 57 }, "end": { "line": 30, "column": 66 }, "identifierName": "undefined" }, "name": "undefined" } } ], "body": { "type": "BlockStatement", "start": 925, "end": 1022, "loc": { "start": { "line": 30, "column": 68 }, "end": { "line": 34, "column": 5 } }, "body": [ { "type": "ReturnStatement", "start": 935, "end": 1016, "loc": { "start": { "line": 31, "column": 8 }, "end": { "line": 33, "column": 10 } }, "argument": { "type": "CallExpression", "start": 942, "end": 1016, "loc": { "start": { "line": 31, "column": 15 }, "end": { "line": 33, "column": 10 } }, "callee": { "type": "MemberExpression", "start": 942, "end": 955, "loc": { "start": { "line": 31, "column": 15 }, "end": { "line": 31, "column": 28 } }, "object": { "type": "MemberExpression", "start": 942, "end": 951, "loc": { "start": { "line": 31, "column": 15 }, "end": { "line": 31, "column": 24 } }, "object": { "type": "ThisExpression", "start": 942, "end": 946, "loc": { "start": { "line": 31, "column": 15 }, "end": { "line": 31, "column": 19 } } }, "property": { "type": "Identifier", "start": 947, "end": 951, "loc": { "start": { "line": 31, "column": 20 }, "end": { "line": 31, "column": 24 }, "identifierName": "http" }, "name": "http" }, "computed": false }, "property": { "type": "Identifier", "start": 952, "end": 955, "loc": { "start": { "line": 31, "column": 25 }, "end": { "line": 31, "column": 28 }, "identifierName": "get" }, "name": "get" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 956, "end": 964, "loc": { "start": { "line": 31, "column": 29 }, "end": { "line": 31, "column": 37 }, "identifierName": "ENDPOINT" }, "name": "ENDPOINT" }, { "type": "ObjectExpression", "start": 966, "end": 1015, "loc": { "start": { "line": 31, "column": 39 }, "end": { "line": 33, "column": 9 } }, "properties": [ { "type": "ObjectProperty", "start": 980, "end": 1005, "loc": { "start": { "line": 32, "column": 12 }, "end": { "line": 32, "column": 37 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 980, "end": 989, "loc": { "start": { "line": 32, "column": 12 }, "end": { "line": 32, "column": 21 }, "identifierName": "territory" }, "name": "territory" }, "value": { "type": "MemberExpression", "start": 991, "end": 1005, "loc": { "start": { "line": 32, "column": 23 }, "end": { "line": 32, "column": 37 } }, "object": { "type": "ThisExpression", "start": 991, "end": 995, "loc": { "start": { "line": 32, "column": 23 }, "end": { "line": 32, "column": 27 } } }, "property": { "type": "Identifier", "start": 996, "end": 1005, "loc": { "start": { "line": 32, "column": 28 }, "end": { "line": 32, "column": 37 }, "identifierName": "territory" }, "name": "territory" }, "computed": false } } ] } ] } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * Fetch all new hits playlists.\n *\n * @param {number} [limit] - The size of one page.\n * @param {number} [offset] - The offset index for first element.\n * @return {Promise}\n * @example api.newHitsPlaylistFetcher.fetchAllNewHitsPlaylists()\n * @see https://kkbox.gelato.io/docs/versions/1.1/resources/new-hits-playlists/endpoints/get-new-hits-playlists\n ", "start": 465, "end": 856, "loc": { "start": { "line": 21, "column": 4 }, "end": { "line": 29, "column": 7 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Init the new hits playlist fetcher.\n *\n * @param {string} playlist_id - The playlist ID.\n * @return {NewHitsPlaylistFetcher}\n * @see https://kkbox.gelato.io/docs/versions/1.1/resources/new-hits-playlists/endpoints/get-new-hits-playlists-playlist_id\n ", "start": 1028, "end": 1311, "loc": { "start": { "line": 36, "column": 4 }, "end": { "line": 42, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 1316, "end": 1417, "loc": { "start": { "line": 43, "column": 4 }, "end": { "line": 46, "column": 5 } }, "computed": false, "key": { "type": "Identifier", "start": 1316, "end": 1329, "loc": { "start": { "line": 43, "column": 4 }, "end": { "line": 43, "column": 17 }, "identifierName": "setPlaylistID" }, "name": "setPlaylistID", "leadingComments": null }, "static": false, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 1330, "end": 1341, "loc": { "start": { "line": 43, "column": 18 }, "end": { "line": 43, "column": 29 }, "identifierName": "playlist_id" }, "name": "playlist_id" } ], "body": { "type": "BlockStatement", "start": 1343, "end": 1417, "loc": { "start": { "line": 43, "column": 31 }, "end": { "line": 46, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 1353, "end": 1383, "loc": { "start": { "line": 44, "column": 8 }, "end": { "line": 44, "column": 38 } }, "expression": { "type": "AssignmentExpression", "start": 1353, "end": 1383, "loc": { "start": { "line": 44, "column": 8 }, "end": { "line": 44, "column": 38 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 1353, "end": 1369, "loc": { "start": { "line": 44, "column": 8 }, "end": { "line": 44, "column": 24 } }, "object": { "type": "ThisExpression", "start": 1353, "end": 1357, "loc": { "start": { "line": 44, "column": 8 }, "end": { "line": 44, "column": 12 } } }, "property": { "type": "Identifier", "start": 1358, "end": 1369, "loc": { "start": { "line": 44, "column": 13 }, "end": { "line": 44, "column": 24 }, "identifierName": "playlist_id" }, "name": "playlist_id" }, "computed": false }, "right": { "type": "Identifier", "start": 1372, "end": 1383, "loc": { "start": { "line": 44, "column": 27 }, "end": { "line": 44, "column": 38 }, "identifierName": "playlist_id" }, "name": "playlist_id" } } }, { "type": "ReturnStatement", "start": 1400, "end": 1411, "loc": { "start": { "line": 45, "column": 8 }, "end": { "line": 45, "column": 19 } }, "argument": { "type": "ThisExpression", "start": 1407, "end": 1411, "loc": { "start": { "line": 45, "column": 15 }, "end": { "line": 45, "column": 19 } } } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * Init the new hits playlist fetcher.\n *\n * @param {string} playlist_id - The playlist ID.\n * @return {NewHitsPlaylistFetcher}\n * @see https://kkbox.gelato.io/docs/versions/1.1/resources/new-hits-playlists/endpoints/get-new-hits-playlists-playlist_id\n ", "start": 1028, "end": 1311, "loc": { "start": { "line": 36, "column": 4 }, "end": { "line": 42, "column": 7 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Fetch metadata of the new release category you set.\n *\n * @return {Promise}\n * @example api.newHitsPlaylistFetcher.setPlaylistID('DZrC8m29ciOFY2JAm3').fetchMetadata()\n * @see https://kkbox.gelato.io/docs/versions/1.1/resources/new-hits-playlists/endpoints/get-new-hits-playlists-playlist_id\n ", "start": 1423, "end": 1748, "loc": { "start": { "line": 48, "column": 4 }, "end": { "line": 54, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 1753, "end": 1863, "loc": { "start": { "line": 55, "column": 4 }, "end": { "line": 57, "column": 5 } }, "computed": false, "key": { "type": "Identifier", "start": 1753, "end": 1766, "loc": { "start": { "line": 55, "column": 4 }, "end": { "line": 55, "column": 17 }, "identifierName": "fetchMetadata" }, "name": "fetchMetadata", "leadingComments": null }, "static": false, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 1769, "end": 1863, "loc": { "start": { "line": 55, "column": 20 }, "end": { "line": 57, "column": 5 } }, "body": [ { "type": "ReturnStatement", "start": 1779, "end": 1857, "loc": { "start": { "line": 56, "column": 8 }, "end": { "line": 56, "column": 86 } }, "argument": { "type": "CallExpression", "start": 1786, "end": 1857, "loc": { "start": { "line": 56, "column": 15 }, "end": { "line": 56, "column": 86 } }, "callee": { "type": "MemberExpression", "start": 1786, "end": 1799, "loc": { "start": { "line": 56, "column": 15 }, "end": { "line": 56, "column": 28 } }, "object": { "type": "MemberExpression", "start": 1786, "end": 1795, "loc": { "start": { "line": 56, "column": 15 }, "end": { "line": 56, "column": 24 } }, "object": { "type": "ThisExpression", "start": 1786, "end": 1790, "loc": { "start": { "line": 56, "column": 15 }, "end": { "line": 56, "column": 19