@honeybadger-io/js 6.11.2 → 6.12.0
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.ext.min.js.map +1 -1
- package/dist/browser/honeybadger.js +7 -4
- package/dist/browser/honeybadger.js.map +1 -1
- package/dist/browser/honeybadger.min.js +1 -1
- package/dist/browser/honeybadger.min.js.map +1 -1
- package/dist/server/check-ins-manager/check-in.d.ts +1 -1
- package/dist/server/check-ins-manager/client.d.ts +3 -4
- package/dist/server/check-ins-manager/index.d.ts +5 -3
- package/dist/server/check-ins-manager/types.d.ts +2 -1
- package/dist/server/check-ins-sync.js +244 -231
- package/dist/server/check-ins-sync.js.map +1 -1
- package/dist/server/honeybadger.d.ts +2 -1
- package/dist/server/honeybadger.js +583 -340
- package/dist/server/honeybadger.js.map +1 -1
- package/dist/server/stacked_store.d.ts +1 -1
- package/package.json +3 -3
|
@@ -959,6 +959,7 @@ defaults.CONFIG = void 0;
|
|
|
959
959
|
defaults.CONFIG = {
|
|
960
960
|
apiKey: null,
|
|
961
961
|
endpoint: 'https://api.honeybadger.io',
|
|
962
|
+
appEndpoint: 'https://app.honeybadger.io',
|
|
962
963
|
environment: null,
|
|
963
964
|
hostname: null,
|
|
964
965
|
projectRoot: null,
|
|
@@ -993,7 +994,7 @@ var __assign$2 = (commonjsGlobal && commonjsGlobal.__assign) || function () {
|
|
|
993
994
|
};
|
|
994
995
|
return __assign$2.apply(this, arguments);
|
|
995
996
|
};
|
|
996
|
-
var __awaiter$
|
|
997
|
+
var __awaiter$3 = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
997
998
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
998
999
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
999
1000
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
@@ -1002,7 +1003,7 @@ var __awaiter$4 = (commonjsGlobal && commonjsGlobal.__awaiter) || function (this
|
|
|
1002
1003
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1003
1004
|
});
|
|
1004
1005
|
};
|
|
1005
|
-
var __generator$
|
|
1006
|
+
var __generator$3 = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
|
|
1006
1007
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
1007
1008
|
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
1008
1009
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
@@ -1081,9 +1082,9 @@ var ThrottledEventsLogger = /** @class */ (function () {
|
|
|
1081
1082
|
});
|
|
1082
1083
|
};
|
|
1083
1084
|
ThrottledEventsLogger.prototype.send = function () {
|
|
1084
|
-
return __awaiter$
|
|
1085
|
+
return __awaiter$3(this, void 0, void 0, function () {
|
|
1085
1086
|
var eventsData, data;
|
|
1086
|
-
return __generator$
|
|
1087
|
+
return __generator$3(this, function (_a) {
|
|
1087
1088
|
if (this.queue.length === 0) {
|
|
1088
1089
|
return [2 /*return*/];
|
|
1089
1090
|
}
|
|
@@ -1095,9 +1096,9 @@ var ThrottledEventsLogger = /** @class */ (function () {
|
|
|
1095
1096
|
});
|
|
1096
1097
|
};
|
|
1097
1098
|
ThrottledEventsLogger.prototype.makeHttpRequest = function (data) {
|
|
1098
|
-
return __awaiter$
|
|
1099
|
+
return __awaiter$3(this, void 0, void 0, function () {
|
|
1099
1100
|
var _this = this;
|
|
1100
|
-
return __generator$
|
|
1101
|
+
return __generator$3(this, function (_a) {
|
|
1101
1102
|
return [2 /*return*/, this.transport
|
|
1102
1103
|
.send({
|
|
1103
1104
|
headers: {
|
|
@@ -1157,7 +1158,7 @@ var __assign$1 = (commonjsGlobal && commonjsGlobal.__assign) || function () {
|
|
|
1157
1158
|
};
|
|
1158
1159
|
return __assign$1.apply(this, arguments);
|
|
1159
1160
|
};
|
|
1160
|
-
var __awaiter$
|
|
1161
|
+
var __awaiter$2 = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
1161
1162
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
1162
1163
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
1163
1164
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
@@ -1166,7 +1167,7 @@ var __awaiter$3 = (commonjsGlobal && commonjsGlobal.__awaiter) || function (this
|
|
|
1166
1167
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1167
1168
|
});
|
|
1168
1169
|
};
|
|
1169
|
-
var __generator$
|
|
1170
|
+
var __generator$2 = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
|
|
1170
1171
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
1171
1172
|
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
1172
1173
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
@@ -1213,7 +1214,7 @@ var Client = /** @class */ (function () {
|
|
|
1213
1214
|
this.__notifier = {
|
|
1214
1215
|
name: '@honeybadger-io/core',
|
|
1215
1216
|
url: 'https://github.com/honeybadger-io/honeybadger-js/tree/master/packages/core',
|
|
1216
|
-
version: '6.
|
|
1217
|
+
version: '6.12.0'
|
|
1217
1218
|
};
|
|
1218
1219
|
this.config = __assign$1(__assign$1({}, defaults_1.CONFIG), opts);
|
|
1219
1220
|
this.__initStore();
|
|
@@ -1548,9 +1549,9 @@ var Client = /** @class */ (function () {
|
|
|
1548
1549
|
notice.__breadcrumbs = [];
|
|
1549
1550
|
}
|
|
1550
1551
|
return (0, util_1$5.getSourceForBacktrace)(originalBacktrace, this.__getSourceFileHandler)
|
|
1551
|
-
.then(function (sourcePerTrace) { return __awaiter$
|
|
1552
|
+
.then(function (sourcePerTrace) { return __awaiter$2(_this, void 0, void 0, function () {
|
|
1552
1553
|
var payload;
|
|
1553
|
-
return __generator$
|
|
1554
|
+
return __generator$2(this, function (_a) {
|
|
1554
1555
|
sourcePerTrace.forEach(function (source, index) {
|
|
1555
1556
|
notice.backtrace[index].source = source;
|
|
1556
1557
|
});
|
|
@@ -1579,7 +1580,8 @@ var Client = /** @class */ (function () {
|
|
|
1579
1580
|
(0, util_1$5.runAfterNotifyHandlers)((0, util_1$5.merge)(notice, {
|
|
1580
1581
|
id: uuid
|
|
1581
1582
|
}), _this.__afterNotifyHandlers);
|
|
1582
|
-
|
|
1583
|
+
var noticeUrl = (0, util_1$5.endpoint)(_this.config.appEndpoint, "notice/".concat(uuid));
|
|
1584
|
+
_this.logger.info("Error report sent \u26A1 ".concat(noticeUrl));
|
|
1583
1585
|
return true;
|
|
1584
1586
|
})
|
|
1585
1587
|
.catch(function (err) {
|
|
@@ -1627,13 +1629,14 @@ Object.defineProperty(types, "__esModule", { value: true });
|
|
|
1627
1629
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
1628
1630
|
};
|
|
1629
1631
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1630
|
-
exports.Plugins = exports.Util = exports.Types = exports.Client = void 0;
|
|
1632
|
+
exports.Plugins = exports.Defaults = exports.Util = exports.Types = exports.Client = void 0;
|
|
1631
1633
|
var events_1 = __importDefault(events);
|
|
1632
1634
|
var client_1 = client$1;
|
|
1633
1635
|
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });
|
|
1634
1636
|
__exportStar(store, exports);
|
|
1635
1637
|
exports.Types = __importStar(types);
|
|
1636
1638
|
exports.Util = __importStar(util$1);
|
|
1639
|
+
exports.Defaults = __importStar(defaults);
|
|
1637
1640
|
exports.Plugins = {
|
|
1638
1641
|
events: events_1.default
|
|
1639
1642
|
};
|
|
@@ -1642,7 +1645,7 @@ Object.defineProperty(types, "__esModule", { value: true });
|
|
|
1642
1645
|
|
|
1643
1646
|
var util = {};
|
|
1644
1647
|
|
|
1645
|
-
var __awaiter$
|
|
1648
|
+
var __awaiter$1 = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
1646
1649
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
1647
1650
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
1648
1651
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
@@ -1651,7 +1654,7 @@ var __awaiter$2 = (commonjsGlobal && commonjsGlobal.__awaiter) || function (this
|
|
|
1651
1654
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1652
1655
|
});
|
|
1653
1656
|
};
|
|
1654
|
-
var __generator$
|
|
1657
|
+
var __generator$1 = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
|
|
1655
1658
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
1656
1659
|
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
1657
1660
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
@@ -1700,9 +1703,9 @@ function fatallyLogAndExit(err, source) {
|
|
|
1700
1703
|
}
|
|
1701
1704
|
util.fatallyLogAndExit = fatallyLogAndExit;
|
|
1702
1705
|
function getStats() {
|
|
1703
|
-
return __awaiter$
|
|
1706
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
1704
1707
|
var load, stats, fallback, memData, data, results;
|
|
1705
|
-
return __generator$
|
|
1708
|
+
return __generator$1(this, function (_a) {
|
|
1706
1709
|
switch (_a.label) {
|
|
1707
1710
|
case 0:
|
|
1708
1711
|
load = os_1.default.loadavg();
|
|
@@ -1761,8 +1764,8 @@ util.getStats = getStats;
|
|
|
1761
1764
|
* @param path to source code
|
|
1762
1765
|
*/
|
|
1763
1766
|
function getSourceFile(path) {
|
|
1764
|
-
return __awaiter$
|
|
1765
|
-
return __generator$
|
|
1767
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
1768
|
+
return __generator$1(this, function (_a) {
|
|
1766
1769
|
switch (_a.label) {
|
|
1767
1770
|
case 0:
|
|
1768
1771
|
_a.trys.push([0, 2, , 3]);
|
|
@@ -2083,7 +2086,7 @@ var shutdown_plugin = {};
|
|
|
2083
2086
|
|
|
2084
2087
|
var shutdown_monitor = {};
|
|
2085
2088
|
|
|
2086
|
-
var __awaiter
|
|
2089
|
+
var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2087
2090
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
2088
2091
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
2089
2092
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
@@ -2092,7 +2095,7 @@ var __awaiter$1 = (commonjsGlobal && commonjsGlobal.__awaiter) || function (this
|
|
|
2092
2095
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
2093
2096
|
});
|
|
2094
2097
|
};
|
|
2095
|
-
var __generator
|
|
2098
|
+
var __generator = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
|
|
2096
2099
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
2097
2100
|
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
2098
2101
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
@@ -2132,8 +2135,8 @@ var ShutdownMonitor = /** @class */ (function () {
|
|
|
2132
2135
|
ShutdownMonitor.prototype.makeListener = function () {
|
|
2133
2136
|
var _this = this;
|
|
2134
2137
|
// noinspection UnnecessaryLocalVariableJS
|
|
2135
|
-
var honeybadgerShutdownListener = function (signal) { return __awaiter
|
|
2136
|
-
return __generator
|
|
2138
|
+
var honeybadgerShutdownListener = function (signal) { return __awaiter(_this, void 0, void 0, function () {
|
|
2139
|
+
return __generator(this, function (_a) {
|
|
2137
2140
|
switch (_a.label) {
|
|
2138
2141
|
case 0:
|
|
2139
2142
|
if (this.__isReporting || !this.__client) {
|
|
@@ -2485,324 +2488,561 @@ var StackedStore = /** @class */ (function () {
|
|
|
2485
2488
|
}());
|
|
2486
2489
|
stacked_store.StackedStore = StackedStore;
|
|
2487
2490
|
|
|
2491
|
+
var checkInsManager = {};
|
|
2492
|
+
|
|
2488
2493
|
var client = {};
|
|
2489
2494
|
|
|
2490
2495
|
var checkIn = {};
|
|
2491
2496
|
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2497
|
+
var hasRequiredCheckIn;
|
|
2498
|
+
|
|
2499
|
+
function requireCheckIn () {
|
|
2500
|
+
if (hasRequiredCheckIn) return checkIn;
|
|
2501
|
+
hasRequiredCheckIn = 1;
|
|
2502
|
+
Object.defineProperty(checkIn, "__esModule", { value: true });
|
|
2503
|
+
checkIn.CheckIn = void 0;
|
|
2504
|
+
var CheckIn = /** @class */ (function () {
|
|
2505
|
+
function CheckIn(props) {
|
|
2506
|
+
this.id = props.id;
|
|
2507
|
+
this.name = props.name;
|
|
2508
|
+
this.slug = props.slug;
|
|
2509
|
+
this.scheduleType = props.scheduleType;
|
|
2510
|
+
this.reportPeriod = props.reportPeriod;
|
|
2511
|
+
this.gracePeriod = props.gracePeriod;
|
|
2512
|
+
this.cronSchedule = props.cronSchedule;
|
|
2513
|
+
this.cronTimezone = props.cronTimezone;
|
|
2514
|
+
this.deleted = false;
|
|
2515
|
+
}
|
|
2516
|
+
CheckIn.prototype.isDeleted = function () {
|
|
2517
|
+
return this.deleted;
|
|
2518
|
+
};
|
|
2519
|
+
CheckIn.prototype.markAsDeleted = function () {
|
|
2520
|
+
this.deleted = true;
|
|
2521
|
+
};
|
|
2522
|
+
CheckIn.prototype.validate = function () {
|
|
2523
|
+
if (!this.slug) {
|
|
2524
|
+
throw new Error('slug is required for each check-in');
|
|
2525
|
+
}
|
|
2526
|
+
if (!this.scheduleType) {
|
|
2527
|
+
throw new Error('scheduleType is required for each check-in');
|
|
2528
|
+
}
|
|
2529
|
+
if (!['simple', 'cron'].includes(this.scheduleType)) {
|
|
2530
|
+
throw new Error("".concat(this.slug, " [scheduleType] must be \"simple\" or \"cron\""));
|
|
2531
|
+
}
|
|
2532
|
+
if (this.scheduleType === 'simple' && !this.reportPeriod) {
|
|
2533
|
+
throw new Error("".concat(this.slug, " [reportPeriod] is required for simple check-ins"));
|
|
2534
|
+
}
|
|
2535
|
+
if (this.scheduleType === 'cron' && !this.cronSchedule) {
|
|
2536
|
+
throw new Error("".concat(this.slug, " [cronSchedule] is required for cron check-ins"));
|
|
2537
|
+
}
|
|
2538
|
+
};
|
|
2539
|
+
CheckIn.prototype.asRequestPayload = function () {
|
|
2540
|
+
var _a, _b;
|
|
2541
|
+
var payload = {
|
|
2542
|
+
name: this.name,
|
|
2543
|
+
schedule_type: this.scheduleType,
|
|
2544
|
+
slug: this.slug,
|
|
2545
|
+
grace_period: (_a = this.gracePeriod) !== null && _a !== void 0 ? _a : '' // default is empty string
|
|
2546
|
+
};
|
|
2547
|
+
if (this.scheduleType === 'simple') {
|
|
2548
|
+
payload.report_period = this.reportPeriod;
|
|
2549
|
+
}
|
|
2550
|
+
else {
|
|
2551
|
+
payload.cron_schedule = this.cronSchedule;
|
|
2552
|
+
payload.cron_timezone = (_b = this.cronTimezone) !== null && _b !== void 0 ? _b : ''; // default is empty string
|
|
2553
|
+
}
|
|
2554
|
+
return payload;
|
|
2555
|
+
};
|
|
2556
|
+
/**
|
|
2557
|
+
* Compares two check-ins, usually the one from the API and the one from the config file.
|
|
2558
|
+
* If the one in the config file does not match the check-in from the API,
|
|
2559
|
+
* then we issue an update request.
|
|
2560
|
+
*
|
|
2561
|
+
* `name`, `gracePeriod` and `cronTimezone` are optional fields that are automatically
|
|
2562
|
+
* set to a value from the server if one is not provided,
|
|
2563
|
+
* so we ignore their values if they are not set locally.
|
|
2564
|
+
*/
|
|
2565
|
+
CheckIn.prototype.isInSync = function (other) {
|
|
2566
|
+
var ignoreNameCheck = this.name === undefined;
|
|
2567
|
+
var ignoreGracePeriodCheck = this.gracePeriod === undefined;
|
|
2568
|
+
var ignoreCronTimezoneCheck = this.cronTimezone === undefined;
|
|
2569
|
+
return this.slug === other.slug
|
|
2570
|
+
&& this.scheduleType === other.scheduleType
|
|
2571
|
+
&& this.reportPeriod === other.reportPeriod
|
|
2572
|
+
&& this.cronSchedule === other.cronSchedule
|
|
2573
|
+
&& (ignoreNameCheck || this.name === other.name)
|
|
2574
|
+
&& (ignoreGracePeriodCheck || this.gracePeriod === other.gracePeriod)
|
|
2575
|
+
&& (ignoreCronTimezoneCheck || this.cronTimezone === other.cronTimezone);
|
|
2576
|
+
};
|
|
2577
|
+
CheckIn.fromResponsePayload = function (payload) {
|
|
2578
|
+
return new CheckIn({
|
|
2579
|
+
id: payload.id,
|
|
2580
|
+
name: payload.name,
|
|
2581
|
+
slug: payload.slug,
|
|
2582
|
+
scheduleType: payload.schedule_type,
|
|
2583
|
+
reportPeriod: payload.report_period,
|
|
2584
|
+
gracePeriod: payload.grace_period,
|
|
2585
|
+
cronSchedule: payload.cron_schedule,
|
|
2586
|
+
cronTimezone: payload.cron_timezone,
|
|
2587
|
+
});
|
|
2588
|
+
};
|
|
2589
|
+
return CheckIn;
|
|
2590
|
+
}());
|
|
2591
|
+
checkIn.CheckIn = CheckIn;
|
|
2592
|
+
|
|
2593
|
+
return checkIn;
|
|
2594
|
+
}
|
|
2582
2595
|
|
|
2583
|
-
var
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
};
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
}
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2596
|
+
var hasRequiredClient;
|
|
2597
|
+
|
|
2598
|
+
function requireClient () {
|
|
2599
|
+
if (hasRequiredClient) return client;
|
|
2600
|
+
hasRequiredClient = 1;
|
|
2601
|
+
var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2602
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
2603
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
2604
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
2605
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
2606
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
2607
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
2608
|
+
});
|
|
2609
|
+
};
|
|
2610
|
+
var __generator = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
|
|
2611
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
2612
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
2613
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
2614
|
+
function step(op) {
|
|
2615
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
2616
|
+
while (_) try {
|
|
2617
|
+
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;
|
|
2618
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
2619
|
+
switch (op[0]) {
|
|
2620
|
+
case 0: case 1: t = op; break;
|
|
2621
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
2622
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
2623
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
2624
|
+
default:
|
|
2625
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
2626
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
2627
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
2628
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
2629
|
+
if (t[2]) _.ops.pop();
|
|
2630
|
+
_.trys.pop(); continue;
|
|
2631
|
+
}
|
|
2632
|
+
op = body.call(thisArg, _);
|
|
2633
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
2634
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
2635
|
+
}
|
|
2636
|
+
};
|
|
2637
|
+
Object.defineProperty(client, "__esModule", { value: true });
|
|
2638
|
+
client.CheckInsClient = void 0;
|
|
2639
|
+
var core_1 = src;
|
|
2640
|
+
var check_in_1 = requireCheckIn();
|
|
2641
|
+
var CheckInsClient = /** @class */ (function () {
|
|
2642
|
+
function CheckInsClient(config, transport) {
|
|
2643
|
+
this.transport = transport;
|
|
2644
|
+
this.config = config;
|
|
2645
|
+
this.logger = config.logger;
|
|
2646
|
+
}
|
|
2647
|
+
CheckInsClient.prototype.getProjectId = function (projectApiKey) {
|
|
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) {
|
|
2675
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2676
|
+
var response, data;
|
|
2677
|
+
return __generator(this, function (_a) {
|
|
2678
|
+
switch (_a.label) {
|
|
2679
|
+
case 0:
|
|
2680
|
+
if (!this.config.personalAuthToken || this.config.personalAuthToken === '') {
|
|
2681
|
+
throw new Error('personalAuthToken is required');
|
|
2682
|
+
}
|
|
2683
|
+
return [4 /*yield*/, this.transport.send({
|
|
2684
|
+
method: 'GET',
|
|
2685
|
+
headers: this.getHeaders(),
|
|
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)));
|
|
2693
|
+
}
|
|
2694
|
+
data = JSON.parse(response.body);
|
|
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:
|
|
2706
|
+
if (!this.config.personalAuthToken || this.config.personalAuthToken === '') {
|
|
2707
|
+
throw new Error('personalAuthToken is required');
|
|
2708
|
+
}
|
|
2709
|
+
return [4 /*yield*/, this.transport.send({
|
|
2710
|
+
method: 'GET',
|
|
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
|
+
})];
|
|
2715
|
+
case 1:
|
|
2716
|
+
response = _a.sent();
|
|
2717
|
+
if (response.statusCode !== 200) {
|
|
2718
|
+
throw new Error("Failed to fetch check-in[".concat(checkInId, "] for project[").concat(projectId, "]: ").concat(this.getErrorMessage(response.body)));
|
|
2719
|
+
}
|
|
2720
|
+
data = JSON.parse(response.body);
|
|
2721
|
+
return [2 /*return*/, check_in_1.CheckIn.fromResponsePayload(data)];
|
|
2722
|
+
}
|
|
2723
|
+
});
|
|
2724
|
+
});
|
|
2725
|
+
};
|
|
2726
|
+
CheckInsClient.prototype.create = function (projectId, checkIn) {
|
|
2727
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2728
|
+
var response, data;
|
|
2729
|
+
return __generator(this, function (_a) {
|
|
2730
|
+
switch (_a.label) {
|
|
2731
|
+
case 0:
|
|
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
|
+
});
|
|
2750
|
+
});
|
|
2751
|
+
};
|
|
2752
|
+
CheckInsClient.prototype.update = function (projectId, checkIn) {
|
|
2753
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2754
|
+
var response;
|
|
2755
|
+
return __generator(this, function (_a) {
|
|
2756
|
+
switch (_a.label) {
|
|
2757
|
+
case 0:
|
|
2758
|
+
if (!this.config.personalAuthToken || this.config.personalAuthToken === '') {
|
|
2759
|
+
throw new Error('personalAuthToken is required');
|
|
2760
|
+
}
|
|
2761
|
+
return [4 /*yield*/, this.transport.send({
|
|
2762
|
+
method: 'PUT',
|
|
2763
|
+
headers: this.getHeaders(),
|
|
2764
|
+
endpoint: core_1.Util.endpoint(this.config.appEndpoint, "v2/projects/".concat(projectId, "/check_ins/").concat(checkIn.id)),
|
|
2765
|
+
logger: this.logger,
|
|
2766
|
+
}, { check_in: checkIn.asRequestPayload() })];
|
|
2767
|
+
case 1:
|
|
2768
|
+
response = _a.sent();
|
|
2769
|
+
if (response.statusCode !== 204) {
|
|
2770
|
+
throw new Error("Failed to update checkin[".concat(checkIn.slug, "] for project[").concat(projectId, "]: ").concat(this.getErrorMessage(response.body)));
|
|
2771
|
+
}
|
|
2772
|
+
return [2 /*return*/, checkIn];
|
|
2773
|
+
}
|
|
2774
|
+
});
|
|
2775
|
+
});
|
|
2776
|
+
};
|
|
2777
|
+
CheckInsClient.prototype.remove = function (projectId, checkIn) {
|
|
2778
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2779
|
+
var response;
|
|
2780
|
+
return __generator(this, function (_a) {
|
|
2781
|
+
switch (_a.label) {
|
|
2782
|
+
case 0:
|
|
2783
|
+
if (!this.config.personalAuthToken || this.config.personalAuthToken === '') {
|
|
2784
|
+
throw new Error('personalAuthToken is required');
|
|
2785
|
+
}
|
|
2786
|
+
return [4 /*yield*/, this.transport.send({
|
|
2787
|
+
method: 'DELETE',
|
|
2788
|
+
headers: this.getHeaders(),
|
|
2789
|
+
endpoint: core_1.Util.endpoint(this.config.appEndpoint, "v2/projects/".concat(projectId, "/check_ins/").concat(checkIn.id)),
|
|
2790
|
+
logger: this.logger,
|
|
2791
|
+
})];
|
|
2792
|
+
case 1:
|
|
2793
|
+
response = _a.sent();
|
|
2794
|
+
if (response.statusCode !== 204) {
|
|
2795
|
+
throw new Error("Failed to remove checkin[".concat(checkIn.slug, "] for project[").concat(projectId, "]: ").concat(this.getErrorMessage(response.body)));
|
|
2796
|
+
}
|
|
2797
|
+
return [2 /*return*/];
|
|
2798
|
+
}
|
|
2799
|
+
});
|
|
2800
|
+
});
|
|
2801
|
+
};
|
|
2802
|
+
CheckInsClient.prototype.getHeaders = function () {
|
|
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;
|
|
2822
|
+
}());
|
|
2823
|
+
client.CheckInsClient = CheckInsClient;
|
|
2824
|
+
|
|
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
|
+
} (checkInsManager));
|
|
3044
|
+
return checkInsManager;
|
|
3045
|
+
}
|
|
2806
3046
|
|
|
2807
3047
|
(function (exports) {
|
|
2808
3048
|
var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
|
|
@@ -2872,7 +3112,7 @@ client.CheckInsClient = CheckInsClient;
|
|
|
2872
3112
|
};
|
|
2873
3113
|
var _a;
|
|
2874
3114
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2875
|
-
exports.Types = void 0;
|
|
3115
|
+
exports.ServerTransport = exports.CheckIn = exports.CheckInsClient = exports.Types = void 0;
|
|
2876
3116
|
var os_1 = __importDefault(require$$0__default["default"]);
|
|
2877
3117
|
var domain_1 = __importDefault(require$$1__default$1["default"]);
|
|
2878
3118
|
var core_1 = src;
|
|
@@ -2884,7 +3124,6 @@ client.CheckInsClient = CheckInsClient;
|
|
|
2884
3124
|
var aws_lambda_1 = aws_lambda;
|
|
2885
3125
|
var transport_1 = transport;
|
|
2886
3126
|
var stacked_store_1 = stacked_store;
|
|
2887
|
-
var client_1 = client;
|
|
2888
3127
|
var endpoint = core_1.Util.endpoint;
|
|
2889
3128
|
var DEFAULT_PLUGINS = [
|
|
2890
3129
|
(0, uncaught_exception_plugin_1.default)(),
|
|
@@ -2920,7 +3159,6 @@ client.CheckInsClient = CheckInsClient;
|
|
|
2920
3159
|
var config = _this.config;
|
|
2921
3160
|
config.reportTimeoutWarning = (_a = config.reportTimeoutWarning) !== null && _a !== void 0 ? _a : true;
|
|
2922
3161
|
config.timeoutWarningThresholdMs = config.timeoutWarningThresholdMs || 50;
|
|
2923
|
-
_this.__checkInsClient = new client_1.CheckInsClient(_this.config, transport);
|
|
2924
3162
|
_this.__getSourceFileHandler = util_1.getSourceFile.bind(_this);
|
|
2925
3163
|
_this.errorHandler = middleware_1.errorHandler.bind(_this);
|
|
2926
3164
|
_this.requestHandler = middleware_1.requestHandler.bind(_this);
|
|
@@ -3042,7 +3280,7 @@ client.CheckInsClient = CheckInsClient;
|
|
|
3042
3280
|
var NOTIFIER = {
|
|
3043
3281
|
name: '@honeybadger-io/js',
|
|
3044
3282
|
url: 'https://github.com/honeybadger-io/honeybadger-js/tree/master/packages/js',
|
|
3045
|
-
version: '6.
|
|
3283
|
+
version: '6.12.0'
|
|
3046
3284
|
};
|
|
3047
3285
|
var userAgent = function () {
|
|
3048
3286
|
return "Honeybadger JS Server Client ".concat(NOTIFIER.version, ", ").concat(os_1.default.version(), "; ").concat(os_1.default.platform());
|
|
@@ -3051,6 +3289,11 @@ client.CheckInsClient = CheckInsClient;
|
|
|
3051
3289
|
singleton.setNotifier(NOTIFIER);
|
|
3052
3290
|
var core_2 = src;
|
|
3053
3291
|
Object.defineProperty(exports, "Types", { enumerable: true, get: function () { return core_2.Types; } });
|
|
3292
|
+
var check_ins_manager_1 = requireCheckInsManager();
|
|
3293
|
+
Object.defineProperty(exports, "CheckInsClient", { enumerable: true, get: function () { return check_ins_manager_1.CheckInsClient; } });
|
|
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; } });
|
|
3054
3297
|
exports.default = singleton;
|
|
3055
3298
|
|
|
3056
3299
|
} (server$1));
|