@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 (1,357 loc) • 129 kB
JSON
{
"type": "File",
"start": 0,
"end": 1202,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 48,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 1202,
"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": 1202,
"loc": {
"start": {
"line": 7,
"column": 0
},
"end": {
"line": 48,
"column": 1
}
},
"declaration": {
"type": "ClassDeclaration",
"start": 165,
"end": 1202,
"loc": {
"start": {
"line": 7,
"column": 15
},
"end": {
"line": 48,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 171,
"end": 181,
"loc": {
"start": {
"line": 7,
"column": 21
},
"end": {
"line": 7,
"column": 31
},
"identifierName": "HttpClient"
},
"name": "HttpClient",
"leadingComments": null
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 182,
"end": 1202,
"loc": {
"start": {
"line": 7,
"column": 32
},
"end": {
"line": 48,
"column": 1
}
},
"body": [
{
"type": "ClassMethod",
"start": 268,
"end": 403,
"loc": {
"start": {
"line": 11,
"column": 4
},
"end": {
"line": 17,
"column": 5
}
},
"computed": false,
"key": {
"type": "Identifier",
"start": 268,
"end": 279,
"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": 280,
"end": 285,
"loc": {
"start": {
"line": 11,
"column": 16
},
"end": {
"line": 11,
"column": 21
},
"identifierName": "token"
},
"name": "token"
}
],
"body": {
"type": "BlockStatement",
"start": 287,
"end": 403,
"loc": {
"start": {
"line": 11,
"column": 23
},
"end": {
"line": 17,
"column": 5
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 367,
"end": 397,
"loc": {
"start": {
"line": 16,
"column": 8
},
"end": {
"line": 16,
"column": 38
}
},
"expression": {
"type": "AssignmentExpression",
"start": 367,
"end": 397,
"loc": {
"start": {
"line": 16,
"column": 8
},
"end": {
"line": 16,
"column": 38
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 367,
"end": 377,
"loc": {
"start": {
"line": 16,
"column": 8
},
"end": {
"line": 16,
"column": 18
}
},
"object": {
"type": "ThisExpression",
"start": 367,
"end": 371,
"loc": {
"start": {
"line": 16,
"column": 8
},
"end": {
"line": 16,
"column": 12
}
},
"leadingComments": null
},
"property": {
"type": "Identifier",
"start": 372,
"end": 377,
"loc": {
"start": {
"line": 16,
"column": 13
},
"end": {
"line": 16,
"column": 18
},
"identifierName": "token"
},
"name": "token"
},
"computed": false,
"leadingComments": null
},
"right": {
"type": "BinaryExpression",
"start": 380,
"end": 397,
"loc": {
"start": {
"line": 16,
"column": 21
},
"end": {
"line": 16,
"column": 38
}
},
"left": {
"type": "StringLiteral",
"start": 380,
"end": 389,
"loc": {
"start": {
"line": 16,
"column": 21
},
"end": {
"line": 16,
"column": 30
}
},
"extra": {
"rawValue": "Bearer ",
"raw": "'Bearer '"
},
"value": "Bearer "
},
"operator": "+",
"right": {
"type": "Identifier",
"start": 392,
"end": 397,
"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": 297,
"end": 358,
"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": 188,
"end": 263,
"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": 409,
"end": 572,
"loc": {
"start": {
"line": 19,
"column": 4
},
"end": {
"line": 25,
"column": 7
}
}
}
]
},
{
"type": "ClassMethod",
"start": 577,
"end": 790,
"loc": {
"start": {
"line": 26,
"column": 4
},
"end": {
"line": 31,
"column": 5
}
},
"computed": false,
"key": {
"type": "Identifier",
"start": 577,
"end": 580,
"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": 581,
"end": 589,
"loc": {
"start": {
"line": 26,
"column": 8
},
"end": {
"line": 26,
"column": 16
},
"identifierName": "endpoint"
},
"name": "endpoint"
},
{
"type": "AssignmentPattern",
"start": 591,
"end": 602,
"loc": {
"start": {
"line": 26,
"column": 18
},
"end": {
"line": 26,
"column": 29
}
},
"left": {
"type": "Identifier",
"start": 591,
"end": 597,
"loc": {
"start": {
"line": 26,
"column": 18
},
"end": {
"line": 26,
"column": 24
},
"identifierName": "params"
},
"name": "params"
},
"right": {
"type": "ObjectExpression",
"start": 600,
"end": 602,
"loc": {
"start": {
"line": 26,
"column": 27
},
"end": {
"line": 26,
"column": 29
}
},
"properties": []
}
}
],
"body": {
"type": "BlockStatement",
"start": 604,
"end": 790,
"loc": {
"start": {
"line": 26,
"column": 31
},
"end": {
"line": 31,
"column": 5
}
},
"body": [
{
"type": "ReturnStatement",
"start": 614,
"end": 784,
"loc": {
"start": {
"line": 27,
"column": 8
},
"end": {
"line": 30,
"column": 26
}
},
"argument": {
"type": "CallExpression",
"start": 621,
"end": 784,
"loc": {
"start": {
"line": 27,
"column": 15
},
"end": {
"line": 30,
"column": 26
}
},
"callee": {
"type": "MemberExpression",
"start": 621,
"end": 774,
"loc": {
"start": {
"line": 27,
"column": 15
},
"end": {
"line": 30,
"column": 16
}
},
"object": {
"type": "CallExpression",
"start": 621,
"end": 768,
"loc": {
"start": {
"line": 27,
"column": 15
},
"end": {
"line": 30,
"column": 10
}
},
"callee": {
"type": "MemberExpression",
"start": 621,
"end": 630,
"loc": {
"start": {
"line": 27,
"column": 15
},
"end": {
"line": 27,
"column": 24
}
},
"object": {
"type": "Identifier",
"start": 621,
"end": 626,
"loc": {
"start": {
"line": 27,
"column": 15
},
"end": {
"line": 27,
"column": 20
},
"identifierName": "axios"
},
"name": "axios"
},
"property": {
"type": "Identifier",
"start": 627,
"end": 630,
"loc": {
"start": {
"line": 27,
"column": 21
},
"end": {
"line": 27,
"column": 24
},
"identifierName": "get"
},
"name": "get"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 631,
"end": 639,
"loc": {
"start": {
"line": 27,
"column": 25
},
"end": {
"line": 27,
"column": 33
},
"identifierName": "endpoint"
},
"name": "endpoint"
},
{
"type": "ObjectExpression",
"start": 641,
"end": 767,
"loc": {
"start": {
"line": 27,
"column": 35
},
"end": {
"line": 30,
"column": 9
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 655,
"end": 669,
"loc": {
"start": {
"line": 28,
"column": 12
},
"end": {
"line": 28,
"column": 26
}
},
"method": false,
"shorthand": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 655,
"end": 661,
"loc": {
"start": {
"line": 28,
"column": 12
},
"end": {
"line": 28,
"column": 18
},
"identifierName": "params"
},
"name": "params"
},
"value": {
"type": "Identifier",
"start": 663,
"end": 669,
"loc": {
"start": {
"line": 28,
"column": 20
},
"end": {
"line": 28,
"column": 26
},
"identifierName": "params"
},
"name": "params"
}
},
{
"type": "ObjectProperty",
"start": 683,
"end": 757,
"loc": {
"start": {
"line": 29,
"column": 12
},
"end": {
"line": 29,
"column": 86
}
},
"method": false,
"shorthand": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 683,
"end": 690,
"loc": {
"start": {
"line": 29,
"column": 12
},
"end": {
"line": 29,
"column": 19
},
"identifierName": "headers"
},
"name": "headers"
},
"value": {
"type": "ObjectExpression",
"start": 692,
"end": 757,
"loc": {
"start": {
"line": 29,
"column": 21
},
"end": {
"line": 29,
"column": 86
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 693,
"end": 718,
"loc": {
"start": {
"line": 29,
"column": 22
},
"end": {
"line": 29,
"column": 47
}
},
"method": false,
"shorthand": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 693,
"end": 706,
"loc": {
"start": {
"line": 29,
"column": 22
},
"end": {
"line": 29,
"column": 35
},
"identifierName": "Authorization"
},
"name": "Authorization"
},
"value": {
"type": "MemberExpression",
"start": 708,
"end": 718,
"loc": {
"start": {
"line": 29,
"column": 37
},
"end": {
"line": 29,
"column": 47
}
},
"object": {
"type": "ThisExpression",
"start": 708,
"end": 712,
"loc": {
"start": {
"line": 29,
"column": 37
},
"end": {
"line": 29,
"column": 41
}
}
},
"property": {
"type": "Identifier",
"start": 713,
"end": 718,
"loc": {
"start": {
"line": 29,
"column": 42
},
"end": {
"line": 29,
"column": 47
},
"identifierName": "token"
},
"name": "token"
},
"computed": false
}
},
{
"type": "ObjectProperty",
"start": 720,
"end": 756,
"loc": {
"start": {
"line": 29,
"column": 49
},
"end": {
"line": 29,
"column": 85
}
},
"method": false,
"shorthand": false,
"computed": false,
"key": {
"type": "StringLiteral",
"start": 720,
"end": 732,
"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": 734,
"end": 756,
"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": 769,
"end": 774,
"loc": {
"start": {
"line": 30,
"column": 11
},
"end": {
"line": 30,
"column": 16
},
"identifierName": "catch"
},
"name": "catch"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 775,
"end": 783,
"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": 409,
"end": 572,
"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": 796,
"end": 958,
"loc": {
"start": {
"line": 33,
"column": 4
},
"end": {
"line": 39,
"column": 7
}
}
}
]
},
{
"type": "ClassMethod",
"start": 963,
"end": 1200,
"loc": {
"start": {
"line": 40,
"column": 4
},
"end": {
"line": 47,
"column": 5
}
},
"computed": false,
"key": {
"type": "Identifier",
"start": 963,
"end": 967,
"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": 968,
"end": 976,
"loc": {
"start": {
"line": 40,
"column": 9
},
"end": {
"line": 40,
"column": 17
},
"identifierName": "endpoint"
},
"name": "endpoint"
},
{
"type": "AssignmentPattern",
"start": 978,
"end": 987,
"loc": {
"start": {
"line": 40,
"column": 19
},
"end": {
"line": 40,
"column": 28
}
},
"left": {
"type": "Identifier",
"start": 978,
"end": 982,
"loc": {
"start": {
"line": 40,
"column": 19
},
"end": {
"line": 40,
"column": 23
},
"identifierName": "data"
},
"name": "data"
},
"right": {
"type": "ObjectExpression",
"start": 985,
"end": 987,
"loc": {
"start": {
"line": 40,
"column": 26
},
"end": {
"line": 40,
"column": 28
}
},
"properties": []
}
}
],
"body": {
"type": "BlockStatement",
"start": 989,
"end": 1200,
"loc": {
"start": {
"line": 40,
"column": 30
},
"end": {
"line": 47,
"column": 5
}
},
"body": [
{
"type": "ReturnStatement",
"start": 999,
"end": 1194,
"loc": {
"start": {
"line": 41,
"column": 8
},
"end": {
"line": 46,
"column": 26
}
},
"argument": {
"type": "CallExpression",
"start": 1006,
"end": 1194,
"loc": {
"start": {
"line": 41,
"column": 15
},
"end": {
"line": 46,
"column": 26
}
},
"callee": {
"type": "MemberExpression",
"start": 1006,
"end": 1184,
"loc": {
"start": {
"line": 41,
"column": 15
},
"end": {
"line": 46,
"column": 16
}
},
"object": {
"type": "CallExpression",
"start": 1006,
"end": 1178,
"loc": {
"start": {
"line": 41,
"column": 15
},
"end": {
"line": 46,
"column": 10
}
},
"callee": {
"type": "MemberExpression",
"start": 1006,
"end": 1016,
"loc": {
"start": {
"line": 41,
"column": 15
},
"end": {
"line": 41,
"column": 25
}
},
"object": {
"type": "Identifier",
"start": 1006,
"end": 1011,
"loc": {
"start": {
"line": 41,
"column": 15
},
"end": {
"line": 41,
"column": 20
},
"identifierName": "axios"
},
"name": "axios"
},
"property": {
"type": "Identifier",
"start": 1012,
"end": 1016,
"loc": {
"start": {
"line": 41,
"column": 21
},
"end": {
"line": 41,
"column": 25
},
"identifierName": "post"
},
"name": "post"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 1017,
"end": 1025,
"loc": {