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,458 lines (1,457 loc) 127 kB
{ "type": "File", "start": 0, "end": 1650, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 55, "column": 1 } }, "program": { "type": "Program", "start": 0, "end": 1650, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 55, "column": 1 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 53, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 53 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 8, "end": 33, "loc": { "start": { "line": 1, "column": 8 }, "end": { "line": 1, "column": 33 } }, "imported": { "type": "Identifier", "start": 8, "end": 21, "loc": { "start": { "line": 1, "column": 8 }, "end": { "line": 1, "column": 21 }, "identifierName": "MOOD_STATIONS" }, "name": "MOOD_STATIONS" }, "local": { "type": "Identifier", "start": 25, "end": 33, "loc": { "start": { "line": 1, "column": 25 }, "end": { "line": 1, "column": 33 }, "identifierName": "ENDPOINT" }, "name": "ENDPOINT" } } ], "source": { "type": "StringLiteral", "start": 40, "end": 53, "loc": { "start": { "line": 1, "column": 40 }, "end": { "line": 1, "column": 53 } }, "extra": { "rawValue": "../Endpoint", "raw": "'../Endpoint'" }, "value": "../Endpoint" } }, { "type": "ImportDeclaration", "start": 54, "end": 85, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 31 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 61, "end": 68, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 14 } }, "local": { "type": "Identifier", "start": 61, "end": 68, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 14 }, "identifierName": "Fetcher" }, "name": "Fetcher" } } ], "source": { "type": "StringLiteral", "start": 74, "end": 85, "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 * Get mood stations.\n * @see https://kkbox.gelato.io/docs/versions/1.1/resources/mood-stations\n ", "start": 87, "end": 190, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 7, "column": 3 } } } ] }, { "type": "ExportDefaultDeclaration", "start": 191, "end": 1650, "loc": { "start": { "line": 8, "column": 0 }, "end": { "line": 55, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 206, "end": 1650, "loc": { "start": { "line": 8, "column": 15 }, "end": { "line": 55, "column": 1 } }, "id": { "type": "Identifier", "start": 212, "end": 230, "loc": { "start": { "line": 8, "column": 21 }, "end": { "line": 8, "column": 39 }, "identifierName": "MoodStationFetcher" }, "name": "MoodStationFetcher", "leadingComments": null }, "superClass": { "type": "Identifier", "start": 239, "end": 246, "loc": { "start": { "line": 8, "column": 48 }, "end": { "line": 8, "column": 55 }, "identifierName": "Fetcher" }, "name": "Fetcher" }, "body": { "type": "ClassBody", "start": 247, "end": 1650, "loc": { "start": { "line": 8, "column": 56 }, "end": { "line": 55, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 284, "end": 443, "loc": { "start": { "line": 12, "column": 4 }, "end": { "line": 19, "column": 5 } }, "computed": false, "key": { "type": "Identifier", "start": 284, "end": 295, "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": 296, "end": 300, "loc": { "start": { "line": 12, "column": 16 }, "end": { "line": 12, "column": 20 }, "identifierName": "http" }, "name": "http" }, { "type": "AssignmentPattern", "start": 302, "end": 318, "loc": { "start": { "line": 12, "column": 22 }, "end": { "line": 12, "column": 38 } }, "left": { "type": "Identifier", "start": 302, "end": 311, "loc": { "start": { "line": 12, "column": 22 }, "end": { "line": 12, "column": 31 }, "identifierName": "territory" }, "name": "territory" }, "right": { "type": "StringLiteral", "start": 314, "end": 318, "loc": { "start": { "line": 12, "column": 34 }, "end": { "line": 12, "column": 38 } }, "extra": { "rawValue": "TW", "raw": "'TW'" }, "value": "TW" } } ], "body": { "type": "BlockStatement", "start": 320, "end": 443, "loc": { "start": { "line": 12, "column": 40 }, "end": { "line": 19, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 330, "end": 352, "loc": { "start": { "line": 13, "column": 8 }, "end": { "line": 13, "column": 30 } }, "expression": { "type": "CallExpression", "start": 330, "end": 352, "loc": { "start": { "line": 13, "column": 8 }, "end": { "line": 13, "column": 30 } }, "callee": { "type": "Super", "start": 330, "end": 335, "loc": { "start": { "line": 13, "column": 8 }, "end": { "line": 13, "column": 13 } } }, "arguments": [ { "type": "Identifier", "start": 336, "end": 340, "loc": { "start": { "line": 13, "column": 14 }, "end": { "line": 13, "column": 18 }, "identifierName": "http" }, "name": "http" }, { "type": "Identifier", "start": 342, "end": 351, "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": 362, "end": 396, "loc": { "start": { "line": 15, "column": 8 }, "end": { "line": 17, "column": 11 } } } ] }, { "type": "ExpressionStatement", "start": 405, "end": 437, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 40 } }, "expression": { "type": "AssignmentExpression", "start": 405, "end": 437, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 40 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 405, "end": 425, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 28 } }, "object": { "type": "ThisExpression", "start": 405, "end": 409, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 410, "end": 425, "loc": { "start": { "line": 18, "column": 13 }, "end": { "line": 18, "column": 28 }, "identifierName": "mood_station_id" }, "name": "mood_station_id" }, "computed": false, "leadingComments": null }, "right": { "type": "Identifier", "start": 428, "end": 437, "loc": { "start": { "line": 18, "column": 31 }, "end": { "line": 18, "column": 40 }, "identifierName": "undefined" }, "name": "undefined" }, "leadingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * @ignore\n ", "start": 362, "end": 396, "loc": { "start": { "line": 15, "column": 8 }, "end": { "line": 17, "column": 11 } } } ] } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * @ignore\n ", "start": 253, "end": 279, "loc": { "start": { "line": 9, "column": 4 }, "end": { "line": 11, "column": 7 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Fetch all mood stations.\n *\n * @return {Promise}\n * @example api.moodStationFetcher.fetchAllMoodStations()\n * @see https://kkbox.gelato.io/docs/versions/1.1/resources/mood-stations/endpoints/get-mood-stations\n ", "start": 449, "end": 692, "loc": { "start": { "line": 21, "column": 4 }, "end": { "line": 27, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 697, "end": 795, "loc": { "start": { "line": 28, "column": 4 }, "end": { "line": 30, "column": 5 } }, "computed": false, "key": { "type": "Identifier", "start": 697, "end": 717, "loc": { "start": { "line": 28, "column": 4 }, "end": { "line": 28, "column": 24 }, "identifierName": "fetchAllMoodStations" }, "name": "fetchAllMoodStations", "leadingComments": null }, "static": false, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 720, "end": 795, "loc": { "start": { "line": 28, "column": 27 }, "end": { "line": 30, "column": 5 } }, "body": [ { "type": "ReturnStatement", "start": 730, "end": 789, "loc": { "start": { "line": 29, "column": 8 }, "end": { "line": 29, "column": 67 } }, "argument": { "type": "CallExpression", "start": 737, "end": 789, "loc": { "start": { "line": 29, "column": 15 }, "end": { "line": 29, "column": 67 } }, "callee": { "type": "MemberExpression", "start": 737, "end": 750, "loc": { "start": { "line": 29, "column": 15 }, "end": { "line": 29, "column": 28 } }, "object": { "type": "MemberExpression", "start": 737, "end": 746, "loc": { "start": { "line": 29, "column": 15 }, "end": { "line": 29, "column": 24 } }, "object": { "type": "ThisExpression", "start": 737, "end": 741, "loc": { "start": { "line": 29, "column": 15 }, "end": { "line": 29, "column": 19 } } }, "property": { "type": "Identifier", "start": 742, "end": 746, "loc": { "start": { "line": 29, "column": 20 }, "end": { "line": 29, "column": 24 }, "identifierName": "http" }, "name": "http" }, "computed": false }, "property": { "type": "Identifier", "start": 747, "end": 750, "loc": { "start": { "line": 29, "column": 25 }, "end": { "line": 29, "column": 28 }, "identifierName": "get" }, "name": "get" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 751, "end": 759, "loc": { "start": { "line": 29, "column": 29 }, "end": { "line": 29, "column": 37 }, "identifierName": "ENDPOINT" }, "name": "ENDPOINT" }, { "type": "ObjectExpression", "start": 761, "end": 788, "loc": { "start": { "line": 29, "column": 39 }, "end": { "line": 29, "column": 66 } }, "properties": [ { "type": "ObjectProperty", "start": 762, "end": 787, "loc": { "start": { "line": 29, "column": 40 }, "end": { "line": 29, "column": 65 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 762, "end": 771, "loc": { "start": { "line": 29, "column": 40 }, "end": { "line": 29, "column": 49 }, "identifierName": "territory" }, "name": "territory" }, "value": { "type": "MemberExpression", "start": 773, "end": 787, "loc": { "start": { "line": 29, "column": 51 }, "end": { "line": 29, "column": 65 } }, "object": { "type": "ThisExpression", "start": 773, "end": 777, "loc": { "start": { "line": 29, "column": 51 }, "end": { "line": 29, "column": 55 } } }, "property": { "type": "Identifier", "start": 778, "end": 787, "loc": { "start": { "line": 29, "column": 56 }, "end": { "line": 29, "column": 65 }, "identifierName": "territory" }, "name": "territory" }, "computed": false } } ] } ] } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * Fetch all mood stations.\n *\n * @return {Promise}\n * @example api.moodStationFetcher.fetchAllMoodStations()\n * @see https://kkbox.gelato.io/docs/versions/1.1/resources/mood-stations/endpoints/get-mood-stations\n ", "start": 449, "end": 692, "loc": { "start": { "line": 21, "column": 4 }, "end": { "line": 27, "column": 7 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Init the mood station fetcher.\n *\n * @param {string} mood_station_id - The ID of a mood station.\n * @param {string} [territory = 'TW'] - ['TW', 'HK', 'SG', 'MY', 'JP'] The territory of a mood station.\n * @return {MoodStation}\n * @see https://kkbox.gelato.io/docs/versions/1.1/resources/mood-stations/endpoints/get-mood-stations-station_id\n ", "start": 801, "end": 1178, "loc": { "start": { "line": 32, "column": 4 }, "end": { "line": 39, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 1183, "end": 1344, "loc": { "start": { "line": 40, "column": 4 }, "end": { "line": 44, "column": 5 } }, "computed": false, "key": { "type": "Identifier", "start": 1183, "end": 1199, "loc": { "start": { "line": 40, "column": 4 }, "end": { "line": 40, "column": 20 }, "identifierName": "setMoodStationID" }, "name": "setMoodStationID", "leadingComments": null }, "static": false, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 1200, "end": 1215, "loc": { "start": { "line": 40, "column": 21 }, "end": { "line": 40, "column": 36 }, "identifierName": "mood_station_id" }, "name": "mood_station_id" }, { "type": "AssignmentPattern", "start": 1217, "end": 1233, "loc": { "start": { "line": 40, "column": 38 }, "end": { "line": 40, "column": 54 } }, "left": { "type": "Identifier", "start": 1217, "end": 1226, "loc": { "start": { "line": 40, "column": 38 }, "end": { "line": 40, "column": 47 }, "identifierName": "territory" }, "name": "territory" }, "right": { "type": "StringLiteral", "start": 1229, "end": 1233, "loc": { "start": { "line": 40, "column": 50 }, "end": { "line": 40, "column": 54 } }, "extra": { "rawValue": "TW", "raw": "'TW'" }, "value": "TW" } } ], "body": { "type": "BlockStatement", "start": 1235, "end": 1344, "loc": { "start": { "line": 40, "column": 56 }, "end": { "line": 44, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 1245, "end": 1283, "loc": { "start": { "line": 41, "column": 8 }, "end": { "line": 41, "column": 46 } }, "expression": { "type": "AssignmentExpression", "start": 1245, "end": 1283, "loc": { "start": { "line": 41, "column": 8 }, "end": { "line": 41, "column": 46 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 1245, "end": 1265, "loc": { "start": { "line": 41, "column": 8 }, "end": { "line": 41, "column": 28 } }, "object": { "type": "ThisExpression", "start": 1245, "end": 1249, "loc": { "start": { "line": 41, "column": 8 }, "end": { "line": 41, "column": 12 } } }, "property": { "type": "Identifier", "start": 1250, "end": 1265, "loc": { "start": { "line": 41, "column": 13 }, "end": { "line": 41, "column": 28 }, "identifierName": "mood_station_id" }, "name": "mood_station_id" }, "computed": false }, "right": { "type": "Identifier", "start": 1268, "end": 1283, "loc": { "start": { "line": 41, "column": 31 }, "end": { "line": 41, "column": 46 }, "identifierName": "mood_station_id" }, "name": "mood_station_id" } } }, { "type": "ExpressionStatement", "start": 1292, "end": 1318, "loc": { "start": { "line": 42, "column": 8 }, "end": { "line": 42, "column": 34 } }, "expression": { "type": "AssignmentExpression", "start": 1292, "end": 1318, "loc": { "start": { "line": 42, "column": 8 }, "end": { "line": 42, "column": 34 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 1292, "end": 1306, "loc": { "start": { "line": 42, "column": 8 }, "end": { "line": 42, "column": 22 } }, "object": { "type": "ThisExpression", "start": 1292, "end": 1296, "loc": { "start": { "line": 42, "column": 8 }, "end": { "line": 42, "column": 12 } } }, "property": { "type": "Identifier", "start": 1297, "end": 1306, "loc": { "start": { "line": 42, "column": 13 }, "end": { "line": 42, "column": 22 }, "identifierName": "territory" }, "name": "territory" }, "computed": false }, "right": { "type": "Identifier", "start": 1309, "end": 1318, "loc": { "start": { "line": 42, "column": 25 }, "end": { "line": 42, "column": 34 }, "identifierName": "territory" }, "name": "territory" } } }, { "type": "ReturnStatement", "start": 1327, "end": 1338, "loc": { "start": { "line": 43, "column": 8 }, "end": { "line": 43, "column": 19 } }, "argument": { "type": "ThisExpression", "start": 1334, "end": 1338, "loc": { "start": { "line": 43, "column": 15 }, "end": { "line": 43, "column": 19 } } } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * Init the mood station fetcher.\n *\n * @param {string} mood_station_id - The ID of a mood station.\n * @param {string} [territory = 'TW'] - ['TW', 'HK', 'SG', 'MY', 'JP'] The territory of a mood station.\n * @return {MoodStation}\n * @see https://kkbox.gelato.io/docs/versions/1.1/resources/mood-stations/endpoints/get-mood-stations-station_id\n ", "start": 801, "end": 1178, "loc": { "start": { "line": 32, "column": 4 }, "end": { "line": 39, "column": 7 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Fetch the mood station's metadata.\n *\n * @return {Promise}\n * @example api.moodStationFetcher.setMoodStationID('StGZp2ToWq92diPHS7').fetchMetadata()\n ", "start": 1350, "end": 1529, "loc": { "start": { "line": 46, "column": 4 }, "end": { "line": 51, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 1534, "end": 1648, "loc": { "start": { "line": 52, "column": 4 }, "end": { "line": 54, "column": 5 } }, "computed": false, "key": { "type": "Identifier", "start": 1534, "end": 1547, "loc": { "start": { "line": 52, "column": 4 }, "end": { "line": 52, "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": 1550, "end": 1648, "loc": { "start": { "line": 52, "column": 20 }, "end": { "line": 54, "column": 5 } }, "body": [ { "type": "ReturnStatement", "start": 1560, "end": 1642, "loc": { "start": { "line": 53, "column": 8 }, "end": { "line": 53, "column": 90 } }, "argument": { "type": "CallExpression", "start": 1567, "end": 1642, "loc": { "start": { "line": 53, "column": 15