@atlaskit/collab-provider 9.41.0 → 9.41.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.
@@ -222,19 +222,21 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
222
222
  _this.emit('steps:added', data);
223
223
  }
224
224
  });
225
- _defineProperty(_assertThisInitialized(_this), "fetchCatchup", /*#__PURE__*/function () {
226
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(fromVersion, clientId) {
227
- var _yield$utils$requestS, doc, version, stepMaps, metadata, errorNotFound, errorCatchup;
225
+ _defineProperty(_assertThisInitialized(_this), "fetchCatchupv2", /*#__PURE__*/function () {
226
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(fromVersion, clientId, catchUpOutofSync, reason) {
227
+ var _yield$utils$requestS, steps, metadata, errorNotFound, errorCatchupv2;
228
228
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
229
229
  while (1) switch (_context2.prev = _context2.next) {
230
230
  case 0:
231
231
  _context2.prev = 0;
232
232
  _context2.t0 = utils;
233
233
  _context2.t1 = _this.config;
234
- _context2.t2 = "document/".concat(encodeURIComponent(_this.config.documentAri), "/catchup");
234
+ _context2.t2 = "document/".concat(encodeURIComponent(_this.config.documentAri), "/catchupv2");
235
235
  _context2.t3 = {
236
236
  version: fromVersion,
237
- clientId: clientId
237
+ clientId: clientId,
238
+ catchUpOutofSync: catchUpOutofSync,
239
+ reason: reason
238
240
  };
239
241
  _context2.next = 7;
240
242
  return _this.commonHeaders();
@@ -252,21 +254,17 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
252
254
  return _context2.t0.requestService.call(_context2.t0, _context2.t1, _context2.t6);
253
255
  case 12:
254
256
  _yield$utils$requestS = _context2.sent;
255
- doc = _yield$utils$requestS.doc;
256
- version = _yield$utils$requestS.version;
257
- stepMaps = _yield$utils$requestS.stepMaps;
257
+ steps = _yield$utils$requestS.steps;
258
258
  metadata = _yield$utils$requestS.metadata;
259
259
  return _context2.abrupt("return", {
260
- doc: doc,
261
- version: version,
262
- stepMaps: stepMaps,
260
+ steps: steps,
263
261
  metadata: metadata
264
262
  });
265
- case 20:
266
- _context2.prev = 20;
263
+ case 18:
264
+ _context2.prev = 18;
267
265
  _context2.t7 = _context2["catch"](0);
268
266
  if (!(_context2.t7.code === 404)) {
269
- _context2.next = 26;
267
+ _context2.next = 24;
270
268
  break;
271
269
  }
272
270
  errorNotFound = {
@@ -278,158 +276,83 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
278
276
  };
279
277
  _this.emit('error', errorNotFound);
280
278
  return _context2.abrupt("return", {});
281
- case 26:
282
- logger("Can't fetch the catchup", _context2.t7.message);
283
- errorCatchup = {
284
- message: 'Cannot fetch catchup from collab service',
285
- data: {
286
- status: _context2.t7.status,
287
- code: INTERNAL_ERROR_CODE.CATCHUP_FAILED
288
- }
289
- };
290
- _this.emit('error', errorCatchup);
291
- throw _context2.t7;
292
- case 30:
293
- case "end":
294
- return _context2.stop();
295
- }
296
- }, _callee2, null, [[0, 20]]);
297
- }));
298
- return function (_x, _x2) {
299
- return _ref2.apply(this, arguments);
300
- };
301
- }());
302
- _defineProperty(_assertThisInitialized(_this), "fetchCatchupv2", /*#__PURE__*/function () {
303
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(fromVersion, clientId, catchUpOutofSync, reason) {
304
- var _yield$utils$requestS2, steps, metadata, errorNotFound, errorCatchupv2;
305
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
306
- while (1) switch (_context3.prev = _context3.next) {
307
- case 0:
308
- _context3.prev = 0;
309
- _context3.t0 = utils;
310
- _context3.t1 = _this.config;
311
- _context3.t2 = "document/".concat(encodeURIComponent(_this.config.documentAri), "/catchupv2");
312
- _context3.t3 = {
313
- version: fromVersion,
314
- clientId: clientId,
315
- catchUpOutofSync: catchUpOutofSync,
316
- reason: reason
317
- };
318
- _context3.next = 7;
319
- return _this.commonHeaders();
320
- case 7:
321
- _context3.t4 = _context3.sent;
322
- _context3.t5 = {
323
- headers: _context3.t4
324
- };
325
- _context3.t6 = {
326
- path: _context3.t2,
327
- queryParams: _context3.t3,
328
- requestInit: _context3.t5
329
- };
330
- _context3.next = 12;
331
- return _context3.t0.requestService.call(_context3.t0, _context3.t1, _context3.t6);
332
- case 12:
333
- _yield$utils$requestS2 = _context3.sent;
334
- steps = _yield$utils$requestS2.steps;
335
- metadata = _yield$utils$requestS2.metadata;
336
- return _context3.abrupt("return", {
337
- steps: steps,
338
- metadata: metadata
339
- });
340
- case 18:
341
- _context3.prev = 18;
342
- _context3.t7 = _context3["catch"](0);
343
- if (!(_context3.t7.code === 404)) {
344
- _context3.next = 24;
345
- break;
346
- }
347
- errorNotFound = {
348
- message: 'The requested document is not found',
349
- data: {
350
- status: _context3.t7.code,
351
- code: INTERNAL_ERROR_CODE.DOCUMENT_NOT_FOUND
352
- }
353
- };
354
- _this.emit('error', errorNotFound);
355
- return _context3.abrupt("return", {});
356
279
  case 24:
357
- logger("Can't fetch the catchupv2", _context3.t7.message);
280
+ logger("Can't fetch the catchupv2", _context2.t7.message);
358
281
  errorCatchupv2 = {
359
282
  message: 'Cannot fetch catchupv2 from collab service',
360
283
  data: {
361
- status: _context3.t7.status,
284
+ status: _context2.t7.status,
362
285
  code: INTERNAL_ERROR_CODE.CATCHUP_FAILED
363
286
  }
364
287
  };
365
288
  _this.emit('error', errorCatchupv2);
366
- throw _context3.t7;
289
+ throw _context2.t7;
367
290
  case 28:
368
291
  case "end":
369
- return _context3.stop();
292
+ return _context2.stop();
370
293
  }
371
- }, _callee3, null, [[0, 18]]);
294
+ }, _callee2, null, [[0, 18]]);
372
295
  }));
