@honeybadger-io/js 6.6.0 → 6.6.1
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.js +2 -2
- package/dist/browser/honeybadger.min.js +1 -1
- package/dist/server/{checkins-manager/checkin.d.ts → check-ins-manager/check-in.d.ts} +10 -10
- package/dist/server/check-ins-manager/client.d.ts +21 -0
- package/dist/server/check-ins-manager/index.d.ts +15 -0
- package/dist/server/{checkins-manager → check-ins-manager}/types.d.ts +8 -8
- package/dist/server/check-ins-sync-exec.d.ts +2 -0
- package/dist/server/{checkins-sync-exec.js → check-ins-sync-exec.js} +128 -128
- package/dist/server/check-ins-sync-exec.js.map +1 -0
- package/dist/server/check-ins-sync.d.ts +2 -0
- package/dist/server/honeybadger.d.ts +4 -4
- package/dist/server/honeybadger.js +72 -72
- package/dist/server/honeybadger.js.map +1 -1
- package/package.json +3 -3
- package/dist/server/checkins-manager/client.d.ts +0 -21
- package/dist/server/checkins-manager/index.d.ts +0 -15
- package/dist/server/checkins-sync-exec.d.ts +0 -2
- package/dist/server/checkins-sync-exec.js.map +0 -1
- package/dist/server/checkins-sync.d.ts +0 -2
|
@@ -25,9 +25,9 @@ var require$$4__default = /*#__PURE__*/_interopDefaultLegacy(require$$4);
|
|
|
25
25
|
|
|
26
26
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
27
27
|
|
|
28
|
-
var
|
|
28
|
+
var checkInsSyncExec = {};
|
|
29
29
|
|
|
30
|
-
var
|
|
30
|
+
var checkInsSync = {};
|
|
31
31
|
|
|
32
32
|
var util = {};
|
|
33
33
|
|
|
@@ -178,16 +178,16 @@ function readConfigForModule(moduleName) {
|
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
var
|
|
181
|
+
var checkInsManager = {};
|
|
182
182
|
|
|
183
183
|
var client = {};
|
|
184
184
|
|
|
185
|
-
var
|
|
185
|
+
var checkIn = {};
|
|
186
186
|
|
|
187
|
-
Object.defineProperty(
|
|
188
|
-
|
|
189
|
-
var
|
|
190
|
-
function
|
|
187
|
+
Object.defineProperty(checkIn, "__esModule", { value: true });
|
|
188
|
+
checkIn.CheckIn = void 0;
|
|
189
|
+
var CheckIn = /** @class */ (function () {
|
|
190
|
+
function CheckIn(props) {
|
|
191
191
|
this.id = props.id;
|
|
192
192
|
this.name = props.name;
|
|
193
193
|
this.slug = props.slug;
|
|
@@ -199,33 +199,33 @@ var Checkin = /** @class */ (function () {
|
|
|
199
199
|
this.projectId = props.projectId;
|
|
200
200
|
this.deleted = false;
|
|
201
201
|
}
|
|
202
|
-
|
|
202
|
+
CheckIn.prototype.isDeleted = function () {
|
|
203
203
|
return this.deleted;
|
|
204
204
|
};
|
|
205
|
-
|
|
205
|
+
CheckIn.prototype.markAsDeleted = function () {
|
|
206
206
|
this.deleted = true;
|
|
207
207
|
};
|
|
208
|
-
|
|
208
|
+
CheckIn.prototype.validate = function () {
|
|
209
209
|
if (!this.projectId) {
|
|
210
|
-
throw new Error('projectId is required for each
|
|
210
|
+
throw new Error('projectId is required for each check-in');
|
|
211
211
|
}
|
|
212
212
|
if (!this.name) {
|
|
213
|
-
throw new Error('name is required for each
|
|
213
|
+
throw new Error('name is required for each check-in');
|
|
214
214
|
}
|
|
215
215
|
if (!this.scheduleType) {
|
|
216
|
-
throw new Error('scheduleType is required for each
|
|
216
|
+
throw new Error('scheduleType is required for each check-in');
|
|
217
217
|
}
|
|
218
218
|
if (!['simple', 'cron'].includes(this.scheduleType)) {
|
|
219
219
|
throw new Error("".concat(this.name, " [scheduleType] must be \"simple\" or \"cron\""));
|
|
220
220
|
}
|
|
221
221
|
if (this.scheduleType === 'simple' && !this.reportPeriod) {
|
|
222
|
-
throw new Error("".concat(this.name, " [reportPeriod] is required for simple
|
|
222
|
+
throw new Error("".concat(this.name, " [reportPeriod] is required for simple check-ins"));
|
|
223
223
|
}
|
|
224
224
|
if (this.scheduleType === 'cron' && !this.cronSchedule) {
|
|
225
|
-
throw new Error("".concat(this.name, " [cronSchedule] is required for cron
|
|
225
|
+
throw new Error("".concat(this.name, " [cronSchedule] is required for cron check-ins"));
|
|
226
226
|
}
|
|
227
227
|
};
|
|
228
|
-
|
|
228
|
+
CheckIn.prototype.asRequestPayload = function () {
|
|
229
229
|
var _a, _b, _c;
|
|
230
230
|
var payload = {
|
|
231
231
|
name: this.name,
|
|
@@ -243,11 +243,11 @@ var Checkin = /** @class */ (function () {
|
|
|
243
243
|
return payload;
|
|
244
244
|
};
|
|
245
245
|
/**
|
|
246
|
-
* Compares two
|
|
247
|
-
* If the one in the config file does not match the
|
|
246
|
+
* Compares two check-ins, usually the one from the API and the one from the config file.
|
|
247
|
+
* If the one in the config file does not match the check-in from the API,
|
|
248
248
|
* then we issue an update request.
|
|
249
249
|
*/
|
|
250
|
-
|
|
250
|
+
CheckIn.prototype.isInSync = function (other) {
|
|
251
251
|
var _a, _b, _c, _d, _e, _f;
|
|
252
252
|
return this.name === other.name
|
|
253
253
|
&& this.projectId === other.projectId
|
|
@@ -258,8 +258,8 @@ var Checkin = /** @class */ (function () {
|
|
|
258
258
|
&& ((_c = this.gracePeriod) !== null && _c !== void 0 ? _c : '') === ((_d = other.gracePeriod) !== null && _d !== void 0 ? _d : '')
|
|
259
259
|
&& ((_e = this.cronTimezone) !== null && _e !== void 0 ? _e : '') === ((_f = other.cronTimezone) !== null && _f !== void 0 ? _f : '');
|
|
260
260
|
};
|
|
261
|
-
|
|
262
|
-
return new
|
|
261
|
+
CheckIn.fromResponsePayload = function (projectId, payload) {
|
|
262
|
+
return new CheckIn({
|
|
263
263
|
projectId: projectId,
|
|
264
264
|
id: payload.id,
|
|
265
265
|
name: payload.name,
|
|
@@ -271,9 +271,9 @@ var Checkin = /** @class */ (function () {
|
|
|
271
271
|
cronTimezone: payload.cron_timezone,
|
|
272
272
|
});
|
|
273
273
|
};
|
|
274
|
-
return
|
|
274
|
+
return CheckIn;
|
|
275
275
|
}());
|
|
276
|
-
|
|
276
|
+
checkIn.CheckIn = CheckIn;
|
|
277
277
|
|
|
278
278
|
var __awaiter$2 = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
279
279
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
@@ -312,19 +312,19 @@ var __generator$2 = (commonjsGlobal && commonjsGlobal.__generator) || function (
|
|
|
312
312
|
}
|
|
313
313
|
};
|
|
314
314
|
Object.defineProperty(client, "__esModule", { value: true });
|
|
315
|
-
client.
|
|
316
|
-
var
|
|
317
|
-
var
|
|
318
|
-
function
|
|
315
|
+
client.CheckInsClient = void 0;
|
|
316
|
+
var check_in_1$1 = checkIn;
|
|
317
|
+
var CheckInsClient = /** @class */ (function () {
|
|
318
|
+
function CheckInsClient(config, transport) {
|
|
319
319
|
this.BASE_URL = 'https://app.honeybadger.io';
|
|
320
320
|
this.transport = transport;
|
|
321
321
|
this.config = config;
|
|
322
322
|
this.logger = config.logger;
|
|
323
323
|
this.cache = {};
|
|
324
324
|
}
|
|
325
|
-
|
|
325
|
+
CheckInsClient.prototype.listForProject = function (projectId) {
|
|
326
326
|
return __awaiter$2(this, void 0, void 0, function () {
|
|
327
|
-
var response, data,
|
|
327
|
+
var response, data, checkIns;
|
|
328
328
|
return __generator$2(this, function (_a) {
|
|
329
329
|
switch (_a.label) {
|
|
330
330
|
case 0:
|
|
@@ -346,16 +346,16 @@ var CheckinsClient = /** @class */ (function () {
|
|
|
346
346
|
throw new Error("Failed to fetch checkins for project[".concat(projectId, "]: ").concat(this.getErrorMessage(response.body)));
|
|
347
347
|
}
|
|
348
348
|
data = JSON.parse(response.body);
|
|
349
|
-
|
|
350
|
-
this.cache[projectId] =
|
|
351
|
-
return [2 /*return*/,
|
|
349
|
+
checkIns = data.results.map(function (checkin) { return check_in_1$1.CheckIn.fromResponsePayload(projectId, checkin); });
|
|
350
|
+
this.cache[projectId] = checkIns;
|
|
351
|
+
return [2 /*return*/, checkIns];
|
|
352
352
|
}
|
|
353
353
|
});
|
|
354
354
|
});
|
|
355
355
|
};
|
|
356
|
-
|
|
356
|
+
CheckInsClient.prototype.get = function (projectId, checkInId) {
|
|
357
357
|
return __awaiter$2(this, void 0, void 0, function () {
|
|
358
|
-
var response, data,
|
|
358
|
+
var response, data, checkIn;
|
|
359
359
|
return __generator$2(this, function (_a) {
|
|
360
360
|
switch (_a.label) {
|
|
361
361
|
case 0:
|
|
@@ -365,23 +365,23 @@ var CheckinsClient = /** @class */ (function () {
|
|
|
365
365
|
return [4 /*yield*/, this.transport.send({
|
|
366
366
|
method: 'GET',
|
|
367
367
|
headers: this.getHeaders(),
|
|
368
|
-
endpoint: "".concat(this.BASE_URL, "/v2/projects/").concat(projectId, "/check_ins/").concat(
|
|
368
|
+
endpoint: "".concat(this.BASE_URL, "/v2/projects/").concat(projectId, "/check_ins/").concat(checkInId),
|
|
369
369
|
logger: this.logger,
|
|
370
370
|
})];
|
|
371
371
|
case 1:
|
|
372
372
|
response = _a.sent();
|
|
373
373
|
if (response.statusCode !== 200) {
|
|
374
|
-
throw new Error("Failed to fetch
|
|
374
|
+
throw new Error("Failed to fetch check-in[".concat(checkInId, "] for project[").concat(projectId, "]: ").concat(this.getErrorMessage(response.body)));
|
|
375
375
|
}
|
|
376
376
|
data = JSON.parse(response.body);
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
return [2 /*return*/,
|
|
377
|
+
checkIn = check_in_1$1.CheckIn.fromResponsePayload(projectId, data);
|
|
378
|
+
checkIn.projectId = projectId;
|
|
379
|
+
return [2 /*return*/, checkIn];
|
|
380
380
|
}
|
|
381
381
|
});
|
|
382
382
|
});
|
|
383
383
|
};
|
|
384
|
-
|
|
384
|
+
CheckInsClient.prototype.create = function (checkIn) {
|
|
385
385
|
return __awaiter$2(this, void 0, void 0, function () {
|
|
386
386
|
var response, data, result;
|
|
387
387
|
return __generator$2(this, function (_a) {
|
|
@@ -393,23 +393,23 @@ var CheckinsClient = /** @class */ (function () {
|
|
|
393
393
|
return [4 /*yield*/, this.transport.send({
|
|
394
394
|
method: 'POST',
|
|
395
395
|
headers: this.getHeaders(),
|
|
396
|
-
endpoint: "".concat(this.BASE_URL, "/v2/projects/").concat(
|
|
396
|
+
endpoint: "".concat(this.BASE_URL, "/v2/projects/").concat(checkIn.projectId, "/check_ins"),
|
|
397
397
|
logger: this.logger,
|
|
398
|
-
}, { check_in:
|
|
398
|
+
}, { check_in: checkIn.asRequestPayload() })];
|
|
399
399
|
case 1:
|
|
400
400
|
response = _a.sent();
|
|
401
401
|
if (response.statusCode !== 201) {
|
|
402
|
-
throw new Error("Failed to create
|
|
402
|
+
throw new Error("Failed to create check-in[".concat(checkIn.name, "] for project[").concat(checkIn.projectId, "]: ").concat(this.getErrorMessage(response.body)));
|
|
403
403
|
}
|
|
404
404
|
data = JSON.parse(response.body);
|
|
405
|
-
result =
|
|
406
|
-
result.projectId =
|
|
405
|
+
result = check_in_1$1.CheckIn.fromResponsePayload(checkIn.projectId, data);
|
|
406
|
+
result.projectId = checkIn.projectId;
|
|
407
407
|
return [2 /*return*/, result];
|
|
408
408
|
}
|
|
409
409
|
});
|
|
410
410
|
});
|
|
411
411
|
};
|
|
412
|
-
|
|
412
|
+
CheckInsClient.prototype.update = function (checkIn) {
|
|
413
413
|
return __awaiter$2(this, void 0, void 0, function () {
|
|
414
414
|
var response;
|
|
415
415
|
return __generator$2(this, function (_a) {
|
|
@@ -421,20 +421,20 @@ var CheckinsClient = /** @class */ (function () {
|
|
|
421
421
|
return [4 /*yield*/, this.transport.send({
|
|
422
422
|
method: 'PUT',
|
|
423
423
|
headers: this.getHeaders(),
|
|
424
|
-
endpoint: "".concat(this.BASE_URL, "/v2/projects/").concat(
|
|
424
|
+
endpoint: "".concat(this.BASE_URL, "/v2/projects/").concat(checkIn.projectId, "/check_ins/").concat(checkIn.id),
|
|
425
425
|
logger: this.logger,
|
|
426
|
-
}, { check_in:
|
|
426
|
+
}, { check_in: checkIn.asRequestPayload() })];
|
|
427
427
|
case 1:
|
|
428
428
|
response = _a.sent();
|
|
429
429
|
if (response.statusCode !== 204) {
|
|
430
|
-
throw new Error("Failed to update checkin[".concat(
|
|
430
|
+
throw new Error("Failed to update checkin[".concat(checkIn.name, "] for project[").concat(checkIn.projectId, "]: ").concat(this.getErrorMessage(response.body)));
|
|
431
431
|
}
|
|
432
|
-
return [2 /*return*/,
|
|
432
|
+
return [2 /*return*/, checkIn];
|
|
433
433
|
}
|
|
434
434
|
});
|
|
435
435
|
});
|
|
436
436
|
};
|
|
437
|
-
|
|
437
|
+
CheckInsClient.prototype.remove = function (checkIn) {
|
|
438
438
|
return __awaiter$2(this, void 0, void 0, function () {
|
|
439
439
|
var response;
|
|
440
440
|
return __generator$2(this, function (_a) {
|
|
@@ -446,26 +446,26 @@ var CheckinsClient = /** @class */ (function () {
|
|
|
446
446
|
return [4 /*yield*/, this.transport.send({
|
|
447
447
|
method: 'DELETE',
|
|
448
448
|
headers: this.getHeaders(),
|
|
449
|
-
endpoint: "".concat(this.BASE_URL, "/v2/projects/").concat(
|
|
449
|
+
endpoint: "".concat(this.BASE_URL, "/v2/projects/").concat(checkIn.projectId, "/check_ins/").concat(checkIn.id),
|
|
450
450
|
logger: this.logger,
|
|
451
451
|
})];
|
|
452
452
|
case 1:
|
|
453
453
|
response = _a.sent();
|
|
454
454
|
if (response.statusCode !== 204) {
|
|
455
|
-
throw new Error("Failed to remove checkin[".concat(
|
|
455
|
+
throw new Error("Failed to remove checkin[".concat(checkIn.name, "] for project[").concat(checkIn.projectId, "]: ").concat(this.getErrorMessage(response.body)));
|
|
456
456
|
}
|
|
457
457
|
return [2 /*return*/];
|
|
458
458
|
}
|
|
459
459
|
});
|
|
460
460
|
});
|
|
461
461
|
};
|
|
462
|
-
|
|
462
|
+
CheckInsClient.prototype.getHeaders = function () {
|
|
463
463
|
return {
|
|
464
464
|
'Authorization': "Basic ".concat(Buffer.from("".concat(this.config.personalAuthToken, ":")).toString('base64')),
|
|
465
465
|
'Content-Type': 'application/json'
|
|
466
466
|
};
|
|
467
467
|
};
|
|
468
|
-
|
|
468
|
+
CheckInsClient.prototype.getErrorMessage = function (responseBody) {
|
|
469
469
|
var _a;
|
|
470
470
|
if (!responseBody) {
|
|
471
471
|
return '';
|
|
@@ -478,9 +478,9 @@ var CheckinsClient = /** @class */ (function () {
|
|
|
478
478
|
return responseBody;
|
|
479
479
|
}
|
|
480
480
|
};
|
|
481
|
-
return
|
|
481
|
+
return CheckInsClient;
|
|
482
482
|
}());
|
|
483
|
-
client.
|
|
483
|
+
client.CheckInsClient = CheckInsClient;
|
|
484
484
|
|
|
485
485
|
var transport = {};
|
|
486
486
|
|
|
@@ -640,14 +640,14 @@ var __spreadArray = (commonjsGlobal && commonjsGlobal.__spreadArray) || function
|
|
|
640
640
|
}
|
|
641
641
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
642
642
|
};
|
|
643
|
-
Object.defineProperty(
|
|
644
|
-
|
|
643
|
+
Object.defineProperty(checkInsManager, "__esModule", { value: true });
|
|
644
|
+
checkInsManager.CheckInsManager = void 0;
|
|
645
645
|
var core_1 = require$$0__default$1["default"];
|
|
646
646
|
var client_1 = client;
|
|
647
647
|
var transport_1 = transport;
|
|
648
|
-
var
|
|
649
|
-
var
|
|
650
|
-
function
|
|
648
|
+
var check_in_1 = checkIn;
|
|
649
|
+
var CheckInsManager$1 = /** @class */ (function () {
|
|
650
|
+
function CheckInsManager(config, client) {
|
|
651
651
|
var _a, _b, _c, _d;
|
|
652
652
|
this.config = {
|
|
653
653
|
debug: (_a = config.debug) !== null && _a !== void 0 ? _a : false,
|
|
@@ -657,14 +657,14 @@ var CheckinsManager$1 = /** @class */ (function () {
|
|
|
657
657
|
};
|
|
658
658
|
var transport = new transport_1.ServerTransport();
|
|
659
659
|
this.logger = core_1.Util.logger(this);
|
|
660
|
-
this.client = client !== null && client !== void 0 ? client : new client_1.
|
|
660
|
+
this.client = client !== null && client !== void 0 ? client : new client_1.CheckInsClient({
|
|
661
661
|
personalAuthToken: config.personalAuthToken,
|
|
662
662
|
logger: this.logger
|
|
663
663
|
}, transport);
|
|
664
664
|
}
|
|
665
|
-
|
|
665
|
+
CheckInsManager.prototype.sync = function () {
|
|
666
666
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
667
|
-
var
|
|
667
|
+
var localCheckIns, createdOrUpdated, removed;
|
|
668
668
|
return __generator$1(this, function (_a) {
|
|
669
669
|
switch (_a.label) {
|
|
670
670
|
case 0:
|
|
@@ -672,11 +672,11 @@ var CheckinsManager$1 = /** @class */ (function () {
|
|
|
672
672
|
if (!this.config.personalAuthToken || this.config.personalAuthToken === '') {
|
|
673
673
|
throw new Error('personalAuthToken is required');
|
|
674
674
|
}
|
|
675
|
-
|
|
676
|
-
return [4 /*yield*/, this.createOrUpdate(
|
|
675
|
+
localCheckIns = this.getLocalCheckIns();
|
|
676
|
+
return [4 /*yield*/, this.createOrUpdate(localCheckIns)];
|
|
677
677
|
case 1:
|
|
678
678
|
createdOrUpdated = _a.sent();
|
|
679
|
-
return [4 /*yield*/, this.remove(
|
|
679
|
+
return [4 /*yield*/, this.remove(localCheckIns)];
|
|
680
680
|
case 2:
|
|
681
681
|
removed = _a.sent();
|
|
682
682
|
return [2 /*return*/, __spreadArray(__spreadArray([], createdOrUpdated, true), removed, true)];
|
|
@@ -684,68 +684,68 @@ var CheckinsManager$1 = /** @class */ (function () {
|
|
|
684
684
|
});
|
|
685
685
|
});
|
|
686
686
|
};
|
|
687
|
-
|
|
688
|
-
// create
|
|
689
|
-
var
|
|
690
|
-
var
|
|
691
|
-
|
|
692
|
-
return
|
|
687
|
+
CheckInsManager.prototype.getLocalCheckIns = function () {
|
|
688
|
+
// create check-ins from configuration and validate them
|
|
689
|
+
var localCheckIns = this.config.checkins.map(function (dto) {
|
|
690
|
+
var checkIn = new check_in_1.CheckIn(dto);
|
|
691
|
+
checkIn.validate();
|
|
692
|
+
return checkIn;
|
|
693
693
|
});
|
|
694
|
-
// validate that we have unique
|
|
695
|
-
// throw error if there are
|
|
696
|
-
var
|
|
697
|
-
var
|
|
698
|
-
if (
|
|
694
|
+
// validate that we have unique check-in names
|
|
695
|
+
// throw error if there are check-ins with the same name and project id
|
|
696
|
+
var checkInNames = localCheckIns.map(function (checkIn) { return "".concat(checkIn.projectId, "_").concat(checkIn.name); });
|
|
697
|
+
var uniqueCheckInNames = new Set(checkInNames);
|
|
698
|
+
if (checkInNames.length !== uniqueCheckInNames.size) {
|
|
699
699
|
throw new Error('check-in names must be unique per project');
|
|
700
700
|
}
|
|
701
|
-
return
|
|
701
|
+
return localCheckIns;
|
|
702
702
|
};
|
|
703
|
-
|
|
703
|
+
CheckInsManager.prototype.createOrUpdate = function (localCheckIns) {
|
|
704
704
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
705
|
-
var results, _loop_1, this_1, _i,
|
|
705
|
+
var results, _loop_1, this_1, _i, localCheckIns_1, localCheckIn;
|
|
706
706
|
return __generator$1(this, function (_a) {
|
|
707
707
|
switch (_a.label) {
|
|
708
708
|
case 0:
|
|
709
709
|
results = [];
|
|
710
|
-
_loop_1 = function (
|
|
711
|
-
var
|
|
710
|
+
_loop_1 = function (localCheckIn) {
|
|
711
|
+
var projectCheckIns, remoteCheckIn, _b, _c, _d, _e;
|
|
712
712
|
return __generator$1(this, function (_f) {
|
|
713
713
|
switch (_f.label) {
|
|
714
|
-
case 0: return [4 /*yield*/, this_1.client.listForProject(
|
|
714
|
+
case 0: return [4 /*yield*/, this_1.client.listForProject(localCheckIn.projectId)];
|
|
715
715
|
case 1:
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
return
|
|
716
|
+
projectCheckIns = _f.sent();
|
|
717
|
+
remoteCheckIn = projectCheckIns.find(function (checkIn) {
|
|
718
|
+
return checkIn.name === localCheckIn.name;
|
|
719
719
|
});
|
|
720
|
-
if (!!
|
|
720
|
+
if (!!remoteCheckIn) return [3 /*break*/, 3];
|
|
721
721
|
_c = (_b = results).push;
|
|
722
|
-
return [4 /*yield*/, this_1.client.create(
|
|
722
|
+
return [4 /*yield*/, this_1.client.create(localCheckIn)];
|
|
723
723
|
case 2:
|
|
724
724
|
_c.apply(_b, [_f.sent()]);
|
|
725
725
|
return [3 /*break*/, 6];
|
|
726
726
|
case 3:
|
|
727
|
-
if (!!
|
|
728
|
-
|
|
727
|
+
if (!!localCheckIn.isInSync(remoteCheckIn)) return [3 /*break*/, 5];
|
|
728
|
+
localCheckIn.id = remoteCheckIn.id;
|
|
729
729
|
_e = (_d = results).push;
|
|
730
|
-
return [4 /*yield*/, this_1.client.update(
|
|
730
|
+
return [4 /*yield*/, this_1.client.update(localCheckIn)];
|
|
731
731
|
case 4:
|
|
732
732
|
_e.apply(_d, [_f.sent()]);
|
|
733
733
|
return [3 /*break*/, 6];
|
|
734
734
|
case 5:
|
|
735
735
|
// no change - still need to add to results
|
|
736
|
-
results.push(
|
|
736
|
+
results.push(remoteCheckIn);
|
|
737
737
|
_f.label = 6;
|
|
738
738
|
case 6: return [2 /*return*/];
|
|
739
739
|
}
|
|
740
740
|
});
|
|
741
741
|
};
|
|
742
742
|
this_1 = this;
|
|
743
|
-
_i = 0,
|
|
743
|
+
_i = 0, localCheckIns_1 = localCheckIns;
|
|
744
744
|
_a.label = 1;
|
|
745
745
|
case 1:
|
|
746
|
-
if (!(_i <
|
|
747
|
-
|
|
748
|
-
return [5 /*yield**/, _loop_1(
|
|
746
|
+
if (!(_i < localCheckIns_1.length)) return [3 /*break*/, 4];
|
|
747
|
+
localCheckIn = localCheckIns_1[_i];
|
|
748
|
+
return [5 /*yield**/, _loop_1(localCheckIn)];
|
|
749
749
|
case 2:
|
|
750
750
|
_a.sent();
|
|
751
751
|
_a.label = 3;
|
|
@@ -757,33 +757,33 @@ var CheckinsManager$1 = /** @class */ (function () {
|
|
|
757
757
|
});
|
|
758
758
|
});
|
|
759
759
|
};
|
|
760
|
-
|
|
760
|
+
CheckInsManager.prototype.remove = function (localCheckIns) {
|
|
761
761
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
762
|
-
var projectIds,
|
|
762
|
+
var projectIds, remoteCheckInsPerProject, allRemoteCheckIns, checkInsToRemove;
|
|
763
763
|
var _this = this;
|
|
764
764
|
return __generator$1(this, function (_a) {
|
|
765
765
|
switch (_a.label) {
|
|
766
766
|
case 0:
|
|
767
|
-
projectIds = Array.from(new Set(
|
|
767
|
+
projectIds = Array.from(new Set(localCheckIns.map(function (checkIn) { return checkIn.projectId; })));
|
|
768
768
|
return [4 /*yield*/, Promise.all(projectIds.map(function (projectId) {
|
|
769
769
|
return _this.client.listForProject(projectId);
|
|
770
770
|
}))];
|
|
771
771
|
case 1:
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
return !
|
|
776
|
-
return
|
|
772
|
+
remoteCheckInsPerProject = _a.sent();
|
|
773
|
+
allRemoteCheckIns = remoteCheckInsPerProject.flat();
|
|
774
|
+
checkInsToRemove = allRemoteCheckIns.filter(function (remoteCheckIn) {
|
|
775
|
+
return !localCheckIns.find(function (localCheckIn) {
|
|
776
|
+
return localCheckIn.name === remoteCheckIn.name;
|
|
777
777
|
});
|
|
778
778
|
});
|
|
779
|
-
return [2 /*return*/, Promise.all(
|
|
779
|
+
return [2 /*return*/, Promise.all(checkInsToRemove.map(function (checkIn) { return __awaiter$1(_this, void 0, void 0, function () {
|
|
780
780
|
return __generator$1(this, function (_a) {
|
|
781
781
|
switch (_a.label) {
|
|
782
|
-
case 0: return [4 /*yield*/, this.client.remove(
|
|
782
|
+
case 0: return [4 /*yield*/, this.client.remove(checkIn)];
|
|
783
783
|
case 1:
|
|
784
784
|
_a.sent();
|
|
785
|
-
|
|
786
|
-
return [2 /*return*/,
|
|
785
|
+
checkIn.markAsDeleted();
|
|
786
|
+
return [2 /*return*/, checkIn];
|
|
787
787
|
}
|
|
788
788
|
});
|
|
789
789
|
}); }))];
|
|
@@ -791,9 +791,9 @@ var CheckinsManager$1 = /** @class */ (function () {
|
|
|
791
791
|
});
|
|
792
792
|
});
|
|
793
793
|
};
|
|
794
|
-
return
|
|
794
|
+
return CheckInsManager;
|
|
795
795
|
}());
|
|
796
|
-
|
|
796
|
+
checkInsManager.CheckInsManager = CheckInsManager$1;
|
|
797
797
|
|
|
798
798
|
var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
799
799
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
@@ -831,13 +831,13 @@ var __generator = (commonjsGlobal && commonjsGlobal.__generator) || function (th
|
|
|
831
831
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
832
832
|
}
|
|
833
833
|
};
|
|
834
|
-
Object.defineProperty(
|
|
835
|
-
|
|
834
|
+
Object.defineProperty(checkInsSync, "__esModule", { value: true });
|
|
835
|
+
checkInsSync.syncCheckIns = void 0;
|
|
836
836
|
var readConfigFromFileSystem = util.readConfigFromFileSystem;
|
|
837
|
-
var
|
|
838
|
-
function
|
|
837
|
+
var CheckInsManager = checkInsManager.CheckInsManager;
|
|
838
|
+
function syncCheckIns$1() {
|
|
839
839
|
return __awaiter(this, void 0, void 0, function () {
|
|
840
|
-
var config,
|
|
840
|
+
var config, checkInsManager, checkIns, table;
|
|
841
841
|
return __generator(this, function (_a) {
|
|
842
842
|
switch (_a.label) {
|
|
843
843
|
case 0:
|
|
@@ -845,15 +845,15 @@ function syncCheckins$1() {
|
|
|
845
845
|
if (!config) {
|
|
846
846
|
throw new Error('Could not find a Honeybadger configuration file.');
|
|
847
847
|
}
|
|
848
|
-
|
|
849
|
-
return [4 /*yield*/,
|
|
848
|
+
checkInsManager = new CheckInsManager(config);
|
|
849
|
+
return [4 /*yield*/, checkInsManager.sync()];
|
|
850
850
|
case 1:
|
|
851
|
-
|
|
852
|
-
if (!
|
|
851
|
+
checkIns = _a.sent();
|
|
852
|
+
if (!checkIns.length) {
|
|
853
853
|
console.log('No check-ins found to synchronize with Honeybadger.');
|
|
854
854
|
return [2 /*return*/];
|
|
855
855
|
}
|
|
856
|
-
table =
|
|
856
|
+
table = checkIns.map(function (c) {
|
|
857
857
|
return {
|
|
858
858
|
'Id': c.id,
|
|
859
859
|
'Name': c.name,
|
|
@@ -873,13 +873,13 @@ function syncCheckins$1() {
|
|
|
873
873
|
});
|
|
874
874
|
});
|
|
875
875
|
}
|
|
876
|
-
|
|
876
|
+
checkInsSync.syncCheckIns = syncCheckIns$1;
|
|
877
877
|
|
|
878
|
-
var
|
|
879
|
-
|
|
878
|
+
var syncCheckIns = checkInsSync.syncCheckIns;
|
|
879
|
+
syncCheckIns().catch(function (err) {
|
|
880
880
|
console.error(err);
|
|
881
881
|
process.exit(1);
|
|
882
882
|
});
|
|
883
883
|
|
|
884
|
-
exports["default"] =
|
|
885
|
-
//# sourceMappingURL=
|
|
884
|
+
exports["default"] = checkInsSyncExec;
|
|
885
|
+
//# sourceMappingURL=check-ins-sync-exec.js.map
|