@webex/plugin-meetings 3.12.0-next.9 → 3.12.0-task-refactor.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/annotation/index.js +5 -14
- package/dist/annotation/index.js.map +1 -1
- package/dist/breakouts/breakout.js +1 -1
- package/dist/breakouts/index.js +1 -1
- package/dist/config.js +2 -8
- package/dist/config.js.map +1 -1
- package/dist/constants.js +6 -29
- package/dist/constants.js.map +1 -1
- package/dist/hashTree/hashTreeParser.js +29 -1563
- package/dist/hashTree/hashTreeParser.js.map +1 -1
- package/dist/hashTree/types.js +3 -13
- package/dist/hashTree/types.js.map +1 -1
- package/dist/index.js +2 -11
- package/dist/index.js.map +1 -1
- package/dist/interceptors/index.js +0 -7
- package/dist/interceptors/index.js.map +1 -1
- package/dist/interceptors/locusRouteToken.js +5 -27
- package/dist/interceptors/locusRouteToken.js.map +1 -1
- package/dist/interpretation/index.js +2 -2
- package/dist/interpretation/index.js.map +1 -1
- package/dist/interpretation/siLanguage.js +1 -1
- package/dist/locus-info/controlsUtils.js +3 -7
- package/dist/locus-info/controlsUtils.js.map +1 -1
- package/dist/locus-info/index.js +247 -642
- package/dist/locus-info/index.js.map +1 -1
- package/dist/locus-info/selfUtils.js +0 -1
- package/dist/locus-info/selfUtils.js.map +1 -1
- package/dist/locus-info/types.js.map +1 -1
- package/dist/media/MediaConnectionAwaiter.js +1 -57
- package/dist/media/MediaConnectionAwaiter.js.map +1 -1
- package/dist/media/properties.js +2 -4
- package/dist/media/properties.js.map +1 -1
- package/dist/meeting/in-meeting-actions.js +1 -7
- package/dist/meeting/in-meeting-actions.js.map +1 -1
- package/dist/meeting/index.js +1036 -1481
- package/dist/meeting/index.js.map +1 -1
- package/dist/meeting/request.js +0 -50
- package/dist/meeting/request.js.map +1 -1
- package/dist/meeting/request.type.js.map +1 -1
- package/dist/meeting/util.js +3 -133
- package/dist/meeting/util.js.map +1 -1
- package/dist/meetings/index.js +59 -142
- package/dist/meetings/index.js.map +1 -1
- package/dist/meetings/util.js +7 -11
- package/dist/meetings/util.js.map +1 -1
- package/dist/member/index.js +0 -10
- package/dist/member/index.js.map +1 -1
- package/dist/member/util.js +0 -10
- package/dist/member/util.js.map +1 -1
- package/dist/metrics/constants.js +1 -7
- package/dist/metrics/constants.js.map +1 -1
- package/dist/multistream/mediaRequestManager.js +60 -9
- package/dist/multistream/mediaRequestManager.js.map +1 -1
- package/dist/multistream/remoteMediaManager.js +0 -11
- package/dist/multistream/remoteMediaManager.js.map +1 -1
- package/dist/multistream/sendSlotManager.js +2 -116
- package/dist/multistream/sendSlotManager.js.map +1 -1
- package/dist/reachability/clusterReachability.js +18 -171
- package/dist/reachability/clusterReachability.js.map +1 -1
- package/dist/reachability/index.js +11 -21
- package/dist/reachability/index.js.map +1 -1
- package/dist/reachability/reachabilityPeerConnection.js +1 -1
- package/dist/reachability/reachabilityPeerConnection.js.map +1 -1
- package/dist/reactions/reactions.type.js.map +1 -1
- package/dist/reconnection-manager/index.js +1 -0
- package/dist/reconnection-manager/index.js.map +1 -1
- package/dist/types/common/browser-detection.d.ts +0 -1
- package/dist/types/common/events/events-scope.d.ts +0 -1
- package/dist/types/common/events/events.d.ts +0 -1
- package/dist/types/config.d.ts +0 -5
- package/dist/types/constants.d.ts +1 -24
- package/dist/types/hashTree/hashTreeParser.d.ts +11 -260
- package/dist/types/hashTree/types.d.ts +0 -20
- package/dist/types/index.d.ts +0 -1
- package/dist/types/interceptors/index.d.ts +1 -2
- package/dist/types/interceptors/locusRouteToken.d.ts +0 -2
- package/dist/types/locus-info/index.d.ts +47 -68
- package/dist/types/locus-info/types.d.ts +12 -28
- package/dist/types/media/MediaConnectionAwaiter.d.ts +1 -10
- package/dist/types/media/properties.d.ts +1 -2
- package/dist/types/meeting/in-meeting-actions.d.ts +0 -6
- package/dist/types/meeting/index.d.ts +7 -86
- package/dist/types/meeting/request.d.ts +1 -16
- package/dist/types/meeting/request.type.d.ts +0 -5
- package/dist/types/meeting/util.d.ts +0 -31
- package/dist/types/meeting-info/util.d.ts +0 -1
- package/dist/types/meeting-info/utilv2.d.ts +0 -1
- package/dist/types/meetings/index.d.ts +2 -4
- package/dist/types/member/index.d.ts +0 -1
- package/dist/types/member/types.d.ts +4 -4
- package/dist/types/member/util.d.ts +0 -5
- package/dist/types/metrics/constants.d.ts +0 -6
- package/dist/types/multistream/mediaRequestManager.d.ts +23 -0
- package/dist/types/multistream/sendSlotManager.d.ts +1 -23
- package/dist/types/reachability/clusterReachability.d.ts +3 -30
- package/dist/types/reactions/reactions.type.d.ts +0 -1
- package/dist/types/recording-controller/util.d.ts +5 -5
- package/dist/types/roap/index.d.ts +1 -1
- package/dist/webinar/index.js +163 -438
- package/dist/webinar/index.js.map +1 -1
- package/package.json +24 -26
- package/src/annotation/index.ts +7 -27
- package/src/config.ts +0 -5
- package/src/constants.ts +1 -30
- package/src/hashTree/hashTreeParser.ts +25 -1523
- package/src/hashTree/types.ts +1 -24
- package/src/index.ts +1 -8
- package/src/interceptors/index.ts +1 -2
- package/src/interceptors/locusRouteToken.ts +5 -22
- package/src/interpretation/index.ts +2 -2
- package/src/locus-info/controlsUtils.ts +0 -17
- package/src/locus-info/index.ts +213 -707
- package/src/locus-info/selfUtils.ts +0 -1
- package/src/locus-info/types.ts +12 -27
- package/src/media/MediaConnectionAwaiter.ts +1 -41
- package/src/media/properties.ts +1 -3
- package/src/meeting/in-meeting-actions.ts +0 -12
- package/src/meeting/index.ts +84 -461
- package/src/meeting/request.ts +0 -42
- package/src/meeting/request.type.ts +0 -6
- package/src/meeting/util.ts +2 -160
- package/src/meetings/index.ts +60 -180
- package/src/meetings/util.ts +9 -10
- package/src/member/index.ts +0 -10
- package/src/member/util.ts +0 -12
- package/src/metrics/constants.ts +0 -7
- package/src/multistream/mediaRequestManager.ts +54 -4
- package/src/multistream/remoteMediaManager.ts +0 -13
- package/src/multistream/sendSlotManager.ts +3 -97
- package/src/reachability/clusterReachability.ts +27 -153
- package/src/reachability/index.ts +1 -15
- package/src/reachability/reachabilityPeerConnection.ts +1 -3
- package/src/reactions/reactions.type.ts +0 -1
- package/src/reconnection-manager/index.ts +1 -0
- package/src/webinar/index.ts +6 -265
- package/test/unit/spec/annotation/index.ts +7 -69
- package/test/unit/spec/interceptors/locusRouteToken.ts +0 -44
- package/test/unit/spec/locus-info/controlsUtils.js +1 -56
- package/test/unit/spec/locus-info/index.js +90 -1457
- package/test/unit/spec/media/MediaConnectionAwaiter.ts +1 -41
- package/test/unit/spec/media/properties.ts +3 -12
- package/test/unit/spec/meeting/in-meeting-actions.ts +2 -8
- package/test/unit/spec/meeting/index.js +128 -981
- package/test/unit/spec/meeting/request.js +0 -70
- package/test/unit/spec/meeting/utils.js +26 -438
- package/test/unit/spec/meetings/index.js +33 -845
- package/test/unit/spec/meetings/utils.js +1 -51
- package/test/unit/spec/member/index.js +4 -28
- package/test/unit/spec/member/util.js +27 -65
- package/test/unit/spec/multistream/mediaRequestManager.ts +85 -2
- package/test/unit/spec/multistream/remoteMediaManager.ts +0 -30
- package/test/unit/spec/multistream/sendSlotManager.ts +36 -135
- package/test/unit/spec/reachability/clusterReachability.ts +1 -125
- package/test/unit/spec/reachability/index.ts +3 -26
- package/test/unit/spec/reconnection-manager/index.js +8 -4
- package/test/unit/spec/webinar/index.ts +37 -534
- package/dist/aiEnableRequest/index.js +0 -184
- package/dist/aiEnableRequest/index.js.map +0 -1
- package/dist/aiEnableRequest/utils.js +0 -36
- package/dist/aiEnableRequest/utils.js.map +0 -1
- package/dist/hashTree/constants.js +0 -22
- package/dist/hashTree/constants.js.map +0 -1
- package/dist/hashTree/hashTree.js +0 -533
- package/dist/hashTree/hashTree.js.map +0 -1
- package/dist/hashTree/utils.js +0 -69
- package/dist/hashTree/utils.js.map +0 -1
- package/dist/interceptors/constant.js +0 -12
- package/dist/interceptors/constant.js.map +0 -1
- package/dist/interceptors/dataChannelAuthToken.js +0 -290
- package/dist/interceptors/dataChannelAuthToken.js.map +0 -1
- package/dist/interceptors/utils.js +0 -27
- package/dist/interceptors/utils.js.map +0 -1
- package/dist/types/aiEnableRequest/index.d.ts +0 -5
- package/dist/types/aiEnableRequest/utils.d.ts +0 -2
- package/dist/types/hashTree/constants.d.ts +0 -9
- package/dist/types/hashTree/hashTree.d.ts +0 -136
- package/dist/types/hashTree/utils.d.ts +0 -22
- package/dist/types/interceptors/constant.d.ts +0 -5
- package/dist/types/interceptors/dataChannelAuthToken.d.ts +0 -43
- package/dist/types/interceptors/utils.d.ts +0 -1
- package/dist/types/webinar/utils.d.ts +0 -6
- package/dist/webinar/utils.js +0 -25
- package/dist/webinar/utils.js.map +0 -1
- package/src/aiEnableRequest/README.md +0 -84
- package/src/aiEnableRequest/index.ts +0 -170
- package/src/aiEnableRequest/utils.ts +0 -25
- package/src/hashTree/constants.ts +0 -10
- package/src/hashTree/hashTree.ts +0 -480
- package/src/hashTree/utils.ts +0 -62
- package/src/interceptors/constant.ts +0 -6
- package/src/interceptors/dataChannelAuthToken.ts +0 -170
- package/src/interceptors/utils.ts +0 -16
- package/src/webinar/utils.ts +0 -16
- package/test/unit/spec/aiEnableRequest/index.ts +0 -981
- package/test/unit/spec/aiEnableRequest/utils.ts +0 -130
- package/test/unit/spec/hashTree/hashTree.ts +0 -721
- package/test/unit/spec/hashTree/hashTreeParser.ts +0 -3670
- package/test/unit/spec/hashTree/utils.ts +0 -140
- package/test/unit/spec/interceptors/dataChannelAuthToken.ts +0 -210
- package/test/unit/spec/interceptors/utils.ts +0 -75
- package/test/unit/spec/webinar/utils.ts +0 -39
|
@@ -1,31 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _Reflect$construct = require("@babel/runtime-corejs2/core-js/reflect/construct");
|
|
4
|
-
var _Array$from = require("@babel/runtime-corejs2/core-js/array/from");
|
|
5
|
-
var _Symbol = require("@babel/runtime-corejs2/core-js/symbol");
|
|
6
|
-
var _Symbol$iterator = require("@babel/runtime-corejs2/core-js/symbol/iterator");
|
|
7
|
-
var _Array$isArray2 = require("@babel/runtime-corejs2/core-js/array/is-array");
|
|
8
|
-
var _Object$keys4 = require("@babel/runtime-corejs2/core-js/object/keys");
|
|
9
|
-
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
|
|
10
|
-
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
|
|
11
|
-
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
|
|
12
|
-
var _Object$defineProperties = require("@babel/runtime-corejs2/core-js/object/define-properties");
|
|
13
4
|
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
14
5
|
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
15
6
|
_Object$defineProperty(exports, "__esModule", {
|
|
16
7
|
value: true
|
|
17
8
|
});
|
|
18
|
-
exports.default = exports.
|
|
9
|
+
exports.default = exports.LocusInfoUpdateType = void 0;
|
|
10
|
+
exports.isSelf = isSelf;
|
|
19
11
|
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
|
|
20
|
-
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
|
|
21
|
-
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
22
|
-
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/array/is-array"));
|
|
23
|
-
var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
|
|
24
|
-
var _values = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/values"));
|
|
25
|
-
var _parseInt2 = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/parse-int"));
|
|
26
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/slicedToArray"));
|
|
27
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/typeof"));
|
|
28
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/toConsumableArray"));
|
|
29
12
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
|
|
30
13
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
31
14
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
|
|
@@ -34,18 +17,7 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
|
|
|
34
17
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/getPrototypeOf"));
|
|
35
18
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/inherits"));
|
|
36
19
|
var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/wrapNativeSuper"));
|
|
37
|
-
var _lodash = require("lodash");
|
|
38
|
-
var _hashTree = _interopRequireDefault(require("./hashTree"));
|
|
39
|
-
var _loggerProxy = _interopRequireDefault(require("../common/logs/logger-proxy"));
|
|
40
|
-
var _constants = require("../constants");
|
|
41
|
-
var _constants2 = require("./constants");
|
|
42
20
|
var _types = require("./types");
|
|
43
|
-
var _utils = require("./utils");
|
|
44
|
-
function ownKeys(e, r) { var t = _Object$keys4(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
45
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
46
|
-
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof _Symbol && r[_Symbol$iterator] || r["@@iterator"]; if (!t) { if (_Array$isArray2(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
47
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? _Array$from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
48
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
49
21
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? _Reflect$construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
50
22
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
51
23
|
var LocusInfoUpdateType = exports.LocusInfoUpdateType = {
|
|
@@ -56,7 +28,7 @@ var LocusInfoUpdateType = exports.LocusInfoUpdateType = {
|
|
|
56
28
|
* This error is thrown if we receive information that the meeting has ended while we're processing some hash messages.
|
|
57
29
|
* It's handled internally by HashTreeParser and results in MEETING_ENDED being sent up.
|
|
58
30
|
*/
|
|
59
|
-
var MeetingEndedError =
|
|
31
|
+
var MeetingEndedError = /*#__PURE__*/function (_Error) {
|
|
60
32
|
function MeetingEndedError() {
|
|
61
33
|
(0, _classCallCheck2.default)(this, MeetingEndedError);
|
|
62
34
|
return _callSuper(this, MeetingEndedError, arguments);
|
|
@@ -64,11 +36,14 @@ var MeetingEndedError = exports.MeetingEndedError = /*#__PURE__*/function (_Erro
|
|
|
64
36
|
(0, _inherits2.default)(MeetingEndedError, _Error);
|
|
65
37
|
return (0, _createClass2.default)(MeetingEndedError);
|
|
66
38
|
}(/*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
|
|
67
|
-
|
|
68
|
-
*
|
|
39
|
+
/**
|
|
40
|
+
* Checks if the given hash tree object is of type "self"
|
|
41
|
+
* @param {HashTreeObject} object object to check
|
|
42
|
+
* @returns {boolean} True if the object is of type "self", false otherwise
|
|
69
43
|
*/
|
|
70
|
-
|
|
71
|
-
|
|
44
|
+
function isSelf(object) {
|
|
45
|
+
return object.htMeta.elementId.type.toLowerCase() === _types.ObjectType.self;
|
|
46
|
+
}
|
|
72
47
|
|
|
73
48
|
/**
|
|
74
49
|
* Parses hash tree eventing locus data
|
|
@@ -80,7 +55,7 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
80
55
|
* @param {Object} options.initialLocus The initial locus data containing the hash tree information
|
|
81
56
|
*/
|
|
82
57
|
function HashTreeParser(options) {
|
|
83
|
-
var _locus$
|
|
58
|
+
var _locus$self;
|
|
84
59
|
(0, _classCallCheck2.default)(this, HashTreeParser);
|
|
85
60
|
(0, _defineProperty2.default)(this, "dataSets", {});
|
|
86
61
|
(0, _defineProperty2.default)(this, "visibleDataSetsUrl", void 0);
|
|
@@ -89,234 +64,30 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
89
64
|
(0, _defineProperty2.default)(this, "locusInfoUpdateCallback", void 0);
|
|
90
65
|
(0, _defineProperty2.default)(this, "visibleDataSets", void 0);
|
|
91
66
|
(0, _defineProperty2.default)(this, "debugId", void 0);
|
|
92
|
-
|
|
93
|
-
(0, _defineProperty2.default)(this, "excludedDataSets", void 0);
|
|
94
|
-
(0, _defineProperty2.default)(this, "state", void 0);
|
|
95
|
-
var _options$initialLocus = options.initialLocus,
|
|
96
|
-
dataSets = _options$initialLocus.dataSets,
|
|
97
|
-
locus = _options$initialLocus.locus; // extract dataSets from initialLocus
|
|
98
|
-
|
|
67
|
+
var locus = options.initialLocus.locus;
|
|
99
68
|
this.debugId = options.debugId;
|
|
100
69
|
this.webexRequest = options.webexRequest;
|
|
101
70
|
this.locusInfoUpdateCallback = options.locusInfoUpdateCallback;
|
|
102
|
-
this.
|
|
103
|
-
this.visibleDataSetsUrl = locus === null || locus === void 0 ? void 0 : (_locus$links = locus.links) === null || _locus$links === void 0 ? void 0 : (_locus$links$resource = _locus$links.resources) === null || _locus$links$resource === void 0 ? void 0 : (_locus$links$resource2 = _locus$links$resource.visibleDataSets) === null || _locus$links$resource2 === void 0 ? void 0 : _locus$links$resource2.url;
|
|
104
|
-
this.setVisibleDataSets(((_options$metadata = options.metadata) === null || _options$metadata === void 0 ? void 0 : _options$metadata.visibleDataSets) || [], dataSets);
|
|
105
|
-
this.state = 'active';
|
|
106
|
-
if (((_options$metadata2 = options.metadata) === null || _options$metadata2 === void 0 ? void 0 : (_options$metadata2$vi = _options$metadata2.visibleDataSets) === null || _options$metadata2$vi === void 0 ? void 0 : _options$metadata2$vi.length) === 0) {
|
|
107
|
-
_loggerProxy.default.logger.warn("HashTreeParser#constructor --> ".concat(this.debugId, " No visibleDataSets found in Metadata"));
|
|
108
|
-
}
|
|
109
|
-
// object mapping dataset names to arrays of leaf data
|
|
110
|
-
var leafData = this.analyzeLocusHtMeta(locus);
|
|
111
|
-
if (options.metadata) {
|
|
112
|
-
// add also the metadata that's outside of locus object itself
|
|
113
|
-
this.analyzeMetadata(leafData, options.metadata);
|
|
114
|
-
}
|
|
115
|
-
_loggerProxy.default.logger.info("HashTreeParser#constructor --> ".concat(this.debugId, " creating HashTreeParser for datasets: ").concat((0, _stringify.default)(dataSets.map(function (ds) {
|
|
116
|
-
return ds.name;
|
|
117
|
-
})), " with visible datasets: ").concat((0, _stringify.default)(this.visibleDataSets.map(function (vds) {
|
|
118
|
-
return vds.name;
|
|
119
|
-
}))));
|
|
120
|
-
var _iterator = _createForOfIteratorHelper(dataSets),
|
|
121
|
-
_step;
|
|
122
|
-
try {
|
|
123
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
124
|
-
var dataSet = _step.value;
|
|
125
|
-
var name = dataSet.name,
|
|
126
|
-
leafCount = dataSet.leafCount;
|
|
127
|
-
this.dataSets[name] = _objectSpread(_objectSpread({}, dataSet), {}, {
|
|
128
|
-
hashTree: this.isVisibleDataSet(name) ? new _hashTree.default(leafData[name] || [], leafCount) : undefined
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
} catch (err) {
|
|
132
|
-
_iterator.e(err);
|
|
133
|
-
} finally {
|
|
134
|
-
_iterator.f();
|
|
135
|
-
}
|
|
71
|
+
this.visibleDataSets = (locus === null || locus === void 0 ? void 0 : (_locus$self = locus.self) === null || _locus$self === void 0 ? void 0 : _locus$self.visibleDataSets) || [];
|
|
136
72
|
}
|
|
137
73
|
|
|
138
74
|
/**
|
|
139
|
-
*
|
|
140
|
-
* the visible data sets, before any message processsing, so for example from the constructor or when resuming the parser.
|
|
75
|
+
* Initializes the hash tree parser from a message received from Locus.
|
|
141
76
|
*
|
|
142
|
-
* @param {
|
|
143
|
-
* @
|
|
144
|
-
* @returns {void}
|
|
77
|
+
* @param {HashTreeMessage} message - initial hash tree message received from Locus
|
|
78
|
+
* @returns {Promise}
|
|
145
79
|
*/
|
|
146
80
|
return (0, _createClass2.default)(HashTreeParser, [{
|
|
147
|
-
key: "setVisibleDataSets",
|
|
148
|
-
value: function setVisibleDataSets(visibleDataSets, dataSets) {
|
|
149
|
-
var _this = this;
|
|
150
|
-
this.visibleDataSets = (0, _lodash.cloneDeep)(visibleDataSets).filter(function (vds) {
|
|
151
|
-
return (
|
|
152
|
-
// exclude data sets we will never care about
|
|
153
|
-
!_this.isExcludedDataSet(vds.name) &&
|
|
154
|
-
// and make sure that visibleDataSets list is consistent with dataSets list
|
|
155
|
-
dataSets.some(function (ds) {
|
|
156
|
-
return ds.name === vds.name;
|
|
157
|
-
})
|
|
158
|
-
);
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Checks if the given data set name is in the list of visible data sets
|
|
164
|
-
* @param {string} dataSetName data set name to check
|
|
165
|
-
* @returns {Boolean} True if the data set is visible, false otherwise
|
|
166
|
-
*/
|
|
167
|
-
}, {
|
|
168
|
-
key: "isVisibleDataSet",
|
|
169
|
-
value: function isVisibleDataSet(dataSetName) {
|
|
170
|
-
return this.visibleDataSets.some(function (vds) {
|
|
171
|
-
return vds.name === dataSetName;
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Checks if the given data set name is in the excluded list
|
|
177
|
-
* @param {string} dataSetName data set name to check
|
|
178
|
-
* @returns {boolean} True if the data set is excluded, false otherwise
|
|
179
|
-
*/
|
|
180
|
-
}, {
|
|
181
|
-
key: "isExcludedDataSet",
|
|
182
|
-
value: function isExcludedDataSet(dataSetName) {
|
|
183
|
-
return this.excludedDataSets.some(function (name) {
|
|
184
|
-
return name === dataSetName;
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Adds a data set to the visible data sets list, unless it is in the excluded list.
|
|
190
|
-
* @param {VisibleDataSetInfo} dataSetInfo data set info to add
|
|
191
|
-
* @returns {boolean} True if the data set was added, false if it was excluded
|
|
192
|
-
*/
|
|
193
|
-
}, {
|
|
194
|
-
key: "addToVisibleDataSetsList",
|
|
195
|
-
value: function addToVisibleDataSetsList(dataSetInfo) {
|
|
196
|
-
if (this.isExcludedDataSet(dataSetInfo.name)) {
|
|
197
|
-
_loggerProxy.default.logger.info("HashTreeParser#addToVisibleDataSetsList --> ".concat(this.debugId, " Data set \"").concat(dataSetInfo.name, "\" is in the excluded list, ignoring"));
|
|
198
|
-
return false;
|
|
199
|
-
}
|
|
200
|
-
this.visibleDataSets.push(dataSetInfo);
|
|
201
|
-
return true;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Initializes a new visible data set by creating a hash tree for it, adding it to all the internal structures,
|
|
206
|
-
* and sending an initial sync request to Locus with empty leaf data - that will trigger Locus to gives us all the data
|
|
207
|
-
* from that dataset (in the response or via messages).
|
|
208
|
-
*
|
|
209
|
-
* @param {VisibleDataSetInfo} visibleDataSetInfo Information about the new visible data set
|
|
210
|
-
* @param {DataSet} dataSetInfo The new data set to be added
|
|
211
|
-
* @returns {Promise}
|
|
212
|
-
*/
|
|
213
|
-
}, {
|
|
214
|
-
key: "initializeNewVisibleDataSet",
|
|
215
|
-
value: function initializeNewVisibleDataSet(visibleDataSetInfo, dataSetInfo) {
|
|
216
|
-
if (this.isVisibleDataSet(dataSetInfo.name)) {
|
|
217
|
-
_loggerProxy.default.logger.info("HashTreeParser#initializeNewVisibleDataSet --> ".concat(this.debugId, " Data set \"").concat(dataSetInfo.name, "\" already exists, skipping init"));
|
|
218
|
-
return _promise.default.resolve({
|
|
219
|
-
updateType: LocusInfoUpdateType.OBJECTS_UPDATED,
|
|
220
|
-
updatedObjects: []
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
_loggerProxy.default.logger.info("HashTreeParser#initializeNewVisibleDataSet --> ".concat(this.debugId, " Adding visible data set \"").concat(dataSetInfo.name, "\""));
|
|
224
|
-
if (!this.addToVisibleDataSetsList(visibleDataSetInfo)) {
|
|
225
|
-
return _promise.default.resolve({
|
|
226
|
-
updateType: LocusInfoUpdateType.OBJECTS_UPDATED,
|
|
227
|
-
updatedObjects: []
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
var hashTree = new _hashTree.default([], dataSetInfo.leafCount);
|
|
231
|
-
this.dataSets[dataSetInfo.name] = _objectSpread(_objectSpread({}, dataSetInfo), {}, {
|
|
232
|
-
hashTree: hashTree
|
|
233
|
-
});
|
|
234
|
-
return this.sendInitializationSyncRequestToLocus(dataSetInfo.name, 'new visible data set');
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Sends a special sync request to Locus with all leaves empty - this is a way to get all the data for a given dataset.
|
|
239
|
-
*
|
|
240
|
-
* @param {string} datasetName - name of the dataset for which to send the request
|
|
241
|
-
* @param {string} debugText - text to include in logs
|
|
242
|
-
* @returns {Promise}
|
|
243
|
-
*/
|
|
244
|
-
}, {
|
|
245
|
-
key: "sendInitializationSyncRequestToLocus",
|
|
246
|
-
value: function sendInitializationSyncRequestToLocus(datasetName, debugText) {
|
|
247
|
-
var _this2 = this;
|
|
248
|
-
var dataset = this.dataSets[datasetName];
|
|
249
|
-
if (!dataset) {
|
|
250
|
-
_loggerProxy.default.logger.warn("HashTreeParser#sendInitializationSyncRequestToLocus --> ".concat(this.debugId, " No data set found for ").concat(datasetName, ", cannot send the request for leaf data"));
|
|
251
|
-
return _promise.default.resolve(null);
|
|
252
|
-
}
|
|
253
|
-
var emptyLeavesData = new Array(dataset.leafCount).fill([]);
|
|
254
|
-
_loggerProxy.default.logger.info("HashTreeParser#sendInitializationSyncRequestToLocus --> ".concat(this.debugId, " Sending initial sync request to Locus for data set \"").concat(datasetName, "\" with empty leaf data"));
|
|
255
|
-
return this.sendSyncRequestToLocus(this.dataSets[datasetName], emptyLeavesData).then(function (syncResponse) {
|
|
256
|
-
if (syncResponse) {
|
|
257
|
-
return {
|
|
258
|
-
updateType: LocusInfoUpdateType.OBJECTS_UPDATED,
|
|
259
|
-
updatedObjects: _this2.parseMessage(syncResponse, "via empty leaves /sync API call for ".concat(debugText))
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
return {
|
|
263
|
-
updateType: LocusInfoUpdateType.OBJECTS_UPDATED,
|
|
264
|
-
updatedObjects: []
|
|
265
|
-
};
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
* Queries Locus for all up-to-date information about all visible data sets
|
|
271
|
-
*
|
|
272
|
-
* @returns {Promise}
|
|
273
|
-
*/
|
|
274
|
-
}, {
|
|
275
|
-
key: "getAllVisibleDataSetsFromLocus",
|
|
276
|
-
value: function getAllVisibleDataSetsFromLocus() {
|
|
277
|
-
var _this3 = this;
|
|
278
|
-
if (!this.visibleDataSetsUrl) {
|
|
279
|
-
_loggerProxy.default.logger.warn("HashTreeParser#getAllVisibleDataSetsFromLocus --> ".concat(this.debugId, " No visibleDataSetsUrl, cannot get data sets information"));
|
|
280
|
-
return _promise.default.resolve([]);
|
|
281
|
-
}
|
|
282
|
-
return this.webexRequest({
|
|
283
|
-
method: _constants.HTTP_VERBS.GET,
|
|
284
|
-
uri: this.visibleDataSetsUrl
|
|
285
|
-
}).then(function (response) {
|
|
286
|
-
return response.body.dataSets;
|
|
287
|
-
}).catch(function (error) {
|
|
288
|
-
_this3.checkForSentinelHttpResponse(error);
|
|
289
|
-
throw error;
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* Initializes the hash tree parser from a message received from Locus.
|
|
295
|
-
*
|
|
296
|
-
* @param {HashTreeMessage} message - initial hash tree message received from Locus
|
|
297
|
-
* @returns {Promise}
|
|
298
|
-
*/
|
|
299
|
-
}, {
|
|
300
81
|
key: "initializeFromMessage",
|
|
301
82
|
value: (function () {
|
|
302
83
|
var _initializeFromMessage = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee(message) {
|
|
303
|
-
var visibleDataSets;
|
|
304
84
|
return _regenerator.default.wrap(function (_context) {
|
|
305
85
|
while (1) switch (_context.prev = _context.next) {
|
|
306
86
|
case 0:
|
|
307
|
-
this.visibleDataSetsUrl = message.visibleDataSetsUrl;
|
|
308
|
-
_loggerProxy.default.logger.info("HashTreeParser#initializeFromMessage --> ".concat(this.debugId, " visibleDataSetsUrl=").concat(this.visibleDataSetsUrl));
|
|
309
|
-
_context.next = 1;
|
|
310
|
-
return this.getAllVisibleDataSetsFromLocus();
|
|
311
|
-
case 1:
|
|
312
|
-
visibleDataSets = _context.sent;
|
|
313
|
-
_context.next = 2;
|
|
314
|
-
return this.initializeDataSets(visibleDataSets, 'initialization from message');
|
|
315
|
-
case 2:
|
|
316
87
|
case "end":
|
|
317
88
|
return _context.stop();
|
|
318
89
|
}
|
|
319
|
-
}, _callee
|
|
90
|
+
}, _callee);
|
|
320
91
|
}));
|
|
321
92
|
function initializeFromMessage(_x) {
|
|
322
93
|
return _initializeFromMessage.apply(this, arguments);
|
|
@@ -337,374 +108,19 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
337
108
|
key: "initializeFromGetLociResponse",
|
|
338
109
|
value: (function () {
|
|
339
110
|
var _initializeFromGetLociResponse = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2(locus) {
|
|
340
|
-
var _locus$links2, _locus$links2$resourc, _locus$links2$resourc2;
|
|
341
|
-
var visibleDataSets;
|
|
342
111
|
return _regenerator.default.wrap(function (_context2) {
|
|
343
112
|
while (1) switch (_context2.prev = _context2.next) {
|
|
344
113
|
case 0:
|
|
345
|
-
if (locus !== null && locus !== void 0 && (_locus$links2 = locus.links) !== null && _locus$links2 !== void 0 && (_locus$links2$resourc = _locus$links2.resources) !== null && _locus$links2$resourc !== void 0 && (_locus$links2$resourc2 = _locus$links2$resourc.visibleDataSets) !== null && _locus$links2$resourc2 !== void 0 && _locus$links2$resourc2.url) {
|
|
346
|
-
_context2.next = 1;
|
|
347
|
-
break;
|
|
348
|
-
}
|
|
349
|
-
_loggerProxy.default.logger.warn("HashTreeParser#initializeFromGetLociResponse --> ".concat(this.debugId, " missing visibleDataSets url in GET Loci response, cannot initialize hash trees"));
|
|
350
|
-
return _context2.abrupt("return");
|
|
351
|
-
case 1:
|
|
352
|
-
this.visibleDataSetsUrl = locus.links.resources.visibleDataSets.url;
|
|
353
|
-
_loggerProxy.default.logger.info("HashTreeParser#initializeFromGetLociResponse --> ".concat(this.debugId, " visibleDataSets url: ").concat(this.visibleDataSetsUrl));
|
|
354
|
-
_context2.next = 2;
|
|
355
|
-
return this.getAllVisibleDataSetsFromLocus();
|
|
356
|
-
case 2:
|
|
357
|
-
visibleDataSets = _context2.sent;
|
|
358
|
-
_context2.next = 3;
|
|
359
|
-
return this.initializeDataSets(visibleDataSets, 'initialization from GET /loci response');
|
|
360
|
-
case 3:
|
|
361
114
|
case "end":
|
|
362
115
|
return _context2.stop();
|
|
363
116
|
}
|
|
364
|
-
}, _callee2
|
|
117
|
+
}, _callee2);
|
|
365
118
|
}));
|
|
366
119
|
function initializeFromGetLociResponse(_x2) {
|
|
367
120
|
return _initializeFromGetLociResponse.apply(this, arguments);
|
|
368
121
|
}
|
|
369
122
|
return initializeFromGetLociResponse;
|
|
370
123
|
}()
|
|
371
|
-
/**
|
|
372
|
-
* Initializes data sets by doing an initialization sync on each visible data set that doesn't have a hash tree yet.
|
|
373
|
-
*
|
|
374
|
-
* @param {DataSet[]} visibleDataSets Array of visible DataSet objects to initialize
|
|
375
|
-
* @param {string} debugText Text to include in logs for debugging purposes
|
|
376
|
-
* @returns {Promise}
|
|
377
|
-
*/
|
|
378
|
-
)
|
|
379
|
-
}, {
|
|
380
|
-
key: "initializeDataSets",
|
|
381
|
-
value: (function () {
|
|
382
|
-
var _initializeDataSets = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee3(visibleDataSets, debugText) {
|
|
383
|
-
var updatedObjects, _iterator2, _step2, dataSet, name, leafCount, url, _data, _t;
|
|
384
|
-
return _regenerator.default.wrap(function (_context3) {
|
|
385
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
386
|
-
case 0:
|
|
387
|
-
if (!(this.state === 'stopped')) {
|
|
388
|
-
_context3.next = 1;
|
|
389
|
-
break;
|
|
390
|
-
}
|
|
391
|
-
return _context3.abrupt("return");
|
|
392
|
-
case 1:
|
|
393
|
-
updatedObjects = [];
|
|
394
|
-
_iterator2 = _createForOfIteratorHelper(visibleDataSets);
|
|
395
|
-
_context3.prev = 2;
|
|
396
|
-
_iterator2.s();
|
|
397
|
-
case 3:
|
|
398
|
-
if ((_step2 = _iterator2.n()).done) {
|
|
399
|
-
_context3.next = 7;
|
|
400
|
-
break;
|
|
401
|
-
}
|
|
402
|
-
dataSet = _step2.value;
|
|
403
|
-
name = dataSet.name, leafCount = dataSet.leafCount, url = dataSet.url;
|
|
404
|
-
if (!this.dataSets[name]) {
|
|
405
|
-
_loggerProxy.default.logger.info("HashTreeParser#initializeDataSets --> ".concat(this.debugId, " initializing dataset \"").concat(name, "\" (").concat(debugText, ")"));
|
|
406
|
-
this.dataSets[name] = _objectSpread({}, dataSet);
|
|
407
|
-
} else {
|
|
408
|
-
_loggerProxy.default.logger.info("HashTreeParser#initializeDataSets --> ".concat(this.debugId, " dataset \"").concat(name, "\" already exists (").concat(debugText, ")"));
|
|
409
|
-
}
|
|
410
|
-
if (this.isVisibleDataSet(name)) {
|
|
411
|
-
_context3.next = 4;
|
|
412
|
-
break;
|
|
413
|
-
}
|
|
414
|
-
if (this.addToVisibleDataSetsList({
|
|
415
|
-
name: name,
|
|
416
|
-
url: url
|
|
417
|
-
})) {
|
|
418
|
-
_context3.next = 4;
|
|
419
|
-
break;
|
|
420
|
-
}
|
|
421
|
-
return _context3.abrupt("continue", 6);
|
|
422
|
-
case 4:
|
|
423
|
-
if (this.dataSets[name].hashTree) {
|
|
424
|
-
_context3.next = 6;
|
|
425
|
-
break;
|
|
426
|
-
}
|
|
427
|
-
_loggerProxy.default.logger.info("HashTreeParser#initializeDataSets --> ".concat(this.debugId, " creating hash tree for visible dataset \"").concat(name, "\" (").concat(debugText, ")"));
|
|
428
|
-
this.dataSets[name].hashTree = new _hashTree.default([], leafCount);
|
|
429
|
-
|
|
430
|
-
// eslint-disable-next-line no-await-in-loop
|
|
431
|
-
_context3.next = 5;
|
|
432
|
-
return this.sendInitializationSyncRequestToLocus(name, debugText);
|
|
433
|
-
case 5:
|
|
434
|
-
_data = _context3.sent;
|
|
435
|
-
if (_data.updateType === LocusInfoUpdateType.OBJECTS_UPDATED) {
|
|
436
|
-
updatedObjects.push.apply(updatedObjects, (0, _toConsumableArray2.default)(_data.updatedObjects || []));
|
|
437
|
-
}
|
|
438
|
-
case 6:
|
|
439
|
-
_context3.next = 3;
|
|
440
|
-
break;
|
|
441
|
-
case 7:
|
|
442
|
-
_context3.next = 9;
|
|
443
|
-
break;
|
|
444
|
-
case 8:
|
|
445
|
-
_context3.prev = 8;
|
|
446
|
-
_t = _context3["catch"](2);
|
|
447
|
-
_iterator2.e(_t);
|
|
448
|
-
case 9:
|
|
449
|
-
_context3.prev = 9;
|
|
450
|
-
_iterator2.f();
|
|
451
|
-
return _context3.finish(9);
|
|
452
|
-
case 10:
|
|
453
|
-
this.callLocusInfoUpdateCallback({
|
|
454
|
-
updateType: LocusInfoUpdateType.OBJECTS_UPDATED,
|
|
455
|
-
updatedObjects: updatedObjects
|
|
456
|
-
});
|
|
457
|
-
case 11:
|
|
458
|
-
case "end":
|
|
459
|
-
return _context3.stop();
|
|
460
|
-
}
|
|
461
|
-
}, _callee3, this, [[2, 8, 9, 10]]);
|
|
462
|
-
}));
|
|
463
|
-
function initializeDataSets(_x3, _x4) {
|
|
464
|
-
return _initializeDataSets.apply(this, arguments);
|
|
465
|
-
}
|
|
466
|
-
return initializeDataSets;
|
|
467
|
-
}()
|
|
468
|
-
/**
|
|
469
|
-
* Each dataset exists at a different place in the dto
|
|
470
|
-
* iterate recursively over the locus and if it has a htMeta key,
|
|
471
|
-
* create an object with the type, id and version and add it to the appropriate leafData array
|
|
472
|
-
*
|
|
473
|
-
* @param {any} locus - The current part of the locus being processed
|
|
474
|
-
* @param {Object} [options]
|
|
475
|
-
* @param {boolean} [options.copyData=false] - Whether to copy the data for each leaf into returned result
|
|
476
|
-
* @returns {any} - An object mapping dataset names to arrays of leaf data
|
|
477
|
-
*/
|
|
478
|
-
)
|
|
479
|
-
}, {
|
|
480
|
-
key: "analyzeLocusHtMeta",
|
|
481
|
-
value: function analyzeLocusHtMeta(locus, options) {
|
|
482
|
-
var _ref = options || {},
|
|
483
|
-
_ref$copyData = _ref.copyData,
|
|
484
|
-
copyData = _ref$copyData === void 0 ? false : _ref$copyData;
|
|
485
|
-
// object mapping dataset names to arrays of leaf data
|
|
486
|
-
var leafInfo = {};
|
|
487
|
-
var _findAndStoreMetaData = function findAndStoreMetaData(currentLocusPart, currentLocusPartName) {
|
|
488
|
-
if ((0, _typeof2.default)(currentLocusPart) !== 'object' || currentLocusPart === null) {
|
|
489
|
-
return;
|
|
490
|
-
}
|
|
491
|
-
if (currentLocusPart.htMeta && currentLocusPart.htMeta.dataSetNames) {
|
|
492
|
-
var _currentLocusPart$htM = currentLocusPart.htMeta.elementId,
|
|
493
|
-
type = _currentLocusPart$htM.type,
|
|
494
|
-
id = _currentLocusPart$htM.id,
|
|
495
|
-
version = _currentLocusPart$htM.version;
|
|
496
|
-
var dataSetNames = currentLocusPart.htMeta.dataSetNames;
|
|
497
|
-
var newLeafInfo = {
|
|
498
|
-
type: type,
|
|
499
|
-
id: id,
|
|
500
|
-
version: version
|
|
501
|
-
};
|
|
502
|
-
if (copyData) {
|
|
503
|
-
if (type.toLowerCase() === _types.ObjectType.control) {
|
|
504
|
-
// control entries require special handling, because they are signalled by Locus
|
|
505
|
-
// differently when coming in messages vs API responses
|
|
506
|
-
newLeafInfo.data = (0, _defineProperty2.default)({}, currentLocusPartName, (0, _lodash.cloneDeep)(currentLocusPart));
|
|
507
|
-
} else {
|
|
508
|
-
newLeafInfo.data = (0, _lodash.cloneDeep)(currentLocusPart);
|
|
509
|
-
|
|
510
|
-
// remove any nested other objects that have their own htMeta
|
|
511
|
-
(0, _utils.deleteNestedObjectsWithHtMeta)(newLeafInfo.data);
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
var _iterator3 = _createForOfIteratorHelper(dataSetNames),
|
|
515
|
-
_step3;
|
|
516
|
-
try {
|
|
517
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
518
|
-
var dataSetName = _step3.value;
|
|
519
|
-
if (!leafInfo[dataSetName]) {
|
|
520
|
-
leafInfo[dataSetName] = [];
|
|
521
|
-
}
|
|
522
|
-
leafInfo[dataSetName].push(newLeafInfo);
|
|
523
|
-
}
|
|
524
|
-
} catch (err) {
|
|
525
|
-
_iterator3.e(err);
|
|
526
|
-
} finally {
|
|
527
|
-
_iterator3.f();
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
if ((0, _isArray.default)(currentLocusPart)) {
|
|
531
|
-
var _iterator4 = _createForOfIteratorHelper(currentLocusPart.entries()),
|
|
532
|
-
_step4;
|
|
533
|
-
try {
|
|
534
|
-
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
535
|
-
var _step4$value = (0, _slicedToArray2.default)(_step4.value, 2),
|
|
536
|
-
index = _step4$value[0],
|
|
537
|
-
item = _step4$value[1];
|
|
538
|
-
_findAndStoreMetaData(item, index.toString());
|
|
539
|
-
}
|
|
540
|
-
} catch (err) {
|
|
541
|
-
_iterator4.e(err);
|
|
542
|
-
} finally {
|
|
543
|
-
_iterator4.f();
|
|
544
|
-
}
|
|
545
|
-
} else {
|
|
546
|
-
for (var _i = 0, _Object$keys = (0, _keys.default)(currentLocusPart); _i < _Object$keys.length; _i++) {
|
|
547
|
-
var key = _Object$keys[_i];
|
|
548
|
-
if (Object.prototype.hasOwnProperty.call(currentLocusPart, key)) {
|
|
549
|
-
_findAndStoreMetaData(currentLocusPart[key], key);
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
};
|
|
554
|
-
_findAndStoreMetaData(locus, 'locus');
|
|
555
|
-
return leafInfo;
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
/**
|
|
559
|
-
* Analyzes the Metadata object that is sent outside of Locus object, and appends its data to passed in leafInfo
|
|
560
|
-
* structure.
|
|
561
|
-
*
|
|
562
|
-
* @param {Record<string, LeafInfo[]>} leafInfo the structure to which the Metadata info will be appended
|
|
563
|
-
* @param {Metadata} metadata Metadata object
|
|
564
|
-
* @returns {void}
|
|
565
|
-
*/
|
|
566
|
-
}, {
|
|
567
|
-
key: "analyzeMetadata",
|
|
568
|
-
value: function analyzeMetadata(leafInfo, metadata) {
|
|
569
|
-
var _htMeta$dataSetNames;
|
|
570
|
-
var htMeta = metadata.htMeta;
|
|
571
|
-
if ((htMeta === null || htMeta === void 0 ? void 0 : (_htMeta$dataSetNames = htMeta.dataSetNames) === null || _htMeta$dataSetNames === void 0 ? void 0 : _htMeta$dataSetNames.length) === 1 && htMeta.dataSetNames[0].toLowerCase() === MetadataDataSetName) {
|
|
572
|
-
var _metadata$htMeta$elem = metadata.htMeta.elementId,
|
|
573
|
-
type = _metadata$htMeta$elem.type,
|
|
574
|
-
id = _metadata$htMeta$elem.id,
|
|
575
|
-
version = _metadata$htMeta$elem.version;
|
|
576
|
-
var dataSetName = htMeta.dataSetNames[0];
|
|
577
|
-
if (!leafInfo[dataSetName]) {
|
|
578
|
-
leafInfo[dataSetName] = [];
|
|
579
|
-
}
|
|
580
|
-
leafInfo[dataSetName].push({
|
|
581
|
-
type: type,
|
|
582
|
-
id: id,
|
|
583
|
-
version: version
|
|
584
|
-
});
|
|
585
|
-
} else {
|
|
586
|
-
throw new Error("".concat(this.debugId, " Metadata htMeta has unexpected dataSetNames: ").concat(htMeta && htMeta.dataSetNames.join(',')));
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
/**
|
|
591
|
-
* Checks if the provided hash tree message indicates the end of the meeting and that there won't be any more updates.
|
|
592
|
-
*
|
|
593
|
-
* @param {HashTreeMessage} message - The hash tree message to check
|
|
594
|
-
* @returns {boolean} - Returns true if the message indicates the end of the meeting, false otherwise
|
|
595
|
-
*/
|
|
596
|
-
}, {
|
|
597
|
-
key: "isEndMessage",
|
|
598
|
-
value: function isEndMessage(message) {
|
|
599
|
-
var _this4 = this;
|
|
600
|
-
return message.dataSets.some(function (dataSet) {
|
|
601
|
-
if (dataSet.leafCount === 1 && dataSet.root === _constants2.EMPTY_HASH && (!_this4.dataSets[dataSet.name] || _this4.dataSets[dataSet.name].version < dataSet.version) && PossibleSentinelMessageDataSetNames.includes(dataSet.name.toLowerCase())) {
|
|
602
|
-
// this is a special way for Locus to indicate that this meeting has ended
|
|
603
|
-
return true;
|
|
604
|
-
}
|
|
605
|
-
return false;
|
|
606
|
-
});
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
/**
|
|
610
|
-
* Handles the root hash heartbeat message
|
|
611
|
-
*
|
|
612
|
-
* @param {RootHashMessage} message - The root hash heartbeat message
|
|
613
|
-
* @returns {void}
|
|
614
|
-
*/
|
|
615
|
-
}, {
|
|
616
|
-
key: "handleRootHashHeartBeatMessage",
|
|
617
|
-
value: function handleRootHashHeartBeatMessage(message) {
|
|
618
|
-
var _this5 = this;
|
|
619
|
-
var dataSets = message.dataSets;
|
|
620
|
-
_loggerProxy.default.logger.info("HashTreeParser#handleRootHashMessage --> ".concat(this.debugId, " Received heartbeat root hash message with data sets: ").concat((0, _stringify.default)(dataSets.map(function (_ref2) {
|
|
621
|
-
var name = _ref2.name,
|
|
622
|
-
root = _ref2.root,
|
|
623
|
-
leafCount = _ref2.leafCount,
|
|
624
|
-
version = _ref2.version;
|
|
625
|
-
return {
|
|
626
|
-
name: name,
|
|
627
|
-
root: root,
|
|
628
|
-
leafCount: leafCount,
|
|
629
|
-
version: version
|
|
630
|
-
};
|
|
631
|
-
}))));
|
|
632
|
-
dataSets.forEach(function (dataSet) {
|
|
633
|
-
_this5.updateDataSetInfo(dataSet);
|
|
634
|
-
_this5.runSyncAlgorithm(dataSet);
|
|
635
|
-
});
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
/**
|
|
639
|
-
* Asynchronously initializes new visible data sets
|
|
640
|
-
*
|
|
641
|
-
* @param {VisibleDataSetInfo[]} dataSetsRequiringInitialization list of datasets to initialize
|
|
642
|
-
* @returns {void}
|
|
643
|
-
*/
|
|
644
|
-
}, {
|
|
645
|
-
key: "queueInitForNewVisibleDataSets",
|
|
646
|
-
value: function queueInitForNewVisibleDataSets(dataSetsRequiringInitialization) {
|
|
647
|
-
var _this6 = this;
|
|
648
|
-
_loggerProxy.default.logger.info("HashTreeParser#queueInitForNewVisibleDataSets --> ".concat(this.debugId, " queuing initialization of new visible datasets: ").concat(dataSetsRequiringInitialization.map(function (ds) {
|
|
649
|
-
return ds.name;
|
|
650
|
-
}).join(', ')));
|
|
651
|
-
queueMicrotask(function () {
|
|
652
|
-
_this6.initializeNewVisibleDataSets(dataSetsRequiringInitialization).catch(function (error) {
|
|
653
|
-
if (error instanceof MeetingEndedError) {
|
|
654
|
-
_this6.callLocusInfoUpdateCallback({
|
|
655
|
-
updateType: LocusInfoUpdateType.MEETING_ENDED
|
|
656
|
-
});
|
|
657
|
-
} else {
|
|
658
|
-
_loggerProxy.default.logger.warn("HashTreeParser#queueInitForNewVisibleDataSets --> ".concat(_this6.debugId, " error while initializing new visible datasets: ").concat(dataSetsRequiringInitialization.map(function (ds) {
|
|
659
|
-
return ds.name;
|
|
660
|
-
}).join(', '), ": "), error);
|
|
661
|
-
}
|
|
662
|
-
});
|
|
663
|
-
});
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
/**
|
|
667
|
-
* Handles updates to Metadata object that we receive from Locus via other means than messages. Right now
|
|
668
|
-
* that means only in the API response alongside locus object.
|
|
669
|
-
*
|
|
670
|
-
* @param {Metadata} metadata received in Locus update other than a message (for example in an API response)
|
|
671
|
-
* @param {HashTreeObject[]} updatedObjects a list of updated hash tree objects to which any updates resulting from new Metadata will be added
|
|
672
|
-
* @returns {void}
|
|
673
|
-
*/
|
|
674
|
-
}, {
|
|
675
|
-
key: "handleMetadataUpdate",
|
|
676
|
-
value: function handleMetadataUpdate(metadata, updatedObjects) {
|
|
677
|
-
var _this$dataSets$Metada;
|
|
678
|
-
var dataSetsRequiringInitialization = [];
|
|
679
|
-
|
|
680
|
-
// current assumption based on Locus docs is that Metadata object lives always in "self" data set
|
|
681
|
-
var hashTree = (_this$dataSets$Metada = this.dataSets[MetadataDataSetName]) === null || _this$dataSets$Metada === void 0 ? void 0 : _this$dataSets$Metada.hashTree;
|
|
682
|
-
if (!hashTree) {
|
|
683
|
-
_loggerProxy.default.logger.warn("HashTreeParser#handleLocusUpdate --> ".concat(this.debugId, " received Metadata object but no hash tree for \"").concat(MetadataDataSetName, "\" data set exists"));
|
|
684
|
-
} else {
|
|
685
|
-
var metadataUpdated = hashTree.putItem(metadata.htMeta.elementId);
|
|
686
|
-
if (metadataUpdated) {
|
|
687
|
-
// metadata in Locus API response is in a slightly different format than the objects in messages, so need to adapt it
|
|
688
|
-
var metadataObject = {
|
|
689
|
-
htMeta: metadata.htMeta,
|
|
690
|
-
data: metadata
|
|
691
|
-
};
|
|
692
|
-
updatedObjects.push(metadataObject);
|
|
693
|
-
var _this$checkForVisible = this.checkForVisibleDataSetChanges([metadataObject]),
|
|
694
|
-
changeDetected = _this$checkForVisible.changeDetected,
|
|
695
|
-
removedDataSets = _this$checkForVisible.removedDataSets,
|
|
696
|
-
addedDataSets = _this$checkForVisible.addedDataSets;
|
|
697
|
-
if (changeDetected) {
|
|
698
|
-
dataSetsRequiringInitialization = this.processVisibleDataSetChanges(removedDataSets, addedDataSets, updatedObjects);
|
|
699
|
-
}
|
|
700
|
-
if (dataSetsRequiringInitialization.length > 0) {
|
|
701
|
-
// there are some data sets that we need to initialize asynchronously
|
|
702
|
-
this.queueInitForNewVisibleDataSets(dataSetsRequiringInitialization);
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
|
|
708
124
|
/**
|
|
709
125
|
* This method should be called when we receive a partial locus DTO that contains dataSets and htMeta information
|
|
710
126
|
* It updates the hash trees with the new leaf data based on the received Locus
|
|
@@ -712,477 +128,11 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
712
128
|
* @param {Object} update - The locus update containing data sets and locus information
|
|
713
129
|
* @returns {void}
|
|
714
130
|
*/
|
|
131
|
+
)
|
|
715
132
|
}, {
|
|
716
133
|
key: "handleLocusUpdate",
|
|
717
134
|
value: function handleLocusUpdate(update) {
|
|
718
|
-
|
|
719
|
-
if (this.state === 'stopped') {
|
|
720
|
-
return;
|
|
721
|
-
}
|
|
722
|
-
var dataSets = update.dataSets,
|
|
723
|
-
locus = update.locus,
|
|
724
|
-
metadata = update.metadata;
|
|
725
|
-
if (!dataSets) {
|
|
726
|
-
_loggerProxy.default.logger.info("HashTreeParser#handleLocusUpdate --> ".concat(this.debugId, " received hash tree update without dataSets"));
|
|
727
|
-
} else {
|
|
728
|
-
var _iterator5 = _createForOfIteratorHelper(dataSets),
|
|
729
|
-
_step5;
|
|
730
|
-
try {
|
|
731
|
-
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
732
|
-
var dataSet = _step5.value;
|
|
733
|
-
this.updateDataSetInfo(dataSet);
|
|
734
|
-
}
|
|
735
|
-
} catch (err) {
|
|
736
|
-
_iterator5.e(err);
|
|
737
|
-
} finally {
|
|
738
|
-
_iterator5.f();
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
var updatedObjects = [];
|
|
742
|
-
|
|
743
|
-
// first, analyze the locus object to extract the hash tree objects' htMeta and data from it
|
|
744
|
-
var leafInfo = this.analyzeLocusHtMeta(locus, {
|
|
745
|
-
copyData: true
|
|
746
|
-
});
|
|
747
|
-
|
|
748
|
-
// if we got metadata, process it (currently that means only potential visible data set list changes)
|
|
749
|
-
if (metadata) {
|
|
750
|
-
this.handleMetadataUpdate(metadata, updatedObjects);
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
// then process the data in hash trees, if it is a new version, then add it to updatedObjects
|
|
754
|
-
(0, _keys.default)(leafInfo).forEach(function (dataSetName) {
|
|
755
|
-
if (_this7.dataSets[dataSetName]) {
|
|
756
|
-
if (_this7.dataSets[dataSetName].hashTree) {
|
|
757
|
-
var appliedChangesList = _this7.dataSets[dataSetName].hashTree.putItems(leafInfo[dataSetName].map(function (leaf) {
|
|
758
|
-
return {
|
|
759
|
-
id: leaf.id,
|
|
760
|
-
type: leaf.type,
|
|
761
|
-
version: leaf.version
|
|
762
|
-
};
|
|
763
|
-
}));
|
|
764
|
-
(0, _lodash.zip)(appliedChangesList, leafInfo[dataSetName]).forEach(function (_ref3) {
|
|
765
|
-
var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
|
|
766
|
-
changeApplied = _ref4[0],
|
|
767
|
-
leaf = _ref4[1];
|
|
768
|
-
if (changeApplied) {
|
|
769
|
-
updatedObjects.push({
|
|
770
|
-
htMeta: {
|
|
771
|
-
elementId: {
|
|
772
|
-
type: leaf.type,
|
|
773
|
-
id: leaf.id,
|
|
774
|
-
version: leaf.version
|
|
775
|
-
},
|
|
776
|
-
dataSetNames: [dataSetName]
|
|
777
|
-
},
|
|
778
|
-
data: leaf.data
|
|
779
|
-
});
|
|
780
|
-
}
|
|
781
|
-
});
|
|
782
|
-
} else {
|
|
783
|
-
// no hash tree means that the data set is not visible
|
|
784
|
-
_loggerProxy.default.logger.warn("HashTreeParser#handleLocusUpdate --> ".concat(_this7.debugId, " received leaf data for data set \"").concat(dataSetName, "\" that has no hash tree created, ignoring"));
|
|
785
|
-
}
|
|
786
|
-
} else {
|
|
787
|
-
_loggerProxy.default.logger.info("HashTreeParser#handleLocusUpdate --> ".concat(_this7.debugId, " received leaf data for unknown data set \"").concat(dataSetName, "\", ignoring"));
|
|
788
|
-
}
|
|
789
|
-
});
|
|
790
|
-
if (updatedObjects.length === 0) {
|
|
791
|
-
_loggerProxy.default.logger.info("HashTreeParser#handleLocusUpdate --> ".concat(this.debugId, " No objects updated as a result of received API response"));
|
|
792
|
-
} else {
|
|
793
|
-
this.callLocusInfoUpdateCallback({
|
|
794
|
-
updateType: LocusInfoUpdateType.OBJECTS_UPDATED,
|
|
795
|
-
updatedObjects: updatedObjects
|
|
796
|
-
});
|
|
797
|
-
}
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
/**
|
|
801
|
-
* Updates the internal data set information based on the received data set from Locus.
|
|
802
|
-
*
|
|
803
|
-
* @param {DataSet} receivedDataSet - The latest data set information received from Locus to update the internal state.
|
|
804
|
-
* @returns {void}
|
|
805
|
-
*/
|
|
806
|
-
}, {
|
|
807
|
-
key: "updateDataSetInfo",
|
|
808
|
-
value: function updateDataSetInfo(receivedDataSet) {
|
|
809
|
-
if (!this.dataSets[receivedDataSet.name]) {
|
|
810
|
-
this.dataSets[receivedDataSet.name] = _objectSpread({}, receivedDataSet);
|
|
811
|
-
_loggerProxy.default.logger.info("HashTreeParser#updateDataSetInfo --> ".concat(this.debugId, " created entry for \"").concat(receivedDataSet.name, "\" dataset: version=").concat(receivedDataSet.version, ", root=").concat(receivedDataSet.root));
|
|
812
|
-
return;
|
|
813
|
-
}
|
|
814
|
-
// update our version of the dataSet
|
|
815
|
-
if (this.dataSets[receivedDataSet.name].version < receivedDataSet.version) {
|
|
816
|
-
this.dataSets[receivedDataSet.name].version = receivedDataSet.version;
|
|
817
|
-
this.dataSets[receivedDataSet.name].root = receivedDataSet.root;
|
|
818
|
-
this.dataSets[receivedDataSet.name].idleMs = receivedDataSet.idleMs;
|
|
819
|
-
this.dataSets[receivedDataSet.name].backoff = {
|
|
820
|
-
maxMs: receivedDataSet.backoff.maxMs,
|
|
821
|
-
exponent: receivedDataSet.backoff.exponent
|
|
822
|
-
};
|
|
823
|
-
_loggerProxy.default.logger.info("HashTreeParser#updateDataSetInfo --> ".concat(this.debugId, " updated \"").concat(receivedDataSet.name, "\" dataset to version=").concat(receivedDataSet.version, ", root=").concat(receivedDataSet.root));
|
|
824
|
-
}
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
/**
|
|
828
|
-
* Checks for changes in the visible data sets based on the updated objects.
|
|
829
|
-
* @param {HashTreeObject[]} updatedObjects - The list of updated hash tree objects.
|
|
830
|
-
* @returns {Object} An object containing the removed and added visible data sets.
|
|
831
|
-
*/
|
|
832
|
-
}, {
|
|
833
|
-
key: "checkForVisibleDataSetChanges",
|
|
834
|
-
value: function checkForVisibleDataSetChanges(updatedObjects) {
|
|
835
|
-
var _this8 = this;
|
|
836
|
-
var removedDataSets = [];
|
|
837
|
-
var addedDataSets = [];
|
|
838
|
-
|
|
839
|
-
// visibleDataSets can only be changed by Metadata object updates
|
|
840
|
-
updatedObjects.forEach(function (object) {
|
|
841
|
-
var _object$data;
|
|
842
|
-
if ((0, _utils.isMetadata)(object) && (_object$data = object.data) !== null && _object$data !== void 0 && _object$data.visibleDataSets) {
|
|
843
|
-
var newVisibleDataSets = object.data.visibleDataSets.filter(function (vds) {
|
|
844
|
-
return !_this8.isExcludedDataSet(vds.name);
|
|
845
|
-
});
|
|
846
|
-
removedDataSets = _this8.visibleDataSets.filter(function (ds) {
|
|
847
|
-
return !newVisibleDataSets.some(function (nvs) {
|
|
848
|
-
return nvs.name === ds.name;
|
|
849
|
-
});
|
|
850
|
-
});
|
|
851
|
-
addedDataSets = newVisibleDataSets.filter(function (nvs) {
|
|
852
|
-
return _this8.visibleDataSets.every(function (ds) {
|
|
853
|
-
return ds.name !== nvs.name;
|
|
854
|
-
});
|
|
855
|
-
});
|
|
856
|
-
if (removedDataSets.length > 0 || addedDataSets.length > 0) {
|
|
857
|
-
_loggerProxy.default.logger.info("HashTreeParser#checkForVisibleDataSetChanges --> ".concat(_this8.debugId, " visible data sets change: removed: ").concat(removedDataSets.map(function (ds) {
|
|
858
|
-
return ds.name;
|
|
859
|
-
}).join(', '), ", added: ").concat(addedDataSets.map(function (ds) {
|
|
860
|
-
return ds.name;
|
|
861
|
-
}).join(', ')));
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
});
|
|
865
|
-
return {
|
|
866
|
-
changeDetected: removedDataSets.length > 0 || addedDataSets.length > 0,
|
|
867
|
-
removedDataSets: removedDataSets,
|
|
868
|
-
addedDataSets: addedDataSets
|
|
869
|
-
};
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
/**
|
|
873
|
-
* Deletes the hash tree for the specified data set.
|
|
874
|
-
*
|
|
875
|
-
* @param {string} dataSetName name of the data set to delete
|
|
876
|
-
* @returns {void}
|
|
877
|
-
*/
|
|
878
|
-
}, {
|
|
879
|
-
key: "deleteHashTree",
|
|
880
|
-
value: function deleteHashTree(dataSetName) {
|
|
881
|
-
this.dataSets[dataSetName].hashTree = undefined;
|
|
882
|
-
|
|
883
|
-
// we also need to stop the timers as there is no hash tree anymore to sync
|
|
884
|
-
if (this.dataSets[dataSetName].timer) {
|
|
885
|
-
clearTimeout(this.dataSets[dataSetName].timer);
|
|
886
|
-
this.dataSets[dataSetName].timer = undefined;
|
|
887
|
-
}
|
|
888
|
-
if (this.dataSets[dataSetName].heartbeatWatchdogTimer) {
|
|
889
|
-
clearTimeout(this.dataSets[dataSetName].heartbeatWatchdogTimer);
|
|
890
|
-
this.dataSets[dataSetName].heartbeatWatchdogTimer = undefined;
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
|
|
894
|
-
/**
|
|
895
|
-
* Adds entries to the passed in updateObjects array
|
|
896
|
-
* for the changes that result from removing visible data sets and creates hash
|
|
897
|
-
* trees for the new visible data sets, but without populating the hash trees.
|
|
898
|
-
*
|
|
899
|
-
* This function is synchronous. If we are missing information about some new
|
|
900
|
-
* visible data sets and they require async initialization, the names of these data sets
|
|
901
|
-
* are returned in an array.
|
|
902
|
-
*
|
|
903
|
-
* @param {VisibleDataSetInfo[]} removedDataSets - The list of removed data sets.
|
|
904
|
-
* @param {VisibleDataSetInfo[]} addedDataSets - The list of added data sets.
|
|
905
|
-
* @param {HashTreeObject[]} updatedObjects - The list of updated hash tree objects to which changes will be added.
|
|
906
|
-
* @returns {VisibleDataSetInfo[]} list of data sets that couldn't be initialized synchronously
|
|
907
|
-
*/
|
|
908
|
-
}, {
|
|
909
|
-
key: "processVisibleDataSetChanges",
|
|
910
|
-
value: function processVisibleDataSetChanges(removedDataSets, addedDataSets, updatedObjects) {
|
|
911
|
-
var _this9 = this;
|
|
912
|
-
var dataSetsRequiringInitialization = [];
|
|
913
|
-
|
|
914
|
-
// if a visible data set was removed, we need to tell our client that all objects from it are removed
|
|
915
|
-
var removedObjects = [];
|
|
916
|
-
removedDataSets.forEach(function (ds) {
|
|
917
|
-
var _this9$dataSets$ds$na;
|
|
918
|
-
if ((_this9$dataSets$ds$na = _this9.dataSets[ds.name]) !== null && _this9$dataSets$ds$na !== void 0 && _this9$dataSets$ds$na.hashTree) {
|
|
919
|
-
for (var i = 0; i < _this9.dataSets[ds.name].hashTree.numLeaves; i += 1) {
|
|
920
|
-
removedObjects.push.apply(removedObjects, (0, _toConsumableArray2.default)(_this9.dataSets[ds.name].hashTree.getLeafData(i).map(function (elementId) {
|
|
921
|
-
return {
|
|
922
|
-
htMeta: {
|
|
923
|
-
elementId: elementId,
|
|
924
|
-
dataSetNames: [ds.name]
|
|
925
|
-
},
|
|
926
|
-
data: null
|
|
927
|
-
};
|
|
928
|
-
})));
|
|
929
|
-
}
|
|
930
|
-
_this9.deleteHashTree(ds.name);
|
|
931
|
-
}
|
|
932
|
-
});
|
|
933
|
-
this.visibleDataSets = this.visibleDataSets.filter(function (vds) {
|
|
934
|
-
return !removedDataSets.some(function (rds) {
|
|
935
|
-
return rds.name === vds.name;
|
|
936
|
-
});
|
|
937
|
-
});
|
|
938
|
-
updatedObjects.push.apply(updatedObjects, removedObjects);
|
|
939
|
-
|
|
940
|
-
// now setup the new visible data sets
|
|
941
|
-
var _iterator6 = _createForOfIteratorHelper(addedDataSets),
|
|
942
|
-
_step6;
|
|
943
|
-
try {
|
|
944
|
-
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
945
|
-
var ds = _step6.value;
|
|
946
|
-
var dataSetInfo = this.dataSets[ds.name];
|
|
947
|
-
if (dataSetInfo) {
|
|
948
|
-
if (this.isVisibleDataSet(dataSetInfo.name)) {
|
|
949
|
-
_loggerProxy.default.logger.info("HashTreeParser#processVisibleDataSetChanges --> ".concat(this.debugId, " Data set \"").concat(ds.name, "\" is already visible, skipping"));
|
|
950
|
-
|
|
951
|
-
// eslint-disable-next-line no-continue
|
|
952
|
-
continue;
|
|
953
|
-
}
|
|
954
|
-
_loggerProxy.default.logger.info("HashTreeParser#processVisibleDataSetChanges --> ".concat(this.debugId, " Adding visible data set \"").concat(ds.name, "\""));
|
|
955
|
-
if (!this.addToVisibleDataSetsList(ds)) {
|
|
956
|
-
// eslint-disable-next-line no-continue
|
|
957
|
-
continue;
|
|
958
|
-
}
|
|
959
|
-
var hashTree = new _hashTree.default([], dataSetInfo.leafCount);
|
|
960
|
-
this.dataSets[dataSetInfo.name] = _objectSpread(_objectSpread({}, dataSetInfo), {}, {
|
|
961
|
-
hashTree: hashTree
|
|
962
|
-
});
|
|
963
|
-
|
|
964
|
-
// this call is needed here for the edge case where we receive a message with new visible data sets
|
|
965
|
-
// and there are no objects belonging to these data sets in the message but we already have the info about them in this.dataSets
|
|
966
|
-
this.runSyncAlgorithm(this.dataSets[dataSetInfo.name]);
|
|
967
|
-
} else {
|
|
968
|
-
_loggerProxy.default.logger.info("HashTreeParser#processVisibleDataSetChanges --> ".concat(this.debugId, " visible data set \"").concat(ds.name, "\" added but no info about it in our dataSets structures"));
|
|
969
|
-
// todo: add a metric here
|
|
970
|
-
dataSetsRequiringInitialization.push(ds);
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
|
-
} catch (err) {
|
|
974
|
-
_iterator6.e(err);
|
|
975
|
-
} finally {
|
|
976
|
-
_iterator6.f();
|
|
977
|
-
}
|
|
978
|
-
return dataSetsRequiringInitialization;
|
|
979
|
-
}
|
|
980
|
-
|
|
981
|
-
/**
|
|
982
|
-
* Adds entries to the passed in updateObjects array
|
|
983
|
-
* for the changes that result from adding and removing visible data sets.
|
|
984
|
-
*
|
|
985
|
-
* @param {VisibleDataSetInfo[]} addedDataSets - The list of added data sets.
|
|
986
|
-
* @returns {Promise<void>}
|
|
987
|
-
*/
|
|
988
|
-
}, {
|
|
989
|
-
key: "initializeNewVisibleDataSets",
|
|
990
|
-
value: (function () {
|
|
991
|
-
var _initializeNewVisibleDataSets = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee4(addedDataSets) {
|
|
992
|
-
var _this0 = this;
|
|
993
|
-
var allDataSets, _iterator7, _step7, _loop, _t2;
|
|
994
|
-
return _regenerator.default.wrap(function (_context5) {
|
|
995
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
996
|
-
case 0:
|
|
997
|
-
if (!(this.state === 'stopped')) {
|
|
998
|
-
_context5.next = 1;
|
|
999
|
-
break;
|
|
1000
|
-
}
|
|
1001
|
-
return _context5.abrupt("return");
|
|
1002
|
-
case 1:
|
|
1003
|
-
_context5.next = 2;
|
|
1004
|
-
return this.getAllVisibleDataSetsFromLocus();
|
|
1005
|
-
case 2:
|
|
1006
|
-
allDataSets = _context5.sent;
|
|
1007
|
-
_iterator7 = _createForOfIteratorHelper(addedDataSets);
|
|
1008
|
-
_context5.prev = 3;
|
|
1009
|
-
_loop = /*#__PURE__*/_regenerator.default.mark(function _loop() {
|
|
1010
|
-
var ds, dataSetInfo, updates;
|
|
1011
|
-
return _regenerator.default.wrap(function (_context4) {
|
|
1012
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
1013
|
-
case 0:
|
|
1014
|
-
ds = _step7.value;
|
|
1015
|
-
dataSetInfo = allDataSets.find(function (d) {
|
|
1016
|
-
return d.name === ds.name;
|
|
1017
|
-
});
|
|
1018
|
-
_loggerProxy.default.logger.info("HashTreeParser#initializeNewVisibleDataSets --> ".concat(_this0.debugId, " initializing data set \"").concat(ds.name, "\""));
|
|
1019
|
-
if (dataSetInfo) {
|
|
1020
|
-
_context4.next = 1;
|
|
1021
|
-
break;
|
|
1022
|
-
}
|
|
1023
|
-
_loggerProxy.default.logger.warn("HashTreeParser#initializeNewVisibleDataSets --> ".concat(_this0.debugId, " missing info about data set \"").concat(ds.name, "\" in Locus response from visibleDataSetsUrl"));
|
|
1024
|
-
_context4.next = 3;
|
|
1025
|
-
break;
|
|
1026
|
-
case 1:
|
|
1027
|
-
_context4.next = 2;
|
|
1028
|
-
return _this0.initializeNewVisibleDataSet(ds, dataSetInfo);
|
|
1029
|
-
case 2:
|
|
1030
|
-
updates = _context4.sent;
|
|
1031
|
-
_this0.callLocusInfoUpdateCallback(updates);
|
|
1032
|
-
case 3:
|
|
1033
|
-
case "end":
|
|
1034
|
-
return _context4.stop();
|
|
1035
|
-
}
|
|
1036
|
-
}, _loop);
|
|
1037
|
-
});
|
|
1038
|
-
_iterator7.s();
|
|
1039
|
-
case 4:
|
|
1040
|
-
if ((_step7 = _iterator7.n()).done) {
|
|
1041
|
-
_context5.next = 6;
|
|
1042
|
-
break;
|
|
1043
|
-
}
|
|
1044
|
-
return _context5.delegateYield(_loop(), "t0", 5);
|
|
1045
|
-
case 5:
|
|
1046
|
-
_context5.next = 4;
|
|
1047
|
-
break;
|
|
1048
|
-
case 6:
|
|
1049
|
-
_context5.next = 8;
|
|
1050
|
-
break;
|
|
1051
|
-
case 7:
|
|
1052
|
-
_context5.prev = 7;
|
|
1053
|
-
_t2 = _context5["catch"](3);
|
|
1054
|
-
_iterator7.e(_t2);
|
|
1055
|
-
case 8:
|
|
1056
|
-
_context5.prev = 8;
|
|
1057
|
-
_iterator7.f();
|
|
1058
|
-
return _context5.finish(8);
|
|
1059
|
-
case 9:
|
|
1060
|
-
case "end":
|
|
1061
|
-
return _context5.stop();
|
|
1062
|
-
}
|
|
1063
|
-
}, _callee4, this, [[3, 7, 8, 9]]);
|
|
1064
|
-
}));
|
|
1065
|
-
function initializeNewVisibleDataSets(_x5) {
|
|
1066
|
-
return _initializeNewVisibleDataSets.apply(this, arguments);
|
|
1067
|
-
}
|
|
1068
|
-
return initializeNewVisibleDataSets;
|
|
1069
|
-
}()
|
|
1070
|
-
/**
|
|
1071
|
-
* Parses incoming hash tree messages, updates the hash trees and returns information about the changes
|
|
1072
|
-
*
|
|
1073
|
-
* @param {HashTreeMessage} message - The hash tree message containing data sets and objects to be processed
|
|
1074
|
-
* @param {string} [debugText] - Optional debug text to include in logs
|
|
1075
|
-
* @returns {HashTreeObject[]} list of hash tree objects that were updated as a result of processing the message
|
|
1076
|
-
*/
|
|
1077
|
-
)
|
|
1078
|
-
}, {
|
|
1079
|
-
key: "parseMessage",
|
|
1080
|
-
value: function parseMessage(message, debugText) {
|
|
1081
|
-
var _message$locusStateEl,
|
|
1082
|
-
_this1 = this,
|
|
1083
|
-
_message$locusStateEl2;
|
|
1084
|
-
if (this.state === 'stopped') {
|
|
1085
|
-
return [];
|
|
1086
|
-
}
|
|
1087
|
-
var dataSets = message.dataSets,
|
|
1088
|
-
visibleDataSetsUrl = message.visibleDataSetsUrl;
|
|
1089
|
-
_loggerProxy.default.logger.info("HashTreeParser#parseMessage --> ".concat(this.debugId, " received message ").concat(debugText || '', ":"), message);
|
|
1090
|
-
if (((_message$locusStateEl = message.locusStateElements) === null || _message$locusStateEl === void 0 ? void 0 : _message$locusStateEl.length) === 0) {
|
|
1091
|
-
_loggerProxy.default.logger.warn("HashTreeParser#parseMessage --> ".concat(this.debugId, " got empty locusStateElements!!!"));
|
|
1092
|
-
// todo: send a metric
|
|
1093
|
-
}
|
|
1094
|
-
|
|
1095
|
-
// first, update our metadata about the datasets with info from the message
|
|
1096
|
-
this.visibleDataSetsUrl = visibleDataSetsUrl;
|
|
1097
|
-
dataSets.forEach(function (dataSet) {
|
|
1098
|
-
return _this1.updateDataSetInfo(dataSet);
|
|
1099
|
-
});
|
|
1100
|
-
var updatedObjects = [];
|
|
1101
|
-
|
|
1102
|
-
// when we detect new visible datasets, it may be that the metadata about them is not
|
|
1103
|
-
// available in the message, they will require separate async initialization
|
|
1104
|
-
var dataSetsRequiringInitialization = [];
|
|
1105
|
-
|
|
1106
|
-
// first find out if there are any visible data set changes - they're signalled in Metadata object updates
|
|
1107
|
-
var metadataUpdates = (message.locusStateElements || []).filter(function (object) {
|
|
1108
|
-
return (0, _utils.isMetadata)(object);
|
|
1109
|
-
});
|
|
1110
|
-
if (metadataUpdates.length > 0) {
|
|
1111
|
-
var updatedMetadataObjects = [];
|
|
1112
|
-
metadataUpdates.forEach(function (object) {
|
|
1113
|
-
// todo: once Locus supports it, we will use the "view" field here instead of dataSetNames
|
|
1114
|
-
var _iterator8 = _createForOfIteratorHelper(object.htMeta.dataSetNames),
|
|
1115
|
-
_step8;
|
|
1116
|
-
try {
|
|
1117
|
-
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
1118
|
-
var _this1$dataSets$dataS;
|
|
1119
|
-
var dataSetName = _step8.value;
|
|
1120
|
-
var hashTree = (_this1$dataSets$dataS = _this1.dataSets[dataSetName]) === null || _this1$dataSets$dataS === void 0 ? void 0 : _this1$dataSets$dataS.hashTree;
|
|
1121
|
-
if (hashTree && object.data) {
|
|
1122
|
-
if (hashTree.putItem(object.htMeta.elementId)) {
|
|
1123
|
-
updatedMetadataObjects.push(object);
|
|
1124
|
-
}
|
|
1125
|
-
}
|
|
1126
|
-
}
|
|
1127
|
-
} catch (err) {
|
|
1128
|
-
_iterator8.e(err);
|
|
1129
|
-
} finally {
|
|
1130
|
-
_iterator8.f();
|
|
1131
|
-
}
|
|
1132
|
-
});
|
|
1133
|
-
updatedObjects.push.apply(updatedObjects, updatedMetadataObjects);
|
|
1134
|
-
var _this$checkForVisible2 = this.checkForVisibleDataSetChanges(updatedMetadataObjects),
|
|
1135
|
-
changeDetected = _this$checkForVisible2.changeDetected,
|
|
1136
|
-
removedDataSets = _this$checkForVisible2.removedDataSets,
|
|
1137
|
-
addedDataSets = _this$checkForVisible2.addedDataSets;
|
|
1138
|
-
if (changeDetected) {
|
|
1139
|
-
dataSetsRequiringInitialization = this.processVisibleDataSetChanges(removedDataSets, addedDataSets, updatedObjects);
|
|
1140
|
-
}
|
|
1141
|
-
}
|
|
1142
|
-
if (((_message$locusStateEl2 = message.locusStateElements) === null || _message$locusStateEl2 === void 0 ? void 0 : _message$locusStateEl2.length) > 0) {
|
|
1143
|
-
// by this point we now have this.dataSets setup for data sets from this message
|
|
1144
|
-
// and hash trees created for the new visible data sets,
|
|
1145
|
-
// so we can now process all the updates from the message
|
|
1146
|
-
dataSets.forEach(function (dataSet) {
|
|
1147
|
-
if (_this1.dataSets[dataSet.name]) {
|
|
1148
|
-
var hashTree = _this1.dataSets[dataSet.name].hashTree;
|
|
1149
|
-
if (hashTree) {
|
|
1150
|
-
var locusStateElementsForThisSet = message.locusStateElements.filter(function (object) {
|
|
1151
|
-
return object.htMeta.dataSetNames.includes(dataSet.name);
|
|
1152
|
-
});
|
|
1153
|
-
var appliedChangesList = hashTree.updateItems(locusStateElementsForThisSet.map(function (object) {
|
|
1154
|
-
return object.data ? {
|
|
1155
|
-
operation: 'update',
|
|
1156
|
-
item: object.htMeta.elementId
|
|
1157
|
-
} : {
|
|
1158
|
-
operation: 'remove',
|
|
1159
|
-
item: object.htMeta.elementId
|
|
1160
|
-
};
|
|
1161
|
-
}));
|
|
1162
|
-
(0, _lodash.zip)(appliedChangesList, locusStateElementsForThisSet).forEach(function (_ref5) {
|
|
1163
|
-
var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
|
|
1164
|
-
changeApplied = _ref6[0],
|
|
1165
|
-
object = _ref6[1];
|
|
1166
|
-
if (changeApplied) {
|
|
1167
|
-
// add to updatedObjects so that our locus DTO will get updated with the new object
|
|
1168
|
-
updatedObjects.push(object);
|
|
1169
|
-
}
|
|
1170
|
-
});
|
|
1171
|
-
} else {
|
|
1172
|
-
_loggerProxy.default.logger.info("Locus-info:index#parseMessage --> ".concat(_this1.debugId, " unexpected (not visible) dataSet ").concat(dataSet.name, " received in hash tree message"));
|
|
1173
|
-
}
|
|
1174
|
-
}
|
|
1175
|
-
_this1.runSyncAlgorithm(dataSet);
|
|
1176
|
-
});
|
|
1177
|
-
}
|
|
1178
|
-
if (dataSetsRequiringInitialization.length > 0) {
|
|
1179
|
-
// there are some data sets that we need to initialize asynchronously
|
|
1180
|
-
this.queueInitForNewVisibleDataSets(dataSetsRequiringInitialization);
|
|
1181
|
-
}
|
|
1182
|
-
if (updatedObjects.length === 0) {
|
|
1183
|
-
_loggerProxy.default.logger.info("HashTreeParser#parseMessage --> ".concat(this.debugId, " No objects updated as a result of received message"));
|
|
1184
|
-
}
|
|
1185
|
-
return updatedObjects;
|
|
135
|
+
// todo
|
|
1186
136
|
}
|
|
1187
137
|
|
|
1188
138
|
/**
|
|
@@ -1194,505 +144,21 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1194
144
|
*/
|
|
1195
145
|
}, {
|
|
1196
146
|
key: "handleMessage",
|
|
1197
|
-
value: function handleMessage(message, debugText) {
|
|
1198
|
-
if (this.state === 'stopped') {
|
|
1199
|
-
return;
|
|
1200
|
-
}
|
|
1201
|
-
if (message.heartbeatIntervalMs) {
|
|
1202
|
-
this.heartbeatIntervalMs = message.heartbeatIntervalMs;
|
|
1203
|
-
}
|
|
1204
|
-
if (this.isEndMessage(message)) {
|
|
1205
|
-
_loggerProxy.default.logger.info("HashTreeParser#handleMessage --> ".concat(this.debugId, " received sentinel END MEETING message"));
|
|
1206
|
-
this.stopAllTimers();
|
|
1207
|
-
this.callLocusInfoUpdateCallback({
|
|
1208
|
-
updateType: LocusInfoUpdateType.MEETING_ENDED
|
|
1209
|
-
});
|
|
1210
|
-
} else if (message.locusStateElements === undefined) {
|
|
1211
|
-
this.handleRootHashHeartBeatMessage(message);
|
|
1212
|
-
this.resetHeartbeatWatchdogs(message.dataSets);
|
|
1213
|
-
} else {
|
|
1214
|
-
var updatedObjects = this.parseMessage(message, debugText);
|
|
1215
|
-
this.resetHeartbeatWatchdogs(message.dataSets);
|
|
1216
|
-
this.callLocusInfoUpdateCallback({
|
|
1217
|
-
updateType: LocusInfoUpdateType.OBJECTS_UPDATED,
|
|
1218
|
-
updatedObjects: updatedObjects
|
|
1219
|
-
});
|
|
1220
|
-
}
|
|
1221
|
-
}
|
|
1222
|
-
|
|
1223
|
-
/**
|
|
1224
|
-
* Calls the updateInfo callback if there are any updates to report
|
|
1225
|
-
*
|
|
1226
|
-
* @param {Object} updates parsed from a Locus message
|
|
1227
|
-
* @returns {void}
|
|
1228
|
-
*/
|
|
1229
|
-
}, {
|
|
1230
|
-
key: "callLocusInfoUpdateCallback",
|
|
1231
|
-
value: function callLocusInfoUpdateCallback(updates) {
|
|
1232
|
-
var _this10 = this;
|
|
1233
|
-
if (this.state === 'stopped') {
|
|
1234
|
-
return;
|
|
1235
|
-
}
|
|
1236
|
-
var updateType = updates.updateType,
|
|
1237
|
-
updatedObjects = updates.updatedObjects;
|
|
1238
|
-
if (updateType === LocusInfoUpdateType.OBJECTS_UPDATED && (updatedObjects === null || updatedObjects === void 0 ? void 0 : updatedObjects.length) > 0) {
|
|
1239
|
-
// Filter out updates for objects that already have a higher version in their datasets,
|
|
1240
|
-
// or removals for objects that still exist in any of their datasets
|
|
1241
|
-
var filteredUpdates = updatedObjects.filter(function (object) {
|
|
1242
|
-
var elementId = object.htMeta.elementId;
|
|
1243
|
-
var type = elementId.type,
|
|
1244
|
-
id = elementId.id,
|
|
1245
|
-
version = elementId.version;
|
|
1246
|
-
|
|
1247
|
-
// Check all datasets
|
|
1248
|
-
for (var _i2 = 0, _Object$keys3 = (0, _keys.default)(_this10.dataSets); _i2 < _Object$keys3.length; _i2++) {
|
|
1249
|
-
var dataSetName = _Object$keys3[_i2];
|
|
1250
|
-
var dataSet = _this10.dataSets[dataSetName];
|
|
1251
|
-
|
|
1252
|
-
// only visible datasets have hash trees set
|
|
1253
|
-
if (dataSet !== null && dataSet !== void 0 && dataSet.hashTree) {
|
|
1254
|
-
var existingVersion = dataSet.hashTree.getItemVersion(id, type);
|
|
1255
|
-
if (existingVersion !== undefined) {
|
|
1256
|
-
if (object.data) {
|
|
1257
|
-
// For updates: filter out if any dataset has a higher version
|
|
1258
|
-
if (existingVersion > version) {
|
|
1259
|
-
_loggerProxy.default.logger.info("HashTreeParser#callLocusInfoUpdateCallback --> ".concat(_this10.debugId, " Filtering out update for ").concat(type, ":").concat(id, " v").concat(version, " because dataset \"").concat(dataSetName, "\" has v").concat(existingVersion));
|
|
1260
|
-
return false;
|
|
1261
|
-
}
|
|
1262
|
-
} else if (existingVersion >= version) {
|
|
1263
|
-
// For removals: filter out if the object still exists in any dataset
|
|
1264
|
-
_loggerProxy.default.logger.info("HashTreeParser#callLocusInfoUpdateCallback --> ".concat(_this10.debugId, " Filtering out removal for ").concat(type, ":").concat(id, " v").concat(version, " because dataset \"").concat(dataSetName, "\" still has v").concat(existingVersion));
|
|
1265
|
-
return false;
|
|
1266
|
-
}
|
|
1267
|
-
}
|
|
1268
|
-
}
|
|
1269
|
-
}
|
|
1270
|
-
return true;
|
|
1271
|
-
});
|
|
1272
|
-
if (filteredUpdates.length > 0) {
|
|
1273
|
-
this.locusInfoUpdateCallback(updateType, {
|
|
1274
|
-
updatedObjects: filteredUpdates
|
|
1275
|
-
});
|
|
1276
|
-
}
|
|
1277
|
-
} else if (updateType !== LocusInfoUpdateType.OBJECTS_UPDATED) {
|
|
1278
|
-
this.locusInfoUpdateCallback(updateType, {
|
|
1279
|
-
updatedObjects: updatedObjects
|
|
1280
|
-
});
|
|
1281
|
-
}
|
|
1282
|
-
}
|
|
1283
|
-
|
|
1284
|
-
/**
|
|
1285
|
-
* Calculates a weighted backoff time that should be used for syncs
|
|
1286
|
-
*
|
|
1287
|
-
* @param {Object} backoff - The backoff configuration containing maxMs and exponent
|
|
1288
|
-
* @returns {number} - A weighted backoff time based on the provided configuration, using algorithm supplied by Locus team
|
|
1289
|
-
*/
|
|
1290
|
-
}, {
|
|
1291
|
-
key: "getWeightedBackoffTime",
|
|
1292
|
-
value: function getWeightedBackoffTime(backoff) {
|
|
1293
|
-
var maxMs = backoff.maxMs,
|
|
1294
|
-
exponent = backoff.exponent;
|
|
1295
|
-
var randomValue = Math.random();
|
|
1296
|
-
return Math.round(Math.pow(randomValue, exponent) * maxMs);
|
|
1297
|
-
}
|
|
1298
|
-
|
|
1299
|
-
/**
|
|
1300
|
-
* Performs a sync for the given data set.
|
|
1301
|
-
*
|
|
1302
|
-
* @param {InternalDataSet} dataSet - The data set to sync
|
|
1303
|
-
* @param {string} rootHash - Our current root hash for this data set
|
|
1304
|
-
* @param {string} reason - The reason for the sync (used for logging)
|
|
1305
|
-
* @returns {Promise<void>}
|
|
1306
|
-
*/
|
|
1307
|
-
}, {
|
|
1308
|
-
key: "performSync",
|
|
1309
147
|
value: (function () {
|
|
1310
|
-
var
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
148
|
+
var _handleMessage = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee3(message, debugText) {
|
|
149
|
+
return _regenerator.default.wrap(function (_context3) {
|
|
150
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
1314
151
|
case 0:
|
|
1315
|
-
if (dataSet.hashTree) {
|
|
1316
|
-
_context6.next = 1;
|
|
1317
|
-
break;
|
|
1318
|
-
}
|
|
1319
|
-
return _context6.abrupt("return");
|
|
1320
|
-
case 1:
|
|
1321
|
-
_context6.prev = 1;
|
|
1322
|
-
_loggerProxy.default.logger.info("HashTreeParser#performSync --> ".concat(this.debugId, " ").concat(reason, ", syncing data set \"").concat(dataSet.name, "\""));
|
|
1323
|
-
mismatchedLeavesData = {};
|
|
1324
|
-
if (!(dataSet.leafCount !== 1)) {
|
|
1325
|
-
_context6.next = 7;
|
|
1326
|
-
break;
|
|
1327
|
-
}
|
|
1328
|
-
_context6.prev = 2;
|
|
1329
|
-
_context6.next = 3;
|
|
1330
|
-
return this.getHashesFromLocus(dataSet.name, rootHash);
|
|
1331
|
-
case 3:
|
|
1332
|
-
_yield$this$getHashes = _context6.sent;
|
|
1333
|
-
hashes = _yield$this$getHashes.hashes;
|
|
1334
|
-
latestDataSetInfo = _yield$this$getHashes.dataSet;
|
|
1335
|
-
receivedHashes = hashes;
|
|
1336
|
-
dataSet.hashTree.resize(latestDataSetInfo.leafCount);
|
|
1337
|
-
_context6.next = 6;
|
|
1338
|
-
break;
|
|
1339
|
-
case 4:
|
|
1340
|
-
_context6.prev = 4;
|
|
1341
|
-
_t3 = _context6["catch"](2);
|
|
1342
|
-
if (!(_t3.statusCode === 409)) {
|
|
1343
|
-
_context6.next = 5;
|
|
1344
|
-
break;
|
|
1345
|
-
}
|
|
1346
|
-
// this is a leaf count mismatch, we should do nothing, just wait for another heartbeat message from Locus
|
|
1347
|
-
_loggerProxy.default.logger.info("HashTreeParser#getHashesFromLocus --> ".concat(this.debugId, " Got 409 when fetching hashes for data set \"").concat(dataSet.name, "\": ").concat(_t3.message));
|
|
1348
|
-
return _context6.abrupt("return");
|
|
1349
|
-
case 5:
|
|
1350
|
-
throw _t3;
|
|
1351
|
-
case 6:
|
|
1352
|
-
// identify mismatched leaves
|
|
1353
|
-
mismatchedLeaveIndexes = dataSet.hashTree.diffHashes(receivedHashes);
|
|
1354
|
-
mismatchedLeaveIndexes.forEach(function (index) {
|
|
1355
|
-
mismatchedLeavesData[index] = dataSet.hashTree.getLeafData(index);
|
|
1356
|
-
});
|
|
1357
|
-
_context6.next = 8;
|
|
1358
|
-
break;
|
|
1359
|
-
case 7:
|
|
1360
|
-
mismatchedLeavesData[0] = dataSet.hashTree.getLeafData(0);
|
|
1361
|
-
case 8:
|
|
1362
|
-
if (!((0, _keys.default)(mismatchedLeavesData).length > 0)) {
|
|
1363
|
-
_context6.next = 10;
|
|
1364
|
-
break;
|
|
1365
|
-
}
|
|
1366
|
-
_context6.next = 9;
|
|
1367
|
-
return this.sendSyncRequestToLocus(dataSet, mismatchedLeavesData);
|
|
1368
|
-
case 9:
|
|
1369
|
-
syncResponse = _context6.sent;
|
|
1370
|
-
// sync API may return nothing (in that case data will arrive via messages)
|
|
1371
|
-
// or it may return a response in the same format as messages
|
|
1372
|
-
if (syncResponse) {
|
|
1373
|
-
this.handleMessage(syncResponse, 'via sync API');
|
|
1374
|
-
}
|
|
1375
|
-
case 10:
|
|
1376
|
-
_context6.next = 12;
|
|
1377
|
-
break;
|
|
1378
|
-
case 11:
|
|
1379
|
-
_context6.prev = 11;
|
|
1380
|
-
_t4 = _context6["catch"](1);
|
|
1381
|
-
if (_t4 instanceof MeetingEndedError) {
|
|
1382
|
-
this.callLocusInfoUpdateCallback({
|
|
1383
|
-
updateType: LocusInfoUpdateType.MEETING_ENDED
|
|
1384
|
-
});
|
|
1385
|
-
} else {
|
|
1386
|
-
_loggerProxy.default.logger.warn("HashTreeParser#performSync --> ".concat(this.debugId, " error during sync for data set \"").concat(dataSet.name, "\":"), _t4);
|
|
1387
|
-
}
|
|
1388
|
-
case 12:
|
|
1389
152
|
case "end":
|
|
1390
|
-
return
|
|
153
|
+
return _context3.stop();
|
|
1391
154
|
}
|
|
1392
|
-
},
|
|
155
|
+
}, _callee3);
|
|
1393
156
|
}));
|
|
1394
|
-
function
|
|
1395
|
-
return
|
|
1396
|
-
}
|
|
1397
|
-
return performSync;
|
|
1398
|
-
}()
|
|
1399
|
-
/**
|
|
1400
|
-
* Runs the sync algorithm for the given data set.
|
|
1401
|
-
*
|
|
1402
|
-
* @param {DataSet} receivedDataSet - The data set to run the sync algorithm for.
|
|
1403
|
-
* @returns {void}
|
|
1404
|
-
*/
|
|
1405
|
-
)
|
|
1406
|
-
}, {
|
|
1407
|
-
key: "runSyncAlgorithm",
|
|
1408
|
-
value: function runSyncAlgorithm(receivedDataSet) {
|
|
1409
|
-
var _this11 = this;
|
|
1410
|
-
var dataSet = this.dataSets[receivedDataSet.name];
|
|
1411
|
-
if (!dataSet) {
|
|
1412
|
-
_loggerProxy.default.logger.warn("HashTreeParser#runSyncAlgorithm --> ".concat(this.debugId, " No data set found for ").concat(receivedDataSet.name, ", skipping sync algorithm"));
|
|
1413
|
-
return;
|
|
1414
|
-
}
|
|
1415
|
-
if (!dataSet.hashTree) {
|
|
1416
|
-
_loggerProxy.default.logger.info("HashTreeParser#runSyncAlgorithm --> ".concat(this.debugId, " Data set \"").concat(dataSet.name, "\" has no hash tree, skipping sync algorithm"));
|
|
1417
|
-
return;
|
|
1418
|
-
}
|
|
1419
|
-
dataSet.hashTree.resize(receivedDataSet.leafCount);
|
|
1420
|
-
|
|
1421
|
-
// temporary log for the workshop // todo: remove
|
|
1422
|
-
var ourCurrentRootHash = dataSet.hashTree.getRootHash();
|
|
1423
|
-
_loggerProxy.default.logger.info("HashTreeParser#runSyncAlgorithm --> ".concat(this.debugId, " dataSet=\"").concat(dataSet.name, "\" version=").concat(dataSet.version, " hashes before starting timer: ours=").concat(ourCurrentRootHash, " Locus=").concat(dataSet.root));
|
|
1424
|
-
var delay = dataSet.idleMs + this.getWeightedBackoffTime(dataSet.backoff);
|
|
1425
|
-
if (delay > 0) {
|
|
1426
|
-
if (dataSet.timer) {
|
|
1427
|
-
clearTimeout(dataSet.timer);
|
|
1428
|
-
}
|
|
1429
|
-
_loggerProxy.default.logger.info("HashTreeParser#runSyncAlgorithm --> ".concat(this.debugId, " setting \"").concat(dataSet.name, "\" sync timer for ").concat(delay));
|
|
1430
|
-
dataSet.timer = setTimeout(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee6() {
|
|
1431
|
-
var rootHash;
|
|
1432
|
-
return _regenerator.default.wrap(function (_context7) {
|
|
1433
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
1434
|
-
case 0:
|
|
1435
|
-
dataSet.timer = undefined;
|
|
1436
|
-
if (dataSet.hashTree) {
|
|
1437
|
-
_context7.next = 1;
|
|
1438
|
-
break;
|
|
1439
|
-
}
|
|
1440
|
-
_loggerProxy.default.logger.warn("HashTreeParser#runSyncAlgorithm --> ".concat(_this11.debugId, " Data set \"").concat(dataSet.name, "\" no longer has a hash tree, cannot run sync algorithm"));
|
|
1441
|
-
return _context7.abrupt("return");
|
|
1442
|
-
case 1:
|
|
1443
|
-
rootHash = dataSet.hashTree.getRootHash();
|
|
1444
|
-
if (!(dataSet.root !== rootHash)) {
|
|
1445
|
-
_context7.next = 3;
|
|
1446
|
-
break;
|
|
1447
|
-
}
|
|
1448
|
-
_context7.next = 2;
|
|
1449
|
-
return _this11.performSync(dataSet, rootHash, "Root hash mismatch: received=".concat(dataSet.root, ", ours=").concat(rootHash));
|
|
1450
|
-
case 2:
|
|
1451
|
-
_context7.next = 4;
|
|
1452
|
-
break;
|
|
1453
|
-
case 3:
|
|
1454
|
-
_loggerProxy.default.logger.info("HashTreeParser#runSyncAlgorithm --> ".concat(_this11.debugId, " \"").concat(dataSet.name, "\" root hash matching: ").concat(rootHash, ", version=").concat(dataSet.version));
|
|
1455
|
-
case 4:
|
|
1456
|
-
case "end":
|
|
1457
|
-
return _context7.stop();
|
|
1458
|
-
}
|
|
1459
|
-
}, _callee6);
|
|
1460
|
-
})), delay);
|
|
1461
|
-
} else {
|
|
1462
|
-
_loggerProxy.default.logger.info("HashTreeParser#runSyncAlgorithm --> ".concat(this.debugId, " No delay for \"").concat(dataSet.name, "\" data set, skipping sync timer reset/setup"));
|
|
1463
|
-
}
|
|
1464
|
-
}
|
|
1465
|
-
|
|
1466
|
-
/**
|
|
1467
|
-
* Resets the heartbeat watchdog timers for the specified data sets. Each data set has its own
|
|
1468
|
-
* watchdog timer that monitors whether heartbeats are being received within the expected interval.
|
|
1469
|
-
* If a heartbeat is not received for a specific data set within heartbeatIntervalMs plus
|
|
1470
|
-
* a backoff-calculated time, the sync algorithm is initiated for that data set
|
|
1471
|
-
*
|
|
1472
|
-
* @param {Array<DataSet>} receivedDataSets - The data sets from the received message for which watchdog timers should be reset
|
|
1473
|
-
* @returns {void}
|
|
1474
|
-
*/
|
|
1475
|
-
}, {
|
|
1476
|
-
key: "resetHeartbeatWatchdogs",
|
|
1477
|
-
value: function resetHeartbeatWatchdogs(receivedDataSets) {
|
|
1478
|
-
var _this12 = this;
|
|
1479
|
-
if (!this.heartbeatIntervalMs) {
|
|
1480
|
-
return;
|
|
1481
|
-
}
|
|
1482
|
-
var _iterator9 = _createForOfIteratorHelper(receivedDataSets),
|
|
1483
|
-
_step9;
|
|
1484
|
-
try {
|
|
1485
|
-
var _loop2 = function _loop2() {
|
|
1486
|
-
var receivedDataSet = _step9.value;
|
|
1487
|
-
var dataSet = _this12.dataSets[receivedDataSet.name];
|
|
1488
|
-
if (!(dataSet !== null && dataSet !== void 0 && dataSet.hashTree)) {
|
|
1489
|
-
// eslint-disable-next-line no-continue
|
|
1490
|
-
return 1; // continue
|
|
1491
|
-
}
|
|
1492
|
-
if (dataSet.heartbeatWatchdogTimer) {
|
|
1493
|
-
clearTimeout(dataSet.heartbeatWatchdogTimer);
|
|
1494
|
-
dataSet.heartbeatWatchdogTimer = undefined;
|
|
1495
|
-
}
|
|
1496
|
-
var backoffTime = _this12.getWeightedBackoffTime(dataSet.backoff);
|
|
1497
|
-
var delay = _this12.heartbeatIntervalMs + backoffTime;
|
|
1498
|
-
dataSet.heartbeatWatchdogTimer = setTimeout(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee7() {
|
|
1499
|
-
return _regenerator.default.wrap(function (_context8) {
|
|
1500
|
-
while (1) switch (_context8.prev = _context8.next) {
|
|
1501
|
-
case 0:
|
|
1502
|
-
dataSet.heartbeatWatchdogTimer = undefined;
|
|
1503
|
-
_loggerProxy.default.logger.warn("HashTreeParser#resetHeartbeatWatchdogs --> ".concat(_this12.debugId, " Heartbeat watchdog fired for data set \"").concat(dataSet.name, "\" - no heartbeat received within expected interval, initiating sync"));
|
|
1504
|
-
_context8.next = 1;
|
|
1505
|
-
return _this12.performSync(dataSet, dataSet.hashTree.getRootHash(), "heartbeat watchdog expired");
|
|
1506
|
-
case 1:
|
|
1507
|
-
case "end":
|
|
1508
|
-
return _context8.stop();
|
|
1509
|
-
}
|
|
1510
|
-
}, _callee7);
|
|
1511
|
-
})), delay);
|
|
1512
|
-
};
|
|
1513
|
-
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
1514
|
-
if (_loop2()) continue;
|
|
1515
|
-
}
|
|
1516
|
-
} catch (err) {
|
|
1517
|
-
_iterator9.e(err);
|
|
1518
|
-
} finally {
|
|
1519
|
-
_iterator9.f();
|
|
1520
|
-
}
|
|
1521
|
-
}
|
|
1522
|
-
|
|
1523
|
-
/**
|
|
1524
|
-
* Stops all timers for the data sets to prevent any further sync attempts.
|
|
1525
|
-
* @returns {void}
|
|
1526
|
-
*/
|
|
1527
|
-
}, {
|
|
1528
|
-
key: "stopAllTimers",
|
|
1529
|
-
value: function stopAllTimers() {
|
|
1530
|
-
(0, _values.default)(this.dataSets).forEach(function (dataSet) {
|
|
1531
|
-
if (dataSet.timer) {
|
|
1532
|
-
clearTimeout(dataSet.timer);
|
|
1533
|
-
dataSet.timer = undefined;
|
|
1534
|
-
}
|
|
1535
|
-
if (dataSet.heartbeatWatchdogTimer) {
|
|
1536
|
-
clearTimeout(dataSet.heartbeatWatchdogTimer);
|
|
1537
|
-
dataSet.heartbeatWatchdogTimer = undefined;
|
|
1538
|
-
}
|
|
1539
|
-
});
|
|
1540
|
-
}
|
|
1541
|
-
|
|
1542
|
-
/**
|
|
1543
|
-
* Stops the HashTreeParser, preventing it from processing any further messages and clearing all timers.
|
|
1544
|
-
* It also clears all the hash trees, so if the parser is resumed later, it will need to do a sync
|
|
1545
|
-
* to be up-to-date.
|
|
1546
|
-
* @returns {void}
|
|
1547
|
-
*/
|
|
1548
|
-
}, {
|
|
1549
|
-
key: "stop",
|
|
1550
|
-
value: function stop() {
|
|
1551
|
-
_loggerProxy.default.logger.info("HashTreeParser#stop --> ".concat(this.debugId, " Stopping HashTreeParser, clearing timers and hash trees"));
|
|
1552
|
-
this.stopAllTimers();
|
|
1553
|
-
(0, _values.default)(this.dataSets).forEach(function (dataSet) {
|
|
1554
|
-
dataSet.hashTree = undefined;
|
|
1555
|
-
});
|
|
1556
|
-
this.visibleDataSets = [];
|
|
1557
|
-
this.state = 'stopped';
|
|
1558
|
-
}
|
|
1559
|
-
|
|
1560
|
-
/**
|
|
1561
|
-
* Resumes the HashTreeParser that was previously stopped.
|
|
1562
|
-
* @param {HashTreeMessage} message - The message to resume with, it must contain metadata with visible data sets info
|
|
1563
|
-
* @returns {void}
|
|
1564
|
-
*/
|
|
1565
|
-
}, {
|
|
1566
|
-
key: "resume",
|
|
1567
|
-
value: function resume(message) {
|
|
1568
|
-
var _message$locusStateEl3, _metadataObject$data;
|
|
1569
|
-
// check that message contains metadata with visible data sets - this is essential to be able to resume
|
|
1570
|
-
var metadataObject = (_message$locusStateEl3 = message.locusStateElements) === null || _message$locusStateEl3 === void 0 ? void 0 : _message$locusStateEl3.find(function (el) {
|
|
1571
|
-
return (0, _utils.isMetadata)(el);
|
|
1572
|
-
});
|
|
1573
|
-
if (!(metadataObject !== null && metadataObject !== void 0 && (_metadataObject$data = metadataObject.data) !== null && _metadataObject$data !== void 0 && _metadataObject$data.visibleDataSets)) {
|
|
1574
|
-
_loggerProxy.default.logger.warn("HashTreeParser#resume --> ".concat(this.debugId, " Cannot resume HashTreeParser because the message is missing metadata with visible data sets info"));
|
|
1575
|
-
return;
|
|
1576
|
-
}
|
|
1577
|
-
this.setVisibleDataSets(metadataObject.data.visibleDataSets, message.dataSets);
|
|
1578
|
-
this.dataSets = {};
|
|
1579
|
-
var _iterator0 = _createForOfIteratorHelper(message.dataSets),
|
|
1580
|
-
_step0;
|
|
1581
|
-
try {
|
|
1582
|
-
for (_iterator0.s(); !(_step0 = _iterator0.n()).done;) {
|
|
1583
|
-
var dataSet = _step0.value;
|
|
1584
|
-
var name = dataSet.name,
|
|
1585
|
-
leafCount = dataSet.leafCount;
|
|
1586
|
-
this.dataSets[name] = _objectSpread(_objectSpread({}, dataSet), {}, {
|
|
1587
|
-
hashTree: this.isVisibleDataSet(name) ? new _hashTree.default([], leafCount) : undefined
|
|
1588
|
-
});
|
|
1589
|
-
}
|
|
1590
|
-
} catch (err) {
|
|
1591
|
-
_iterator0.e(err);
|
|
1592
|
-
} finally {
|
|
1593
|
-
_iterator0.f();
|
|
157
|
+
function handleMessage(_x3, _x4) {
|
|
158
|
+
return _handleMessage.apply(this, arguments);
|
|
1594
159
|
}
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
}).join(', ')));
|
|
1598
|
-
this.state = 'active';
|
|
1599
|
-
this.handleMessage(message, 'on resume');
|
|
1600
|
-
}
|
|
1601
|
-
}, {
|
|
1602
|
-
key: "checkForSentinelHttpResponse",
|
|
1603
|
-
value: function checkForSentinelHttpResponse(error, dataSetName) {
|
|
1604
|
-
var _error$body;
|
|
1605
|
-
var isValidDataSetForSentinel = dataSetName === undefined || PossibleSentinelMessageDataSetNames.includes(dataSetName.toLowerCase());
|
|
1606
|
-
if ((error.statusCode === 409 && ((_error$body = error.body) === null || _error$body === void 0 ? void 0 : _error$body.errorCode) === 2403004 || error.statusCode === 404) && isValidDataSetForSentinel) {
|
|
1607
|
-
_loggerProxy.default.logger.info("HashTreeParser#checkForSentinelHttpResponse --> ".concat(this.debugId, " Received ").concat(error.statusCode, " for data set \"").concat(dataSetName, "\", indicating that the meeting has ended"));
|
|
1608
|
-
this.stopAllTimers();
|
|
1609
|
-
throw new MeetingEndedError();
|
|
1610
|
-
}
|
|
1611
|
-
}
|
|
1612
|
-
|
|
1613
|
-
/**
|
|
1614
|
-
* Gets the current hashes from the locus for a specific data set.
|
|
1615
|
-
* @param {string} dataSetName
|
|
1616
|
-
* @param {string} currentRootHash
|
|
1617
|
-
* @returns {string[]}
|
|
1618
|
-
*/
|
|
1619
|
-
}, {
|
|
1620
|
-
key: "getHashesFromLocus",
|
|
1621
|
-
value: function getHashesFromLocus(dataSetName, currentRootHash) {
|
|
1622
|
-
var _this13 = this;
|
|
1623
|
-
_loggerProxy.default.logger.info("HashTreeParser#getHashesFromLocus --> ".concat(this.debugId, " Requesting hashes for data set \"").concat(dataSetName, "\""));
|
|
1624
|
-
var dataSet = this.dataSets[dataSetName];
|
|
1625
|
-
var url = "".concat(dataSet.url, "/hashtree");
|
|
1626
|
-
return this.webexRequest({
|
|
1627
|
-
method: _constants.HTTP_VERBS.GET,
|
|
1628
|
-
uri: url,
|
|
1629
|
-
qs: {
|
|
1630
|
-
rootHash: currentRootHash
|
|
1631
|
-
}
|
|
1632
|
-
}).then(function (response) {
|
|
1633
|
-
var _response$body, _response$body2;
|
|
1634
|
-
var hashes = (_response$body = response.body) === null || _response$body === void 0 ? void 0 : _response$body.hashes;
|
|
1635
|
-
var dataSetFromResponse = (_response$body2 = response.body) === null || _response$body2 === void 0 ? void 0 : _response$body2.dataSet;
|
|
1636
|
-
if (!hashes || !(0, _isArray.default)(hashes)) {
|
|
1637
|
-
_loggerProxy.default.logger.warn("HashTreeParser#getHashesFromLocus --> ".concat(_this13.debugId, " Locus returned invalid hashes, response body="), response.body);
|
|
1638
|
-
throw new Error("Locus returned invalid hashes: ".concat(hashes));
|
|
1639
|
-
}
|
|
1640
|
-
_loggerProxy.default.logger.info("HashTreeParser#getHashesFromLocus --> ".concat(_this13.debugId, " Received hashes for data set \"").concat(dataSetName, "\": ").concat((0, _stringify.default)(hashes)));
|
|
1641
|
-
return {
|
|
1642
|
-
hashes: hashes,
|
|
1643
|
-
dataSet: dataSetFromResponse
|
|
1644
|
-
};
|
|
1645
|
-
}).catch(function (error) {
|
|
1646
|
-
_loggerProxy.default.logger.error("HashTreeParser#getHashesFromLocus --> ".concat(_this13.debugId, " Error ").concat(error.statusCode, " fetching hashes for data set \"").concat(dataSetName, "\":"), error);
|
|
1647
|
-
_this13.checkForSentinelHttpResponse(error, dataSet.name);
|
|
1648
|
-
throw error;
|
|
1649
|
-
});
|
|
1650
|
-
}
|
|
1651
|
-
|
|
1652
|
-
/**
|
|
1653
|
-
* Sends a sync request to Locus for the specified data set.
|
|
1654
|
-
*
|
|
1655
|
-
* @param {InternalDataSet} dataSet The data set to sync.
|
|
1656
|
-
* @param {Record<number, LeafDataItem[]>} mismatchedLeavesData The mismatched leaves data to include in the sync request.
|
|
1657
|
-
* @returns {Promise<HashTreeMessage|null>}
|
|
1658
|
-
*/
|
|
1659
|
-
}, {
|
|
1660
|
-
key: "sendSyncRequestToLocus",
|
|
1661
|
-
value: function sendSyncRequestToLocus(dataSet, mismatchedLeavesData) {
|
|
1662
|
-
var _this14 = this;
|
|
1663
|
-
_loggerProxy.default.logger.info("HashTreeParser#sendSyncRequestToLocus --> ".concat(this.debugId, " Sending sync request for data set \"").concat(dataSet.name, "\""));
|
|
1664
|
-
var url = "".concat(dataSet.url, "/sync");
|
|
1665
|
-
var body = {
|
|
1666
|
-
leafCount: dataSet.leafCount,
|
|
1667
|
-
leafDataEntries: []
|
|
1668
|
-
};
|
|
1669
|
-
(0, _keys.default)(mismatchedLeavesData).forEach(function (index) {
|
|
1670
|
-
body.leafDataEntries.push({
|
|
1671
|
-
leafIndex: (0, _parseInt2.default)(index, 10),
|
|
1672
|
-
elementIds: mismatchedLeavesData[index]
|
|
1673
|
-
});
|
|
1674
|
-
});
|
|
1675
|
-
var ourCurrentRootHash = dataSet.hashTree ? dataSet.hashTree.getRootHash() : _constants2.EMPTY_HASH;
|
|
1676
|
-
return this.webexRequest({
|
|
1677
|
-
method: _constants.HTTP_VERBS.POST,
|
|
1678
|
-
uri: url,
|
|
1679
|
-
qs: {
|
|
1680
|
-
rootHash: ourCurrentRootHash
|
|
1681
|
-
},
|
|
1682
|
-
body: body
|
|
1683
|
-
}).then(function (resp) {
|
|
1684
|
-
_loggerProxy.default.logger.info("HashTreeParser#sendSyncRequestToLocus --> ".concat(_this14.debugId, " Sync request succeeded for \"").concat(dataSet.name, "\""));
|
|
1685
|
-
if (!resp.body || (0, _lodash.isEmpty)(resp.body)) {
|
|
1686
|
-
_loggerProxy.default.logger.info("HashTreeParser#sendSyncRequestToLocus --> ".concat(_this14.debugId, " Got ").concat(resp.statusCode, " with empty body for sync request for data set \"").concat(dataSet.name, "\", data should arrive via messages"));
|
|
1687
|
-
return null;
|
|
1688
|
-
}
|
|
1689
|
-
return resp.body;
|
|
1690
|
-
}).catch(function (error) {
|
|
1691
|
-
_loggerProxy.default.logger.error("HashTreeParser#sendSyncRequestToLocus --> ".concat(_this14.debugId, " Error ").concat(error.statusCode, " sending sync request for data set \"").concat(dataSet.name, "\":"), error);
|
|
1692
|
-
_this14.checkForSentinelHttpResponse(error, dataSet.name);
|
|
1693
|
-
throw error;
|
|
1694
|
-
});
|
|
1695
|
-
}
|
|
160
|
+
return handleMessage;
|
|
161
|
+
}())
|
|
1696
162
|
}]);
|
|
1697
163
|
}();
|
|
1698
164
|
var _default = exports.default = HashTreeParser;
|