@atlaskit/collab-provider 8.3.0 → 8.4.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/CHANGELOG.md +16 -0
- package/dist/cjs/analytics/index.js +2 -1
- package/dist/cjs/analytics/performance.js +1 -0
- package/dist/cjs/channel.js +230 -120
- package/dist/cjs/{error-code-mapper.js → errors/error-code-mapper.js} +1 -1
- package/dist/cjs/errors/error-types.js +43 -0
- package/dist/cjs/helpers/const.js +2 -4
- package/dist/cjs/provider/commit-step.js +39 -35
- package/dist/cjs/provider/index.js +71 -56
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/analytics/index.js +2 -1
- package/dist/es2019/analytics/performance.js +1 -0
- package/dist/es2019/channel.js +116 -48
- package/dist/es2019/{error-code-mapper.js → errors/error-code-mapper.js} +1 -1
- package/dist/es2019/errors/error-types.js +13 -0
- package/dist/es2019/helpers/const.js +2 -4
- package/dist/es2019/provider/commit-step.js +37 -33
- package/dist/es2019/provider/index.js +83 -71
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/analytics/index.js +2 -1
- package/dist/esm/analytics/performance.js +1 -0
- package/dist/esm/channel.js +231 -121
- package/dist/esm/{error-code-mapper.js → errors/error-code-mapper.js} +1 -1
- package/dist/esm/errors/error-types.js +34 -0
- package/dist/esm/helpers/const.js +2 -4
- package/dist/esm/provider/commit-step.js +39 -35
- package/dist/esm/provider/index.js +70 -56
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/analytics/performance.d.ts +2 -1
- package/dist/types/channel.d.ts +5 -0
- package/dist/types/{error-code-mapper.d.ts → errors/error-code-mapper.d.ts} +1 -1
- package/dist/types/errors/error-types.d.ts +8 -0
- package/dist/types/helpers/const.d.ts +29 -6
- package/dist/types/provider/index.d.ts +15 -1
- package/dist/types/socket-io-provider.d.ts +2 -2
- package/dist/types/types.d.ts +18 -3
- package/package.json +3 -3
- package/report.api.md +21 -4
- package/error-code-mapper/package.json +0 -15
|
@@ -20,39 +20,43 @@ export var commitStep = function commitStep(_ref) {
|
|
|
20
20
|
});
|
|
21
21
|
});
|
|
22
22
|
var start = new Date().getTime();
|
|
23
|
-
|
|
24
|
-
steps:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
23
|
+
try {
|
|
24
|
+
channel.broadcast('steps:commit', {
|
|
25
|
+
steps: stepsWithClientAndUserId,
|
|
26
|
+
version: version,
|
|
27
|
+
userId: userId
|
|
28
|
+
}, function (response) {
|
|
29
|
+
var latency = new Date().getTime() - start;
|
|
30
|
+
if (response.type === AcknowledgementResponseTypes.SUCCESS) {
|
|
31
|
+
onStepsAdded({
|
|
32
|
+
steps: stepsWithClientAndUserId,
|
|
33
|
+
version: response.version
|
|
34
|
+
});
|
|
35
|
+
analyticsHelper === null || analyticsHelper === void 0 ? void 0 : analyticsHelper.sendActionEvent(EVENT_ACTION.ADD_STEPS, EVENT_STATUS.SUCCESS, {
|
|
36
|
+
type: ADD_STEPS_TYPE.ACCEPTED,
|
|
37
|
+
latency: latency,
|
|
38
|
+
stepType: countBy(stepsWithClientAndUserId, function (stepWithClientAndUserId) {
|
|
39
|
+
return stepWithClientAndUserId.stepType;
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
} else if (response.type === AcknowledgementResponseTypes.ERROR) {
|
|
43
|
+
var _response$error, _response$error$data, _response$error2, _response$error2$data;
|
|
44
|
+
onErrorHandled(response.error);
|
|
45
|
+
analyticsHelper === null || analyticsHelper === void 0 ? void 0 : analyticsHelper.sendActionEvent(EVENT_ACTION.ADD_STEPS, EVENT_STATUS.FAILURE, {
|
|
46
|
+
// User tried committing steps but they were rejected because:
|
|
47
|
+
// - HEAD_VERSION_UPDATE_FAILED: the collab service's latest stored step tail version didn't correspond to the head version of the first step submitted
|
|
48
|
+
// - VERSION_NUMBER_ALREADY_EXISTS: while storing the steps there was a conflict meaning someone else wrote steps into the database more quickly
|
|
49
|
+
type: ((_response$error = response.error) === null || _response$error === void 0 ? void 0 : (_response$error$data = _response$error.data) === null || _response$error$data === void 0 ? void 0 : _response$error$data.code) === 'HEAD_VERSION_UPDATE_FAILED' || ((_response$error2 = response.error) === null || _response$error2 === void 0 ? void 0 : (_response$error2$data = _response$error2.data) === null || _response$error2$data === void 0 ? void 0 : _response$error2$data.code) === 'VERSION_NUMBER_ALREADY_EXISTS' ? ADD_STEPS_TYPE.REJECTED : ADD_STEPS_TYPE.ERROR,
|
|
50
|
+
latency: latency
|
|
51
|
+
});
|
|
52
|
+
analyticsHelper === null || analyticsHelper === void 0 ? void 0 : analyticsHelper.sendErrorEvent(response.error, 'Error while adding steps - Acknowledgement Error');
|
|
53
|
+
} else {
|
|
54
|
+
analyticsHelper === null || analyticsHelper === void 0 ? void 0 : analyticsHelper.sendErrorEvent(
|
|
55
|
+
// @ts-expect-error We didn't type the invalid type case
|
|
56
|
+
new Error("Response type: ".concat((response === null || response === void 0 ? void 0 : response.type) || 'No response type')), 'Error while adding steps - Invalid Acknowledgement');
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
} catch (error) {
|
|
60
|
+
analyticsHelper === null || analyticsHelper === void 0 ? void 0 : analyticsHelper.sendErrorEvent(error, 'Error while adding steps - Broadcast threw exception');
|
|
61
|
+
}
|
|
58
62
|
};
|
|
@@ -23,7 +23,7 @@ import { createLogger, getParticipant, sleep } from '../helpers/utils';
|
|
|
23
23
|
import { ACK_MAX_TRY, EVENT_ACTION, EVENT_STATUS } from '../helpers/const';
|
|
24
24
|
import AnalyticsHelper from '../analytics';
|
|
25
25
|
import { catchup } from './catchup';
|
|
26
|
-
import { ErrorCodeMapper, errorCodeMapper } from '../error-code-mapper';
|
|
26
|
+
import { ErrorCodeMapper, errorCodeMapper } from '../errors/error-code-mapper';
|
|
27
27
|
import { disconnectedReasonMapper } from '../disconnected-reason-mapper';
|
|
28
28
|
import { MEASURE_NAME, startMeasure, stopMeasure } from '../analytics/performance';
|
|
29
29
|
import { commitStep } from './commit-step';
|
|
@@ -36,7 +36,7 @@ var CATCHUP_THROTTLE = 1 * 1000; // 1 second
|
|
|
36
36
|
var OUT_OF_SYNC_PERIOD = 3 * 1000; // 3 seconds
|
|
37
37
|
var noop = function noop() {};
|
|
38
38
|
export var MAX_STEP_REJECTED_ERROR = 15;
|
|
39
|
-
var throttledCommitStep = throttle(commitStep, SEND_STEPS_THROTTLE, {
|
|
39
|
+
export var throttledCommitStep = throttle(commitStep, SEND_STEPS_THROTTLE, {
|
|
40
40
|
leading: false,
|
|
41
41
|
trailing: true
|
|
42
42
|
});
|
|
@@ -544,68 +544,79 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
544
544
|
}
|
|
545
545
|
});
|
|
546
546
|
_defineProperty(_assertThisInitialized(_this), "getCurrentState", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
547
|
-
var _this$metadata$title, state, adfDocument, _this$
|
|
547
|
+
var _this$metadata$title, _this$analyticsHelper20, state, adfDocument, currentState, measure, _this$analyticsHelper21, _this$analyticsHelper22, _measure;
|
|
548
548
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
549
549
|
while (1) {
|
|
550
550
|
switch (_context3.prev = _context3.next) {
|
|
551
551
|
case 0:
|
|
552
552
|
_context3.prev = 0;
|
|
553
|
+
startMeasure(MEASURE_NAME.GET_CURRENT_STATE, _this.analyticsHelper);
|
|
554
|
+
|
|
553
555
|
// Convert ProseMirror document in Editor state to ADF document
|
|
554
556
|
state = _this.getState();
|
|
555
557
|
adfDocument = new JSONTransformer().encode(state.doc);
|
|
556
|
-
|
|
558
|
+
currentState = {
|
|
557
559
|
content: adfDocument,
|
|
558
560
|
title: (_this$metadata$title = _this.metadata.title) === null || _this$metadata$title === void 0 ? void 0 : _this$metadata$title.toString(),
|
|
559
561
|
stepVersion: getVersion(state)
|
|
562
|
+
};
|
|
563
|
+
measure = stopMeasure(MEASURE_NAME.GET_CURRENT_STATE, _this.analyticsHelper);
|
|
564
|
+
(_this$analyticsHelper20 = _this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 ? void 0 : _this$analyticsHelper20.sendActionEvent(EVENT_ACTION.GET_CURRENT_STATE, EVENT_STATUS.SUCCESS, {
|
|
565
|
+
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
560
566
|
});
|
|
561
|
-
|
|
562
|
-
|
|
567
|
+
return _context3.abrupt("return", currentState);
|
|
568
|
+
case 10:
|
|
569
|
+
_context3.prev = 10;
|
|
563
570
|
_context3.t0 = _context3["catch"](0);
|
|
564
|
-
|
|
571
|
+
_measure = stopMeasure(MEASURE_NAME.GET_CURRENT_STATE, _this.analyticsHelper);
|
|
572
|
+
(_this$analyticsHelper21 = _this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 ? void 0 : _this$analyticsHelper21.sendActionEvent(EVENT_ACTION.GET_CURRENT_STATE, EVENT_STATUS.FAILURE, {
|
|
573
|
+
latency: _measure === null || _measure === void 0 ? void 0 : _measure.duration
|
|
574
|
+
});
|
|
575
|
+
(_this$analyticsHelper22 = _this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 ? void 0 : _this$analyticsHelper22.sendErrorEvent(_context3.t0, 'Error while returning ADF version of current draft document');
|
|
565
576
|
throw _context3.t0;
|
|
566
|
-
case
|
|
577
|
+
case 16:
|
|
567
578
|
case "end":
|
|
568
579
|
return _context3.stop();
|
|
569
580
|
}
|
|
570
581
|
}
|
|
571
|
-
}, _callee3, null, [[0,
|
|
582
|
+
}, _callee3, null, [[0, 10]]);
|
|
572
583
|
})));
|
|
573
584
|
_defineProperty(_assertThisInitialized(_this), "commitUnconfirmedSteps", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
574
|
-
var
|
|
585
|
+
var unconfirmedSteps, _this$analyticsHelper24, _this$analyticsHelper25, measure;
|
|
575
586
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
576
587
|
while (1) {
|
|
577
588
|
switch (_context5.prev = _context5.next) {
|
|
578
589
|
case 0:
|
|
579
|
-
count = 0;
|
|
580
590
|
unconfirmedSteps = _this.getUnconfirmedSteps();
|
|
591
|
+
_context5.prev = 1;
|
|
581
592
|
if (!(unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length)) {
|
|
582
593
|
_context5.next = 4;
|
|
583
594
|
break;
|
|
584
595
|
}
|
|
585
596
|
return _context5.delegateYield( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
586
|
-
var _this$
|
|
587
|
-
var unconfirmedTrs, lastTr, isLastTrConfirmed, nextUnconfirmedSteps, nextUnconfirmedTrs,
|
|
597
|
+
var _this$analyticsHelper23;
|
|
598
|
+
var count, unconfirmedTrs, lastTr, isLastTrConfirmed, nextUnconfirmedSteps, nextUnconfirmedTrs, state, measure;
|
|
588
599
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
589
600
|
while (1) {
|
|
590
601
|
switch (_context4.prev = _context4.next) {
|
|
591
602
|
case 0:
|
|
592
603
|
startMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
|
|
593
|
-
// We use origins here as steps can be rebased. When steps are rebased a new step is created.
|
|
604
|
+
count = 0; // We use origins here as steps can be rebased. When steps are rebased a new step is created.
|
|
594
605
|
// This means that we can not track if it has been removed from the unconfirmed array or not.
|
|
595
606
|
// Origins points to the original transaction that the step was created in. This is never changed
|
|
596
607
|
// and gets passed down when a step is rebased.
|
|
597
608
|
unconfirmedTrs = _this.getUnconfirmedStepsOrigins();
|
|
598
609
|
lastTr = unconfirmedTrs === null || unconfirmedTrs === void 0 ? void 0 : unconfirmedTrs[unconfirmedTrs.length - 1];
|
|
599
610
|
isLastTrConfirmed = false;
|
|
600
|
-
case
|
|
611
|
+
case 5:
|
|
601
612
|
if (isLastTrConfirmed) {
|
|
602
|
-
_context4.next =
|
|
613
|
+
_context4.next = 16;
|
|
603
614
|
break;
|
|
604
615
|
}
|
|
605
616
|
_this.sendStepsFromCurrentState();
|
|
606
|
-
_context4.next =
|
|
617
|
+
_context4.next = 9;
|
|
607
618
|
return sleep(1000);
|
|
608
|
-
case
|
|
619
|
+
case 9:
|
|
609
620
|
nextUnconfirmedSteps = _this.getUnconfirmedSteps();
|
|
610
621
|
if (nextUnconfirmedSteps !== null && nextUnconfirmedSteps !== void 0 && nextUnconfirmedSteps.length) {
|
|
611
622
|
nextUnconfirmedTrs = _this.getUnconfirmedStepsOrigins();
|
|
@@ -616,7 +627,7 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
616
627
|
isLastTrConfirmed = true;
|
|
617
628
|
}
|
|
618
629
|
if (!(!isLastTrConfirmed && count++ >= ACK_MAX_TRY)) {
|
|
619
|
-
_context4.next =
|
|
630
|
+
_context4.next = 14;
|
|
620
631
|
break;
|
|
621
632
|
}
|
|
622
633
|
if (_this.onSyncUpError) {
|
|
@@ -629,24 +640,18 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
629
640
|
version: getVersion(state)
|
|
630
641
|
});
|
|
631
642
|
}
|
|
632
|
-
_measure = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
|
|
633
|
-
(_this$analyticsHelper21 = _this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 ? void 0 : _this$analyticsHelper21.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.FAILURE, {
|
|
634
|
-
latency: _measure === null || _measure === void 0 ? void 0 : _measure.duration,
|
|
635
|
-
// upon failure, emit the number of unconfirmed steps we attempted to sync
|
|
636
|
-
numUnconfirmedSteps: nextUnconfirmedSteps === null || nextUnconfirmedSteps === void 0 ? void 0 : nextUnconfirmedSteps.length
|
|
637
|
-
});
|
|
638
643
|
throw new Error("Can't sync up with Collab Service");
|
|
639
|
-
case
|
|
640
|
-
_context4.next =
|
|
644
|
+
case 14:
|
|
645
|
+
_context4.next = 5;
|
|
641
646
|
break;
|
|
642
|
-
case
|
|
647
|
+
case 16:
|
|
643
648
|
measure = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
|
|
644
|
-
(_this$
|
|
649
|
+
(_this$analyticsHelper23 = _this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 ? void 0 : _this$analyticsHelper23.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.SUCCESS, {
|
|
645
650
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
646
651
|
// upon success, emit the total number of unconfirmed steps we synced
|
|
647
652
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
|
|
648
653
|
});
|
|
649
|
-
case
|
|
654
|
+
case 18:
|
|
650
655
|
case "end":
|
|
651
656
|
return _context4.stop();
|
|
652
657
|
}
|
|
@@ -654,53 +659,60 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
654
659
|
}, _callee4);
|
|
655
660
|
})(), "t0", 4);
|
|
656
661
|
case 4:
|
|
662
|
+
_context5.next = 12;
|
|
663
|
+
break;
|
|
664
|
+
case 6:
|
|
665
|
+
_context5.prev = 6;
|
|
666
|
+
_context5.t1 = _context5["catch"](1);
|
|
667
|
+
measure = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
|
|
668
|
+
(_this$analyticsHelper24 = _this.analyticsHelper) === null || _this$analyticsHelper24 === void 0 ? void 0 : _this$analyticsHelper24.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.FAILURE, {
|
|
669
|
+
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
670
|
+
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
|
|
671
|
+
});
|
|
672
|
+
(_this$analyticsHelper25 = _this.analyticsHelper) === null || _this$analyticsHelper25 === void 0 ? void 0 : _this$analyticsHelper25.sendErrorEvent(_context5.t1, 'Error while committing unconfirmed steps');
|
|
673
|
+
throw _context5.t1;
|
|
674
|
+
case 12:
|
|
657
675
|
case "end":
|
|
658
676
|
return _context5.stop();
|
|
659
677
|
}
|
|
660
678
|
}
|
|
661
|
-
}, _callee5);
|
|
679
|
+
}, _callee5, null, [[1, 6]]);
|
|
662
680
|
})));
|
|
663
681
|
_defineProperty(_assertThisInitialized(_this), "getFinalAcknowledgedState", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
664
|
-
var _this$
|
|
682
|
+
var _this$analyticsHelper26, currentState, measure, _this$analyticsHelper27, _this$analyticsHelper28, _measure2;
|
|
665
683
|
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
666
684
|
while (1) {
|
|
667
685
|
switch (_context6.prev = _context6.next) {
|
|
668
686
|
case 0:
|
|
669
|
-
|
|
687
|
+
_context6.prev = 0;
|
|
670
688
|
startMeasure(MEASURE_NAME.PUBLISH_PAGE, _this.analyticsHelper);
|
|
671
|
-
_context6.next =
|
|
689
|
+
_context6.next = 4;
|
|
672
690
|
return _this.commitUnconfirmedSteps();
|
|
673
|
-
case
|
|
674
|
-
_context6.prev = 3;
|
|
691
|
+
case 4:
|
|
675
692
|
_context6.next = 6;
|
|
676
693
|
return _this.getCurrentState();
|
|
677
694
|
case 6:
|
|
678
695
|
currentState = _context6.sent;
|
|
679
696
|
measure = stopMeasure(MEASURE_NAME.PUBLISH_PAGE, _this.analyticsHelper);
|
|
680
|
-
(_this$
|
|
697
|
+
(_this$analyticsHelper26 = _this.analyticsHelper) === null || _this$analyticsHelper26 === void 0 ? void 0 : _this$analyticsHelper26.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.SUCCESS, {
|
|
681
698
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
682
699
|
});
|
|
683
700
|
return _context6.abrupt("return", currentState);
|
|
684
701
|
case 12:
|
|
685
702
|
_context6.prev = 12;
|
|
686
|
-
_context6.t0 = _context6["catch"](
|
|
687
|
-
_measure2 = stopMeasure(MEASURE_NAME.
|
|
688
|
-
(_this$
|
|
703
|
+
_context6.t0 = _context6["catch"](0);
|
|
704
|
+
_measure2 = stopMeasure(MEASURE_NAME.PUBLISH_PAGE, _this.analyticsHelper);
|
|
705
|
+
(_this$analyticsHelper27 = _this.analyticsHelper) === null || _this$analyticsHelper27 === void 0 ? void 0 : _this$analyticsHelper27.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.FAILURE, {
|
|
689
706
|
latency: _measure2 === null || _measure2 === void 0 ? void 0 : _measure2.duration
|
|
690
707
|
});
|
|
691
|
-
(_this$
|
|
692
|
-
|
|
693
|
-
return _context6.abrupt("return", {
|
|
694
|
-
content: undefined,
|
|
695
|
-
title: (_this$metadata$title2 = _this.metadata.title) === null || _this$metadata$title2 === void 0 ? void 0 : _this$metadata$title2.toString(),
|
|
696
|
-
stepVersion: getVersion(_this.getState())
|
|
697
|
-
});
|
|
708
|
+
(_this$analyticsHelper28 = _this.analyticsHelper) === null || _this$analyticsHelper28 === void 0 ? void 0 : _this$analyticsHelper28.sendErrorEvent(_context6.t0, 'Error while returning ADF version of the final draft document');
|
|
709
|
+
throw _context6.t0;
|
|
698
710
|
case 18:
|
|
699
711
|
case "end":
|
|
700
712
|
return _context6.stop();
|
|
701
713
|
}
|
|
702
714
|
}
|
|
703
|
-
}, _callee6, null, [[
|
|
715
|
+
}, _callee6, null, [[0, 12]]);
|
|
704
716
|
})));
|
|
705
717
|
_defineProperty(_assertThisInitialized(_this), "onNamespaceStatusChanged", /*#__PURE__*/function () {
|
|
706
718
|
var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(data) {
|
|
@@ -780,8 +792,8 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
780
792
|
this.isChannelInitialized = true;
|
|
781
793
|
}
|
|
782
794
|
} catch (initError) {
|
|
783
|
-
var _this$
|
|
784
|
-
(_this$
|
|
795
|
+
var _this$analyticsHelper29;
|
|
796
|
+
(_this$analyticsHelper29 = this.analyticsHelper) === null || _this$analyticsHelper29 === void 0 ? void 0 : _this$analyticsHelper29.sendErrorEvent(initError, 'Error while initialising the provider');
|
|
785
797
|
// Throw error so consumers are aware the initialisation failed when initialising themselves
|
|
786
798
|
throw initError;
|
|
787
799
|
}
|
|
@@ -904,9 +916,9 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
904
916
|
}, 100);
|
|
905
917
|
}
|
|
906
918
|
} catch (error) {
|
|
907
|
-
var _this$
|
|
919
|
+
var _this$analyticsHelper30;
|
|
908
920
|
logger("Processing steps failed with error: ".concat(error, ". Triggering catch up call."));
|
|
909
|
-
(_this$
|
|
921
|
+
(_this$analyticsHelper30 = this.analyticsHelper) === null || _this$analyticsHelper30 === void 0 ? void 0 : _this$analyticsHelper30.sendErrorEvent(error, 'Error while processing steps');
|
|
910
922
|
this.throttledCatchup();
|
|
911
923
|
}
|
|
912
924
|
}
|
|
@@ -929,9 +941,9 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
929
941
|
var callback = telepointerCallback(this.config.documentAri);
|
|
930
942
|
this.channel.broadcast('participant:telepointer', payload, callback);
|
|
931
943
|
} catch (error) {
|
|
932
|
-
var _this$
|
|
944
|
+
var _this$analyticsHelper31;
|
|
933
945
|
// We don't want to throw errors for Presence features as they tend to self-restore
|
|
934
|
-
(_this$
|
|
946
|
+
(_this$analyticsHelper31 = this.analyticsHelper) === null || _this$analyticsHelper31 === void 0 ? void 0 : _this$analyticsHelper31.sendErrorEvent(error, 'Error while sending message - telepointer');
|
|
935
947
|
}
|
|
936
948
|
}
|
|
937
949
|
}
|
|
@@ -947,11 +959,13 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
947
959
|
}
|
|
948
960
|
});
|
|
949
961
|
} catch (error) {
|
|
950
|
-
var _this$
|
|
962
|
+
var _this$analyticsHelper32;
|
|
951
963
|
// We don't want to throw errors for Presence features as they tend to self-restore
|
|
952
|
-
(_this$
|
|
964
|
+
(_this$analyticsHelper32 = this.analyticsHelper) === null || _this$analyticsHelper32 === void 0 ? void 0 : _this$analyticsHelper32.sendErrorEvent(error, 'Error while emitting telepointers from steps');
|
|
953
965
|
}
|
|
954
966
|
}
|
|
967
|
+
|
|
968
|
+
// Note: this gets triggered on page reload for Firefox (not other browsers) because of closeOnBeforeunload: false
|
|
955
969
|
}, {
|
|
956
970
|
key: "destroy",
|
|
957
971
|
value: function destroy() {
|
package/dist/esm/version.json
CHANGED
|
@@ -3,7 +3,8 @@ export declare enum MEASURE_NAME {
|
|
|
3
3
|
SOCKET_CONNECT = "socketConnect",
|
|
4
4
|
DOCUMENT_INIT = "documentInit",
|
|
5
5
|
COMMIT_UNCONFIRMED_STEPS = "commitUnconfirmedSteps",
|
|
6
|
-
PUBLISH_PAGE = "publishPage"
|
|
6
|
+
PUBLISH_PAGE = "publishPage",
|
|
7
|
+
GET_CURRENT_STATE = "getCurrentState"
|
|
7
8
|
}
|
|
8
9
|
export declare function startMeasure(measureName: MEASURE_NAME, analyticsHelper: AnalyticsHelper | undefined): void;
|
|
9
10
|
export declare function stopMeasure(measureName: MEASURE_NAME, analyticsHelper: AnalyticsHelper | undefined, onMeasureComplete?: (duration: number, startTime: number) => void): {
|
package/dist/types/channel.d.ts
CHANGED
|
@@ -10,15 +10,20 @@ export declare class Channel extends Emitter<ChannelEvent> {
|
|
|
10
10
|
private initialized;
|
|
11
11
|
private analyticsHelper?;
|
|
12
12
|
private initExperience?;
|
|
13
|
+
private token?;
|
|
13
14
|
private network;
|
|
14
15
|
constructor(config: Config, analyticsHelper: AnalyticsHelper);
|
|
15
16
|
getInitialized: () => boolean;
|
|
16
17
|
getConnected: () => boolean;
|
|
17
18
|
getSocket: () => Socket<import("@socket.io/component-emitter").DefaultEventsMap, import("@socket.io/component-emitter").DefaultEventsMap> | null;
|
|
19
|
+
getToken: () => string | undefined;
|
|
20
|
+
private setToken;
|
|
21
|
+
private unsetToken;
|
|
18
22
|
/**
|
|
19
23
|
* Connect to collab service using websockets
|
|
20
24
|
*/
|
|
21
25
|
connect(): void;
|
|
26
|
+
private handlePermissionInvalidateToken;
|
|
22
27
|
private onConnectError;
|
|
23
28
|
private onReconnectError;
|
|
24
29
|
private onConnect;
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import type { CollabErrorPayload } from '../types';
|
|
2
2
|
export declare enum EVENT_ACTION {
|
|
3
3
|
CONNECTION = "connection",
|
|
4
|
-
RECONNECTION = "reconnection",
|
|
5
4
|
CATCHUP = "catchup",
|
|
6
5
|
DOCUMENT_INIT = "documentInit",
|
|
7
6
|
ADD_STEPS = "addSteps",
|
|
8
7
|
UPDATE_PARTICIPANTS = "updateParticipants",
|
|
9
8
|
COMMIT_UNCONFIRMED_STEPS = "commitUnconfirmedSteps",
|
|
10
9
|
REINITIALISE_DOCUMENT = "reinitialiseDocument",
|
|
11
|
-
INIT_PROVIDER = "initProvider",
|
|
12
10
|
ERROR = "error",
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
PUBLISH_PAGE = "publishPage",
|
|
12
|
+
GET_CURRENT_STATE = "getCurrentState",
|
|
13
|
+
INVALIDATE_TOKEN = "invalidateToken"
|
|
16
14
|
}
|
|
17
15
|
export declare enum EVENT_STATUS {
|
|
18
16
|
SUCCESS = "SUCCESS",
|
|
@@ -27,6 +25,7 @@ export declare type ErrorAnalyticsEvent = {
|
|
|
27
25
|
eventAction: EVENT_ACTION.ERROR;
|
|
28
26
|
attributes: {
|
|
29
27
|
errorMessage: string;
|
|
28
|
+
errorName?: string;
|
|
30
29
|
documentAri?: string;
|
|
31
30
|
mappedError?: CollabErrorPayload;
|
|
32
31
|
};
|
|
@@ -34,6 +33,14 @@ export declare type ErrorAnalyticsEvent = {
|
|
|
34
33
|
error: unknown;
|
|
35
34
|
};
|
|
36
35
|
};
|
|
36
|
+
declare type InvalidateTokenAnalyticsEvent = {
|
|
37
|
+
eventAction: EVENT_ACTION.INVALIDATE_TOKEN;
|
|
38
|
+
attributes: {
|
|
39
|
+
eventStatus: EVENT_STATUS.SUCCESS;
|
|
40
|
+
reason?: string;
|
|
41
|
+
usedCachedToken?: boolean;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
37
44
|
declare type AddStepsSuccessAnalyticsEvent = {
|
|
38
45
|
eventAction: EVENT_ACTION.ADD_STEPS;
|
|
39
46
|
attributes: {
|
|
@@ -155,7 +162,23 @@ declare type PublishPageFailureAnalyticsEvent = {
|
|
|
155
162
|
latency?: number;
|
|
156
163
|
};
|
|
157
164
|
};
|
|
158
|
-
|
|
165
|
+
declare type GetCurrentStateSuccessAnalyticsEvent = {
|
|
166
|
+
eventAction: EVENT_ACTION.GET_CURRENT_STATE;
|
|
167
|
+
attributes: {
|
|
168
|
+
documentAri: string;
|
|
169
|
+
eventStatus: EVENT_STATUS.SUCCESS;
|
|
170
|
+
latency?: number;
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
declare type GetCurrentStateFailureAnalyticsEvent = {
|
|
174
|
+
eventAction: EVENT_ACTION.GET_CURRENT_STATE;
|
|
175
|
+
attributes: {
|
|
176
|
+
documentAri: string;
|
|
177
|
+
eventStatus: EVENT_STATUS.FAILURE;
|
|
178
|
+
latency?: number;
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
export declare type ActionAnalyticsEvent = AddStepsSuccessAnalyticsEvent | AddStepsFailureAnalyticsEvent | ReInitDocFailAnalyticsEvent | ReInitDocSuccessAnalyticsEvent | ConnectionSuccessAnalyticsEvent | ConnectionFailureAnalyticsEvent | CatchUpSuccessAnalyticsEvent | CatchUpFailureAnalyticsEvent | DocumentInitSuccessAnalyticsEvent | UpdateParticipantsSuccessAnalyticsEvent | CommitUnconfirmedStepsSuccessAnalyticsEvent | CommitUnconfirmedStepsFailureAnalyticsEvent | PublishPageSuccessAnalyticsEvent | PublishPageFailureAnalyticsEvent | GetCurrentStateSuccessAnalyticsEvent | GetCurrentStateFailureAnalyticsEvent | InvalidateTokenAnalyticsEvent;
|
|
159
182
|
export declare const ACK_MAX_TRY = 30;
|
|
160
183
|
export declare const CONFLUENCE = "confluence";
|
|
161
184
|
export {};
|
|
@@ -1,9 +1,23 @@
|
|
|
1
|
+
/// <reference types="lodash" />
|
|
1
2
|
import type { EditorState, Transaction } from 'prosemirror-state';
|
|
3
|
+
import type { Step as ProseMirrorStep } from 'prosemirror-transform';
|
|
2
4
|
import { Emitter } from '../emitter';
|
|
5
|
+
import { Channel } from '../channel';
|
|
3
6
|
import type { CollabEditProvider, CollabParticipant, ResolvedEditorState } from '@atlaskit/editor-common/collab';
|
|
4
|
-
import type { CollabEvents, Config, Metadata } from '../types';
|
|
7
|
+
import type { CollabEvents, Config, ErrorPayload, Metadata, StepsPayload } from '../types';
|
|
8
|
+
import AnalyticsHelper from '../analytics';
|
|
5
9
|
import type { SyncUpErrorFunction } from '@atlaskit/editor-common/types';
|
|
6
10
|
export declare const MAX_STEP_REJECTED_ERROR = 15;
|
|
11
|
+
export declare const throttledCommitStep: import("lodash").DebouncedFunc<({ channel, steps, version, userId, clientId, onStepsAdded, onErrorHandled, analyticsHelper, }: {
|
|
12
|
+
channel: Channel;
|
|
13
|
+
steps: readonly ProseMirrorStep<any>[];
|
|
14
|
+
version: number;
|
|
15
|
+
userId: string;
|
|
16
|
+
clientId: string | number;
|
|
17
|
+
onStepsAdded: (data: StepsPayload) => void;
|
|
18
|
+
onErrorHandled: (error: ErrorPayload) => void;
|
|
19
|
+
analyticsHelper?: AnalyticsHelper | undefined;
|
|
20
|
+
}) => void>;
|
|
7
21
|
declare type BaseEvents = Pick<CollabEditProvider<CollabEvents>, 'setup' | 'send' | 'sendMessage'>;
|
|
8
22
|
export declare type ParticipantsMap = Map<string, CollabParticipant & {
|
|
9
23
|
userId: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Provider } from './provider';
|
|
2
2
|
import { Socket } from 'socket.io-client';
|
|
3
|
-
import { Config, ProductInformation } from './types';
|
|
4
|
-
export declare function createSocketIOSocket(url: string, auth?:
|
|
3
|
+
import { Config, ProductInformation, InitAndAuthData, AuthCallback } from './types';
|
|
4
|
+
export declare function createSocketIOSocket(url: string, auth?: AuthCallback | InitAndAuthData, productInfo?: ProductInformation): Socket;
|
|
5
5
|
export declare function createSocketIOCollabProvider(config: Omit<Config, 'createSocket'>): Provider;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export interface Config {
|
|
|
15
15
|
lifecycle?: Lifecycle;
|
|
16
16
|
storage?: Storage;
|
|
17
17
|
need404?: boolean;
|
|
18
|
-
createSocket: (path: string, auth?:
|
|
18
|
+
createSocket: (path: string, auth?: AuthCallback | InitAndAuthData, productInfo?: ProductInformation) => Socket;
|
|
19
19
|
analyticsClient?: AnalyticsWebClient;
|
|
20
20
|
featureFlags?: {
|
|
21
21
|
[key: string]: boolean;
|
|
@@ -23,9 +23,24 @@ export interface Config {
|
|
|
23
23
|
getUser?(userId: string): Promise<Pick<CollabParticipant, 'avatar' | 'email' | 'name'> & {
|
|
24
24
|
userId: string;
|
|
25
25
|
}>;
|
|
26
|
+
/**
|
|
27
|
+
* If provided, permissionTokenRefresh is called whenever a new JWT token is required.
|
|
28
|
+
*/
|
|
26
29
|
permissionTokenRefresh?: () => Promise<string | null>;
|
|
30
|
+
cacheToken?: boolean;
|
|
27
31
|
productInfo?: ProductInformation;
|
|
32
|
+
/**
|
|
33
|
+
* Throws errors when trying to send data to collab but the client is not offline.
|
|
34
|
+
* This can lead to potential dataloss and retrying should be considered. Without this flag the provider silently drops the requests.
|
|
35
|
+
*/
|
|
36
|
+
throwOnNotConnected?: boolean;
|
|
28
37
|
}
|
|
38
|
+
export interface InitAndAuthData {
|
|
39
|
+
initialized: boolean;
|
|
40
|
+
need404?: boolean;
|
|
41
|
+
token?: string;
|
|
42
|
+
}
|
|
43
|
+
export declare type AuthCallback = (cb: (data: InitAndAuthData) => void) => void;
|
|
29
44
|
interface SimpleEventEmitter {
|
|
30
45
|
on(event: string, fn: Function): SimpleEventEmitter;
|
|
31
46
|
}
|
|
@@ -127,14 +142,14 @@ declare type SliceJson = {
|
|
|
127
142
|
openEnd: number;
|
|
128
143
|
};
|
|
129
144
|
export declare type StepJson = {
|
|
145
|
+
stepType?: string;
|
|
130
146
|
from?: number;
|
|
131
147
|
to?: number;
|
|
132
|
-
|
|
148
|
+
slice?: SliceJson;
|
|
133
149
|
clientId: number | string;
|
|
134
150
|
userId: string;
|
|
135
151
|
createdAt?: number;
|
|
136
152
|
structure?: boolean;
|
|
137
|
-
slice?: SliceJson;
|
|
138
153
|
};
|
|
139
154
|
export declare enum AcknowledgementResponseTypes {
|
|
140
155
|
SUCCESS = "SUCCESS",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/collab-provider",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.4.0",
|
|
4
4
|
"description": "A provider for collaborative editing.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@atlaskit/analytics-gas-types": "^5.0.10",
|
|
25
25
|
"@atlaskit/analytics-listeners": "^8.5.0",
|
|
26
|
-
"@atlaskit/editor-common": "^72.
|
|
26
|
+
"@atlaskit/editor-common": "^72.6.0",
|
|
27
27
|
"@atlaskit/editor-json-transformer": "^8.8.0",
|
|
28
28
|
"@atlaskit/prosemirror-collab": "^0.1.0",
|
|
29
29
|
"@atlaskit/ufo": "^0.1.4",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@atlaskit/adf-schema": "^25.3.0",
|
|
53
53
|
"@atlaskit/analytics-listeners": "^8.5.0",
|
|
54
|
-
"@atlaskit/editor-test-helpers": "^18.
|
|
54
|
+
"@atlaskit/editor-test-helpers": "^18.1.0",
|
|
55
55
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
56
56
|
"@types/prosemirror-model": "^1.11.0",
|
|
57
57
|
"@types/prosemirror-state": "^1.2.0",
|