@webex/plugin-meetings 3.12.0-next.23 → 3.12.0-next.25

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.
@@ -1282,7 +1282,7 @@ var HashTreeParser = /*#__PURE__*/function () {
1282
1282
  key: "performSync",
1283
1283
  value: (function () {
1284
1284
  var _performSync = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee6(dataSet, reason, isInitialization) {
1285
- var hashTree, rootHash, leavesData, i, receivedHashes, hashesResult, mismatchedLeaveIndexes, syncResponse, _t3, _t4;
1285
+ var hashTree, rootHash, leavesData, receivedHashes, hashesResult, mismatchedLeaveIndexes, syncResponse, _t3, _t4;
1286
1286
  return _regenerator.default.wrap(function (_context7) {
1287
1287
  while (1) switch (_context7.prev = _context7.next) {
1288
1288
  case 0:
@@ -1296,81 +1296,90 @@ var HashTreeParser = /*#__PURE__*/function () {
1296
1296
  rootHash = hashTree.getRootHash();
1297
1297
  _context7.prev = 2;
1298
1298
  _loggerProxy.default.logger.info("HashTreeParser#performSync --> ".concat(this.debugId, " ").concat(reason, ", syncing data set \"").concat(dataSet.name, "\""));
1299
- if (!isInitialization) {
1300
- _context7.next = 3;
1301
- break;
1302
- }
1303
- // initialization sync: send all leaves as empty to get all data from Locus
1304
1299
  leavesData = {};
1305
- for (i = 0; i < dataSet.leafCount; i += 1) {
1306
- leavesData[i] = [];
1300
+ if (isInitialization) {
1301
+ _context7.next = 10;
1302
+ break;
1307
1303
  }
1308
- _context7.next = 11;
1309
- break;
1310
- case 3:
1311
1304
  if (!(dataSet.leafCount !== 1)) {
1312
- _context7.next = 10;
1305
+ _context7.next = 9;
1313
1306
  break;
1314
1307
  }
1315
- leavesData = {};
1316
- _context7.prev = 4;
1317
- _context7.next = 5;
1308
+ _context7.prev = 3;
1309
+ _context7.next = 4;
1318
1310
  return this.getHashesFromLocus(dataSet.name, rootHash);
1319
- case 5:
1311
+ case 4:
1320
1312
  hashesResult = _context7.sent;
1321
1313
  if (hashesResult) {
1322
- _context7.next = 6;
1314
+ _context7.next = 5;
1323
1315
  break;
1324
1316
  }
1325
1317
  return _context7.abrupt("return");
1326
- case 6:
1318
+ case 5:
1327
1319
  receivedHashes = hashesResult.hashes;
1328
1320
  hashTree.resize(hashesResult.dataSet.leafCount);
1329
- _context7.next = 9;
1321
+ _context7.next = 8;
1330
1322
  break;
1331
- case 7:
1332
- _context7.prev = 7;
1333
- _t3 = _context7["catch"](4);
1323
+ case 6:
1324
+ _context7.prev = 6;
1325
+ _t3 = _context7["catch"](3);
1334
1326
  if (!((_t3 === null || _t3 === void 0 ? void 0 : _t3.statusCode) === 409)) {
1335
- _context7.next = 8;
1327
+ _context7.next = 7;
1336
1328
  break;
1337
1329
  }
1338
1330
  // this is a leaf count mismatch, we should do nothing, just wait for another heartbeat message from Locus
1339
1331
  _loggerProxy.default.logger.info("HashTreeParser#getHashesFromLocus --> ".concat(this.debugId, " Got 409 when fetching hashes for data set \"").concat(dataSet.name, "\": ").concat(_t3.message));
1340
1332
  return _context7.abrupt("return");
1341
- case 8:
1333
+ case 7:
1342
1334
  throw _t3;
1343
- case 9:
1335
+ case 8:
1344
1336
  // identify mismatched leaves
1345
1337
  mismatchedLeaveIndexes = hashTree.diffHashes(receivedHashes);
1346
1338
  mismatchedLeaveIndexes.forEach(function (index) {
1347
1339
  leavesData[index] = hashTree.getLeafData(index);
1348
1340
  });
1349
- _context7.next = 11;
1341
+ _context7.next = 10;
1350
1342
  break;
1351
- case 10:
1343
+ case 9:
1352
1344
  leavesData = {
1353
1345
  0: hashTree.getLeafData(0)
1354
1346
  };
1347
+ case 10:
1348
+ // request sync for mismatched leaves
1349
+ syncResponse = null;
1350
+ if (!isInitialization) {
1351
+ _context7.next = 12;
1352
+ break;
1353
+ }
1354
+ _context7.next = 11;
1355
+ return this.sendSyncRequestToLocus(dataSet, {
1356
+ isInitialization: true
1357
+ });
1355
1358
  case 11:
1359
+ syncResponse = _context7.sent;
1360
+ _context7.next = 14;
1361
+ break;
1362
+ case 12:
1356
1363
  if (!((0, _keys.default)(leavesData).length > 0)) {
1357
- _context7.next = 13;
1364
+ _context7.next = 14;
1358
1365
  break;
1359
1366
  }
1360
- _context7.next = 12;
1361
- return this.sendSyncRequestToLocus(dataSet, leavesData);
1362
- case 12:
1367
+ _context7.next = 13;
1368
+ return this.sendSyncRequestToLocus(dataSet, {
1369
+ mismatchedLeavesData: leavesData
1370
+ });
1371
+ case 13:
1363
1372
  syncResponse = _context7.sent;
1373
+ case 14:
1364
1374
  // sync API may return nothing (in that case data will arrive via messages)
1365
1375
  // or it may return a response in the same format as messages
1366
1376
  if (syncResponse) {
1367
1377
  this.handleMessage(syncResponse, 'via sync API');
1368
1378
  }
1369
- case 13:
1370
- _context7.next = 15;
1379
+ _context7.next = 16;
1371
1380
  break;
1372
- case 14:
1373
- _context7.prev = 14;
1381
+ case 15:
1382
+ _context7.prev = 15;
1374
1383
  _t4 = _context7["catch"](2);
1375
1384
  if (_t4 instanceof MeetingEndedError) {
1376
1385
  this.callLocusInfoUpdateCallback({
@@ -1379,11 +1388,11 @@ var HashTreeParser = /*#__PURE__*/function () {
1379
1388
  } else {
1380
1389
  _loggerProxy.default.logger.warn("HashTreeParser#performSync --> ".concat(this.debugId, " error during sync for data set \"").concat(dataSet.name, "\":"), _t4);
1381
1390
  }
1382
- case 15:
1391
+ case 16:
1383
1392
  case "end":
1384
1393
  return _context7.stop();
1385
1394
  }
1386
- }, _callee6, this, [[2, 14], [4, 7]]);
1395
+ }, _callee6, this, [[2, 15], [3, 6]]);
1387
1396
  }));
1388
1397
  function performSync(_x8, _x9, _x0) {
1389
1398
  return _performSync.apply(this, arguments);
@@ -1828,26 +1837,36 @@ var HashTreeParser = /*#__PURE__*/function () {
1828
1837
  * Sends a sync request to Locus for the specified data set.
1829
1838
  *
1830
1839
  * @param {InternalDataSet} dataSet The data set to sync.
1831
- * @param {Record<number, LeafDataItem[]>} mismatchedLeavesData The mismatched leaves data to include in the sync request.
1840
+ * @param {Object} options Either `{ isInitialization: true }` for init syncs (uses leafCount=1 with empty leaf data) or `{ mismatchedLeavesData }` for normal syncs.
1832
1841
  * @returns {Promise<HashTreeMessage|null>}
1833
1842
  */
1834
1843
  }, {
1835
1844
  key: "sendSyncRequestToLocus",
1836
- value: function sendSyncRequestToLocus(dataSet, mismatchedLeavesData) {
1845
+ value: function sendSyncRequestToLocus(dataSet, options) {
1837
1846
  var _this13 = this;
1838
1847
  _loggerProxy.default.logger.info("HashTreeParser#sendSyncRequestToLocus --> ".concat(this.debugId, " Sending sync request for data set \"").concat(dataSet.name, "\""));
1848
+ var isInitialization = 'isInitialization' in options;
1839
1849
  var url = "".concat(dataSet.url, "/sync");
1840
1850
  var body = {
1841
- leafCount: dataSet.leafCount,
1851
+ leafCount: isInitialization ? 1 : dataSet.leafCount,
1842
1852
  leafDataEntries: []
1843
1853
  };
1844
- (0, _keys.default)(mismatchedLeavesData).forEach(function (index) {
1845
- var leafIndex = (0, _parseInt2.default)(index, 10);
1854
+ if (isInitialization) {
1855
+ // initialization sync: Locus requires leafCount=1 with a single empty leaf
1846
1856
  body.leafDataEntries.push({
1847
- leafIndex: leafIndex,
1848
- elementIds: mismatchedLeavesData[leafIndex]
1857
+ leafIndex: 0,
1858
+ elementIds: []
1849
1859
  });
1850
- });
1860
+ } else {
1861
+ var mismatchedLeavesData = options.mismatchedLeavesData;
1862
+ (0, _keys.default)(mismatchedLeavesData).forEach(function (index) {
1863
+ var leafIndex = (0, _parseInt2.default)(index, 10);
1864
+ body.leafDataEntries.push({
1865
+ leafIndex: leafIndex,
1866
+ elementIds: mismatchedLeavesData[leafIndex]
1867
+ });
1868
+ });
1869
+ }
1851
1870
  var ourCurrentRootHash = dataSet.hashTree ? dataSet.hashTree.getRootHash() : _constants2.EMPTY_HASH;
1852
1871
  return this.webexRequest({
1853
1872
  method: _constants.HTTP_VERBS.POST,