woodenfish-bot 5.0.2 → 5.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/index.js +77 -56
- package/lib/index.js +77 -56
- package/package.json +1 -1
package/es/index.js
CHANGED
|
@@ -282,7 +282,7 @@ var Guild = /*#__PURE__*/function () {
|
|
|
282
282
|
}]);
|
|
283
283
|
}();
|
|
284
284
|
|
|
285
|
-
var version = "5.0.
|
|
285
|
+
var version = "5.0.3";
|
|
286
286
|
|
|
287
287
|
function getDefaultExportFromCjs (x) {
|
|
288
288
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
@@ -1309,8 +1309,8 @@ var Audio = /*#__PURE__*/function () {
|
|
|
1309
1309
|
}]);
|
|
1310
1310
|
}();
|
|
1311
1311
|
|
|
1312
|
-
function ownKeys$
|
|
1313
|
-
function _objectSpread$
|
|
1312
|
+
function ownKeys$5(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1313
|
+
function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1314
1314
|
var Mute = /*#__PURE__*/function () {
|
|
1315
1315
|
function Mute(request, config) {
|
|
1316
1316
|
_classCallCheck(this, Mute);
|
|
@@ -1371,7 +1371,7 @@ var Mute = /*#__PURE__*/function () {
|
|
|
1371
1371
|
guildID: guildID
|
|
1372
1372
|
},
|
|
1373
1373
|
// 将options和userIDList合并到一起
|
|
1374
|
-
data: _objectSpread$
|
|
1374
|
+
data: _objectSpread$5(_objectSpread$5({}, options), {}, {
|
|
1375
1375
|
user_ids: userIDList
|
|
1376
1376
|
})
|
|
1377
1377
|
};
|
|
@@ -1567,8 +1567,8 @@ var Schedule = /*#__PURE__*/function () {
|
|
|
1567
1567
|
}]);
|
|
1568
1568
|
}();
|
|
1569
1569
|
|
|
1570
|
-
function ownKeys$
|
|
1571
|
-
function _objectSpread$
|
|
1570
|
+
function ownKeys$4(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1571
|
+
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1572
1572
|
var Threads = /*#__PURE__*/function () {
|
|
1573
1573
|
function Threads(request, config) {
|
|
1574
1574
|
_classCallCheck(this, Threads);
|
|
@@ -1582,7 +1582,7 @@ var Threads = /*#__PURE__*/function () {
|
|
|
1582
1582
|
return _createClass(Threads, [{
|
|
1583
1583
|
key: "threads",
|
|
1584
1584
|
value: function threads(channelID, requestOptions) {
|
|
1585
|
-
var options = _objectSpread$
|
|
1585
|
+
var options = _objectSpread$4({
|
|
1586
1586
|
method: 'GET',
|
|
1587
1587
|
url: getURL$1('threadsURI'),
|
|
1588
1588
|
rest: {
|
|
@@ -1596,7 +1596,7 @@ var Threads = /*#__PURE__*/function () {
|
|
|
1596
1596
|
}, {
|
|
1597
1597
|
key: "thread",
|
|
1598
1598
|
value: function thread(channelID, threadID, requestOptions) {
|
|
1599
|
-
var options = _objectSpread$
|
|
1599
|
+
var options = _objectSpread$4({
|
|
1600
1600
|
method: 'GET',
|
|
1601
1601
|
url: getURL$1('threadURI'),
|
|
1602
1602
|
rest: {
|
|
@@ -1611,7 +1611,7 @@ var Threads = /*#__PURE__*/function () {
|
|
|
1611
1611
|
}, {
|
|
1612
1612
|
key: "putThreads",
|
|
1613
1613
|
value: function putThreads(channelID, _Threads2, requestOptions) {
|
|
1614
|
-
var options = _objectSpread$
|
|
1614
|
+
var options = _objectSpread$4({
|
|
1615
1615
|
method: 'PUT',
|
|
1616
1616
|
url: getURL$1('threadsURI'),
|
|
1617
1617
|
rest: {
|
|
@@ -1628,7 +1628,7 @@ var Threads = /*#__PURE__*/function () {
|
|
|
1628
1628
|
}, {
|
|
1629
1629
|
key: "putPostReply",
|
|
1630
1630
|
value: function putPostReply(channelID, threadID, postID, reply, requestOptions) {
|
|
1631
|
-
var options = _objectSpread$
|
|
1631
|
+
var options = _objectSpread$4({
|
|
1632
1632
|
method: 'PUT',
|
|
1633
1633
|
url: getURL$1('threadPostRepliesURI'),
|
|
1634
1634
|
rest: {
|
|
@@ -1645,7 +1645,7 @@ var Threads = /*#__PURE__*/function () {
|
|
|
1645
1645
|
}, {
|
|
1646
1646
|
key: "deleteThreads",
|
|
1647
1647
|
value: function deleteThreads(channelID, threadID, requestOptions) {
|
|
1648
|
-
var options = _objectSpread$
|
|
1648
|
+
var options = _objectSpread$4({
|
|
1649
1649
|
method: 'DELETE',
|
|
1650
1650
|
url: getURL$1('threadURI'),
|
|
1651
1651
|
rest: {
|
|
@@ -1727,6 +1727,43 @@ var Interaction = /*#__PURE__*/function () {
|
|
|
1727
1727
|
}]);
|
|
1728
1728
|
}();
|
|
1729
1729
|
|
|
1730
|
+
function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1731
|
+
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1732
|
+
var getTraceID = function getTraceID(error) {
|
|
1733
|
+
var _error$response;
|
|
1734
|
+
return error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 || (_error$response = _error$response.headers) === null || _error$response === void 0 ? void 0 : _error$response['x-tps-trace-id'];
|
|
1735
|
+
};
|
|
1736
|
+
var normalizeV1OpenAPIError = function normalizeV1OpenAPIError(error) {
|
|
1737
|
+
var _error$response2;
|
|
1738
|
+
var traceid = getTraceID(error);
|
|
1739
|
+
if (error !== null && error !== void 0 && (_error$response2 = error.response) !== null && _error$response2 !== void 0 && _error$response2.data) {
|
|
1740
|
+
return _objectSpread$3(_objectSpread$3({}, error.response.data), {}, {
|
|
1741
|
+
traceid: traceid
|
|
1742
|
+
});
|
|
1743
|
+
}
|
|
1744
|
+
if (error !== null && error !== void 0 && error.response) {
|
|
1745
|
+
return _objectSpread$3(_objectSpread$3({}, error.response), {}, {
|
|
1746
|
+
traceid: traceid
|
|
1747
|
+
});
|
|
1748
|
+
}
|
|
1749
|
+
return error;
|
|
1750
|
+
};
|
|
1751
|
+
var normalizeV2OpenAPIError = function normalizeV2OpenAPIError(error) {
|
|
1752
|
+
var _error$response3;
|
|
1753
|
+
var traceID = getTraceID(error);
|
|
1754
|
+
if (error !== null && error !== void 0 && (_error$response3 = error.response) !== null && _error$response3 !== void 0 && _error$response3.data) {
|
|
1755
|
+
return _objectSpread$3(_objectSpread$3({}, error.response.data), {}, {
|
|
1756
|
+
trace_id: error.response.data.trace_id || traceID
|
|
1757
|
+
});
|
|
1758
|
+
}
|
|
1759
|
+
if (error !== null && error !== void 0 && error.response) {
|
|
1760
|
+
return _objectSpread$3(_objectSpread$3({}, error.response), {}, {
|
|
1761
|
+
trace_id: traceID
|
|
1762
|
+
});
|
|
1763
|
+
}
|
|
1764
|
+
return error;
|
|
1765
|
+
};
|
|
1766
|
+
|
|
1730
1767
|
function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1731
1768
|
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1732
1769
|
var OpenAPI$1 = /*#__PURE__*/function () {
|
|
@@ -1757,7 +1794,7 @@ var OpenAPI$1 = /*#__PURE__*/function () {
|
|
|
1757
1794
|
// 基础rest请求
|
|
1758
1795
|
_defineProperty(this, "request", /*#__PURE__*/function () {
|
|
1759
1796
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(options) {
|
|
1760
|
-
var _this$config, appID, token, botUrl, client;
|
|
1797
|
+
var _this$config, appID, token, botUrl, client, _t;
|
|
1761
1798
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
1762
1799
|
while (1) switch (_context.prev = _context.next) {
|
|
1763
1800
|
case 0:
|
|
@@ -1769,31 +1806,22 @@ var OpenAPI$1 = /*#__PURE__*/function () {
|
|
|
1769
1806
|
// 添加鉴权信息
|
|
1770
1807
|
addV1Authorization(options.headers, appID, token);
|
|
1771
1808
|
// 组装完整Url
|
|
1772
|
-
botUrl = buildUrl(options.url, _this.config.sandbox);
|
|
1773
|
-
resty.useRes(function (result) {
|
|
1774
|
-
return result;
|
|
1775
|
-
}, function (error) {
|
|
1776
|
-
var _error$response, _error$response2;
|
|
1777
|
-
var traceid = error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 || (_error$response = _error$response.headers) === null || _error$response === void 0 ? void 0 : _error$response['x-tps-trace-id'];
|
|
1778
|
-
if (error !== null && error !== void 0 && (_error$response2 = error.response) !== null && _error$response2 !== void 0 && _error$response2.data) {
|
|
1779
|
-
return Promise.reject(_objectSpread$2(_objectSpread$2({}, error.response.data), {}, {
|
|
1780
|
-
traceid: traceid
|
|
1781
|
-
}));
|
|
1782
|
-
}
|
|
1783
|
-
if (error !== null && error !== void 0 && error.response) {
|
|
1784
|
-
return Promise.reject(_objectSpread$2(_objectSpread$2({}, error.response), {}, {
|
|
1785
|
-
traceid: traceid
|
|
1786
|
-
}));
|
|
1787
|
-
}
|
|
1788
|
-
return Promise.reject(error);
|
|
1789
|
-
});
|
|
1809
|
+
botUrl = buildUrl(options.url, _this.config.sandbox);
|
|
1790
1810
|
client = resty.create(options);
|
|
1791
|
-
|
|
1792
|
-
|
|
1811
|
+
_context.prev = 1;
|
|
1812
|
+
_context.next = 2;
|
|
1813
|
+
return client.request(botUrl, options);
|
|
1814
|
+
case 2:
|
|
1815
|
+
return _context.abrupt("return", _context.sent);
|
|
1816
|
+
case 3:
|
|
1817
|
+
_context.prev = 3;
|
|
1818
|
+
_t = _context["catch"](1);
|
|
1819
|
+
throw normalizeV1OpenAPIError(_t);
|
|
1820
|
+
case 4:
|
|
1793
1821
|
case "end":
|
|
1794
1822
|
return _context.stop();
|
|
1795
1823
|
}
|
|
1796
|
-
}, _callee);
|
|
1824
|
+
}, _callee, null, [[1, 3]]);
|
|
1797
1825
|
}));
|
|
1798
1826
|
return function (_x) {
|
|
1799
1827
|
return _ref.apply(this, arguments);
|
|
@@ -2278,7 +2306,9 @@ var Message = /*#__PURE__*/function (_CommonMessage) {
|
|
|
2278
2306
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2279
2307
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2280
2308
|
var isAuthenticationError = function isAuthenticationError(error) {
|
|
2281
|
-
|
|
2309
|
+
var _error$response, _error$response2;
|
|
2310
|
+
var responseData = error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data;
|
|
2311
|
+
return (error === null || error === void 0 ? void 0 : error.status) === 401 || (error === null || error === void 0 ? void 0 : error.statusCode) === 401 || (error === null || error === void 0 || (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.status) === 401 || (error === null || error === void 0 ? void 0 : error.code) === 11201 || (error === null || error === void 0 ? void 0 : error.err_code) === 40012001 || (responseData === null || responseData === void 0 ? void 0 : responseData.code) === 11201 || (responseData === null || responseData === void 0 ? void 0 : responseData.err_code) === 40012001;
|
|
2282
2312
|
};
|
|
2283
2313
|
var OpenAPI = /*#__PURE__*/function () {
|
|
2284
2314
|
function OpenAPI(config) {
|
|
@@ -2332,27 +2362,10 @@ var OpenAPI = /*#__PURE__*/function () {
|
|
|
2332
2362
|
}());
|
|
2333
2363
|
_defineProperty(this, "request", /*#__PURE__*/function () {
|
|
2334
2364
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(options) {
|
|
2335
|
-
var botUrl, preparedOptions, _t;
|
|
2365
|
+
var botUrl, preparedOptions, _t, _t2;
|
|
2336
2366
|
return _regeneratorRuntime.wrap(function (_context2) {
|
|
2337
2367
|
while (1) switch (_context2.prev = _context2.next) {
|
|
2338
2368
|
case 0:
|
|
2339
|
-
resty.useRes(function (result) {
|
|
2340
|
-
return result;
|
|
2341
|
-
}, function (error) {
|
|
2342
|
-
var _error$response, _error$response2;
|
|
2343
|
-
var traceID = error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 || (_error$response = _error$response.headers) === null || _error$response === void 0 ? void 0 : _error$response['x-tps-trace-id'];
|
|
2344
|
-
if (error !== null && error !== void 0 && (_error$response2 = error.response) !== null && _error$response2 !== void 0 && _error$response2.data) {
|
|
2345
|
-
return Promise.reject(_objectSpread(_objectSpread({}, error.response.data), {}, {
|
|
2346
|
-
trace_id: error.response.data.trace_id || traceID
|
|
2347
|
-
}));
|
|
2348
|
-
}
|
|
2349
|
-
if (error !== null && error !== void 0 && error.response) {
|
|
2350
|
-
return Promise.reject(_objectSpread(_objectSpread({}, error.response), {}, {
|
|
2351
|
-
trace_id: traceID
|
|
2352
|
-
}));
|
|
2353
|
-
}
|
|
2354
|
-
return Promise.reject(error);
|
|
2355
|
-
});
|
|
2356
2369
|
botUrl = buildUrl(options.url, _this.config.sandbox);
|
|
2357
2370
|
_context2.next = 1;
|
|
2358
2371
|
return _this.prepareOptions(options);
|
|
@@ -2370,19 +2383,27 @@ var OpenAPI = /*#__PURE__*/function () {
|
|
|
2370
2383
|
_context2.next = 5;
|
|
2371
2384
|
break;
|
|
2372
2385
|
}
|
|
2373
|
-
throw _t;
|
|
2386
|
+
throw normalizeV2OpenAPIError(_t);
|
|
2374
2387
|
case 5:
|
|
2375
2388
|
invalidateV2AccessToken(_this.config.appID);
|
|
2376
2389
|
_context2.next = 6;
|
|
2377
2390
|
return _this.prepareOptions(options, true);
|
|
2378
2391
|
case 6:
|
|
2379
2392
|
preparedOptions = _context2.sent;
|
|
2380
|
-
|
|
2381
|
-
|
|
2393
|
+
_context2.prev = 7;
|
|
2394
|
+
_context2.next = 8;
|
|
2395
|
+
return resty.create(preparedOptions).request(botUrl, preparedOptions);
|
|
2396
|
+
case 8:
|
|
2397
|
+
return _context2.abrupt("return", _context2.sent);
|
|
2398
|
+
case 9:
|
|
2399
|
+
_context2.prev = 9;
|
|
2400
|
+
_t2 = _context2["catch"](7);
|
|
2401
|
+
throw normalizeV2OpenAPIError(_t2);
|
|
2402
|
+
case 10:
|
|
2382
2403
|
case "end":
|
|
2383
2404
|
return _context2.stop();
|
|
2384
2405
|
}
|
|
2385
|
-
}, _callee2, null, [[2, 4]]);
|
|
2406
|
+
}, _callee2, null, [[2, 4], [7, 9]]);
|
|
2386
2407
|
}));
|
|
2387
2408
|
return function (_x2) {
|
|
2388
2409
|
return _ref2.apply(this, arguments);
|
package/lib/index.js
CHANGED
|
@@ -284,7 +284,7 @@ var Guild = /*#__PURE__*/function () {
|
|
|
284
284
|
}]);
|
|
285
285
|
}();
|
|
286
286
|
|
|
287
|
-
var version = "5.0.
|
|
287
|
+
var version = "5.0.3";
|
|
288
288
|
|
|
289
289
|
function getDefaultExportFromCjs (x) {
|
|
290
290
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
@@ -1311,8 +1311,8 @@ var Audio = /*#__PURE__*/function () {
|
|
|
1311
1311
|
}]);
|
|
1312
1312
|
}();
|
|
1313
1313
|
|
|
1314
|
-
function ownKeys$
|
|
1315
|
-
function _objectSpread$
|
|
1314
|
+
function ownKeys$5(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1315
|
+
function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1316
1316
|
var Mute = /*#__PURE__*/function () {
|
|
1317
1317
|
function Mute(request, config) {
|
|
1318
1318
|
_classCallCheck(this, Mute);
|
|
@@ -1373,7 +1373,7 @@ var Mute = /*#__PURE__*/function () {
|
|
|
1373
1373
|
guildID: guildID
|
|
1374
1374
|
},
|
|
1375
1375
|
// 将options和userIDList合并到一起
|
|
1376
|
-
data: _objectSpread$
|
|
1376
|
+
data: _objectSpread$5(_objectSpread$5({}, options), {}, {
|
|
1377
1377
|
user_ids: userIDList
|
|
1378
1378
|
})
|
|
1379
1379
|
};
|
|
@@ -1569,8 +1569,8 @@ var Schedule = /*#__PURE__*/function () {
|
|
|
1569
1569
|
}]);
|
|
1570
1570
|
}();
|
|
1571
1571
|
|
|
1572
|
-
function ownKeys$
|
|
1573
|
-
function _objectSpread$
|
|
1572
|
+
function ownKeys$4(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1573
|
+
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1574
1574
|
var Threads = /*#__PURE__*/function () {
|
|
1575
1575
|
function Threads(request, config) {
|
|
1576
1576
|
_classCallCheck(this, Threads);
|
|
@@ -1584,7 +1584,7 @@ var Threads = /*#__PURE__*/function () {
|
|
|
1584
1584
|
return _createClass(Threads, [{
|
|
1585
1585
|
key: "threads",
|
|
1586
1586
|
value: function threads(channelID, requestOptions) {
|
|
1587
|
-
var options = _objectSpread$
|
|
1587
|
+
var options = _objectSpread$4({
|
|
1588
1588
|
method: 'GET',
|
|
1589
1589
|
url: getURL$1('threadsURI'),
|
|
1590
1590
|
rest: {
|
|
@@ -1598,7 +1598,7 @@ var Threads = /*#__PURE__*/function () {
|
|
|
1598
1598
|
}, {
|
|
1599
1599
|
key: "thread",
|
|
1600
1600
|
value: function thread(channelID, threadID, requestOptions) {
|
|
1601
|
-
var options = _objectSpread$
|
|
1601
|
+
var options = _objectSpread$4({
|
|
1602
1602
|
method: 'GET',
|
|
1603
1603
|
url: getURL$1('threadURI'),
|
|
1604
1604
|
rest: {
|
|
@@ -1613,7 +1613,7 @@ var Threads = /*#__PURE__*/function () {
|
|
|
1613
1613
|
}, {
|
|
1614
1614
|
key: "putThreads",
|
|
1615
1615
|
value: function putThreads(channelID, _Threads2, requestOptions) {
|
|
1616
|
-
var options = _objectSpread$
|
|
1616
|
+
var options = _objectSpread$4({
|
|
1617
1617
|
method: 'PUT',
|
|
1618
1618
|
url: getURL$1('threadsURI'),
|
|
1619
1619
|
rest: {
|
|
@@ -1630,7 +1630,7 @@ var Threads = /*#__PURE__*/function () {
|
|
|
1630
1630
|
}, {
|
|
1631
1631
|
key: "putPostReply",
|
|
1632
1632
|
value: function putPostReply(channelID, threadID, postID, reply, requestOptions) {
|
|
1633
|
-
var options = _objectSpread$
|
|
1633
|
+
var options = _objectSpread$4({
|
|
1634
1634
|
method: 'PUT',
|
|
1635
1635
|
url: getURL$1('threadPostRepliesURI'),
|
|
1636
1636
|
rest: {
|
|
@@ -1647,7 +1647,7 @@ var Threads = /*#__PURE__*/function () {
|
|
|
1647
1647
|
}, {
|
|
1648
1648
|
key: "deleteThreads",
|
|
1649
1649
|
value: function deleteThreads(channelID, threadID, requestOptions) {
|
|
1650
|
-
var options = _objectSpread$
|
|
1650
|
+
var options = _objectSpread$4({
|
|
1651
1651
|
method: 'DELETE',
|
|
1652
1652
|
url: getURL$1('threadURI'),
|
|
1653
1653
|
rest: {
|
|
@@ -1729,6 +1729,43 @@ var Interaction = /*#__PURE__*/function () {
|
|
|
1729
1729
|
}]);
|
|
1730
1730
|
}();
|
|
1731
1731
|
|
|
1732
|
+
function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1733
|
+
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1734
|
+
var getTraceID = function getTraceID(error) {
|
|
1735
|
+
var _error$response;
|
|
1736
|
+
return error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 || (_error$response = _error$response.headers) === null || _error$response === void 0 ? void 0 : _error$response['x-tps-trace-id'];
|
|
1737
|
+
};
|
|
1738
|
+
var normalizeV1OpenAPIError = function normalizeV1OpenAPIError(error) {
|
|
1739
|
+
var _error$response2;
|
|
1740
|
+
var traceid = getTraceID(error);
|
|
1741
|
+
if (error !== null && error !== void 0 && (_error$response2 = error.response) !== null && _error$response2 !== void 0 && _error$response2.data) {
|
|
1742
|
+
return _objectSpread$3(_objectSpread$3({}, error.response.data), {}, {
|
|
1743
|
+
traceid: traceid
|
|
1744
|
+
});
|
|
1745
|
+
}
|
|
1746
|
+
if (error !== null && error !== void 0 && error.response) {
|
|
1747
|
+
return _objectSpread$3(_objectSpread$3({}, error.response), {}, {
|
|
1748
|
+
traceid: traceid
|
|
1749
|
+
});
|
|
1750
|
+
}
|
|
1751
|
+
return error;
|
|
1752
|
+
};
|
|
1753
|
+
var normalizeV2OpenAPIError = function normalizeV2OpenAPIError(error) {
|
|
1754
|
+
var _error$response3;
|
|
1755
|
+
var traceID = getTraceID(error);
|
|
1756
|
+
if (error !== null && error !== void 0 && (_error$response3 = error.response) !== null && _error$response3 !== void 0 && _error$response3.data) {
|
|
1757
|
+
return _objectSpread$3(_objectSpread$3({}, error.response.data), {}, {
|
|
1758
|
+
trace_id: error.response.data.trace_id || traceID
|
|
1759
|
+
});
|
|
1760
|
+
}
|
|
1761
|
+
if (error !== null && error !== void 0 && error.response) {
|
|
1762
|
+
return _objectSpread$3(_objectSpread$3({}, error.response), {}, {
|
|
1763
|
+
trace_id: traceID
|
|
1764
|
+
});
|
|
1765
|
+
}
|
|
1766
|
+
return error;
|
|
1767
|
+
};
|
|
1768
|
+
|
|
1732
1769
|
function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1733
1770
|
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1734
1771
|
var OpenAPI$1 = /*#__PURE__*/function () {
|
|
@@ -1759,7 +1796,7 @@ var OpenAPI$1 = /*#__PURE__*/function () {
|
|
|
1759
1796
|
// 基础rest请求
|
|
1760
1797
|
_defineProperty(this, "request", /*#__PURE__*/function () {
|
|
1761
1798
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(options) {
|
|
1762
|
-
var _this$config, appID, token, botUrl, client;
|
|
1799
|
+
var _this$config, appID, token, botUrl, client, _t;
|
|
1763
1800
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
1764
1801
|
while (1) switch (_context.prev = _context.next) {
|
|
1765
1802
|
case 0:
|
|
@@ -1771,31 +1808,22 @@ var OpenAPI$1 = /*#__PURE__*/function () {
|
|
|
1771
1808
|
// 添加鉴权信息
|
|
1772
1809
|
addV1Authorization(options.headers, appID, token);
|
|
1773
1810
|
// 组装完整Url
|
|
1774
|
-
botUrl = buildUrl(options.url, _this.config.sandbox);
|
|
1775
|
-
resty.useRes(function (result) {
|
|
1776
|
-
return result;
|
|
1777
|
-
}, function (error) {
|
|
1778
|
-
var _error$response, _error$response2;
|
|
1779
|
-
var traceid = error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 || (_error$response = _error$response.headers) === null || _error$response === void 0 ? void 0 : _error$response['x-tps-trace-id'];
|
|
1780
|
-
if (error !== null && error !== void 0 && (_error$response2 = error.response) !== null && _error$response2 !== void 0 && _error$response2.data) {
|
|
1781
|
-
return Promise.reject(_objectSpread$2(_objectSpread$2({}, error.response.data), {}, {
|
|
1782
|
-
traceid: traceid
|
|
1783
|
-
}));
|
|
1784
|
-
}
|
|
1785
|
-
if (error !== null && error !== void 0 && error.response) {
|
|
1786
|
-
return Promise.reject(_objectSpread$2(_objectSpread$2({}, error.response), {}, {
|
|
1787
|
-
traceid: traceid
|
|
1788
|
-
}));
|
|
1789
|
-
}
|
|
1790
|
-
return Promise.reject(error);
|
|
1791
|
-
});
|
|
1811
|
+
botUrl = buildUrl(options.url, _this.config.sandbox);
|
|
1792
1812
|
client = resty.create(options);
|
|
1793
|
-
|
|
1794
|
-
|
|
1813
|
+
_context.prev = 1;
|
|
1814
|
+
_context.next = 2;
|
|
1815
|
+
return client.request(botUrl, options);
|
|
1816
|
+
case 2:
|
|
1817
|
+
return _context.abrupt("return", _context.sent);
|
|
1818
|
+
case 3:
|
|
1819
|
+
_context.prev = 3;
|
|
1820
|
+
_t = _context["catch"](1);
|
|
1821
|
+
throw normalizeV1OpenAPIError(_t);
|
|
1822
|
+
case 4:
|
|
1795
1823
|
case "end":
|
|
1796
1824
|
return _context.stop();
|
|
1797
1825
|
}
|
|
1798
|
-
}, _callee);
|
|
1826
|
+
}, _callee, null, [[1, 3]]);
|
|
1799
1827
|
}));
|
|
1800
1828
|
return function (_x) {
|
|
1801
1829
|
return _ref.apply(this, arguments);
|
|
@@ -2280,7 +2308,9 @@ var Message = /*#__PURE__*/function (_CommonMessage) {
|
|
|
2280
2308
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2281
2309
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2282
2310
|
var isAuthenticationError = function isAuthenticationError(error) {
|
|
2283
|
-
|
|
2311
|
+
var _error$response, _error$response2;
|
|
2312
|
+
var responseData = error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data;
|
|
2313
|
+
return (error === null || error === void 0 ? void 0 : error.status) === 401 || (error === null || error === void 0 ? void 0 : error.statusCode) === 401 || (error === null || error === void 0 || (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.status) === 401 || (error === null || error === void 0 ? void 0 : error.code) === 11201 || (error === null || error === void 0 ? void 0 : error.err_code) === 40012001 || (responseData === null || responseData === void 0 ? void 0 : responseData.code) === 11201 || (responseData === null || responseData === void 0 ? void 0 : responseData.err_code) === 40012001;
|
|
2284
2314
|
};
|
|
2285
2315
|
var OpenAPI = /*#__PURE__*/function () {
|
|
2286
2316
|
function OpenAPI(config) {
|
|
@@ -2334,27 +2364,10 @@ var OpenAPI = /*#__PURE__*/function () {
|
|
|
2334
2364
|
}());
|
|
2335
2365
|
_defineProperty(this, "request", /*#__PURE__*/function () {
|
|
2336
2366
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(options) {
|
|
2337
|
-
var botUrl, preparedOptions, _t;
|
|
2367
|
+
var botUrl, preparedOptions, _t, _t2;
|
|
2338
2368
|
return _regeneratorRuntime.wrap(function (_context2) {
|
|
2339
2369
|
while (1) switch (_context2.prev = _context2.next) {
|
|
2340
2370
|
case 0:
|
|
2341
|
-
resty.useRes(function (result) {
|
|
2342
|
-
return result;
|
|
2343
|
-
}, function (error) {
|
|
2344
|
-
var _error$response, _error$response2;
|
|
2345
|
-
var traceID = error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 || (_error$response = _error$response.headers) === null || _error$response === void 0 ? void 0 : _error$response['x-tps-trace-id'];
|
|
2346
|
-
if (error !== null && error !== void 0 && (_error$response2 = error.response) !== null && _error$response2 !== void 0 && _error$response2.data) {
|
|
2347
|
-
return Promise.reject(_objectSpread(_objectSpread({}, error.response.data), {}, {
|
|
2348
|
-
trace_id: error.response.data.trace_id || traceID
|
|
2349
|
-
}));
|
|
2350
|
-
}
|
|
2351
|
-
if (error !== null && error !== void 0 && error.response) {
|
|
2352
|
-
return Promise.reject(_objectSpread(_objectSpread({}, error.response), {}, {
|
|
2353
|
-
trace_id: traceID
|
|
2354
|
-
}));
|
|
2355
|
-
}
|
|
2356
|
-
return Promise.reject(error);
|
|
2357
|
-
});
|
|
2358
2371
|
botUrl = buildUrl(options.url, _this.config.sandbox);
|
|
2359
2372
|
_context2.next = 1;
|
|
2360
2373
|
return _this.prepareOptions(options);
|
|
@@ -2372,19 +2385,27 @@ var OpenAPI = /*#__PURE__*/function () {
|
|
|
2372
2385
|
_context2.next = 5;
|
|
2373
2386
|
break;
|
|
2374
2387
|
}
|
|
2375
|
-
throw _t;
|
|
2388
|
+
throw normalizeV2OpenAPIError(_t);
|
|
2376
2389
|
case 5:
|
|
2377
2390
|
invalidateV2AccessToken(_this.config.appID);
|
|
2378
2391
|
_context2.next = 6;
|
|
2379
2392
|
return _this.prepareOptions(options, true);
|
|
2380
2393
|
case 6:
|
|
2381
2394
|
preparedOptions = _context2.sent;
|
|
2382
|
-
|
|
2383
|
-
|
|
2395
|
+
_context2.prev = 7;
|
|
2396
|
+
_context2.next = 8;
|
|
2397
|
+
return resty.create(preparedOptions).request(botUrl, preparedOptions);
|
|
2398
|
+
case 8:
|
|
2399
|
+
return _context2.abrupt("return", _context2.sent);
|
|
2400
|
+
case 9:
|
|
2401
|
+
_context2.prev = 9;
|
|
2402
|
+
_t2 = _context2["catch"](7);
|
|
2403
|
+
throw normalizeV2OpenAPIError(_t2);
|
|
2404
|
+
case 10:
|
|
2384
2405
|
case "end":
|
|
2385
2406
|
return _context2.stop();
|
|
2386
2407
|
}
|
|
2387
|
-
}, _callee2, null, [[2, 4]]);
|
|
2408
|
+
}, _callee2, null, [[2, 4], [7, 9]]);
|
|
2388
2409
|
}));
|
|
2389
2410
|
return function (_x2) {
|
|
2390
2411
|
return _ref2.apply(this, arguments);
|