@honeybadger-io/js 6.12.1 → 6.12.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/dist/browser/honeybadger.ext.min.js +1 -1
- package/dist/browser/honeybadger.js +2 -2
- package/dist/browser/honeybadger.min.js +1 -1
- package/dist/server/check-ins-manager/client.d.ts +6 -5
- package/dist/server/check-ins-sync.js +10 -5
- package/dist/server/check-ins-sync.js.map +1 -1
- package/dist/server/honeybadger.d.ts +3 -2
- package/dist/server/honeybadger.js +407 -413
- package/dist/server/honeybadger.js.map +1 -1
- package/honeybadger.d.ts +0 -3
- package/package.json +2 -2
|
@@ -994,7 +994,7 @@ var __assign$2 = (commonjsGlobal && commonjsGlobal.__assign) || function () {
|
|
|
994
994
|
};
|
|
995
995
|
return __assign$2.apply(this, arguments);
|
|
996
996
|
};
|
|
997
|
-
var __awaiter$
|
|
997
|
+
var __awaiter$4 = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
998
998
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
999
999
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
1000
1000
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
@@ -1003,7 +1003,7 @@ var __awaiter$3 = (commonjsGlobal && commonjsGlobal.__awaiter) || function (this
|
|
|
1003
1003
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1004
1004
|
});
|
|
1005
1005
|
};
|
|
1006
|
-
var __generator$
|
|
1006
|
+
var __generator$4 = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
|
|
1007
1007
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
1008
1008
|
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
1009
1009
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
@@ -1082,9 +1082,9 @@ var ThrottledEventsLogger = /** @class */ (function () {
|
|
|
1082
1082
|
});
|
|
1083
1083
|
};
|
|
1084
1084
|
ThrottledEventsLogger.prototype.send = function () {
|
|
1085
|
-
return __awaiter$
|
|
1085
|
+
return __awaiter$4(this, void 0, void 0, function () {
|
|
1086
1086
|
var eventsData, data;
|
|
1087
|
-
return __generator$
|
|
1087
|
+
return __generator$4(this, function (_a) {
|
|
1088
1088
|
if (this.queue.length === 0) {
|
|
1089
1089
|
return [2 /*return*/];
|
|
1090
1090
|
}
|
|
@@ -1096,9 +1096,9 @@ var ThrottledEventsLogger = /** @class */ (function () {
|
|
|
1096
1096
|
});
|
|
1097
1097
|
};
|
|
1098
1098
|
ThrottledEventsLogger.prototype.makeHttpRequest = function (data) {
|
|
1099
|
-
return __awaiter$
|
|
1099
|
+
return __awaiter$4(this, void 0, void 0, function () {
|
|
1100
1100
|
var _this = this;
|
|
1101
|
-
return __generator$
|
|
1101
|
+
return __generator$4(this, function (_a) {
|
|
1102
1102
|
return [2 /*return*/, this.transport
|
|
1103
1103
|
.send({
|
|
1104
1104
|
headers: {
|
|
@@ -1158,7 +1158,7 @@ var __assign$1 = (commonjsGlobal && commonjsGlobal.__assign) || function () {
|
|
|
1158
1158
|
};
|
|
1159
1159
|
return __assign$1.apply(this, arguments);
|
|
1160
1160
|
};
|
|
1161
|
-
var __awaiter$
|
|
1161
|
+
var __awaiter$3 = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
1162
1162
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
1163
1163
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
1164
1164
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
@@ -1167,7 +1167,7 @@ var __awaiter$2 = (commonjsGlobal && commonjsGlobal.__awaiter) || function (this
|
|
|
1167
1167
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1168
1168
|
});
|
|
1169
1169
|
};
|
|
1170
|
-
var __generator$
|
|
1170
|
+
var __generator$3 = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
|
|
1171
1171
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
1172
1172
|
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
1173
1173
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
@@ -1214,7 +1214,7 @@ var Client = /** @class */ (function () {
|
|
|
1214
1214
|
this.__notifier = {
|
|
1215
1215
|
name: '@honeybadger-io/core',
|
|
1216
1216
|
url: 'https://github.com/honeybadger-io/honeybadger-js/tree/master/packages/core',
|
|
1217
|
-
version: '6.12.
|
|
1217
|
+
version: '6.12.3'
|
|
1218
1218
|
};
|
|
1219
1219
|
this.config = __assign$1(__assign$1({}, defaults_1.CONFIG), opts);
|
|
1220
1220
|
this.__initStore();
|
|
@@ -1549,9 +1549,9 @@ var Client = /** @class */ (function () {
|
|
|
1549
1549
|
notice.__breadcrumbs = [];
|
|
1550
1550
|
}
|
|
1551
1551
|
return (0, util_1$5.getSourceForBacktrace)(originalBacktrace, this.__getSourceFileHandler)
|
|
1552
|
-
.then(function (sourcePerTrace) { return __awaiter$
|
|
1552
|
+
.then(function (sourcePerTrace) { return __awaiter$3(_this, void 0, void 0, function () {
|
|
1553
1553
|
var payload;
|
|
1554
|
-
return __generator$
|
|
1554
|
+
return __generator$3(this, function (_a) {
|
|
1555
1555
|
sourcePerTrace.forEach(function (source, index) {
|
|
1556
1556
|
notice.backtrace[index].source = source;
|
|
1557
1557
|
});
|
|
@@ -1645,7 +1645,7 @@ Object.defineProperty(types, "__esModule", { value: true });
|
|
|
1645
1645
|
|
|
1646
1646
|
var util = {};
|
|
1647
1647
|
|
|
1648
|
-
var __awaiter$
|
|
1648
|
+
var __awaiter$2 = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
1649
1649
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
1650
1650
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
1651
1651
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
@@ -1654,7 +1654,7 @@ var __awaiter$1 = (commonjsGlobal && commonjsGlobal.__awaiter) || function (this
|
|
|
1654
1654
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1655
1655
|
});
|
|
1656
1656
|
};
|
|
1657
|
-
var __generator$
|
|
1657
|
+
var __generator$2 = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
|
|
1658
1658
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
1659
1659
|
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
1660
1660
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
@@ -1703,9 +1703,9 @@ function fatallyLogAndExit(err, source) {
|
|
|
1703
1703
|
}
|
|
1704
1704
|
util.fatallyLogAndExit = fatallyLogAndExit;
|
|
1705
1705
|
function getStats() {
|
|
1706
|
-
return __awaiter$
|
|
1706
|
+
return __awaiter$2(this, void 0, void 0, function () {
|
|
1707
1707
|
var load, stats, fallback, memData, data, results;
|
|
1708
|
-
return __generator$
|
|
1708
|
+
return __generator$2(this, function (_a) {
|
|
1709
1709
|
switch (_a.label) {
|
|
1710
1710
|
case 0:
|
|
1711
1711
|
load = os_1.default.loadavg();
|
|
@@ -1764,8 +1764,8 @@ util.getStats = getStats;
|
|
|
1764
1764
|
* @param path to source code
|
|
1765
1765
|
*/
|
|
1766
1766
|
function getSourceFile(path) {
|
|
1767
|
-
return __awaiter$
|
|
1768
|
-
return __generator$
|
|
1767
|
+
return __awaiter$2(this, void 0, void 0, function () {
|
|
1768
|
+
return __generator$2(this, function (_a) {
|
|
1769
1769
|
switch (_a.label) {
|
|
1770
1770
|
case 0:
|
|
1771
1771
|
_a.trys.push([0, 2, , 3]);
|
|
@@ -2086,7 +2086,7 @@ var shutdown_plugin = {};
|
|
|
2086
2086
|
|
|
2087
2087
|
var shutdown_monitor = {};
|
|
2088
2088
|
|
|
2089
|
-
var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2089
|
+
var __awaiter$1 = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2090
2090
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
2091
2091
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
2092
2092
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
@@ -2095,7 +2095,7 @@ var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisAr
|
|
|
2095
2095
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
2096
2096
|
});
|
|
2097
2097
|
};
|
|
2098
|
-
var __generator = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
|
|
2098
|
+
var __generator$1 = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
|
|
2099
2099
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
2100
2100
|
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
2101
2101
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
@@ -2135,8 +2135,8 @@ var ShutdownMonitor = /** @class */ (function () {
|
|
|
2135
2135
|
ShutdownMonitor.prototype.makeListener = function () {
|
|
2136
2136
|
var _this = this;
|
|
2137
2137
|
// noinspection UnnecessaryLocalVariableJS
|
|
2138
|
-
var honeybadgerShutdownListener = function (signal) { return __awaiter(_this, void 0, void 0, function () {
|
|
2139
|
-
return __generator(this, function (_a) {
|
|
2138
|
+
var honeybadgerShutdownListener = function (signal) { return __awaiter$1(_this, void 0, void 0, function () {
|
|
2139
|
+
return __generator$1(this, function (_a) {
|
|
2140
2140
|
switch (_a.label) {
|
|
2141
2141
|
case 0:
|
|
2142
2142
|
if (this.__isReporting || !this.__client) {
|
|
@@ -2159,7 +2159,7 @@ var ShutdownMonitor = /** @class */ (function () {
|
|
|
2159
2159
|
ShutdownMonitor.prototype.maybeAddListener = function () {
|
|
2160
2160
|
for (var _i = 0, _a = ShutdownMonitor.KILL_SIGNALS; _i < _a.length; _i++) {
|
|
2161
2161
|
var signal = _a[_i];
|
|
2162
|
-
var signalListeners = process.listeners(signal);
|
|
2162
|
+
var signalListeners = process.listeners(signal) || [];
|
|
2163
2163
|
if (!signalListeners.includes(this.__listener)) {
|
|
2164
2164
|
process.on(signal, this.__listener);
|
|
2165
2165
|
}
|
|
@@ -2168,7 +2168,7 @@ var ShutdownMonitor = /** @class */ (function () {
|
|
|
2168
2168
|
ShutdownMonitor.prototype.maybeRemoveListener = function () {
|
|
2169
2169
|
for (var _i = 0, _a = ShutdownMonitor.KILL_SIGNALS; _i < _a.length; _i++) {
|
|
2170
2170
|
var signal = _a[_i];
|
|
2171
|
-
var signalListeners = process.listeners(signal);
|
|
2171
|
+
var signalListeners = process.listeners(signal) || [];
|
|
2172
2172
|
if (signalListeners.includes(this.__listener)) {
|
|
2173
2173
|
process.removeListener(signal, this.__listener);
|
|
2174
2174
|
}
|
|
@@ -2176,8 +2176,7 @@ var ShutdownMonitor = /** @class */ (function () {
|
|
|
2176
2176
|
};
|
|
2177
2177
|
ShutdownMonitor.prototype.hasOtherShutdownListeners = function (signal) {
|
|
2178
2178
|
var _this = this;
|
|
2179
|
-
var otherListeners = process
|
|
2180
|
-
.listeners(signal)
|
|
2179
|
+
var otherListeners = (process.listeners(signal) || [])
|
|
2181
2180
|
.filter(function (listener) { return listener !== _this.__listener; });
|
|
2182
2181
|
return otherListeners.length > 0;
|
|
2183
2182
|
};
|
|
@@ -2293,12 +2292,12 @@ var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (
|
|
|
2293
2292
|
};
|
|
2294
2293
|
Object.defineProperty(transport, "__esModule", { value: true });
|
|
2295
2294
|
transport.ServerTransport = void 0;
|
|
2296
|
-
var core_1$
|
|
2295
|
+
var core_1$2 = src;
|
|
2297
2296
|
var url_1 = require$$0__default$1["default"];
|
|
2298
2297
|
var util_1 = util;
|
|
2299
2298
|
var http = __importStar(require$$3__default$1["default"]);
|
|
2300
2299
|
var https = __importStar(require$$4__default["default"]);
|
|
2301
|
-
var sanitize = core_1$
|
|
2300
|
+
var sanitize = core_1$2.Util.sanitize;
|
|
2302
2301
|
var ServerTransport = /** @class */ (function () {
|
|
2303
2302
|
function ServerTransport(headers) {
|
|
2304
2303
|
if (headers === void 0) { headers = {}; }
|
|
@@ -2445,7 +2444,7 @@ async_store.AsyncStore = AsyncStore;
|
|
|
2445
2444
|
|
|
2446
2445
|
Object.defineProperty(stacked_store, "__esModule", { value: true });
|
|
2447
2446
|
stacked_store.StackedStore = void 0;
|
|
2448
|
-
var core_1 = src;
|
|
2447
|
+
var core_1$1 = src;
|
|
2449
2448
|
var async_store_1 = async_store;
|
|
2450
2449
|
/**
|
|
2451
2450
|
* A store that's really a "stack" of stores (async and global)
|
|
@@ -2458,7 +2457,7 @@ var StackedStore = /** @class */ (function () {
|
|
|
2458
2457
|
function StackedStore(breadcrumbsLimit) {
|
|
2459
2458
|
this.contents = { context: {}, breadcrumbs: [] };
|
|
2460
2459
|
this.asyncStore = async_store_1.AsyncStore.create(this.contents, breadcrumbsLimit);
|
|
2461
|
-
this.globalStore = core_1.GlobalStore.create(this.contents, breadcrumbsLimit);
|
|
2460
|
+
this.globalStore = core_1$1.GlobalStore.create(this.contents, breadcrumbsLimit);
|
|
2462
2461
|
}
|
|
2463
2462
|
StackedStore.prototype.__activeStore = function () {
|
|
2464
2463
|
var _a;
|
|
@@ -2593,11 +2592,236 @@ function requireCheckIn () {
|
|
|
2593
2592
|
return checkIn;
|
|
2594
2593
|
}
|
|
2595
2594
|
|
|
2596
|
-
var
|
|
2595
|
+
var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2596
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
2597
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
2598
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
2599
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
2600
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
2601
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
2602
|
+
});
|
|
2603
|
+
};
|
|
2604
|
+
var __generator = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
|
|
2605
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
2606
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
2607
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
2608
|
+
function step(op) {
|
|
2609
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
2610
|
+
while (_) try {
|
|
2611
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
2612
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
2613
|
+
switch (op[0]) {
|
|
2614
|
+
case 0: case 1: t = op; break;
|
|
2615
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
2616
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
2617
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
2618
|
+
default:
|
|
2619
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
2620
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
2621
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
2622
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
2623
|
+
if (t[2]) _.ops.pop();
|
|
2624
|
+
_.trys.pop(); continue;
|
|
2625
|
+
}
|
|
2626
|
+
op = body.call(thisArg, _);
|
|
2627
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
2628
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
2629
|
+
}
|
|
2630
|
+
};
|
|
2631
|
+
Object.defineProperty(client, "__esModule", { value: true });
|
|
2632
|
+
client.CheckInsClient = void 0;
|
|
2633
|
+
var core_1 = src;
|
|
2634
|
+
var check_in_1 = requireCheckIn();
|
|
2635
|
+
var CheckInsClient = /** @class */ (function () {
|
|
2636
|
+
function CheckInsClient(config, transport) {
|
|
2637
|
+
this.transport = transport;
|
|
2638
|
+
this.config = config;
|
|
2639
|
+
this.logger = config.logger;
|
|
2640
|
+
}
|
|
2641
|
+
CheckInsClient.prototype.configure = function (config) {
|
|
2642
|
+
this.config = config;
|
|
2643
|
+
};
|
|
2644
|
+
CheckInsClient.prototype.getProjectId = function (projectApiKey) {
|
|
2645
|
+
var _a;
|
|
2646
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2647
|
+
var response, data;
|
|
2648
|
+
return __generator(this, function (_b) {
|
|
2649
|
+
switch (_b.label) {
|
|
2650
|
+
case 0:
|
|
2651
|
+
if (!this.config.personalAuthToken || this.config.personalAuthToken === '') {
|
|
2652
|
+
throw new Error('personalAuthToken is required');
|
|
2653
|
+
}
|
|
2654
|
+
return [4 /*yield*/, this.transport.send({
|
|
2655
|
+
method: 'GET',
|
|
2656
|
+
headers: this.getHeaders(),
|
|
2657
|
+
endpoint: core_1.Util.endpoint(this.config.appEndpoint, "v2/project_keys/".concat(projectApiKey)),
|
|
2658
|
+
logger: this.logger,
|
|
2659
|
+
})];
|
|
2660
|
+
case 1:
|
|
2661
|
+
response = _b.sent();
|
|
2662
|
+
if (response.statusCode !== 200) {
|
|
2663
|
+
throw new Error("Failed to fetch project[".concat(projectApiKey, "]: ").concat(this.getErrorMessage(response.body)));
|
|
2664
|
+
}
|
|
2665
|
+
data = JSON.parse(response.body);
|
|
2666
|
+
return [2 /*return*/, (_a = data === null || data === void 0 ? void 0 : data.project) === null || _a === void 0 ? void 0 : _a.id];
|
|
2667
|
+
}
|
|
2668
|
+
});
|
|
2669
|
+
});
|
|
2670
|
+
};
|
|
2671
|
+
CheckInsClient.prototype.listForProject = function (projectId) {
|
|
2672
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2673
|
+
var response, data;
|
|
2674
|
+
return __generator(this, function (_a) {
|
|
2675
|
+
switch (_a.label) {
|
|
2676
|
+
case 0:
|
|
2677
|
+
if (!this.config.personalAuthToken || this.config.personalAuthToken === '') {
|
|
2678
|
+
throw new Error('personalAuthToken is required');
|
|
2679
|
+
}
|
|
2680
|
+
return [4 /*yield*/, this.transport.send({
|
|
2681
|
+
method: 'GET',
|
|
2682
|
+
headers: this.getHeaders(),
|
|
2683
|
+
endpoint: core_1.Util.endpoint(this.config.appEndpoint, "v2/projects/".concat(projectId, "/check_ins")),
|
|
2684
|
+
logger: this.logger,
|
|
2685
|
+
})];
|
|
2686
|
+
case 1:
|
|
2687
|
+
response = _a.sent();
|
|
2688
|
+
if (response.statusCode !== 200) {
|
|
2689
|
+
throw new Error("Failed to fetch checkins for project[".concat(projectId, "]: ").concat(this.getErrorMessage(response.body)));
|
|
2690
|
+
}
|
|
2691
|
+
data = JSON.parse(response.body);
|
|
2692
|
+
return [2 /*return*/, data.results.map(function (checkin) { return check_in_1.CheckIn.fromResponsePayload(checkin); })];
|
|
2693
|
+
}
|
|
2694
|
+
});
|
|
2695
|
+
});
|
|
2696
|
+
};
|
|
2697
|
+
CheckInsClient.prototype.get = function (projectId, checkInId) {
|
|
2698
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2699
|
+
var response, data;
|
|
2700
|
+
return __generator(this, function (_a) {
|
|
2701
|
+
switch (_a.label) {
|
|
2702
|
+
case 0:
|
|
2703
|
+
if (!this.config.personalAuthToken || this.config.personalAuthToken === '') {
|
|
2704
|
+
throw new Error('personalAuthToken is required');
|
|
2705
|
+
}
|
|
2706
|
+
return [4 /*yield*/, this.transport.send({
|
|
2707
|
+
method: 'GET',
|
|
2708
|
+
headers: this.getHeaders(),
|
|
2709
|
+
endpoint: core_1.Util.endpoint(this.config.appEndpoint, "v2/projects/".concat(projectId, "/check_ins/").concat(checkInId)),
|
|
2710
|
+
logger: this.logger,
|
|
2711
|
+
})];
|
|
2712
|
+
case 1:
|
|
2713
|
+
response = _a.sent();
|
|
2714
|
+
if (response.statusCode !== 200) {
|
|
2715
|
+
throw new Error("Failed to fetch check-in[".concat(checkInId, "] for project[").concat(projectId, "]: ").concat(this.getErrorMessage(response.body)));
|
|
2716
|
+
}
|
|
2717
|
+
data = JSON.parse(response.body);
|
|
2718
|
+
return [2 /*return*/, check_in_1.CheckIn.fromResponsePayload(data)];
|
|
2719
|
+
}
|
|
2720
|
+
});
|
|
2721
|
+
});
|
|
2722
|
+
};
|
|
2723
|
+
CheckInsClient.prototype.create = function (projectId, checkIn) {
|
|
2724
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2725
|
+
var checkInTyped, response, data;
|
|
2726
|
+
return __generator(this, function (_a) {
|
|
2727
|
+
switch (_a.label) {
|
|
2728
|
+
case 0:
|
|
2729
|
+
if (!this.config.personalAuthToken || this.config.personalAuthToken === '') {
|
|
2730
|
+
throw new Error('personalAuthToken is required');
|
|
2731
|
+
}
|
|
2732
|
+
checkInTyped = checkIn instanceof check_in_1.CheckIn ? checkIn : new check_in_1.CheckIn(checkIn);
|
|
2733
|
+
return [4 /*yield*/, this.transport.send({
|
|
2734
|
+
method: 'POST',
|
|
2735
|
+
headers: this.getHeaders(),
|
|
2736
|
+
endpoint: core_1.Util.endpoint(this.config.appEndpoint, "v2/projects/".concat(projectId, "/check_ins")),
|
|
2737
|
+
logger: this.logger,
|
|
2738
|
+
}, { check_in: checkInTyped.asRequestPayload() })];
|
|
2739
|
+
case 1:
|
|
2740
|
+
response = _a.sent();
|
|
2741
|
+
if (response.statusCode !== 201) {
|
|
2742
|
+
throw new Error("Failed to create check-in[".concat(checkIn.slug, "] for project[").concat(projectId, "]: ").concat(this.getErrorMessage(response.body)));
|
|
2743
|
+
}
|
|
2744
|
+
data = JSON.parse(response.body);
|
|
2745
|
+
return [2 /*return*/, check_in_1.CheckIn.fromResponsePayload(data)];
|
|
2746
|
+
}
|
|
2747
|
+
});
|
|
2748
|
+
});
|
|
2749
|
+
};
|
|
2750
|
+
CheckInsClient.prototype.update = function (projectId, checkIn) {
|
|
2751
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2752
|
+
var checkInTyped, response;
|
|
2753
|
+
return __generator(this, function (_a) {
|
|
2754
|
+
switch (_a.label) {
|
|
2755
|
+
case 0:
|
|
2756
|
+
if (!this.config.personalAuthToken || this.config.personalAuthToken === '') {
|
|
2757
|
+
throw new Error('personalAuthToken is required');
|
|
2758
|
+
}
|
|
2759
|
+
checkInTyped = checkIn instanceof check_in_1.CheckIn ? checkIn : new check_in_1.CheckIn(checkIn);
|
|
2760
|
+
return [4 /*yield*/, this.transport.send({
|
|
2761
|
+
method: 'PUT',
|
|
2762
|
+
headers: this.getHeaders(),
|
|
2763
|
+
endpoint: core_1.Util.endpoint(this.config.appEndpoint, "v2/projects/".concat(projectId, "/check_ins/").concat(checkIn.id)),
|
|
2764
|
+
logger: this.logger,
|
|
2765
|
+
}, { check_in: checkInTyped.asRequestPayload() })];
|
|
2766
|
+
case 1:
|
|
2767
|
+
response = _a.sent();
|
|
2768
|
+
if (response.statusCode !== 204) {
|
|
2769
|
+
throw new Error("Failed to update checkin[".concat(checkIn.slug, "] for project[").concat(projectId, "]: ").concat(this.getErrorMessage(response.body)));
|
|
2770
|
+
}
|
|
2771
|
+
return [2 /*return*/, checkInTyped];
|
|
2772
|
+
}
|
|
2773
|
+
});
|
|
2774
|
+
});
|
|
2775
|
+
};
|
|
2776
|
+
CheckInsClient.prototype.remove = function (projectId, checkIn) {
|
|
2777
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2778
|
+
var response;
|
|
2779
|
+
return __generator(this, function (_a) {
|
|
2780
|
+
switch (_a.label) {
|
|
2781
|
+
case 0:
|
|
2782
|
+
if (!this.config.personalAuthToken || this.config.personalAuthToken === '') {
|
|
2783
|
+
throw new Error('personalAuthToken is required');
|
|
2784
|
+
}
|
|
2785
|
+
return [4 /*yield*/, this.transport.send({
|
|
2786
|
+
method: 'DELETE',
|
|
2787
|
+
headers: this.getHeaders(),
|
|
2788
|
+
endpoint: core_1.Util.endpoint(this.config.appEndpoint, "v2/projects/".concat(projectId, "/check_ins/").concat(checkIn.id)),
|
|
2789
|
+
logger: this.logger,
|
|
2790
|
+
})];
|
|
2791
|
+
case 1:
|
|
2792
|
+
response = _a.sent();
|
|
2793
|
+
if (response.statusCode !== 204) {
|
|
2794
|
+
throw new Error("Failed to remove checkin[".concat(checkIn.slug, "] for project[").concat(projectId, "]: ").concat(this.getErrorMessage(response.body)));
|
|
2795
|
+
}
|
|
2796
|
+
return [2 /*return*/];
|
|
2797
|
+
}
|
|
2798
|
+
});
|
|
2799
|
+
});
|
|
2800
|
+
};
|
|
2801
|
+
CheckInsClient.prototype.getHeaders = function () {
|
|
2802
|
+
return {
|
|
2803
|
+
'Authorization': "Basic ".concat(Buffer.from("".concat(this.config.personalAuthToken, ":")).toString('base64')),
|
|
2804
|
+
'Content-Type': 'application/json'
|
|
2805
|
+
};
|
|
2806
|
+
};
|
|
2807
|
+
CheckInsClient.prototype.getErrorMessage = function (responseBody) {
|
|
2808
|
+
var _a;
|
|
2809
|
+
if (!responseBody) {
|
|
2810
|
+
return '';
|
|
2811
|
+
}
|
|
2812
|
+
try {
|
|
2813
|
+
var jsonBody = JSON.parse(responseBody);
|
|
2814
|
+
return (_a = jsonBody.errors) !== null && _a !== void 0 ? _a : '';
|
|
2815
|
+
}
|
|
2816
|
+
catch (e) {
|
|
2817
|
+
return responseBody;
|
|
2818
|
+
}
|
|
2819
|
+
};
|
|
2820
|
+
return CheckInsClient;
|
|
2821
|
+
}());
|
|
2822
|
+
client.CheckInsClient = CheckInsClient;
|
|
2597
2823
|
|
|
2598
|
-
function
|
|
2599
|
-
if (hasRequiredClient) return client;
|
|
2600
|
-
hasRequiredClient = 1;
|
|
2824
|
+
(function (exports) {
|
|
2601
2825
|
var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2602
2826
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
2603
2827
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -2634,415 +2858,180 @@ function requireClient () {
|
|
|
2634
2858
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
2635
2859
|
}
|
|
2636
2860
|
};
|
|
2637
|
-
|
|
2638
|
-
|
|
2861
|
+
var __spreadArray = (commonjsGlobal && commonjsGlobal.__spreadArray) || function (to, from, pack) {
|
|
2862
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
2863
|
+
if (ar || !(i in from)) {
|
|
2864
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
2865
|
+
ar[i] = from[i];
|
|
2866
|
+
}
|
|
2867
|
+
}
|
|
2868
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
2869
|
+
};
|
|
2870
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2871
|
+
exports.CheckInsManager = exports.CheckIn = exports.CheckInsClient = void 0;
|
|
2639
2872
|
var core_1 = src;
|
|
2873
|
+
var client_1 = client;
|
|
2874
|
+
var transport_1 = transport;
|
|
2640
2875
|
var check_in_1 = requireCheckIn();
|
|
2641
|
-
var
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2876
|
+
var client_2 = client;
|
|
2877
|
+
Object.defineProperty(exports, "CheckInsClient", { enumerable: true, get: function () { return client_2.CheckInsClient; } });
|
|
2878
|
+
var check_in_2 = requireCheckIn();
|
|
2879
|
+
Object.defineProperty(exports, "CheckIn", { enumerable: true, get: function () { return check_in_2.CheckIn; } });
|
|
2880
|
+
var CheckInsManager = /** @class */ (function () {
|
|
2881
|
+
function CheckInsManager(config, client) {
|
|
2882
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2883
|
+
this.config = {
|
|
2884
|
+
appEndpoint: (_a = config.appEndpoint) !== null && _a !== void 0 ? _a : core_1.Defaults.CONFIG.appEndpoint,
|
|
2885
|
+
debug: (_b = config.debug) !== null && _b !== void 0 ? _b : false,
|
|
2886
|
+
apiKey: (_c = config.apiKey) !== null && _c !== void 0 ? _c : undefined,
|
|
2887
|
+
personalAuthToken: (_d = config.personalAuthToken) !== null && _d !== void 0 ? _d : undefined,
|
|
2888
|
+
checkins: (_e = config.checkins) !== null && _e !== void 0 ? _e : [],
|
|
2889
|
+
logger: (_f = config.logger) !== null && _f !== void 0 ? _f : console,
|
|
2890
|
+
};
|
|
2891
|
+
var transport = new transport_1.ServerTransport();
|
|
2892
|
+
this.logger = core_1.Util.logger(this);
|
|
2893
|
+
this.client = client !== null && client !== void 0 ? client : new client_1.CheckInsClient({
|
|
2894
|
+
appEndpoint: config.appEndpoint,
|
|
2895
|
+
apiKey: config.apiKey,
|
|
2896
|
+
personalAuthToken: config.personalAuthToken,
|
|
2897
|
+
logger: this.logger
|
|
2898
|
+
}, transport);
|
|
2646
2899
|
}
|
|
2647
|
-
|
|
2648
|
-
var _a;
|
|
2649
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2650
|
-
var response, data;
|
|
2651
|
-
return __generator(this, function (_b) {
|
|
2652
|
-
switch (_b.label) {
|
|
2653
|
-
case 0:
|
|
2654
|
-
if (!this.config.personalAuthToken || this.config.personalAuthToken === '') {
|
|
2655
|
-
throw new Error('personalAuthToken is required');
|
|
2656
|
-
}
|
|
2657
|
-
return [4 /*yield*/, this.transport.send({
|
|
2658
|
-
method: 'GET',
|
|
2659
|
-
headers: this.getHeaders(),
|
|
2660
|
-
endpoint: core_1.Util.endpoint(this.config.appEndpoint, "v2/project_keys/".concat(projectApiKey)),
|
|
2661
|
-
logger: this.logger,
|
|
2662
|
-
})];
|
|
2663
|
-
case 1:
|
|
2664
|
-
response = _b.sent();
|
|
2665
|
-
if (response.statusCode !== 200) {
|
|
2666
|
-
throw new Error("Failed to fetch project[".concat(projectApiKey, "]: ").concat(this.getErrorMessage(response.body)));
|
|
2667
|
-
}
|
|
2668
|
-
data = JSON.parse(response.body);
|
|
2669
|
-
return [2 /*return*/, (_a = data === null || data === void 0 ? void 0 : data.project) === null || _a === void 0 ? void 0 : _a.id];
|
|
2670
|
-
}
|
|
2671
|
-
});
|
|
2672
|
-
});
|
|
2673
|
-
};
|
|
2674
|
-
CheckInsClient.prototype.listForProject = function (projectId) {
|
|
2900
|
+
CheckInsManager.prototype.sync = function () {
|
|
2675
2901
|
return __awaiter(this, void 0, void 0, function () {
|
|
2676
|
-
var
|
|
2902
|
+
var localCheckIns, projectId, remoteCheckIns, createdOrUpdated, removed;
|
|
2677
2903
|
return __generator(this, function (_a) {
|
|
2678
2904
|
switch (_a.label) {
|
|
2679
2905
|
case 0:
|
|
2680
|
-
|
|
2681
|
-
|
|
2906
|
+
// check if app endpoint is set
|
|
2907
|
+
if (!this.config.appEndpoint || this.config.appEndpoint === '') {
|
|
2908
|
+
throw new Error('appEndpoint is required');
|
|
2682
2909
|
}
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
endpoint: core_1.Util.endpoint(this.config.appEndpoint, "v2/projects/".concat(projectId, "/check_ins")),
|
|
2687
|
-
logger: this.logger,
|
|
2688
|
-
})];
|
|
2689
|
-
case 1:
|
|
2690
|
-
response = _a.sent();
|
|
2691
|
-
if (response.statusCode !== 200) {
|
|
2692
|
-
throw new Error("Failed to fetch checkins for project[".concat(projectId, "]: ").concat(this.getErrorMessage(response.body)));
|
|
2910
|
+
// check if api key is set
|
|
2911
|
+
if (!this.config.apiKey || this.config.apiKey === '') {
|
|
2912
|
+
throw new Error('apiKey is required');
|
|
2693
2913
|
}
|
|
2694
|
-
|
|
2695
|
-
return [2 /*return*/, data.results.map(function (checkin) { return check_in_1.CheckIn.fromResponsePayload(checkin); })];
|
|
2696
|
-
}
|
|
2697
|
-
});
|
|
2698
|
-
});
|
|
2699
|
-
};
|
|
2700
|
-
CheckInsClient.prototype.get = function (projectId, checkInId) {
|
|
2701
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2702
|
-
var response, data;
|
|
2703
|
-
return __generator(this, function (_a) {
|
|
2704
|
-
switch (_a.label) {
|
|
2705
|
-
case 0:
|
|
2914
|
+
// check if personal auth token is set
|
|
2706
2915
|
if (!this.config.personalAuthToken || this.config.personalAuthToken === '') {
|
|
2707
2916
|
throw new Error('personalAuthToken is required');
|
|
2708
2917
|
}
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
headers: this.getHeaders(),
|
|
2712
|
-
endpoint: core_1.Util.endpoint(this.config.appEndpoint, "v2/projects/".concat(projectId, "/check_ins/").concat(checkInId)),
|
|
2713
|
-
logger: this.logger,
|
|
2714
|
-
})];
|
|
2918
|
+
localCheckIns = this.getLocalCheckIns();
|
|
2919
|
+
return [4 /*yield*/, this.client.getProjectId(this.config.apiKey)];
|
|
2715
2920
|
case 1:
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2921
|
+
projectId = _a.sent();
|
|
2922
|
+
return [4 /*yield*/, this.client.listForProject(projectId)];
|
|
2923
|
+
case 2:
|
|
2924
|
+
remoteCheckIns = _a.sent();
|
|
2925
|
+
return [4 /*yield*/, this.createOrUpdate(projectId, localCheckIns, remoteCheckIns)];
|
|
2926
|
+
case 3:
|
|
2927
|
+
createdOrUpdated = _a.sent();
|
|
2928
|
+
return [4 /*yield*/, this.remove(projectId, localCheckIns, remoteCheckIns)];
|
|
2929
|
+
case 4:
|
|
2930
|
+
removed = _a.sent();
|
|
2931
|
+
return [2 /*return*/, __spreadArray(__spreadArray([], createdOrUpdated, true), removed, true)];
|
|
2722
2932
|
}
|
|
2723
2933
|
});
|
|
2724
2934
|
});
|
|
2725
2935
|
};
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
if (!this.config.personalAuthToken || this.config.personalAuthToken === '') {
|
|
2733
|
-
throw new Error('personalAuthToken is required');
|
|
2734
|
-
}
|
|
2735
|
-
return [4 /*yield*/, this.transport.send({
|
|
2736
|
-
method: 'POST',
|
|
2737
|
-
headers: this.getHeaders(),
|
|
2738
|
-
endpoint: core_1.Util.endpoint(this.config.appEndpoint, "v2/projects/".concat(projectId, "/check_ins")),
|
|
2739
|
-
logger: this.logger,
|
|
2740
|
-
}, { check_in: checkIn.asRequestPayload() })];
|
|
2741
|
-
case 1:
|
|
2742
|
-
response = _a.sent();
|
|
2743
|
-
if (response.statusCode !== 201) {
|
|
2744
|
-
throw new Error("Failed to create check-in[".concat(checkIn.slug, "] for project[").concat(projectId, "]: ").concat(this.getErrorMessage(response.body)));
|
|
2745
|
-
}
|
|
2746
|
-
data = JSON.parse(response.body);
|
|
2747
|
-
return [2 /*return*/, check_in_1.CheckIn.fromResponsePayload(data)];
|
|
2748
|
-
}
|
|
2749
|
-
});
|
|
2936
|
+
CheckInsManager.prototype.getLocalCheckIns = function () {
|
|
2937
|
+
// create check-ins from configuration and validate them
|
|
2938
|
+
var localCheckIns = this.config.checkins.map(function (dto) {
|
|
2939
|
+
var checkIn = new check_in_1.CheckIn(dto);
|
|
2940
|
+
checkIn.validate();
|
|
2941
|
+
return checkIn;
|
|
2750
2942
|
});
|
|
2943
|
+
// validate that we have unique check-in slugs
|
|
2944
|
+
var checkInSlugs = localCheckIns.map(function (checkIn) { return checkIn.slug; });
|
|
2945
|
+
var uniqueCheckInSlugs = new Set(checkInSlugs);
|
|
2946
|
+
if (checkInSlugs.length !== uniqueCheckInSlugs.size) {
|
|
2947
|
+
throw new Error('check-in slugs must be unique');
|
|
2948
|
+
}
|
|
2949
|
+
return localCheckIns;
|
|
2751
2950
|
};
|
|
2752
|
-
|
|
2951
|
+
CheckInsManager.prototype.createOrUpdate = function (projectId, localCheckIns, remoteCheckIns) {
|
|
2753
2952
|
return __awaiter(this, void 0, void 0, function () {
|
|
2754
|
-
var
|
|
2953
|
+
var results, _loop_1, this_1, _i, localCheckIns_1, localCheckIn;
|
|
2755
2954
|
return __generator(this, function (_a) {
|
|
2756
2955
|
switch (_a.label) {
|
|
2757
2956
|
case 0:
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2957
|
+
results = [];
|
|
2958
|
+
_loop_1 = function (localCheckIn) {
|
|
2959
|
+
var remoteCheckIn, _b, _c, _d, _e;
|
|
2960
|
+
return __generator(this, function (_f) {
|
|
2961
|
+
switch (_f.label) {
|
|
2962
|
+
case 0:
|
|
2963
|
+
remoteCheckIn = remoteCheckIns.find(function (checkIn) {
|
|
2964
|
+
return checkIn.slug === localCheckIn.slug;
|
|
2965
|
+
});
|
|
2966
|
+
if (!!remoteCheckIn) return [3 /*break*/, 2];
|
|
2967
|
+
_c = (_b = results).push;
|
|
2968
|
+
return [4 /*yield*/, this_1.client.create(projectId, localCheckIn)];
|
|
2969
|
+
case 1:
|
|
2970
|
+
_c.apply(_b, [_f.sent()]);
|
|
2971
|
+
return [3 /*break*/, 5];
|
|
2972
|
+
case 2:
|
|
2973
|
+
if (!!localCheckIn.isInSync(remoteCheckIn)) return [3 /*break*/, 4];
|
|
2974
|
+
localCheckIn.id = remoteCheckIn.id;
|
|
2975
|
+
_e = (_d = results).push;
|
|
2976
|
+
return [4 /*yield*/, this_1.client.update(projectId, localCheckIn)];
|
|
2977
|
+
case 3:
|
|
2978
|
+
_e.apply(_d, [_f.sent()]);
|
|
2979
|
+
return [3 /*break*/, 5];
|
|
2980
|
+
case 4:
|
|
2981
|
+
// no change - still need to add to results
|
|
2982
|
+
results.push(remoteCheckIn);
|
|
2983
|
+
_f.label = 5;
|
|
2984
|
+
case 5: return [2 /*return*/];
|
|
2985
|
+
}
|
|
2986
|
+
});
|
|
2987
|
+
};
|
|
2988
|
+
this_1 = this;
|
|
2989
|
+
_i = 0, localCheckIns_1 = localCheckIns;
|
|
2990
|
+
_a.label = 1;
|
|
2767
2991
|
case 1:
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2992
|
+
if (!(_i < localCheckIns_1.length)) return [3 /*break*/, 4];
|
|
2993
|
+
localCheckIn = localCheckIns_1[_i];
|
|
2994
|
+
return [5 /*yield**/, _loop_1(localCheckIn)];
|
|
2995
|
+
case 2:
|
|
2996
|
+
_a.sent();
|
|
2997
|
+
_a.label = 3;
|
|
2998
|
+
case 3:
|
|
2999
|
+
_i++;
|
|
3000
|
+
return [3 /*break*/, 1];
|
|
3001
|
+
case 4: return [2 /*return*/, results];
|
|
2773
3002
|
}
|
|
2774
3003
|
});
|
|
2775
3004
|
});
|
|
2776
3005
|
};
|
|
2777
|
-
|
|
3006
|
+
CheckInsManager.prototype.remove = function (projectId, localCheckIns, remoteCheckIns) {
|
|
2778
3007
|
return __awaiter(this, void 0, void 0, function () {
|
|
2779
|
-
var
|
|
3008
|
+
var checkInsToRemove;
|
|
3009
|
+
var _this = this;
|
|
2780
3010
|
return __generator(this, function (_a) {
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
return [2 /*return*/];
|
|
2798
|
-
}
|
|
3011
|
+
checkInsToRemove = remoteCheckIns.filter(function (remoteCheckIn) {
|
|
3012
|
+
return !localCheckIns.find(function (localCheckIn) {
|
|
3013
|
+
return localCheckIn.slug === remoteCheckIn.slug;
|
|
3014
|
+
});
|
|
3015
|
+
});
|
|
3016
|
+
return [2 /*return*/, Promise.all(checkInsToRemove.map(function (checkIn) { return __awaiter(_this, void 0, void 0, function () {
|
|
3017
|
+
return __generator(this, function (_a) {
|
|
3018
|
+
switch (_a.label) {
|
|
3019
|
+
case 0: return [4 /*yield*/, this.client.remove(projectId, checkIn)];
|
|
3020
|
+
case 1:
|
|
3021
|
+
_a.sent();
|
|
3022
|
+
checkIn.markAsDeleted();
|
|
3023
|
+
return [2 /*return*/, checkIn];
|
|
3024
|
+
}
|
|
3025
|
+
});
|
|
3026
|
+
}); }))];
|
|
2799
3027
|
});
|
|
2800
3028
|
});
|
|
2801
3029
|
};
|
|
2802
|
-
|
|
2803
|
-
return {
|
|
2804
|
-
'Authorization': "Basic ".concat(Buffer.from("".concat(this.config.personalAuthToken, ":")).toString('base64')),
|
|
2805
|
-
'Content-Type': 'application/json'
|
|
2806
|
-
};
|
|
2807
|
-
};
|
|
2808
|
-
CheckInsClient.prototype.getErrorMessage = function (responseBody) {
|
|
2809
|
-
var _a;
|
|
2810
|
-
if (!responseBody) {
|
|
2811
|
-
return '';
|
|
2812
|
-
}
|
|
2813
|
-
try {
|
|
2814
|
-
var jsonBody = JSON.parse(responseBody);
|
|
2815
|
-
return (_a = jsonBody.errors) !== null && _a !== void 0 ? _a : '';
|
|
2816
|
-
}
|
|
2817
|
-
catch (e) {
|
|
2818
|
-
return responseBody;
|
|
2819
|
-
}
|
|
2820
|
-
};
|
|
2821
|
-
return CheckInsClient;
|
|
3030
|
+
return CheckInsManager;
|
|
2822
3031
|
}());
|
|
2823
|
-
|
|
3032
|
+
exports.CheckInsManager = CheckInsManager;
|
|
2824
3033
|
|
|
2825
|
-
return client;
|
|
2826
|
-
}
|
|
2827
|
-
|
|
2828
|
-
var hasRequiredCheckInsManager;
|
|
2829
|
-
|
|
2830
|
-
function requireCheckInsManager () {
|
|
2831
|
-
if (hasRequiredCheckInsManager) return checkInsManager;
|
|
2832
|
-
hasRequiredCheckInsManager = 1;
|
|
2833
|
-
(function (exports) {
|
|
2834
|
-
var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2835
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
2836
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
2837
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
2838
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
2839
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
2840
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
2841
|
-
});
|
|
2842
|
-
};
|
|
2843
|
-
var __generator = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
|
|
2844
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
2845
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
2846
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
2847
|
-
function step(op) {
|
|
2848
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
2849
|
-
while (_) try {
|
|
2850
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
2851
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
2852
|
-
switch (op[0]) {
|
|
2853
|
-
case 0: case 1: t = op; break;
|
|
2854
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
2855
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
2856
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
2857
|
-
default:
|
|
2858
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
2859
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
2860
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
2861
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
2862
|
-
if (t[2]) _.ops.pop();
|
|
2863
|
-
_.trys.pop(); continue;
|
|
2864
|
-
}
|
|
2865
|
-
op = body.call(thisArg, _);
|
|
2866
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
2867
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
2868
|
-
}
|
|
2869
|
-
};
|
|
2870
|
-
var __spreadArray = (commonjsGlobal && commonjsGlobal.__spreadArray) || function (to, from, pack) {
|
|
2871
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
2872
|
-
if (ar || !(i in from)) {
|
|
2873
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
2874
|
-
ar[i] = from[i];
|
|
2875
|
-
}
|
|
2876
|
-
}
|
|
2877
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
2878
|
-
};
|
|
2879
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2880
|
-
exports.CheckInsManager = exports.CheckIn = exports.CheckInsClient = void 0;
|
|
2881
|
-
var core_1 = src;
|
|
2882
|
-
var client_1 = requireClient();
|
|
2883
|
-
var transport_1 = transport;
|
|
2884
|
-
var check_in_1 = requireCheckIn();
|
|
2885
|
-
var client_2 = requireClient();
|
|
2886
|
-
Object.defineProperty(exports, "CheckInsClient", { enumerable: true, get: function () { return client_2.CheckInsClient; } });
|
|
2887
|
-
var check_in_2 = requireCheckIn();
|
|
2888
|
-
Object.defineProperty(exports, "CheckIn", { enumerable: true, get: function () { return check_in_2.CheckIn; } });
|
|
2889
|
-
var CheckInsManager = /** @class */ (function () {
|
|
2890
|
-
function CheckInsManager(config, client) {
|
|
2891
|
-
var _a, _b, _c, _d, _e, _f;
|
|
2892
|
-
this.config = {
|
|
2893
|
-
appEndpoint: (_a = config.appEndpoint) !== null && _a !== void 0 ? _a : core_1.Defaults.CONFIG.appEndpoint,
|
|
2894
|
-
debug: (_b = config.debug) !== null && _b !== void 0 ? _b : false,
|
|
2895
|
-
apiKey: (_c = config.apiKey) !== null && _c !== void 0 ? _c : undefined,
|
|
2896
|
-
personalAuthToken: (_d = config.personalAuthToken) !== null && _d !== void 0 ? _d : undefined,
|
|
2897
|
-
checkins: (_e = config.checkins) !== null && _e !== void 0 ? _e : [],
|
|
2898
|
-
logger: (_f = config.logger) !== null && _f !== void 0 ? _f : console,
|
|
2899
|
-
};
|
|
2900
|
-
var transport = new transport_1.ServerTransport();
|
|
2901
|
-
this.logger = core_1.Util.logger(this);
|
|
2902
|
-
this.client = client !== null && client !== void 0 ? client : new client_1.CheckInsClient({
|
|
2903
|
-
appEndpoint: config.appEndpoint,
|
|
2904
|
-
apiKey: config.apiKey,
|
|
2905
|
-
personalAuthToken: config.personalAuthToken,
|
|
2906
|
-
logger: this.logger
|
|
2907
|
-
}, transport);
|
|
2908
|
-
}
|
|
2909
|
-
CheckInsManager.prototype.sync = function () {
|
|
2910
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2911
|
-
var localCheckIns, projectId, remoteCheckIns, createdOrUpdated, removed;
|
|
2912
|
-
return __generator(this, function (_a) {
|
|
2913
|
-
switch (_a.label) {
|
|
2914
|
-
case 0:
|
|
2915
|
-
// check if app endpoint is set
|
|
2916
|
-
if (!this.config.appEndpoint || this.config.appEndpoint === '') {
|
|
2917
|
-
throw new Error('appEndpoint is required');
|
|
2918
|
-
}
|
|
2919
|
-
// check if api key is set
|
|
2920
|
-
if (!this.config.apiKey || this.config.apiKey === '') {
|
|
2921
|
-
throw new Error('apiKey is required');
|
|
2922
|
-
}
|
|
2923
|
-
// check if personal auth token is set
|
|
2924
|
-
if (!this.config.personalAuthToken || this.config.personalAuthToken === '') {
|
|
2925
|
-
throw new Error('personalAuthToken is required');
|
|
2926
|
-
}
|
|
2927
|
-
localCheckIns = this.getLocalCheckIns();
|
|
2928
|
-
return [4 /*yield*/, this.client.getProjectId(this.config.apiKey)];
|
|
2929
|
-
case 1:
|
|
2930
|
-
projectId = _a.sent();
|
|
2931
|
-
return [4 /*yield*/, this.client.listForProject(projectId)];
|
|
2932
|
-
case 2:
|
|
2933
|
-
remoteCheckIns = _a.sent();
|
|
2934
|
-
return [4 /*yield*/, this.createOrUpdate(projectId, localCheckIns, remoteCheckIns)];
|
|
2935
|
-
case 3:
|
|
2936
|
-
createdOrUpdated = _a.sent();
|
|
2937
|
-
return [4 /*yield*/, this.remove(projectId, localCheckIns, remoteCheckIns)];
|
|
2938
|
-
case 4:
|
|
2939
|
-
removed = _a.sent();
|
|
2940
|
-
return [2 /*return*/, __spreadArray(__spreadArray([], createdOrUpdated, true), removed, true)];
|
|
2941
|
-
}
|
|
2942
|
-
});
|
|
2943
|
-
});
|
|
2944
|
-
};
|
|
2945
|
-
CheckInsManager.prototype.getLocalCheckIns = function () {
|
|
2946
|
-
// create check-ins from configuration and validate them
|
|
2947
|
-
var localCheckIns = this.config.checkins.map(function (dto) {
|
|
2948
|
-
var checkIn = new check_in_1.CheckIn(dto);
|
|
2949
|
-
checkIn.validate();
|
|
2950
|
-
return checkIn;
|
|
2951
|
-
});
|
|
2952
|
-
// validate that we have unique check-in slugs
|
|
2953
|
-
var checkInSlugs = localCheckIns.map(function (checkIn) { return checkIn.slug; });
|
|
2954
|
-
var uniqueCheckInSlugs = new Set(checkInSlugs);
|
|
2955
|
-
if (checkInSlugs.length !== uniqueCheckInSlugs.size) {
|
|
2956
|
-
throw new Error('check-in slugs must be unique');
|
|
2957
|
-
}
|
|
2958
|
-
return localCheckIns;
|
|
2959
|
-
};
|
|
2960
|
-
CheckInsManager.prototype.createOrUpdate = function (projectId, localCheckIns, remoteCheckIns) {
|
|
2961
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2962
|
-
var results, _loop_1, this_1, _i, localCheckIns_1, localCheckIn;
|
|
2963
|
-
return __generator(this, function (_a) {
|
|
2964
|
-
switch (_a.label) {
|
|
2965
|
-
case 0:
|
|
2966
|
-
results = [];
|
|
2967
|
-
_loop_1 = function (localCheckIn) {
|
|
2968
|
-
var remoteCheckIn, _b, _c, _d, _e;
|
|
2969
|
-
return __generator(this, function (_f) {
|
|
2970
|
-
switch (_f.label) {
|
|
2971
|
-
case 0:
|
|
2972
|
-
remoteCheckIn = remoteCheckIns.find(function (checkIn) {
|
|
2973
|
-
return checkIn.slug === localCheckIn.slug;
|
|
2974
|
-
});
|
|
2975
|
-
if (!!remoteCheckIn) return [3 /*break*/, 2];
|
|
2976
|
-
_c = (_b = results).push;
|
|
2977
|
-
return [4 /*yield*/, this_1.client.create(projectId, localCheckIn)];
|
|
2978
|
-
case 1:
|
|
2979
|
-
_c.apply(_b, [_f.sent()]);
|
|
2980
|
-
return [3 /*break*/, 5];
|
|
2981
|
-
case 2:
|
|
2982
|
-
if (!!localCheckIn.isInSync(remoteCheckIn)) return [3 /*break*/, 4];
|
|
2983
|
-
localCheckIn.id = remoteCheckIn.id;
|
|
2984
|
-
_e = (_d = results).push;
|
|
2985
|
-
return [4 /*yield*/, this_1.client.update(projectId, localCheckIn)];
|
|
2986
|
-
case 3:
|
|
2987
|
-
_e.apply(_d, [_f.sent()]);
|
|
2988
|
-
return [3 /*break*/, 5];
|
|
2989
|
-
case 4:
|
|
2990
|
-
// no change - still need to add to results
|
|
2991
|
-
results.push(remoteCheckIn);
|
|
2992
|
-
_f.label = 5;
|
|
2993
|
-
case 5: return [2 /*return*/];
|
|
2994
|
-
}
|
|
2995
|
-
});
|
|
2996
|
-
};
|
|
2997
|
-
this_1 = this;
|
|
2998
|
-
_i = 0, localCheckIns_1 = localCheckIns;
|
|
2999
|
-
_a.label = 1;
|
|
3000
|
-
case 1:
|
|
3001
|
-
if (!(_i < localCheckIns_1.length)) return [3 /*break*/, 4];
|
|
3002
|
-
localCheckIn = localCheckIns_1[_i];
|
|
3003
|
-
return [5 /*yield**/, _loop_1(localCheckIn)];
|
|
3004
|
-
case 2:
|
|
3005
|
-
_a.sent();
|
|
3006
|
-
_a.label = 3;
|
|
3007
|
-
case 3:
|
|
3008
|
-
_i++;
|
|
3009
|
-
return [3 /*break*/, 1];
|
|
3010
|
-
case 4: return [2 /*return*/, results];
|
|
3011
|
-
}
|
|
3012
|
-
});
|
|
3013
|
-
});
|
|
3014
|
-
};
|
|
3015
|
-
CheckInsManager.prototype.remove = function (projectId, localCheckIns, remoteCheckIns) {
|
|
3016
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
3017
|
-
var checkInsToRemove;
|
|
3018
|
-
var _this = this;
|
|
3019
|
-
return __generator(this, function (_a) {
|
|
3020
|
-
checkInsToRemove = remoteCheckIns.filter(function (remoteCheckIn) {
|
|
3021
|
-
return !localCheckIns.find(function (localCheckIn) {
|
|
3022
|
-
return localCheckIn.slug === remoteCheckIn.slug;
|
|
3023
|
-
});
|
|
3024
|
-
});
|
|
3025
|
-
return [2 /*return*/, Promise.all(checkInsToRemove.map(function (checkIn) { return __awaiter(_this, void 0, void 0, function () {
|
|
3026
|
-
return __generator(this, function (_a) {
|
|
3027
|
-
switch (_a.label) {
|
|
3028
|
-
case 0: return [4 /*yield*/, this.client.remove(projectId, checkIn)];
|
|
3029
|
-
case 1:
|
|
3030
|
-
_a.sent();
|
|
3031
|
-
checkIn.markAsDeleted();
|
|
3032
|
-
return [2 /*return*/, checkIn];
|
|
3033
|
-
}
|
|
3034
|
-
});
|
|
3035
|
-
}); }))];
|
|
3036
|
-
});
|
|
3037
|
-
});
|
|
3038
|
-
};
|
|
3039
|
-
return CheckInsManager;
|
|
3040
|
-
}());
|
|
3041
|
-
exports.CheckInsManager = CheckInsManager;
|
|
3042
|
-
|
|
3043
3034
|
} (checkInsManager));
|
|
3044
|
-
return checkInsManager;
|
|
3045
|
-
}
|
|
3046
3035
|
|
|
3047
3036
|
(function (exports) {
|
|
3048
3037
|
var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
|
|
@@ -3112,7 +3101,7 @@ function requireCheckInsManager () {
|
|
|
3112
3101
|
};
|
|
3113
3102
|
var _a;
|
|
3114
3103
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3115
|
-
exports.
|
|
3104
|
+
exports.CheckIn = exports.Types = void 0;
|
|
3116
3105
|
var os_1 = __importDefault(require$$0__default["default"]);
|
|
3117
3106
|
var domain_1 = __importDefault(require$$1__default$1["default"]);
|
|
3118
3107
|
var core_1 = src;
|
|
@@ -3124,6 +3113,7 @@ function requireCheckInsManager () {
|
|
|
3124
3113
|
var aws_lambda_1 = aws_lambda;
|
|
3125
3114
|
var transport_1 = transport;
|
|
3126
3115
|
var stacked_store_1 = stacked_store;
|
|
3116
|
+
var check_ins_manager_1 = checkInsManager;
|
|
3127
3117
|
var endpoint = core_1.Util.endpoint;
|
|
3128
3118
|
var DEFAULT_PLUGINS = [
|
|
3129
3119
|
(0, uncaught_exception_plugin_1.default)(),
|
|
@@ -3163,6 +3153,7 @@ function requireCheckInsManager () {
|
|
|
3163
3153
|
_this.errorHandler = middleware_1.errorHandler.bind(_this);
|
|
3164
3154
|
_this.requestHandler = middleware_1.requestHandler.bind(_this);
|
|
3165
3155
|
_this.lambdaHandler = aws_lambda_1.lambdaHandler.bind(_this);
|
|
3156
|
+
_this.checkInsApi = new check_ins_manager_1.CheckInsClient(_this.config, transport);
|
|
3166
3157
|
return _this;
|
|
3167
3158
|
}
|
|
3168
3159
|
Honeybadger.prototype.factory = function (opts) {
|
|
@@ -3173,6 +3164,12 @@ function requireCheckInsManager () {
|
|
|
3173
3164
|
};
|
|
3174
3165
|
Honeybadger.prototype.configure = function (opts) {
|
|
3175
3166
|
if (opts === void 0) { opts = {}; }
|
|
3167
|
+
this.checkInsApi.configure({
|
|
3168
|
+
appEndpoint: opts.appEndpoint,
|
|
3169
|
+
apiKey: opts.apiKey,
|
|
3170
|
+
personalAuthToken: opts.personalAuthToken,
|
|
3171
|
+
logger: opts.logger,
|
|
3172
|
+
});
|
|
3176
3173
|
return _super.prototype.configure.call(this, opts);
|
|
3177
3174
|
};
|
|
3178
3175
|
Honeybadger.prototype.__initStore = function () {
|
|
@@ -3280,7 +3277,7 @@ function requireCheckInsManager () {
|
|
|
3280
3277
|
var NOTIFIER = {
|
|
3281
3278
|
name: '@honeybadger-io/js',
|
|
3282
3279
|
url: 'https://github.com/honeybadger-io/honeybadger-js/tree/master/packages/js',
|
|
3283
|
-
version: '6.12.
|
|
3280
|
+
version: '6.12.3'
|
|
3284
3281
|
};
|
|
3285
3282
|
var userAgent = function () {
|
|
3286
3283
|
return "Honeybadger JS Server Client ".concat(NOTIFIER.version, ", ").concat(os_1.default.version(), "; ").concat(os_1.default.platform());
|
|
@@ -3289,11 +3286,8 @@ function requireCheckInsManager () {
|
|
|
3289
3286
|
singleton.setNotifier(NOTIFIER);
|
|
3290
3287
|
var core_2 = src;
|
|
3291
3288
|
Object.defineProperty(exports, "Types", { enumerable: true, get: function () { return core_2.Types; } });
|
|
3292
|
-
var
|
|
3293
|
-
Object.defineProperty(exports, "
|
|
3294
|
-
Object.defineProperty(exports, "CheckIn", { enumerable: true, get: function () { return check_ins_manager_1.CheckIn; } });
|
|
3295
|
-
var transport_2 = transport;
|
|
3296
|
-
Object.defineProperty(exports, "ServerTransport", { enumerable: true, get: function () { return transport_2.ServerTransport; } });
|
|
3289
|
+
var check_in_1 = requireCheckIn();
|
|
3290
|
+
Object.defineProperty(exports, "CheckIn", { enumerable: true, get: function () { return check_in_1.CheckIn; } });
|
|
3297
3291
|
exports.default = singleton;
|
|
3298
3292
|
|
|
3299
3293
|
} (server$1));
|