@atlaskit/collab-provider 8.3.0 → 8.5.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 +50 -0
- package/dist/cjs/analytics/{index.js → analytics-helper.js} +45 -5
- package/dist/cjs/analytics/performance.js +7 -5
- package/dist/cjs/channel.js +318 -210
- package/dist/cjs/{provider → document}/catchup.js +2 -2
- package/dist/cjs/document/document-service.js +617 -0
- package/dist/cjs/document/step-queue-state.js +51 -0
- package/dist/cjs/errors/error-code-mapper.js +107 -0
- package/dist/cjs/errors/error-types.js +273 -0
- package/dist/cjs/helpers/const.js +2 -4
- package/dist/cjs/helpers/utils.js +1 -12
- package/dist/cjs/participants/participants-helper.js +51 -0
- package/dist/cjs/participants/participants-service.js +217 -0
- package/dist/cjs/participants/participants-state.js +53 -0
- package/dist/cjs/{provider/telepointers.js → participants/telepointers-helper.js} +6 -6
- package/dist/cjs/provider/commit-step.js +40 -36
- package/dist/cjs/provider/index.js +215 -762
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/analytics/{index.js → analytics-helper.js} +17 -5
- package/dist/es2019/analytics/performance.js +6 -6
- package/dist/es2019/channel.js +204 -129
- package/dist/es2019/{provider → document}/catchup.js +2 -2
- package/dist/es2019/document/document-service.js +495 -0
- package/dist/es2019/document/step-queue-state.js +30 -0
- package/dist/es2019/errors/error-code-mapper.js +102 -0
- package/dist/es2019/errors/error-types.js +151 -0
- package/dist/es2019/helpers/const.js +2 -4
- package/dist/es2019/helpers/utils.js +0 -10
- package/dist/es2019/participants/participants-helper.js +25 -0
- package/dist/es2019/participants/participants-service.js +166 -0
- package/dist/es2019/participants/participants-state.js +28 -0
- package/dist/es2019/{provider/telepointers.js → participants/telepointers-helper.js} +2 -2
- package/dist/es2019/provider/commit-step.js +38 -34
- package/dist/es2019/provider/index.js +163 -626
- package/dist/es2019/types.js +4 -0
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/analytics/{index.js → analytics-helper.js} +45 -5
- package/dist/esm/analytics/performance.js +6 -6
- package/dist/esm/channel.js +318 -210
- package/dist/esm/{provider → document}/catchup.js +2 -2
- package/dist/esm/document/document-service.js +609 -0
- package/dist/esm/document/step-queue-state.js +43 -0
- package/dist/esm/errors/error-code-mapper.js +102 -0
- package/dist/esm/errors/error-types.js +259 -0
- package/dist/esm/helpers/const.js +2 -4
- package/dist/esm/helpers/utils.js +0 -10
- package/dist/esm/participants/participants-helper.js +43 -0
- package/dist/esm/participants/participants-service.js +209 -0
- package/dist/esm/participants/participants-state.js +45 -0
- package/dist/esm/{provider/telepointers.js → participants/telepointers-helper.js} +4 -4
- package/dist/esm/provider/commit-step.js +40 -36
- package/dist/esm/provider/index.js +214 -762
- package/dist/esm/types.js +4 -0
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/analytics/{index.d.ts → analytics-helper.d.ts} +3 -1
- package/dist/types/analytics/performance.d.ts +5 -2
- package/dist/types/analytics/ufo.d.ts +1 -1
- package/dist/types/channel.d.ts +17 -5
- package/dist/types/document/document-service.d.ts +105 -0
- package/dist/types/document/step-queue-state.d.ts +16 -0
- package/dist/types/errors/error-code-mapper.d.ts +2 -0
- package/dist/types/errors/error-types.d.ts +443 -0
- package/dist/types/helpers/const.d.ts +31 -8
- package/dist/types/helpers/utils.d.ts +0 -6
- package/dist/types/index.d.ts +2 -1
- package/dist/types/participants/participants-helper.d.ts +15 -0
- package/dist/types/participants/participants-service.d.ts +70 -0
- package/dist/types/participants/participants-state.d.ts +13 -0
- package/dist/types/participants/telepointers-helper.d.ts +4 -0
- package/dist/types/provider/commit-step.d.ts +6 -6
- package/dist/types/provider/index.d.ts +86 -65
- package/dist/types/socket-io-provider.d.ts +2 -2
- package/dist/types/types.d.ts +65 -33
- package/package.json +4 -4
- package/report.api.md +193 -23
- package/dist/cjs/error-code-mapper.js +0 -88
- package/dist/es2019/error-code-mapper.js +0 -78
- package/dist/esm/error-code-mapper.js +0 -79
- package/dist/types/error-code-mapper.d.ts +0 -36
- package/dist/types/provider/telepointers.d.ts +0 -5
- package/error-code-mapper/package.json +0 -15
- /package/dist/types/{provider → document}/catchup.d.ts +0 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
5
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
|
+
export var ParticipantsState = /*#__PURE__*/_createClass(function ParticipantsState() {
|
|
8
|
+
var _this = this;
|
|
9
|
+
var baseParticipants = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Map();
|
|
10
|
+
_classCallCheck(this, ParticipantsState);
|
|
11
|
+
_defineProperty(this, "getBySessionId", function (sessionId) {
|
|
12
|
+
var participant = _this.participants.get(sessionId);
|
|
13
|
+
// Spread to ensure we get a deep copy
|
|
14
|
+
return participant ? _objectSpread({}, participant) : undefined;
|
|
15
|
+
});
|
|
16
|
+
_defineProperty(this, "setBySessionId", function (sessionId, participant) {
|
|
17
|
+
_this.participants.set(sessionId, participant);
|
|
18
|
+
});
|
|
19
|
+
_defineProperty(this, "getParticipants", function () {
|
|
20
|
+
return (
|
|
21
|
+
// Spread to get deep copy
|
|
22
|
+
_toConsumableArray(_this.participants.values()).map(function (p) {
|
|
23
|
+
return _objectSpread({}, p);
|
|
24
|
+
})
|
|
25
|
+
);
|
|
26
|
+
});
|
|
27
|
+
_defineProperty(this, "removeBySessionId", function (sessionId) {
|
|
28
|
+
return _this.participants.delete(sessionId);
|
|
29
|
+
});
|
|
30
|
+
_defineProperty(this, "clear", function () {
|
|
31
|
+
return _this.participants.clear();
|
|
32
|
+
});
|
|
33
|
+
_defineProperty(this, "doesntHave", function (sessionId) {
|
|
34
|
+
return !_this.participants.has(sessionId);
|
|
35
|
+
});
|
|
36
|
+
_defineProperty(this, "size", function () {
|
|
37
|
+
return _this.participants.size;
|
|
38
|
+
});
|
|
39
|
+
_defineProperty(this, "updateLastActive", function (now, userIds) {
|
|
40
|
+
return _this.participants.forEach(function (p) {
|
|
41
|
+
p.lastActive = userIds.includes(p.userId) ? now : p.lastActive;
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
this.participants = baseParticipants;
|
|
45
|
+
});
|
|
@@ -4,12 +4,12 @@ import { createLogger } from '../helpers/utils';
|
|
|
4
4
|
import { ExperiencePerformanceTypes, ExperienceTypes, UFOExperience } from '@atlaskit/ufo';
|
|
5
5
|
import { AcknowledgementResponseTypes } from '../types';
|
|
6
6
|
var logger = createLogger('Telepointer', 'green');
|
|
7
|
-
export var
|
|
8
|
-
var
|
|
7
|
+
export var telepointerFromStep = function telepointerFromStep(participants, step) {
|
|
8
|
+
var _participants$filter = participants.filter(function (p) {
|
|
9
9
|
return p.clientId === step.clientId;
|
|
10
10
|
}),
|
|
11
|
-
|
|
12
|
-
participant =
|
|
11
|
+
_participants$filter2 = _slicedToArray(_participants$filter, 1),
|
|
12
|
+
participant = _participants$filter2[0];
|
|
13
13
|
if (participant) {
|
|
14
14
|
var _node$text;
|
|
15
15
|
var stepType = step.stepType,
|
|
@@ -4,8 +4,9 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
4
4
|
import countBy from 'lodash/countBy';
|
|
5
5
|
import { ADD_STEPS_TYPE, EVENT_ACTION, EVENT_STATUS } from '../helpers/const';
|
|
6
6
|
import { AcknowledgementResponseTypes } from '../types';
|
|
7
|
+
import { NCS_ERROR_CODE } from '../errors/error-types';
|
|
7
8
|
export var commitStep = function commitStep(_ref) {
|
|
8
|
-
var
|
|
9
|
+
var broadcast = _ref.broadcast,
|
|
9
10
|
steps = _ref.steps,
|
|
10
11
|
version = _ref.version,
|
|
11
12
|
userId = _ref.userId,
|
|
@@ -20,39 +21,42 @@ export var commitStep = function commitStep(_ref) {
|
|
|
20
21
|
});
|
|
21
22
|
});
|
|
22
23
|
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
|
-
|
|
24
|
+
try {
|
|
25
|
+
broadcast('steps:commit', {
|
|
26
|
+
steps: stepsWithClientAndUserId,
|
|
27
|
+
version: version,
|
|
28
|
+
userId: userId
|
|
29
|
+
}, function (response) {
|
|
30
|
+
var latency = new Date().getTime() - start;
|
|
31
|
+
if (response.type === AcknowledgementResponseTypes.SUCCESS) {
|
|
32
|
+
onStepsAdded({
|
|
33
|
+
steps: stepsWithClientAndUserId,
|
|
34
|
+
version: response.version
|
|
35
|
+
});
|
|
36
|
+
analyticsHelper === null || analyticsHelper === void 0 ? void 0 : analyticsHelper.sendActionEvent(EVENT_ACTION.ADD_STEPS, EVENT_STATUS.SUCCESS, {
|
|
37
|
+
type: ADD_STEPS_TYPE.ACCEPTED,
|
|
38
|
+
latency: latency,
|
|
39
|
+
stepType: countBy(stepsWithClientAndUserId, function (stepWithClientAndUserId) {
|
|
40
|
+
return stepWithClientAndUserId.stepType;
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
} else if (response.type === AcknowledgementResponseTypes.ERROR) {
|
|
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.data.code === NCS_ERROR_CODE.HEAD_VERSION_UPDATE_FAILED || response.error.data.code === NCS_ERROR_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
|
};
|