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,372 lines (1,371 loc) 120 kB
{ "type": "File", "start": 0, "end": 1066, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 54, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 1066, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 54, "column": 0 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 26, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 26 } }, "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": 27, "end": 68, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 41 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 36, "end": 44, "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 17 } }, "imported": { "type": "Identifier", "start": 36, "end": 44, "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 17 }, "identifierName": "apiError" }, "name": "apiError" }, "local": { "type": "Identifier", "start": 36, "end": 44, "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 17 }, "identifierName": "apiError" }, "name": "apiError" } } ], "source": { "type": "StringLiteral", "start": 52, "end": 67, "loc": { "start": { "line": 2, "column": 25 }, "end": { "line": 2, "column": 40 } }, "extra": { "rawValue": "../catchError", "raw": "'../catchError'" }, "value": "../catchError" }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Do request to open api server with authorization header and error catch.\n ", "start": 70, "end": 153, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 6, "column": 3 } } } ] }, { "type": "ExportDefaultDeclaration", "start": 154, "end": 1065, "loc": { "start": { "line": 7, "column": 0 }, "end": { "line": 53, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 169, "end": 1065, "loc": { "start": { "line": 7, "column": 15 }, "end": { "line": 53, "column": 1 } }, "id": { "type": "Identifier", "start": 175, "end": 185, "loc": { "start": { "line": 7, "column": 21 }, "end": { "line": 7, "column": 31 }, "identifierName": "HttpClient" }, "name": "HttpClient", "leadingComments": null }, "superClass": null, "body": { "type": "ClassBody", "start": 186, "end": 1065, "loc": { "start": { "line": 7, "column": 32 }, "end": { "line": 53, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 264, "end": 378, "loc": { "start": { "line": 11, "column": 2 }, "end": { "line": 17, "column": 3 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 264, "end": 275, "loc": { "start": { "line": 11, "column": 2 }, "end": { "line": 11, "column": 13 }, "identifierName": "constructor" }, "name": "constructor", "leadingComments": null }, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 276, "end": 281, "loc": { "start": { "line": 11, "column": 14 }, "end": { "line": 11, "column": 19 }, "identifierName": "token" }, "name": "token" } ], "body": { "type": "BlockStatement", "start": 283, "end": 378, "loc": { "start": { "line": 11, "column": 21 }, "end": { "line": 17, "column": 3 } }, "body": [ { "type": "ExpressionStatement", "start": 343, "end": 374, "loc": { "start": { "line": 16, "column": 4 }, "end": { "line": 16, "column": 35 } }, "expression": { "type": "AssignmentExpression", "start": 343, "end": 373, "loc": { "start": { "line": 16, "column": 4 }, "end": { "line": 16, "column": 34 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 343, "end": 353, "loc": { "start": { "line": 16, "column": 4 }, "end": { "line": 16, "column": 14 } }, "object": { "type": "ThisExpression", "start": 343, "end": 347, "loc": { "start": { "line": 16, "column": 4 }, "end": { "line": 16, "column": 8 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 348, "end": 353, "loc": { "start": { "line": 16, "column": 9 }, "end": { "line": 16, "column": 14 }, "identifierName": "token" }, "name": "token" }, "computed": false, "leadingComments": null }, "right": { "type": "BinaryExpression", "start": 356, "end": 373, "loc": { "start": { "line": 16, "column": 17 }, "end": { "line": 16, "column": 34 } }, "left": { "type": "StringLiteral", "start": 356, "end": 365, "loc": { "start": { "line": 16, "column": 17 }, "end": { "line": 16, "column": 26 } }, "extra": { "rawValue": "Bearer ", "raw": "'Bearer '" }, "value": "Bearer " }, "operator": "+", "right": { "type": "Identifier", "start": 368, "end": 373, "loc": { "start": { "line": 16, "column": 29 }, "end": { "line": 16, "column": 34 }, "identifierName": "token" }, "name": "token" } }, "leadingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * @private\n * @type {string}\n ", "start": 289, "end": 338, "loc": { "start": { "line": 12, "column": 4 }, "end": { "line": 15, "column": 7 } } } ] } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * @param {string} token - Need access token to initialize.\n ", "start": 190, "end": 261, "loc": { "start": { "line": 8, "column": 2 }, "end": { "line": 10, "column": 5 } } } ], "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": 382, "end": 533, "loc": { "start": { "line": 19, "column": 2 }, "end": { "line": 25, "column": 5 } } } ] }, { "type": "ClassMethod", "start": 536, "end": 730, "loc": { "start": { "line": 26, "column": 2 }, "end": { "line": 35, "column": 3 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 536, "end": 539, "loc": { "start": { "line": 26, "column": 2 }, "end": { "line": 26, "column": 5 }, "identifierName": "get" }, "name": "get", "leadingComments": null }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 540, "end": 548, "loc": { "start": { "line": 26, "column": 6 }, "end": { "line": 26, "column": 14 }, "identifierName": "endpoint" }, "name": "endpoint" }, { "type": "AssignmentPattern", "start": 550, "end": 561, "loc": { "start": { "line": 26, "column": 16 }, "end": { "line": 26, "column": 27 } }, "left": { "type": "Identifier", "start": 550, "end": 556, "loc": { "start": { "line": 26, "column": 16 }, "end": { "line": 26, "column": 22 }, "identifierName": "params" }, "name": "params" }, "right": { "type": "ObjectExpression", "start": 559, "end": 561, "loc": { "start": { "line": 26, "column": 25 }, "end": { "line": 26, "column": 27 } }, "properties": [] } } ], "body": { "type": "BlockStatement", "start": 563, "end": 730, "loc": { "start": { "line": 26, "column": 29 }, "end": { "line": 35, "column": 3 } }, "body": [ { "type": "ReturnStatement", "start": 569, "end": 726, "loc": { "start": { "line": 27, "column": 4 }, "end": { "line": 34, "column": 23 } }, "argument": { "type": "CallExpression", "start": 576, "end": 725, "loc": { "start": { "line": 27, "column": 11 }, "end": { "line": 34, "column": 22 } }, "callee": { "type": "MemberExpression", "start": 576, "end": 715, "loc": { "start": { "line": 27, "column": 11 }, "end": { "line": 34, "column": 12 } }, "object": { "type": "CallExpression", "start": 576, "end": 702, "loc": { "start": { "line": 27, "column": 11 }, "end": { "line": 33, "column": 8 } }, "callee": { "type": "MemberExpression", "start": 576, "end": 592, "loc": { "start": { "line": 27, "column": 11 }, "end": { "line": 28, "column": 10 } }, "object": { "type": "Identifier", "start": 576, "end": 581, "loc": { "start": { "line": 27, "column": 11 }, "end": { "line": 27, "column": 16 }, "identifierName": "axios" }, "name": "axios" }, "property": { "type": "Identifier", "start": 589, "end": 592, "loc": { "start": { "line": 28, "column": 7 }, "end": { "line": 28, "column": 10 }, "identifierName": "get" }, "name": "get" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 593, "end": 601, "loc": { "start": { "line": 28, "column": 11 }, "end": { "line": 28, "column": 19 }, "identifierName": "endpoint" }, "name": "endpoint" }, { "type": "ObjectExpression", "start": 603, "end": 701, "loc": { "start": { "line": 28, "column": 21 }, "end": { "line": 33, "column": 7 } }, "properties": [ { "type": "ObjectProperty", "start": 613, "end": 627, "loc": { "start": { "line": 29, "column": 8 }, "end": { "line": 29, "column": 22 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 613, "end": 619, "loc": { "start": { "line": 29, "column": 8 }, "end": { "line": 29, "column": 14 }, "identifierName": "params" }, "name": "params" }, "value": { "type": "Identifier", "start": 621, "end": 627, "loc": { "start": { "line": 29, "column": 16 }, "end": { "line": 29, "column": 22 }, "identifierName": "params" }, "name": "params" } }, { "type": "ObjectProperty", "start": 637, "end": 693, "loc": { "start": { "line": 30, "column": 8 }, "end": { "line": 32, "column": 9 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 637, "end": 644, "loc": { "start": { "line": 30, "column": 8 }, "end": { "line": 30, "column": 15 }, "identifierName": "headers" }, "name": "headers" }, "value": { "type": "ObjectExpression", "start": 646, "end": 693, "loc": { "start": { "line": 30, "column": 17 }, "end": { "line": 32, "column": 9 } }, "properties": [ { "type": "ObjectProperty", "start": 658, "end": 683, "loc": { "start": { "line": 31, "column": 10 }, "end": { "line": 31, "column": 35 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 658, "end": 671, "loc": { "start": { "line": 31, "column": 10 }, "end": { "line": 31, "column": 23 }, "identifierName": "Authorization" }, "name": "Authorization" }, "value": { "type": "MemberExpression", "start": 673, "end": 683, "loc": { "start": { "line": 31, "column": 25 }, "end": { "line": 31, "column": 35 } }, "object": { "type": "ThisExpression", "start": 673, "end": 677, "loc": { "start": { "line": 31, "column": 25 }, "end": { "line": 31, "column": 29 } } }, "property": { "type": "Identifier", "start": 678, "end": 683, "loc": { "start": { "line": 31, "column": 30 }, "end": { "line": 31, "column": 35 }, "identifierName": "token" }, "name": "token" }, "computed": false } } ] } } ] } ] }, "property": { "type": "Identifier", "start": 710, "end": 715, "loc": { "start": { "line": 34, "column": 7 }, "end": { "line": 34, "column": 12 }, "identifierName": "catch" }, "name": "catch" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 716, "end": 724, "loc": { "start": { "line": 34, "column": 13 }, "end": { "line": 34, "column": 21 }, "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": 382, "end": 533, "loc": { "start": { "line": 19, "column": 2 }, "end": { "line": 25, "column": 5 } } } ], "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": 734, "end": 884, "loc": { "start": { "line": 37, "column": 2 }, "end": { "line": 43, "column": 5 } } } ] }, { "type": "ClassMethod", "start": 887, "end": 1063, "loc": { "start": { "line": 44, "column": 2 }, "end": { "line": 52, "column": 3 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 887, "end": 891, "loc": { "start": { "line": 44, "column": 2 }, "end": { "line": 44, "column": 6 }, "identifierName": "post" }, "name": "post", "leadingComments": null }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 892, "end": 900, "loc": { "start": { "line": 44, "column": 7 }, "end": { "line": 44, "column": 15 }, "identifierName": "endpoint" }, "name": "endpoint" }, { "type": "AssignmentPattern", "start": 902, "end": 911, "loc": { "start": { "line": 44, "column": 17 }, "end": { "line": 44, "column": 26 } }, "left": { "type": "Identifier", "start": 902, "end": 906, "loc": { "start": { "line": 44, "column": 17 }, "end": { "line": 44, "column": 21 }, "identifierName": "data" }, "name": "data" }, "right": { "type": "ObjectExpression", "start": 909, "end": 911, "loc": { "start": { "line": 44, "column": 24 }, "end": { "line": 44, "column": 26 } }, "properties": [] } } ], "body": { "type": "BlockStatement", "start": 913, "end": 1063, "loc": { "start": { "line": 44, "column": 28 }, "end": { "line": 52, "column": 3 } }, "body": [ { "type": "ReturnStatement", "start": 919, "end": 1059, "loc": { "start": { "line": 45, "column": 4 }, "end": { "line": 51, "column": 23 } }, "argument": { "type": "CallExpression", "start": 926, "end": 1058, "loc": { "start": { "line": 45, "column": 11 }, "end": { "line": 51, "column": 22 } }, "callee": { "type": "MemberExpression", "start": 926, "end": 1048, "loc": { "start": { "line": 45, "column": 11 }, "end": { "line": 51, "column": 12 } }, "object": { "type": "CallExpression", "start": 926, "end": 1035, "loc": { "start": { "line": 45, "column": 11 }, "end": { "line": 50, "column": 8 } }, "callee": { "type": "MemberExpression", "start": 926, "end": 943, "loc": { "start": { "line": 45, "column": 11 }, "end": { "line": 46, "column": 11 } }, "object": { "type": "Identifier", "start": 926, "end": 931, "loc": { "start": { "line": 45, "column": 11 }, "end": { "line": 45, "column": 16 }, "identifierName": "axios" }, "name": "axios" }, "property": { "type": "Identifier", "start": 939, "end": 943, "loc": { "start": { "line": 46, "column": 7 }, "end": { "line": 46, "column": 11 }, "identifierName": "post" }, "name": "post" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 944, "end": 952, "loc": { "start": { "line": 46, "column": 12 }, "end": { "line": 46, "column": 20 }, "identifierName": "endpoint" }, "name": "endpoint" }, { "type": "Identifier", "start": 954, "end": 958, "loc": { "start": { "line": 46, "column": 22 }, "end": { "line": 46, "column": 26 }, "identifierName": "data" }, "name": "data" }, { "type": "ObjectExpression", "start": 960, "end": 1034, "loc": { "start": { "line": 46, "column": 28 }, "end": { "line": 50, "column": 7 } }, "properties": [ { "type": "ObjectProperty", "start": 970, "end": 1026, "loc": { "start": { "line": 47, "column": 8 }, "end": { "line": 49, "column": 9 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 970, "end": 977, "loc": { "start": { "line": 47, "column": 8 }, "end": { "line": 47, "column": 15 },