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,453 lines (1,452 loc) 255 kB
{ "type": "File", "start": 0, "end": 2780, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 97, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 2780, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 97, "column": 0 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 50, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 50 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 9, "end": 28, "loc": { "start": { "line": 1, "column": 9 }, "end": { "line": 1, "column": 28 } }, "imported": { "type": "Identifier", "start": 9, "end": 16, "loc": { "start": { "line": 1, "column": 9 }, "end": { "line": 1, "column": 16 }, "identifierName": "ARTISTS" }, "name": "ARTISTS" }, "local": { "type": "Identifier", "start": 20, "end": 28, "loc": { "start": { "line": 1, "column": 20 }, "end": { "line": 1, "column": 28 }, "identifierName": "ENDPOINT" }, "name": "ENDPOINT" } } ], "source": { "type": "StringLiteral", "start": 36, "end": 49, "loc": { "start": { "line": 1, "column": 36 }, "end": { "line": 1, "column": 49 } }, "extra": { "rawValue": "../Endpoint", "raw": "'../Endpoint'" }, "value": "../Endpoint" } }, { "type": "ImportDeclaration", "start": 51, "end": 83, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 32 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 58, "end": 65, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 14 } }, "local": { "type": "Identifier", "start": 58, "end": 65, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 14 }, "identifierName": "Fetcher" }, "name": "Fetcher" } } ], "source": { "type": "StringLiteral", "start": 71, "end": 82, "loc": { "start": { "line": 2, "column": 20 }, "end": { "line": 2, "column": 31 } }, "extra": { "rawValue": "./Fetcher", "raw": "'./Fetcher'" }, "value": "./Fetcher" }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Get artist metadata.\n * @see https://docs-en.kkbox.codes/v1.1/reference#artists\n ", "start": 85, "end": 175, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 7, "column": 3 } } } ] }, { "type": "ExportDefaultDeclaration", "start": 176, "end": 2779, "loc": { "start": { "line": 8, "column": 0 }, "end": { "line": 96, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 191, "end": 2779, "loc": { "start": { "line": 8, "column": 15 }, "end": { "line": 96, "column": 1 } }, "id": { "type": "Identifier", "start": 197, "end": 210, "loc": { "start": { "line": 8, "column": 21 }, "end": { "line": 8, "column": 34 }, "identifierName": "ArtistFetcher" }, "name": "ArtistFetcher", "leadingComments": null }, "superClass": { "type": "Identifier", "start": 219, "end": 226, "loc": { "start": { "line": 8, "column": 43 }, "end": { "line": 8, "column": 50 }, "identifierName": "Fetcher" }, "name": "Fetcher" }, "body": { "type": "ClassBody", "start": 227, "end": 2779, "loc": { "start": { "line": 8, "column": 51 }, "end": { "line": 96, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 256, "end": 388, "loc": { "start": { "line": 12, "column": 2 }, "end": { "line": 19, "column": 3 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 256, "end": 267, "loc": { "start": { "line": 12, "column": 2 }, "end": { "line": 12, "column": 13 }, "identifierName": "constructor" }, "name": "constructor", "leadingComments": null }, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 268, "end": 272, "loc": { "start": { "line": 12, "column": 14 }, "end": { "line": 12, "column": 18 }, "identifierName": "http" }, "name": "http" }, { "type": "AssignmentPattern", "start": 274, "end": 290, "loc": { "start": { "line": 12, "column": 20 }, "end": { "line": 12, "column": 36 } }, "left": { "type": "Identifier", "start": 274, "end": 283, "loc": { "start": { "line": 12, "column": 20 }, "end": { "line": 12, "column": 29 }, "identifierName": "territory" }, "name": "territory" }, "right": { "type": "StringLiteral", "start": 286, "end": 290, "loc": { "start": { "line": 12, "column": 32 }, "end": { "line": 12, "column": 36 } }, "extra": { "rawValue": "TW", "raw": "'TW'" }, "value": "TW" } } ], "body": { "type": "BlockStatement", "start": 292, "end": 388, "loc": { "start": { "line": 12, "column": 38 }, "end": { "line": 19, "column": 3 } }, "body": [ { "type": "ExpressionStatement", "start": 298, "end": 321, "loc": { "start": { "line": 13, "column": 4 }, "end": { "line": 13, "column": 27 } }, "expression": { "type": "CallExpression", "start": 298, "end": 320, "loc": { "start": { "line": 13, "column": 4 }, "end": { "line": 13, "column": 26 } }, "callee": { "type": "Super", "start": 298, "end": 303, "loc": { "start": { "line": 13, "column": 4 }, "end": { "line": 13, "column": 9 } } }, "arguments": [ { "type": "Identifier", "start": 304, "end": 308, "loc": { "start": { "line": 13, "column": 10 }, "end": { "line": 13, "column": 14 }, "identifierName": "http" }, "name": "http" }, { "type": "Identifier", "start": 310, "end": 319, "loc": { "start": { "line": 13, "column": 16 }, "end": { "line": 13, "column": 25 }, "identifierName": "territory" }, "name": "territory" } ] }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * @ignore\n ", "start": 327, "end": 353, "loc": { "start": { "line": 15, "column": 4 }, "end": { "line": 17, "column": 7 } } } ] }, { "type": "ExpressionStatement", "start": 358, "end": 384, "loc": { "start": { "line": 18, "column": 4 }, "end": { "line": 18, "column": 30 } }, "expression": { "type": "AssignmentExpression", "start": 358, "end": 383, "loc": { "start": { "line": 18, "column": 4 }, "end": { "line": 18, "column": 29 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 358, "end": 371, "loc": { "start": { "line": 18, "column": 4 }, "end": { "line": 18, "column": 17 } }, "object": { "type": "ThisExpression", "start": 358, "end": 362, "loc": { "start": { "line": 18, "column": 4 }, "end": { "line": 18, "column": 8 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 363, "end": 371, "loc": { "start": { "line": 18, "column": 9 }, "end": { "line": 18, "column": 17 }, "identifierName": "artistID" }, "name": "artistID" }, "computed": false, "leadingComments": null }, "right": { "type": "Identifier", "start": 374, "end": 383, "loc": { "start": { "line": 18, "column": 20 }, "end": { "line": 18, "column": 29 }, "identifierName": "undefined" }, "name": "undefined" }, "leadingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * @ignore\n ", "start": 327, "end": 353, "loc": { "start": { "line": 15, "column": 4 }, "end": { "line": 17, "column": 7 } } } ] } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * @ignore\n ", "start": 231, "end": 253, "loc": { "start": { "line": 9, "column": 2 }, "end": { "line": 11, "column": 5 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Init the artist object.\n *\n * @param {string} artistID - The ID of an artist.\n * @return {Artist}\n * @see https://docs-en.kkbox.codes/v1.1/reference#artists-artist_id\n ", "start": 392, "end": 581, "loc": { "start": { "line": 21, "column": 2 }, "end": { "line": 27, "column": 5 } } } ] }, { "type": "ClassMethod", "start": 584, "end": 658, "loc": { "start": { "line": 28, "column": 2 }, "end": { "line": 31, "column": 3 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 584, "end": 595, "loc": { "start": { "line": 28, "column": 2 }, "end": { "line": 28, "column": 13 }, "identifierName": "setArtistID" }, "name": "setArtistID", "leadingComments": null }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 596, "end": 604, "loc": { "start": { "line": 28, "column": 14 }, "end": { "line": 28, "column": 22 }, "identifierName": "artistID" }, "name": "artistID" } ], "body": { "type": "BlockStatement", "start": 606, "end": 658, "loc": { "start": { "line": 28, "column": 24 }, "end": { "line": 31, "column": 3 } }, "body": [ { "type": "ExpressionStatement", "start": 612, "end": 637, "loc": { "start": { "line": 29, "column": 4 }, "end": { "line": 29, "column": 29 } }, "expression": { "type": "AssignmentExpression", "start": 612, "end": 636, "loc": { "start": { "line": 29, "column": 4 }, "end": { "line": 29, "column": 28 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 612, "end": 625, "loc": { "start": { "line": 29, "column": 4 }, "end": { "line": 29, "column": 17 } }, "object": { "type": "ThisExpression", "start": 612, "end": 616, "loc": { "start": { "line": 29, "column": 4 }, "end": { "line": 29, "column": 8 } } }, "property": { "type": "Identifier", "start": 617, "end": 625, "loc": { "start": { "line": 29, "column": 9 }, "end": { "line": 29, "column": 17 }, "identifierName": "artistID" }, "name": "artistID" }, "computed": false }, "right": { "type": "Identifier", "start": 628, "end": 636, "loc": { "start": { "line": 29, "column": 20 }, "end": { "line": 29, "column": 28 }, "identifierName": "artistID" }, "name": "artistID" } } }, { "type": "ReturnStatement", "start": 642, "end": 654, "loc": { "start": { "line": 30, "column": 4 }, "end": { "line": 30, "column": 16 } }, "argument": { "type": "ThisExpression", "start": 649, "end": 653, "loc": { "start": { "line": 30, "column": 11 }, "end": { "line": 30, "column": 15 } } } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * Init the artist object.\n *\n * @param {string} artistID - The ID of an artist.\n * @return {Artist}\n * @see https://docs-en.kkbox.codes/v1.1/reference#artists-artist_id\n ", "start": 392, "end": 581, "loc": { "start": { "line": 21, "column": 2 }, "end": { "line": 27, "column": 5 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Fetch metadata of the artist you find.\n *\n * @return {Promise}\n * @example api.artistFetcher.setArtistID('Cnv_K6i5Ft4y41SxLy').fetchMetadata();\n * @see https://docs-en.kkbox.codes/v1.1/reference#artists-artist_id\n ", "start": 662, "end": 897, "loc": { "start": { "line": 33, "column": 2 }, "end": { "line": 39, "column": 5 } } } ] }, { "type": "ClassMethod", "start": 900, "end": 1020, "loc": { "start": { "line": 40, "column": 2 }, "end": { "line": 44, "column": 3 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 900, "end": 913, "loc": { "start": { "line": 40, "column": 2 }, "end": { "line": 40, "column": 15 }, "identifierName": "fetchMetadata" }, "name": "fetchMetadata", "leadingComments": null }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 916, "end": 1020, "loc": { "start": { "line": 40, "column": 18 }, "end": { "line": 44, "column": 3 } }, "body": [ { "type": "ReturnStatement", "start": 922, "end": 1016, "loc": { "start": { "line": 41, "column": 4 }, "end": { "line": 43, "column": 7 } }, "argument": { "type": "CallExpression", "start": 929, "end": 1015, "loc": { "start": { "line": 41, "column": 11 }, "end": { "line": 43, "column": 6 } }, "callee": { "type": "MemberExpression", "start": 929, "end": 942, "loc": { "start": { "line": 41, "column": 11 }, "end": { "line": 41, "column": 24 } }, "object": { "type": "MemberExpression", "start": 929, "end": 938, "loc": { "start": { "line": 41, "column": 11 }, "end": { "line": 41, "column": 20 } }, "object": { "type": "ThisExpression", "start": 929, "end": 933, "loc": { "start": { "line": 41, "column": 11 }, "end": { "line": 41, "column": 15 } } }, "property": { "type": "Identifier", "start": 934, "end": 938, "loc": { "start": { "line": 41, "column": 16 }, "end": { "line": 41, "column": 20 }, "identifierName": "http" }, "name": "http" }, "computed": false }, "property": { "type": "Identifier", "start": 939, "end": 942, "loc": { "start": { "line": 41, "column": 21 }, "end": { "line": 41, "column": 24 }, "identifierName": "get" }, "name": "get" }, "computed": false }, "arguments": [ { "type": "BinaryExpression", "start": 943, "end": 973, "loc": { "start": { "line": 41, "column": 25 }, "end": { "line": 41, "column": 55 } }, "left": { "type": "BinaryExpression", "start": 943, "end": 957, "loc": { "start": { "line": 41, "column": 25 }, "end": { "line": 41, "column": 39 } }, "left": { "type": "Identifier", "start": 943, "end": 951, "loc": { "start": { "line": 41, "column": 25 }, "end": { "line": 41, "column": 33 }, "identifierName": "ENDPOINT" }, "name": "ENDPOINT" }, "operator": "+", "right": { "type": "StringLiteral", "start": 954, "end": 957, "loc": { "start": { "line": 41, "column": 36 }, "end": { "line": 41, "column": 39 } }, "extra": { "rawValue": "/", "raw": "'/'" }, "value": "/" } }, "operator": "+", "right": { "type": "MemberExpression", "start": 960, "end": 973, "loc": { "start": { "line": 41, "column": 42 }, "end": { "line": 41, "column": 55 } }, "object": { "type": "ThisExpression", "start": 960, "end": 964, "loc": { "start": { "line": 41, "column": 42 }, "end": { "line": 41, "column": 46 } } }, "property": { "type": "Identifier", "start": 965, "end": 973, "loc": { "start": { "line": 41, "column": 47 }, "end": { "line": 41, "column": 55 }, "identifierName": "artistID" }, "name": "artistID" }, "computed": false } }, { "type": "ObjectExpression", "start": 975, "end": 1014, "loc": { "start": { "line": 41, "column": 57 }, "end": { "line": 43, "column": 5 } }, "properties": [ { "type": "ObjectProperty", "start": 983, "end": 1008, "loc": { "start": { "line": 42, "column": 6 }, "end": { "line": 42, "column": 31 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 983, "end": 992, "loc": { "start": { "line": 42, "column": 6 }, "end": { "line": 42, "column": 15 }, "identifierName": "territory" }, "name": "territory" }, "value": { "type": "MemberExpression", "start": 994, "end": 1008, "loc": { "start": { "line": 42, "column": 17 }, "end": { "line": 42, "column": 31 } }, "object": { "type": "ThisExpression", "start": 994, "end": 998, "loc": { "start": { "line": 42, "column": 17 }, "end": { "line": 42, "column": 21 } } }, "property": { "type": "Identifier", "start": 999, "end": 1008, "loc": { "start": { "line": 42, "column": 22 }, "end": { "line": 42, "column": 31 }, "identifierName": "territory" }, "name": "territory" }, "computed": false } } ] } ] } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * Fetch metadata of the artist you find.\n *\n * @return {Promise}\n * @example api.artistFetcher.setArtistID('Cnv_K6i5Ft4y41SxLy').fetchMetadata();\n * @see https://docs-en.kkbox.codes/v1.1/reference#artists-artist_id\n ", "start": 662, "end": 897, "loc": { "start": { "line": 33, "column": 2 }, "end": { "line": 39, "column": 5 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Fetch albums belong to an artist.\n *\n * @param {number} [limit] - The size for one page.\n * @param {number} [offset] - The offset index for first element.\n * @return {Promise}\n * @example api.artistFetcher.setArtistID('Cnv_K6i5Ft4y41SxLy').fetchAlbums();\n * @see https://docs-en.kkbox.codes/v1.1/reference#artists-artist_id-albums\n ", "start": 1024, "end": 1381, "loc": { "start": { "line": 46, "column": 2 }, "end": { "line": 54, "column": 5 } } } ] }, { "type": "ClassMethod", "start": 1384, "end": 1593, "loc": { "start": { "line": 55, "column": 2 }, "end": { "line": 61, "column": 3 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 1384, "end": 1395, "loc": { "start": { "line": 55, "column": 2 }, "end": { "line": 55, "column": 13 }, "identifierName": "fetchAlbums" }, "name": "fetchAlbums", "leadingComments": null }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "AssignmentPattern", "start": 1396, "end": 1413, "loc": { "start": { "line": 55, "column": 14 }, "end": { "line": 55, "column": 31 } }, "left": { "type": "Identifier", "start": 1396, "end": 1401, "loc": { "start": { "line": 55, "column": 14 }, "end": { "line": 55, "column": 19 }, "identifierName": "limit" }, "name": "limit" }, "right": { "type": "Identifier", "start": 1404, "end": 1413, "loc": { "start": { "line": 55, "column": 22 }, "end": { "line": 55, "column": 31 }, "identifierName": "undefined" }, "name": "undefined" } }, { "type": "AssignmentPattern", "start": 1415, "end": 1433, "loc": { "start": { "line": 55, "column": 33 }, "end": { "line": 55, "column": 51 } }, "left": { "type": "Identifier", "start": 1415, "end": 1421, "loc": { "start": { "line": 55, "column": 33 }, "end": { "line": 55, "column": 39 }, "identifierName": "offset" }, "name": "offset" }, "right": { "type": "Identifier", "start": 1424,