@honeybadger-io/js 6.11.3 → 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.js +2 -2
- package/dist/browser/honeybadger.min.js +1 -1
- package/dist/server/check-ins-manager/check-in.d.ts +1 -1
- package/dist/server/check-ins-manager/client.d.ts +2 -2
- package/dist/server/check-ins-manager/index.d.ts +5 -3
- package/dist/server/check-ins-manager/types.d.ts +1 -1
- package/dist/server/check-ins-sync.js +244 -237
- package/dist/server/check-ins-sync.js.map +1 -1
- package/dist/server/honeybadger.d.ts +2 -0
- package/dist/server/honeybadger.js +569 -8
- package/dist/server/honeybadger.js.map +1 -1
- package/dist/server/stacked_store.d.ts +1 -1
- package/package.json +2 -2
|
@@ -891,7 +891,7 @@ function default_1$3(_window) {
|
|
|
891
891
|
}
|
|
892
892
|
events.default = default_1$3;
|
|
893
893
|
|
|
894
|
-
var client = {};
|
|
894
|
+
var client$1 = {};
|
|
895
895
|
|
|
896
896
|
var store = {};
|
|
897
897
|
|
|
@@ -1194,8 +1194,8 @@ var __generator$2 = (commonjsGlobal && commonjsGlobal.__generator) || function (
|
|
|
1194
1194
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
1195
1195
|
}
|
|
1196
1196
|
};
|
|
1197
|
-
Object.defineProperty(client, "__esModule", { value: true });
|
|
1198
|
-
client.Client = void 0;
|
|
1197
|
+
Object.defineProperty(client$1, "__esModule", { value: true });
|
|
1198
|
+
client$1.Client = void 0;
|
|
1199
1199
|
var util_1$5 = util$1;
|
|
1200
1200
|
var store_1 = store;
|
|
1201
1201
|
var throttled_events_logger_1 = throttled_events_logger;
|
|
@@ -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.
|
|
1217
|
+
version: '6.12.0'
|
|
1218
1218
|
};
|
|
1219
1219
|
this.config = __assign$1(__assign$1({}, defaults_1.CONFIG), opts);
|
|
1220
1220
|
this.__initStore();
|
|
@@ -1592,7 +1592,7 @@ var Client = /** @class */ (function () {
|
|
|
1592
1592
|
};
|
|
1593
1593
|
return Client;
|
|
1594
1594
|
}());
|
|
1595
|
-
client.Client = Client;
|
|
1595
|
+
client$1.Client = Client;
|
|
1596
1596
|
|
|
1597
1597
|
var types = {};
|
|
1598
1598
|
|
|
@@ -1631,7 +1631,7 @@ Object.defineProperty(types, "__esModule", { value: true });
|
|
|
1631
1631
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1632
1632
|
exports.Plugins = exports.Defaults = exports.Util = exports.Types = exports.Client = void 0;
|
|
1633
1633
|
var events_1 = __importDefault(events);
|
|
1634
|
-
var client_1 = client;
|
|
1634
|
+
var client_1 = client$1;
|
|
1635
1635
|
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });
|
|
1636
1636
|
__exportStar(store, exports);
|
|
1637
1637
|
exports.Types = __importStar(types);
|
|
@@ -2488,6 +2488,562 @@ var StackedStore = /** @class */ (function () {
|
|
|
2488
2488
|
}());
|
|
2489
2489
|
stacked_store.StackedStore = StackedStore;
|
|
2490
2490
|
|
|
2491
|
+
var checkInsManager = {};
|
|
2492
|
+
|
|
2493
|
+
var client = {};
|
|
2494
|
+
|
|
2495
|
+
var checkIn = {};
|
|
2496
|
+
|
|
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
|
+
}
|
|
2595
|
+
|
|
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
|
+
}
|
|
3046
|
+
|
|
2491
3047
|
(function (exports) {
|
|
2492
3048
|
var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
|
|
2493
3049
|
var extendStatics = function (d, b) {
|
|
@@ -2556,7 +3112,7 @@ stacked_store.StackedStore = StackedStore;
|
|
|
2556
3112
|
};
|
|
2557
3113
|
var _a;
|
|
2558
3114
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2559
|
-
exports.Types = void 0;
|
|
3115
|
+
exports.ServerTransport = exports.CheckIn = exports.CheckInsClient = exports.Types = void 0;
|
|
2560
3116
|
var os_1 = __importDefault(require$$0__default["default"]);
|
|
2561
3117
|
var domain_1 = __importDefault(require$$1__default$1["default"]);
|
|
2562
3118
|
var core_1 = src;
|
|
@@ -2724,7 +3280,7 @@ stacked_store.StackedStore = StackedStore;
|
|
|
2724
3280
|
var NOTIFIER = {
|
|
2725
3281
|
name: '@honeybadger-io/js',
|
|
2726
3282
|
url: 'https://github.com/honeybadger-io/honeybadger-js/tree/master/packages/js',
|
|
2727
|
-
version: '6.
|
|
3283
|
+
version: '6.12.0'
|
|
2728
3284
|
};
|
|
2729
3285
|
var userAgent = function () {
|
|
2730
3286
|
return "Honeybadger JS Server Client ".concat(NOTIFIER.version, ", ").concat(os_1.default.version(), "; ").concat(os_1.default.platform());
|
|
@@ -2733,6 +3289,11 @@ stacked_store.StackedStore = StackedStore;
|
|
|
2733
3289
|
singleton.setNotifier(NOTIFIER);
|
|
2734
3290
|
var core_2 = src;
|
|
2735
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; } });
|
|
2736
3297
|
exports.default = singleton;
|
|
2737
3298
|
|
|
2738
3299
|
} (server$1));
|