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,358 lines 129 kB
{ "type": "File", "start": 0, "end": 1196, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 48, "column": 1 } }, "program": { "type": "Program", "start": 0, "end": 1196, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 48, "column": 1 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 25, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 25 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 7, "end": 12, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 12 } }, "local": { "type": "Identifier", "start": 7, "end": 12, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 12 }, "identifierName": "axios" }, "name": "axios" } } ], "source": { "type": "StringLiteral", "start": 18, "end": 25, "loc": { "start": { "line": 1, "column": 18 }, "end": { "line": 1, "column": 25 } }, "extra": { "rawValue": "axios", "raw": "'axios'" }, "value": "axios" } }, { "type": "ImportDeclaration", "start": 26, "end": 64, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 38 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 34, "end": 42, "loc": { "start": { "line": 2, "column": 8 }, "end": { "line": 2, "column": 16 } }, "imported": { "type": "Identifier", "start": 34, "end": 42, "loc": { "start": { "line": 2, "column": 8 }, "end": { "line": 2, "column": 16 }, "identifierName": "apiError" }, "name": "apiError" }, "local": { "type": "Identifier", "start": 34, "end": 42, "loc": { "start": { "line": 2, "column": 8 }, "end": { "line": 2, "column": 16 }, "identifierName": "apiError" }, "name": "apiError" } } ], "source": { "type": "StringLiteral", "start": 49, "end": 64, "loc": { "start": { "line": 2, "column": 23 }, "end": { "line": 2, "column": 38 } }, "extra": { "rawValue": "../catchError", "raw": "'../catchError'" }, "value": "../catchError", "leadingComments": null, "trailingComments": null }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Do request to open api server with authorization header and error catch.\n ", "start": 66, "end": 149, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 6, "column": 3 } } } ] }, { "type": "ExportDefaultDeclaration", "start": 150, "end": 1196, "loc": { "start": { "line": 7, "column": 0 }, "end": { "line": 48, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 165, "end": 1196, "loc": { "start": { "line": 7, "column": 15 }, "end": { "line": 48, "column": 1 } }, "id": { "type": "Identifier", "start": 171, "end": 175, "loc": { "start": { "line": 7, "column": 21 }, "end": { "line": 7, "column": 25 }, "identifierName": "Http" }, "name": "Http", "leadingComments": null }, "superClass": null, "body": { "type": "ClassBody", "start": 176, "end": 1196, "loc": { "start": { "line": 7, "column": 26 }, "end": { "line": 48, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 262, "end": 397, "loc": { "start": { "line": 11, "column": 4 }, "end": { "line": 17, "column": 5 } }, "computed": false, "key": { "type": "Identifier", "start": 262, "end": 273, "loc": { "start": { "line": 11, "column": 4 }, "end": { "line": 11, "column": 15 }, "identifierName": "constructor" }, "name": "constructor", "leadingComments": null }, "static": false, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 274, "end": 279, "loc": { "start": { "line": 11, "column": 16 }, "end": { "line": 11, "column": 21 }, "identifierName": "token" }, "name": "token" } ], "body": { "type": "BlockStatement", "start": 281, "end": 397, "loc": { "start": { "line": 11, "column": 23 }, "end": { "line": 17, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 361, "end": 391, "loc": { "start": { "line": 16, "column": 8 }, "end": { "line": 16, "column": 38 } }, "expression": { "type": "AssignmentExpression", "start": 361, "end": 391, "loc": { "start": { "line": 16, "column": 8 }, "end": { "line": 16, "column": 38 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 361, "end": 371, "loc": { "start": { "line": 16, "column": 8 }, "end": { "line": 16, "column": 18 } }, "object": { "type": "ThisExpression", "start": 361, "end": 365, "loc": { "start": { "line": 16, "column": 8 }, "end": { "line": 16, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 366, "end": 371, "loc": { "start": { "line": 16, "column": 13 }, "end": { "line": 16, "column": 18 }, "identifierName": "token" }, "name": "token" }, "computed": false, "leadingComments": null }, "right": { "type": "BinaryExpression", "start": 374, "end": 391, "loc": { "start": { "line": 16, "column": 21 }, "end": { "line": 16, "column": 38 } }, "left": { "type": "StringLiteral", "start": 374, "end": 383, "loc": { "start": { "line": 16, "column": 21 }, "end": { "line": 16, "column": 30 } }, "extra": { "rawValue": "Bearer ", "raw": "'Bearer '" }, "value": "Bearer " }, "operator": "+", "right": { "type": "Identifier", "start": 386, "end": 391, "loc": { "start": { "line": 16, "column": 33 }, "end": { "line": 16, "column": 38 }, "identifierName": "token" }, "name": "token" } }, "leadingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * @private\n * @type {string}\n ", "start": 291, "end": 352, "loc": { "start": { "line": 12, "column": 8 }, "end": { "line": 15, "column": 11 } } } ] } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * @param {string} token - Need access token to initialize.\n ", "start": 182, "end": 257, "loc": { "start": { "line": 8, "column": 4 }, "end": { "line": 10, "column": 7 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Http get method.\n *\n * @param {string} endpoint - Uri endpoint.\n * @param {object} params - Uri parameters.\n * @return {Promise}\n ", "start": 403, "end": 566, "loc": { "start": { "line": 19, "column": 4 }, "end": { "line": 25, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 571, "end": 784, "loc": { "start": { "line": 26, "column": 4 }, "end": { "line": 31, "column": 5 } }, "computed": false, "key": { "type": "Identifier", "start": 571, "end": 574, "loc": { "start": { "line": 26, "column": 4 }, "end": { "line": 26, "column": 7 }, "identifierName": "get" }, "name": "get", "leadingComments": null }, "static": false, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 575, "end": 583, "loc": { "start": { "line": 26, "column": 8 }, "end": { "line": 26, "column": 16 }, "identifierName": "endpoint" }, "name": "endpoint" }, { "type": "AssignmentPattern", "start": 585, "end": 596, "loc": { "start": { "line": 26, "column": 18 }, "end": { "line": 26, "column": 29 } }, "left": { "type": "Identifier", "start": 585, "end": 591, "loc": { "start": { "line": 26, "column": 18 }, "end": { "line": 26, "column": 24 }, "identifierName": "params" }, "name": "params" }, "right": { "type": "ObjectExpression", "start": 594, "end": 596, "loc": { "start": { "line": 26, "column": 27 }, "end": { "line": 26, "column": 29 } }, "properties": [] } } ], "body": { "type": "BlockStatement", "start": 598, "end": 784, "loc": { "start": { "line": 26, "column": 31 }, "end": { "line": 31, "column": 5 } }, "body": [ { "type": "ReturnStatement", "start": 608, "end": 778, "loc": { "start": { "line": 27, "column": 8 }, "end": { "line": 30, "column": 26 } }, "argument": { "type": "CallExpression", "start": 615, "end": 778, "loc": { "start": { "line": 27, "column": 15 }, "end": { "line": 30, "column": 26 } }, "callee": { "type": "MemberExpression", "start": 615, "end": 768, "loc": { "start": { "line": 27, "column": 15 }, "end": { "line": 30, "column": 16 } }, "object": { "type": "CallExpression", "start": 615, "end": 762, "loc": { "start": { "line": 27, "column": 15 }, "end": { "line": 30, "column": 10 } }, "callee": { "type": "MemberExpression", "start": 615, "end": 624, "loc": { "start": { "line": 27, "column": 15 }, "end": { "line": 27, "column": 24 } }, "object": { "type": "Identifier", "start": 615, "end": 620, "loc": { "start": { "line": 27, "column": 15 }, "end": { "line": 27, "column": 20 }, "identifierName": "axios" }, "name": "axios" }, "property": { "type": "Identifier", "start": 621, "end": 624, "loc": { "start": { "line": 27, "column": 21 }, "end": { "line": 27, "column": 24 }, "identifierName": "get" }, "name": "get" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 625, "end": 633, "loc": { "start": { "line": 27, "column": 25 }, "end": { "line": 27, "column": 33 }, "identifierName": "endpoint" }, "name": "endpoint" }, { "type": "ObjectExpression", "start": 635, "end": 761, "loc": { "start": { "line": 27, "column": 35 }, "end": { "line": 30, "column": 9 } }, "properties": [ { "type": "ObjectProperty", "start": 649, "end": 663, "loc": { "start": { "line": 28, "column": 12 }, "end": { "line": 28, "column": 26 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 649, "end": 655, "loc": { "start": { "line": 28, "column": 12 }, "end": { "line": 28, "column": 18 }, "identifierName": "params" }, "name": "params" }, "value": { "type": "Identifier", "start": 657, "end": 663, "loc": { "start": { "line": 28, "column": 20 }, "end": { "line": 28, "column": 26 }, "identifierName": "params" }, "name": "params" } }, { "type": "ObjectProperty", "start": 677, "end": 751, "loc": { "start": { "line": 29, "column": 12 }, "end": { "line": 29, "column": 86 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 677, "end": 684, "loc": { "start": { "line": 29, "column": 12 }, "end": { "line": 29, "column": 19 }, "identifierName": "headers" }, "name": "headers" }, "value": { "type": "ObjectExpression", "start": 686, "end": 751, "loc": { "start": { "line": 29, "column": 21 }, "end": { "line": 29, "column": 86 } }, "properties": [ { "type": "ObjectProperty", "start": 687, "end": 712, "loc": { "start": { "line": 29, "column": 22 }, "end": { "line": 29, "column": 47 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 687, "end": 700, "loc": { "start": { "line": 29, "column": 22 }, "end": { "line": 29, "column": 35 }, "identifierName": "Authorization" }, "name": "Authorization" }, "value": { "type": "MemberExpression", "start": 702, "end": 712, "loc": { "start": { "line": 29, "column": 37 }, "end": { "line": 29, "column": 47 } }, "object": { "type": "ThisExpression", "start": 702, "end": 706, "loc": { "start": { "line": 29, "column": 37 }, "end": { "line": 29, "column": 41 } } }, "property": { "type": "Identifier", "start": 707, "end": 712, "loc": { "start": { "line": 29, "column": 42 }, "end": { "line": 29, "column": 47 }, "identifierName": "token" }, "name": "token" }, "computed": false } }, { "type": "ObjectProperty", "start": 714, "end": 750, "loc": { "start": { "line": 29, "column": 49 }, "end": { "line": 29, "column": 85 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "StringLiteral", "start": 714, "end": 726, "loc": { "start": { "line": 29, "column": 49 }, "end": { "line": 29, "column": 61 } }, "extra": { "rawValue": "User-Agent", "raw": "'User-Agent'" }, "value": "User-Agent" }, "value": { "type": "StringLiteral", "start": 728, "end": 750, "loc": { "start": { "line": 29, "column": 63 }, "end": { "line": 29, "column": 85 } }, "extra": { "rawValue": "KKBOX JavaScript SDK", "raw": "'KKBOX JavaScript SDK'" }, "value": "KKBOX JavaScript SDK" } } ] } } ] } ] }, "property": { "type": "Identifier", "start": 763, "end": 768, "loc": { "start": { "line": 30, "column": 11 }, "end": { "line": 30, "column": 16 }, "identifierName": "catch" }, "name": "catch" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 769, "end": 777, "loc": { "start": { "line": 30, "column": 17 }, "end": { "line": 30, "column": 25 }, "identifierName": "apiError" }, "name": "apiError" } ] } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * Http get method.\n *\n * @param {string} endpoint - Uri endpoint.\n * @param {object} params - Uri parameters.\n * @return {Promise}\n ", "start": 403, "end": 566, "loc": { "start": { "line": 19, "column": 4 }, "end": { "line": 25, "column": 7 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Http post method.\n *\n * @param {string} endpoint - Uri endpoint.\n * @param {object} data - Body json data.\n * @return {Promise}\n ", "start": 790, "end": 952, "loc": { "start": { "line": 33, "column": 4 }, "end": { "line": 39, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 957, "end": 1194, "loc": { "start": { "line": 40, "column": 4 }, "end": { "line": 47, "column": 5 } }, "computed": false, "key": { "type": "Identifier", "start": 957, "end": 961, "loc": { "start": { "line": 40, "column": 4 }, "end": { "line": 40, "column": 8 }, "identifierName": "post" }, "name": "post", "leadingComments": null }, "static": false, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 962, "end": 970, "loc": { "start": { "line": 40, "column": 9 }, "end": { "line": 40, "column": 17 }, "identifierName": "endpoint" }, "name": "endpoint" }, { "type": "AssignmentPattern", "start": 972, "end": 981, "loc": { "start": { "line": 40, "column": 19 }, "end": { "line": 40, "column": 28 } }, "left": { "type": "Identifier", "start": 972, "end": 976, "loc": { "start": { "line": 40, "column": 19 }, "end": { "line": 40, "column": 23 }, "identifierName": "data" }, "name": "data" }, "right": { "type": "ObjectExpression", "start": 979, "end": 981, "loc": { "start": { "line": 40, "column": 26 }, "end": { "line": 40, "column": 28 } }, "properties": [] } } ], "body": { "type": "BlockStatement", "start": 983, "end": 1194, "loc": { "start": { "line": 40, "column": 30 }, "end": { "line": 47, "column": 5 } }, "body": [ { "type": "ReturnStatement", "start": 993, "end": 1188, "loc": { "start": { "line": 41, "column": 8 }, "end": { "line": 46, "column": 26 } }, "argument": { "type": "CallExpression", "start": 1000, "end": 1188, "loc": { "start": { "line": 41, "column": 15 }, "end": { "line": 46, "column": 26 } }, "callee": { "type": "MemberExpression", "start": 1000, "end": 1178, "loc": { "start": { "line": 41, "column": 15 }, "end": { "line": 46, "column": 16 } }, "object": { "type": "CallExpression", "start": 1000, "end": 1172, "loc": { "start": { "line": 41, "column": 15 }, "end": { "line": 46, "column": 10 } }, "callee": { "type": "MemberExpression", "start": 1000, "end": 1010, "loc": { "start": { "line": 41, "column": 15 }, "end": { "line": 41, "column": 25 } }, "object": { "type": "Identifier", "start": 1000, "end": 1005, "loc": { "start": { "line": 41, "column": 15 }, "end": { "line": 41, "column": 20 }, "identifierName": "axios" }, "name": "axios" }, "property": { "type": "Identifier", "start": 1006, "end": 1010, "loc": { "start": { "line": 41, "column": 21 }, "end": { "line": 41, "column": 25 }, "identifierName": "post" }, "name": "post" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 1011, "end": 1019, "loc": { "