373
- return function (_x3, _x4, _x5, _x6) {
374
- return _ref3.apply(this, arguments);
296
+ return function (_x, _x2, _x3, _x4) {
297
+ return _ref2.apply(this, arguments);
375
298
  };
376
299
  }());
377
300
  _defineProperty(_assertThisInitialized(_this), "fetchReconcile", /*#__PURE__*/function () {
378
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(currentStateDoc, reason) {
301
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(currentStateDoc, reason) {
379
302
  var reqBody, reconcileResponse, _this$analyticsHelper7;
380
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
381
- while (1) switch (_context4.prev = _context4.next) {
303
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
304
+ while (1) switch (_context3.prev = _context3.next) {
382
305
  case 0:
383
- _context4.prev = 0;
306
+ _context3.prev = 0;
384
307
  reqBody = JSON.stringify({
385
308
  doc: currentStateDoc,
386
309
  productId: 'ccollab',
387
310
  reason: reason
388
311
  });
389
- _context4.t0 = utils;
390
- _context4.t1 = _this.config;
391
- _context4.t2 = "document/".concat(encodeURIComponent(_this.config.documentAri), "/reconcile");
392
- _context4.t3 = _objectSpread;
393
- _context4.t4 = _objectSpread;
394
- _context4.t5 = {};
395
- _context4.next = 10;
312
+ _context3.t0 = utils;
313
+ _context3.t1 = _this.config;
314
+ _context3.t2 = "document/".concat(encodeURIComponent(_this.config.documentAri), "/reconcile");
315
+ _context3.t3 = _objectSpread;
316
+ _context3.t4 = _objectSpread;
317
+ _context3.t5 = {};
318
+ _context3.next = 10;
396
319
  return _this.commonHeaders();
397
320
  case 10:
398
- _context4.t6 = _context4.sent;
399
- _context4.t7 = (0, _context4.t4)(_context4.t5, _context4.t6);
400
- _context4.t8 = {};
401
- _context4.t9 = {
321
+ _context3.t6 = _context3.sent;
322
+ _context3.t7 = (0, _context3.t4)(_context3.t5, _context3.t6);
323
+ _context3.t8 = {};
324
+ _context3.t9 = {
402
325
  'Content-Type': 'application/json'
403
326
  };
404
- _context4.t10 = (0, _context4.t3)(_context4.t7, _context4.t8, _context4.t9);
405
- _context4.t11 = reqBody;
406
- _context4.t12 = {
407
- headers: _context4.t10,
327
+ _context3.t10 = (0, _context3.t3)(_context3.t7, _context3.t8, _context3.t9);
328
+ _context3.t11 = reqBody;
329
+ _context3.t12 = {
330
+ headers: _context3.t10,
408
331
  method: 'POST',
409
- body: _context4.t11
332
+ body: _context3.t11
410
333
  };
411
- _context4.t13 = {
412
- path: _context4.t2,
413
- requestInit: _context4.t12
334
+ _context3.t13 = {
335
+ path: _context3.t2,
336
+ requestInit: _context3.t12
414
337
  };
415
- _context4.next = 20;
416
- return _context4.t0.requestService.call(_context4.t0, _context4.t1, _context4.t13);
338
+ _context3.next = 20;
339
+ return _context3.t0.requestService.call(_context3.t0, _context3.t1, _context3.t13);
417
340
  case 20:
418
- reconcileResponse = _context4.sent;
419
- return _context4.abrupt("return", reconcileResponse);
341
+ reconcileResponse = _context3.sent;
342
+ return _context3.abrupt("return", reconcileResponse);
420
343
  case 24:
421
- _context4.prev = 24;
422
- _context4.t14 = _context4["catch"](0);
423
- (_this$analyticsHelper7 = _this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 || _this$analyticsHelper7.sendErrorEvent(_context4.t14, 'Error while fetching reconciled document');
424
- throw _context4.t14;
344
+ _context3.prev = 24;
345
+ _context3.t14 = _context3["catch"](0);
346
+ (_this$analyticsHelper7 = _this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 || _this$analyticsHelper7.sendErrorEvent(_context3.t14, 'Error while fetching reconciled document');
347
+ throw _context3.t14;
425
348
  case 28:
426
349
  case "end":
427
- return _context4.stop();
350
+ return _context3.stop();
428
351
  }
429
- }, _callee4, null, [[0, 24]]);
352
+ }, _callee3, null, [[0, 24]]);
430
353
  }));
431
- return function (_x7, _x8) {
432
- return _ref4.apply(this, arguments);
354
+ return function (_x5, _x6) {
355
+ return _ref3.apply(this, arguments);
433
356
  };
434
357
  }());
435
358
  /**
@@ -515,10 +438,10 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
515
438
  var auth;
516
439
  if (permissionTokenRefresh) {
517
440
  auth = /*#__PURE__*/function () {
518
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(cb) {
441
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(cb) {
519
442
  var authData, token, _data, authenticationError;
520
- return _regeneratorRuntime.wrap(function _callee5$(_context5) {
521
- while (1) switch (_context5.prev = _context5.next) {
443
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
444
+ while (1) switch (_context4.prev = _context4.next) {
522
445
  case 0:
523
446
  // Rebuild authData to ensure values are current
524
447
  authData = {
@@ -527,22 +450,22 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
527
450
  // ESS-1009 Allow to opt-in into 404 response
528
451
  need404: _this2.config.need404
529
452
  };
530
- _context5.prev = 1;
531
- _context5.next = 4;
453
+ _context4.prev = 1;
454
+ _context4.next = 4;
532
455
  return permissionTokenRefresh();
533
456
  case 4:
534
- token = _context5.sent;
457
+ token = _context4.sent;
535
458
  if (token) {
536
459
  authData.token = token;
537
460
  } else {
538
461
  authData.token = undefined;
539
462
  }
540
463
  cb(authData);
541
- _context5.next = 13;
464
+ _context4.next = 13;
542
465
  break;
543
466
  case 9:
544
- _context5.prev = 9;
545
- _context5.t0 = _context5["catch"](1);
467
+ _context4.prev = 9;
468
+ _context4.t0 = _context4["catch"](1);
546
469
  // Pass the error back to the consumers so they can deal with exceptional cases themselves (eg. no permissions because the page was deleted)
547
470
  authenticationError = {
548
471
  message: 'Insufficient editing permissions',
@@ -550,8 +473,8 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
550
473
  status: 403,
551
474
  code: INTERNAL_ERROR_CODE.TOKEN_PERMISSION_ERROR,
552
475
  meta: {
553
- originalError: _context5.t0,
554
- reason: _context5.t0 === null || _context5.t0 === void 0 || (_data = _context5.t0.data) === null || _data === void 0 || (_data = _data.meta) === null || _data === void 0 ? void 0 : _data.reason // Should always be 'RESOURCE_DELETED' Temporary, until Confluence Cloud removes their hack
476
+ originalError: _context4.t0,
477
+ reason: _context4.t0 === null || _context4.t0 === void 0 || (_data = _context4.t0.data) === null || _data === void 0 || (_data = _data.meta) === null || _data === void 0 ? void 0 : _data.reason // Should always be 'RESOURCE_DELETED' Temporary, until Confluence Cloud removes their hack
555
478
  // https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/browse/next/packages/native-collab/src/fetchCollabPermissionToken.ts#37
556
479
  }
557
480
  }
@@ -559,20 +482,20 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
559
482
  _this2.emit('error', authenticationError);
560
483
  case 13:
561
484
  case "end":
562
- return _context5.stop();
485
+ return _context4.stop();
563
486
  }
564
- }, _callee5, null, [[1, 9]]);
487
+ }, _callee4, null, [[1, 9]]);
565
488
  }));
566
- return function auth(_x9) {
567
- return _ref5.apply(this, arguments);
489
+ return function auth(_x7) {
490
+ return _ref4.apply(this, arguments);
568
491
  };
569
492
  }();
570
493
  } else {
571
494
  auth = /*#__PURE__*/function () {
572
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(cb) {
495
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(cb) {
573
496
  var authData;
574
- return _regeneratorRuntime.wrap(function _callee6$(_context6) {
575
- while (1) switch (_context6.prev = _context6.next) {
497
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
498
+ while (1) switch (_context5.prev = _context5.next) {
576
499
  case 0:
577
500
  // Rebuild authData to ensure values are current
578
501
  authData = {
@@ -584,12 +507,12 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
584
507
  cb(authData);
585
508
  case 2:
586
509
  case "end":
587
- return _context6.stop();
510
+ return _context5.stop();
588
511
  }
589
- }, _callee6);
512
+ }, _callee5);
590
513
  }));
591
- return function auth(_x10) {
592
- return _ref6.apply(this, arguments);
514
+ return function auth(_x8) {
515
+ return _ref5.apply(this, arguments);
593
516
  };
594
517
  }();
595
518
  }
