@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
|
@@ -28,7 +28,7 @@ var checkInsSync = {};
|
|
|
28
28
|
|
|
29
29
|
var util = {};
|
|
30
30
|
|
|
31
|
-
var __awaiter$
|
|
31
|
+
var __awaiter$2 = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
32
32
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
33
33
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
34
34
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
@@ -37,7 +37,7 @@ var __awaiter$3 = (commonjsGlobal && commonjsGlobal.__awaiter) || function (this
|
|
|
37
37
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
38
38
|
});
|
|
39
39
|
};
|
|
40
|
-
var __generator$
|
|
40
|
+
var __generator$2 = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
|
|
41
41
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
42
42
|
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
43
43
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
@@ -86,9 +86,9 @@ function fatallyLogAndExit(err, source) {
|
|
|
86
86
|
}
|
|
87
87
|
util.fatallyLogAndExit = fatallyLogAndExit;
|
|
88
88
|
function getStats() {
|
|
89
|
-
return __awaiter$
|
|
89
|
+
return __awaiter$2(this, void 0, void 0, function () {
|
|
90
90
|
var load, stats, fallback, memData, data, results;
|
|
91
|
-
return __generator$
|
|
91
|
+
return __generator$2(this, function (_a) {
|
|
92
92
|
switch (_a.label) {
|
|
93
93
|
case 0:
|
|
94
94
|
load = os_1.default.loadavg();
|
|
@@ -147,8 +147,8 @@ util.getStats = getStats;
|
|
|
147
147
|
* @param path to source code
|
|
148
148
|
*/
|
|
149
149
|
function getSourceFile(path) {
|
|
150
|
-
return __awaiter$
|
|
151
|
-
return __generator$
|
|
150
|
+
return __awaiter$2(this, void 0, void 0, function () {
|
|
151
|
+
return __generator$2(this, function (_a) {
|
|
152
152
|
switch (_a.label) {
|
|
153
153
|
case 0:
|
|
154
154
|
_a.trys.push([0, 2, , 3]);
|
|
@@ -274,7 +274,7 @@ var CheckIn = /** @class */ (function () {
|
|
|
274
274
|
}());
|
|
275
275
|
checkIn.CheckIn = CheckIn;
|
|
276
276
|
|
|
277
|
-
var __awaiter$
|
|
277
|
+
var __awaiter$1 = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
278
278
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
279
279
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
280
280
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
@@ -283,7 +283,7 @@ var __awaiter$2 = (commonjsGlobal && commonjsGlobal.__awaiter) || function (this
|
|
|
283
283
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
284
284
|
});
|
|
285
285
|
};
|
|
286
|
-
var __generator$
|
|
286
|
+
var __generator$1 = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
|
|
287
287
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
288
288
|
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
289
289
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
@@ -312,8 +312,8 @@ var __generator$2 = (commonjsGlobal && commonjsGlobal.__generator) || function (
|
|
|
312
312
|
};
|
|
313
313
|
Object.defineProperty(client, "__esModule", { value: true });
|
|
314
314
|
client.CheckInsClient = void 0;
|
|
315
|
-
var core_1$
|
|
316
|
-
var check_in_1
|
|
315
|
+
var core_1$1 = require$$0__default$1["default"];
|
|
316
|
+
var check_in_1 = checkIn;
|
|
317
317
|
var CheckInsClient = /** @class */ (function () {
|
|
318
318
|
function CheckInsClient(config, transport) {
|
|
319
319
|
this.transport = transport;
|
|
@@ -322,9 +322,9 @@ var CheckInsClient = /** @class */ (function () {
|
|
|
322
322
|
}
|
|
323
323
|
CheckInsClient.prototype.getProjectId = function (projectApiKey) {
|
|
324
324
|
var _a;
|
|
325
|
-
return __awaiter$
|
|
325
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
326
326
|
var response, data;
|
|
327
|
-
return __generator$
|
|
327
|
+
return __generator$1(this, function (_b) {
|
|
328
328
|
switch (_b.label) {
|
|
329
329
|
case 0:
|
|
330
330
|
if (!this.config.personalAuthToken || this.config.personalAuthToken === '') {
|
|
@@ -333,7 +333,7 @@ var CheckInsClient = /** @class */ (function () {
|
|
|
333
333
|
return [4 /*yield*/, this.transport.send({
|
|
334
334
|
method: 'GET',
|
|
335
335
|
headers: this.getHeaders(),
|
|
336
|
-
endpoint: core_1$
|
|
336
|
+
endpoint: core_1$1.Util.endpoint(this.config.appEndpoint, "v2/project_keys/".concat(projectApiKey)),
|
|
337
337
|
logger: this.logger,
|
|
338
338
|
})];
|
|
339
339
|
case 1:
|
|
@@ -348,9 +348,9 @@ var CheckInsClient = /** @class */ (function () {
|
|
|
348
348
|
});
|
|
349
349
|
};
|
|
350
350
|
CheckInsClient.prototype.listForProject = function (projectId) {
|
|
351
|
-
return __awaiter$
|
|
351
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
352
352
|
var response, data;
|
|
353
|
-
return __generator$
|
|
353
|
+
return __generator$1(this, function (_a) {
|
|
354
354
|
switch (_a.label) {
|
|
355
355
|
case 0:
|
|
356
356
|
if (!this.config.personalAuthToken || this.config.personalAuthToken === '') {
|
|
@@ -359,7 +359,7 @@ var CheckInsClient = /** @class */ (function () {
|
|
|
359
359
|
return [4 /*yield*/, this.transport.send({
|
|
360
360
|
method: 'GET',
|
|
361
361
|
headers: this.getHeaders(),
|
|
362
|
-
endpoint: core_1$
|
|
362
|
+
endpoint: core_1$1.Util.endpoint(this.config.appEndpoint, "v2/projects/".concat(projectId, "/check_ins")),
|
|
363
363
|
logger: this.logger,
|
|
364
364
|
})];
|
|
365
365
|
case 1:
|
|
@@ -368,15 +368,15 @@ var CheckInsClient = /** @class */ (function () {
|
|
|
368
368
|
throw new Error("Failed to fetch checkins for project[".concat(projectId, "]: ").concat(this.getErrorMessage(response.body)));
|
|
369
369
|
}
|
|
370
370
|
data = JSON.parse(response.body);
|
|
371
|
-
return [2 /*return*/, data.results.map(function (checkin) { return check_in_1
|
|
371
|
+
return [2 /*return*/, data.results.map(function (checkin) { return check_in_1.CheckIn.fromResponsePayload(checkin); })];
|
|
372
372
|
}
|
|
373
373
|
});
|
|
374
374
|
});
|
|
375
375
|
};
|
|
376
376
|
CheckInsClient.prototype.get = function (projectId, checkInId) {
|
|
377
|
-
return __awaiter$
|
|
377
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
378
378
|
var response, data;
|
|
379
|
-
return __generator$
|
|
379
|
+
return __generator$1(this, function (_a) {
|
|
380
380
|
switch (_a.label) {
|
|
381
381
|
case 0:
|
|
382
382
|
if (!this.config.personalAuthToken || this.config.personalAuthToken === '') {
|
|
@@ -385,7 +385,7 @@ var CheckInsClient = /** @class */ (function () {
|
|
|
385
385
|
return [4 /*yield*/, this.transport.send({
|
|
386
386
|
method: 'GET',
|
|
387
387
|
headers: this.getHeaders(),
|
|
388
|
-
endpoint: core_1$
|
|
388
|
+
endpoint: core_1$1.Util.endpoint(this.config.appEndpoint, "v2/projects/".concat(projectId, "/check_ins/").concat(checkInId)),
|
|
389
389
|
logger: this.logger,
|
|
390
390
|
})];
|
|
391
391
|
case 1:
|
|
@@ -394,15 +394,15 @@ var CheckInsClient = /** @class */ (function () {
|
|
|
394
394
|
throw new Error("Failed to fetch check-in[".concat(checkInId, "] for project[").concat(projectId, "]: ").concat(this.getErrorMessage(response.body)));
|
|
395
395
|
}
|
|
396
396
|
data = JSON.parse(response.body);
|
|
397
|
-
return [2 /*return*/, check_in_1
|
|
397
|
+
return [2 /*return*/, check_in_1.CheckIn.fromResponsePayload(data)];
|
|
398
398
|
}
|
|
399
399
|
});
|
|
400
400
|
});
|
|
401
401
|
};
|
|
402
402
|
CheckInsClient.prototype.create = function (projectId, checkIn) {
|
|
403
|
-
return __awaiter$
|
|
403
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
404
404
|
var response, data;
|
|
405
|
-
return __generator$
|
|
405
|
+
return __generator$1(this, function (_a) {
|
|
406
406
|
switch (_a.label) {
|
|
407
407
|
case 0:
|
|
408
408
|
if (!this.config.personalAuthToken || this.config.personalAuthToken === '') {
|
|
@@ -411,7 +411,7 @@ var CheckInsClient = /** @class */ (function () {
|
|
|
411
411
|
return [4 /*yield*/, this.transport.send({
|
|
412
412
|
method: 'POST',
|
|
413
413
|
headers: this.getHeaders(),
|
|
414
|
-
endpoint: core_1$
|
|
414
|
+
endpoint: core_1$1.Util.endpoint(this.config.appEndpoint, "v2/projects/".concat(projectId, "/check_ins")),
|
|
415
415
|
logger: this.logger,
|
|
416
416
|
}, { check_in: checkIn.asRequestPayload() })];
|
|
417
417
|
case 1:
|
|
@@ -420,15 +420,15 @@ var CheckInsClient = /** @class */ (function () {
|
|
|
420
420
|
throw new Error("Failed to create check-in[".concat(checkIn.slug, "] for project[").concat(projectId, "]: ").concat(this.getErrorMessage(response.body)));
|
|
421
421
|
}
|
|
422
422
|
data = JSON.parse(response.body);
|
|
423
|
-
return [2 /*return*/, check_in_1
|
|
423
|
+
return [2 /*return*/, check_in_1.CheckIn.fromResponsePayload(data)];
|
|
424
424
|
}
|
|
425
425
|
});
|
|
426
426
|
});
|
|
427
427
|
};
|
|
428
428
|
CheckInsClient.prototype.update = function (projectId, checkIn) {
|
|
429
|
-
return __awaiter$
|
|
429
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
430
430
|
var response;
|
|
431
|
-
return __generator$
|
|
431
|
+
return __generator$1(this, function (_a) {
|
|
432
432
|
switch (_a.label) {
|
|
433
433
|
case 0:
|
|
434
434
|
if (!this.config.personalAuthToken || this.config.personalAuthToken === '') {
|
|
@@ -437,7 +437,7 @@ var CheckInsClient = /** @class */ (function () {
|
|
|
437
437
|
return [4 /*yield*/, this.transport.send({
|
|
438
438
|
method: 'PUT',
|
|
439
439
|
headers: this.getHeaders(),
|
|
440
|
-
endpoint: core_1$
|
|
440
|
+
endpoint: core_1$1.Util.endpoint(this.config.appEndpoint, "v2/projects/".concat(projectId, "/check_ins/").concat(checkIn.id)),
|
|
441
441
|
logger: this.logger,
|
|
442
442
|
}, { check_in: checkIn.asRequestPayload() })];
|
|
443
443
|
case 1:
|
|
@@ -451,9 +451,9 @@ var CheckInsClient = /** @class */ (function () {
|
|
|
451
451
|
});
|
|
452
452
|
};
|
|
453
453
|
CheckInsClient.prototype.remove = function (projectId, checkIn) {
|
|
454
|
-
return __awaiter$
|
|
454
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
455
455
|
var response;
|
|
456
|
-
return __generator$
|
|
456
|
+
return __generator$1(this, function (_a) {
|
|
457
457
|
switch (_a.label) {
|
|
458
458
|
case 0:
|
|
459
459
|
if (!this.config.personalAuthToken || this.config.personalAuthToken === '') {
|
|
@@ -462,7 +462,7 @@ var CheckInsClient = /** @class */ (function () {
|
|
|
462
462
|
return [4 /*yield*/, this.transport.send({
|
|
463
463
|
method: 'DELETE',
|
|
464
464
|
headers: this.getHeaders(),
|
|
465
|
-
endpoint: core_1$
|
|
465
|
+
endpoint: core_1$1.Util.endpoint(this.config.appEndpoint, "v2/projects/".concat(projectId, "/check_ins/").concat(checkIn.id)),
|
|
466
466
|
logger: this.logger,
|
|
467
467
|
})];
|
|
468
468
|
case 1:
|
|
@@ -536,12 +536,12 @@ var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (
|
|
|
536
536
|
};
|
|
537
537
|
Object.defineProperty(transport, "__esModule", { value: true });
|
|
538
538
|
transport.ServerTransport = void 0;
|
|
539
|
-
var core_1
|
|
539
|
+
var core_1 = require$$0__default$1["default"];
|
|
540
540
|
var url_1 = require$$1__default$1["default"];
|
|
541
541
|
var util_1 = util;
|
|
542
542
|
var http = __importStar(require$$3__default$1["default"]);
|
|
543
543
|
var https = __importStar(require$$4__default["default"]);
|
|
544
|
-
var sanitize = core_1
|
|
544
|
+
var sanitize = core_1.Util.sanitize;
|
|
545
545
|
var ServerTransport = /** @class */ (function () {
|
|
546
546
|
function ServerTransport(headers) {
|
|
547
547
|
if (headers === void 0) { headers = {}; }
|
|
@@ -611,210 +611,217 @@ var ServerTransport = /** @class */ (function () {
|
|
|
611
611
|
}());
|
|
612
612
|
transport.ServerTransport = ServerTransport;
|
|
613
613
|
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
};
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
var
|
|
663
|
-
var
|
|
664
|
-
var
|
|
665
|
-
var
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
}
|
|
817
|
-
|
|
614
|
+
(function (exports) {
|
|
615
|
+
var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
616
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
617
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
618
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
619
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
620
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
621
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
622
|
+
});
|
|
623
|
+
};
|
|
624
|
+
var __generator = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
|
|
625
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
626
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
627
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
628
|
+
function step(op) {
|
|
629
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
630
|
+
while (_) try {
|
|
631
|
+
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;
|
|
632
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
633
|
+
switch (op[0]) {
|
|
634
|
+
case 0: case 1: t = op; break;
|
|
635
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
636
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
637
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
638
|
+
default:
|
|
639
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
640
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
641
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
642
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
643
|
+
if (t[2]) _.ops.pop();
|
|
644
|
+
_.trys.pop(); continue;
|
|
645
|
+
}
|
|
646
|
+
op = body.call(thisArg, _);
|
|
647
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
648
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
var __spreadArray = (commonjsGlobal && commonjsGlobal.__spreadArray) || function (to, from, pack) {
|
|
652
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
653
|
+
if (ar || !(i in from)) {
|
|
654
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
655
|
+
ar[i] = from[i];
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
659
|
+
};
|
|
660
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
661
|
+
exports.CheckInsManager = exports.CheckIn = exports.CheckInsClient = void 0;
|
|
662
|
+
var core_1 = require$$0__default$1["default"];
|
|
663
|
+
var client_1 = client;
|
|
664
|
+
var transport_1 = transport;
|
|
665
|
+
var check_in_1 = checkIn;
|
|
666
|
+
var client_2 = client;
|
|
667
|
+
Object.defineProperty(exports, "CheckInsClient", { enumerable: true, get: function () { return client_2.CheckInsClient; } });
|
|
668
|
+
var check_in_2 = checkIn;
|
|
669
|
+
Object.defineProperty(exports, "CheckIn", { enumerable: true, get: function () { return check_in_2.CheckIn; } });
|
|
670
|
+
var CheckInsManager = /** @class */ (function () {
|
|
671
|
+
function CheckInsManager(config, client) {
|
|
672
|
+
var _a, _b, _c, _d, _e, _f;
|
|
673
|
+
this.config = {
|
|
674
|
+
appEndpoint: (_a = config.appEndpoint) !== null && _a !== void 0 ? _a : core_1.Defaults.CONFIG.appEndpoint,
|
|
675
|
+
debug: (_b = config.debug) !== null && _b !== void 0 ? _b : false,
|
|
676
|
+
apiKey: (_c = config.apiKey) !== null && _c !== void 0 ? _c : undefined,
|
|
677
|
+
personalAuthToken: (_d = config.personalAuthToken) !== null && _d !== void 0 ? _d : undefined,
|
|
678
|
+
checkins: (_e = config.checkins) !== null && _e !== void 0 ? _e : [],
|
|
679
|
+
logger: (_f = config.logger) !== null && _f !== void 0 ? _f : console,
|
|
680
|
+
};
|
|
681
|
+
var transport = new transport_1.ServerTransport();
|
|
682
|
+
this.logger = core_1.Util.logger(this);
|
|
683
|
+
this.client = client !== null && client !== void 0 ? client : new client_1.CheckInsClient({
|
|
684
|
+
appEndpoint: config.appEndpoint,
|
|
685
|
+
apiKey: config.apiKey,
|
|
686
|
+
personalAuthToken: config.personalAuthToken,
|
|
687
|
+
logger: this.logger
|
|
688
|
+
}, transport);
|
|
689
|
+
}
|
|
690
|
+
CheckInsManager.prototype.sync = function () {
|
|
691
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
692
|
+
var localCheckIns, projectId, remoteCheckIns, createdOrUpdated, removed;
|
|
693
|
+
return __generator(this, function (_a) {
|
|
694
|
+
switch (_a.label) {
|
|
695
|
+
case 0:
|
|
696
|
+
// check if app endpoint is set
|
|
697
|
+
if (!this.config.appEndpoint || this.config.appEndpoint === '') {
|
|
698
|
+
throw new Error('appEndpoint is required');
|
|
699
|
+
}
|
|
700
|
+
// check if api key is set
|
|
701
|
+
if (!this.config.apiKey || this.config.apiKey === '') {
|
|
702
|
+
throw new Error('apiKey is required');
|
|
703
|
+
}
|
|
704
|
+
// check if personal auth token is set
|
|
705
|
+
if (!this.config.personalAuthToken || this.config.personalAuthToken === '') {
|
|
706
|
+
throw new Error('personalAuthToken is required');
|
|
707
|
+
}
|
|
708
|
+
localCheckIns = this.getLocalCheckIns();
|
|
709
|
+
return [4 /*yield*/, this.client.getProjectId(this.config.apiKey)];
|
|
710
|
+
case 1:
|
|
711
|
+
projectId = _a.sent();
|
|
712
|
+
return [4 /*yield*/, this.client.listForProject(projectId)];
|
|
713
|
+
case 2:
|
|
714
|
+
remoteCheckIns = _a.sent();
|
|
715
|
+
return [4 /*yield*/, this.createOrUpdate(projectId, localCheckIns, remoteCheckIns)];
|
|
716
|
+
case 3:
|
|
717
|
+
createdOrUpdated = _a.sent();
|
|
718
|
+
return [4 /*yield*/, this.remove(projectId, localCheckIns, remoteCheckIns)];
|
|
719
|
+
case 4:
|
|
720
|
+
removed = _a.sent();
|
|
721
|
+
return [2 /*return*/, __spreadArray(__spreadArray([], createdOrUpdated, true), removed, true)];
|
|
722
|
+
}
|
|
723
|
+
});
|
|
724
|
+
});
|
|
725
|
+
};
|
|
726
|
+
CheckInsManager.prototype.getLocalCheckIns = function () {
|
|
727
|
+
// create check-ins from configuration and validate them
|
|
728
|
+
var localCheckIns = this.config.checkins.map(function (dto) {
|
|
729
|
+
var checkIn = new check_in_1.CheckIn(dto);
|
|
730
|
+
checkIn.validate();
|
|
731
|
+
return checkIn;
|
|
732
|
+
});
|
|
733
|
+
// validate that we have unique check-in slugs
|
|
734
|
+
var checkInSlugs = localCheckIns.map(function (checkIn) { return checkIn.slug; });
|
|
735
|
+
var uniqueCheckInSlugs = new Set(checkInSlugs);
|
|
736
|
+
if (checkInSlugs.length !== uniqueCheckInSlugs.size) {
|
|
737
|
+
throw new Error('check-in slugs must be unique');
|
|
738
|
+
}
|
|
739
|
+
return localCheckIns;
|
|
740
|
+
};
|
|
741
|
+
CheckInsManager.prototype.createOrUpdate = function (projectId, localCheckIns, remoteCheckIns) {
|
|
742
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
743
|
+
var results, _loop_1, this_1, _i, localCheckIns_1, localCheckIn;
|
|
744
|
+
return __generator(this, function (_a) {
|
|
745
|
+
switch (_a.label) {
|
|
746
|
+
case 0:
|
|
747
|
+
results = [];
|
|
748
|
+
_loop_1 = function (localCheckIn) {
|
|
749
|
+
var remoteCheckIn, _b, _c, _d, _e;
|
|
750
|
+
return __generator(this, function (_f) {
|
|
751
|
+
switch (_f.label) {
|
|
752
|
+
case 0:
|
|
753
|
+
remoteCheckIn = remoteCheckIns.find(function (checkIn) {
|
|
754
|
+
return checkIn.slug === localCheckIn.slug;
|
|
755
|
+
});
|
|
756
|
+
if (!!remoteCheckIn) return [3 /*break*/, 2];
|
|
757
|
+
_c = (_b = results).push;
|
|
758
|
+
return [4 /*yield*/, this_1.client.create(projectId, localCheckIn)];
|
|
759
|
+
case 1:
|
|
760
|
+
_c.apply(_b, [_f.sent()]);
|
|
761
|
+
return [3 /*break*/, 5];
|
|
762
|
+
case 2:
|
|
763
|
+
if (!!localCheckIn.isInSync(remoteCheckIn)) return [3 /*break*/, 4];
|
|
764
|
+
localCheckIn.id = remoteCheckIn.id;
|
|
765
|
+
_e = (_d = results).push;
|
|
766
|
+
return [4 /*yield*/, this_1.client.update(projectId, localCheckIn)];
|
|
767
|
+
case 3:
|
|
768
|
+
_e.apply(_d, [_f.sent()]);
|
|
769
|
+
return [3 /*break*/, 5];
|
|
770
|
+
case 4:
|
|
771
|
+
// no change - still need to add to results
|
|
772
|
+
results.push(remoteCheckIn);
|
|
773
|
+
_f.label = 5;
|
|
774
|
+
case 5: return [2 /*return*/];
|
|
775
|
+
}
|
|
776
|
+
});
|
|
777
|
+
};
|
|
778
|
+
this_1 = this;
|
|
779
|
+
_i = 0, localCheckIns_1 = localCheckIns;
|
|
780
|
+
_a.label = 1;
|
|
781
|
+
case 1:
|
|
782
|
+
if (!(_i < localCheckIns_1.length)) return [3 /*break*/, 4];
|
|
783
|
+
localCheckIn = localCheckIns_1[_i];
|
|
784
|
+
return [5 /*yield**/, _loop_1(localCheckIn)];
|
|
785
|
+
case 2:
|
|
786
|
+
_a.sent();
|
|
787
|
+
_a.label = 3;
|
|
788
|
+
case 3:
|
|
789
|
+
_i++;
|
|
790
|
+
return [3 /*break*/, 1];
|
|
791
|
+
case 4: return [2 /*return*/, results];
|
|
792
|
+
}
|
|
793
|
+
});
|
|
794
|
+
});
|
|
795
|
+
};
|
|
796
|
+
CheckInsManager.prototype.remove = function (projectId, localCheckIns, remoteCheckIns) {
|
|
797
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
798
|
+
var checkInsToRemove;
|
|
799
|
+
var _this = this;
|
|
800
|
+
return __generator(this, function (_a) {
|
|
801
|
+
checkInsToRemove = remoteCheckIns.filter(function (remoteCheckIn) {
|
|
802
|
+
return !localCheckIns.find(function (localCheckIn) {
|
|
803
|
+
return localCheckIn.slug === remoteCheckIn.slug;
|
|
804
|
+
});
|
|
805
|
+
});
|
|
806
|
+
return [2 /*return*/, Promise.all(checkInsToRemove.map(function (checkIn) { return __awaiter(_this, void 0, void 0, function () {
|
|
807
|
+
return __generator(this, function (_a) {
|
|
808
|
+
switch (_a.label) {
|
|
809
|
+
case 0: return [4 /*yield*/, this.client.remove(projectId, checkIn)];
|
|
810
|
+
case 1:
|
|
811
|
+
_a.sent();
|
|
812
|
+
checkIn.markAsDeleted();
|
|
813
|
+
return [2 /*return*/, checkIn];
|
|
814
|
+
}
|
|
815
|
+
});
|
|
816
|
+
}); }))];
|
|
817
|
+
});
|
|
818
|
+
});
|
|
819
|
+
};
|
|
820
|
+
return CheckInsManager;
|
|
821
|
+
}());
|
|
822
|
+
exports.CheckInsManager = CheckInsManager;
|
|
823
|
+
|
|
824
|
+
} (checkInsManager));
|
|
818
825
|
|
|
819
826
|
var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
820
827
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|