@@ -606,20 +529,20 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
606
529
  this.socket.on('steps:added', function (data) {
607
530
  _this2.emit('steps:added', data);
608
531
  });
609
- this.socket.on('participant:telepointer', function (_ref7) {
610
- var timestamp = _ref7.timestamp,
611
- data = _ref7.data;
532
+ this.socket.on('participant:telepointer', function (_ref6) {
533
+ var timestamp = _ref6.timestamp,
534
+ data = _ref6.data;
612
535
  // data is TelepointerPayload without timestamp
613
536
  _this2.emit('participant:telepointer', _objectSpread({
614
537
  timestamp: timestamp
615
538
  }, data));
616
539
  });
617
- this.socket.on('participant:activity-ack', function (_ref8) {
618
- var data = _ref8.data;
540
+ this.socket.on('participant:activity-ack', function (_ref7) {
541
+ var data = _ref7.data;
619
542
  _this2.emit('participant:activity-ack', data);
620
543
  });
621
- this.socket.on('participant:activity-join', function (_ref9) {
622
- var data = _ref9.data;
544
+ this.socket.on('participant:activity-join', function (_ref8) {
545
+ var data = _ref8.data;
623
546
  _this2.emit('participant:activity-join', data);
624
547
  });
625
548
  this.socket.on('presence:joined', function (data) {
@@ -631,11 +554,11 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
631
554
  this.socket.on('participant:left', function (data) {
632
555
  _this2.emit('participant:left', data);
633
556
  });
634
- this.socket.on('participant:updated', function (_ref10) {
635
- var sessionId = _ref10.sessionId,
636
- timestamp = _ref10.timestamp,
637
- data = _ref10.data,
638
- clientId = _ref10.clientId;
557
+ this.socket.on('participant:updated', function (_ref9) {
558
+ var sessionId = _ref9.sessionId,
559
+ timestamp = _ref9.timestamp,
560
+ data = _ref9.data,
561
+ clientId = _ref9.clientId;
639
562
  _this2.emit('participant:updated', _objectSpread({
640
563
  sessionId: sessionId,
641
564
  timestamp: timestamp,
@@ -651,10 +574,10 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
651
574
  _this2.emit('status', data);
652
575
  });
653
576
  this.socket.on('disconnect', /*#__PURE__*/function () {
654
- var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(reason) {
577
+ var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(reason) {
655
578
  var _this2$analyticsHelpe, reconnectionError;
656
- return _regeneratorRuntime.wrap(function _callee7$(_context7) {
657
- while (1) switch (_context7.prev = _context7.next) {
579
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
580
+ while (1) switch (_context6.prev = _context6.next) {
658
581
  case 0:
659
582
  _this2.connected = false;
660
583
  logger("disconnect reason: ".concat(reason));
@@ -679,12 +602,12 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
679
602
  }
680
603
  case 4:
681
604
  case "end":
682
- return _context7.stop();
605
+ return _context6.stop();
683
606
  }
684
- }, _callee7);
607
+ }, _callee6);
685
608
  }));
686
- return function (_x11) {
687
- return _ref11.apply(this, arguments);
609
+ return function (_x9) {
610
+ return _ref10.apply(this, arguments);
688
611
  };
689
612
  }());
690
613
 
@@ -789,42 +712,42 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
789
712
  }, {
790
713
  key: "commonHeaders",
791
714
  value: function () {
792
- var _commonHeaders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
793
- return _regeneratorRuntime.wrap(function _callee8$(_context8) {
794
- while (1) switch (_context8.prev = _context8.next) {
715
+ var _commonHeaders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
716
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
717
+ while (1) switch (_context7.prev = _context7.next) {
795
718
  case 0:
796
- _context8.t0 = _objectSpread;
797
- _context8.t1 = _objectSpread;
798
- _context8.t2 = {};
719
+ _context7.t0 = _objectSpread;
720
+ _context7.t1 = _objectSpread;
721
+ _context7.t2 = {};
799
722
  if (!this.config.permissionTokenRefresh) {
800
- _context8.next = 10;
723
+ _context7.next = 10;
801
724
  break;
802
725
  }
803
- _context8.next = 6;
726
+ _context7.next = 6;
804
727
  return this.getChannelToken();
805
728
  case 6:
806
- _context8.t4 = _context8.sent;
807
- _context8.t3 = {
808
- 'x-token': _context8.t4
729
+ _context7.t4 = _context7.sent;
730
+ _context7.t3 = {
731
+ 'x-token': _context7.t4
809
732
  };
810
- _context8.next = 11;
733
+ _context7.next = 11;
811
734
  break;
812
735
  case 10:
813
- _context8.t3 = {};
736
+ _context7.t3 = {};
814
737
  case 11:
815
- _context8.t5 = _context8.t3;
816
- _context8.t6 = (0, _context8.t1)(_context8.t2, _context8.t5);
817
- _context8.t7 = {};
818
- _context8.t8 = {
738
+ _context7.t5 = _context7.t3;
739
+ _context7.t6 = (0, _context7.t1)(_context7.t2, _context7.t5);
740
+ _context7.t7 = {};
741
+ _context7.t8 = {
819
742
  'x-product': getProduct(this.config.productInfo),
820
743
  'x-subproduct': getSubProduct(this.config.productInfo)
821
744
  };
822
- return _context8.abrupt("return", (0, _context8.t0)(_context8.t6, _context8.t7, _context8.t8));
745
+ return _context7.abrupt("return", (0, _context7.t0)(_context7.t6, _context7.t7, _context7.t8));
823
746
  case 16:
824
747
  case "end":
825
- return _context8.stop();
748
+ return _context7.stop();
826
749
  }
827
- }, _callee8, this);
750
+ }, _callee7, this);
828
751
  }));
829
752
  function commonHeaders() {
830
753
  return _commonHeaders.apply(this, arguments);