@atlaskit/collab-provider 9.25.5 → 9.25.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/collab-provider
2
2
 
3
+ ## 9.25.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [#79803](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/79803) [`05d755419b9f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/05d755419b9f) - NONE: remove isWebsocketFirst FF logic
8
+
9
+ ## 9.25.6
10
+
11
+ ### Patch Changes
12
+
13
+ - [#79382](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/79382) [`e6312788d14d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e6312788d14d) - Add CatchupV2 in collab-provider
14
+
3
15
  ## 9.25.5
4
16
 
5
17
  ### Patch Changes
@@ -327,24 +327,23 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
327
327
  return _ref2.apply(this, arguments);
328
328
  };
329
329
  }());
330
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "fetchReconcile", /*#__PURE__*/function () {
331
- var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(currentStateDoc) {
332
- var reqBody, reconcileResponse, _this$analyticsHelper7;
330
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "fetchCatchupv2", /*#__PURE__*/function () {
331
+ var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(fromVersion, clientId) {
332
+ var _yield$utils$requestS2, steps, metadata, errorNotFound, errorCatchupv2;
333
333
  return _regenerator.default.wrap(function _callee3$(_context3) {
334
334
  while (1) switch (_context3.prev = _context3.next) {
335
335
  case 0:
336
336
  _context3.prev = 0;
337
- reqBody = JSON.stringify({
338
- doc: currentStateDoc,
339
- productId: 'ccollab',
340
- reason: 'UNKNOWN' // different reason here?
341
- });
342
337
  _context3.t0 = _utilServiceSupport.utils;
343
338
  _context3.t1 = _this.config;
344
- _context3.t2 = "document/".concat(encodeURIComponent(_this.config.documentAri), "/reconcile");
345
- _context3.t3 = _objectSpread;
339
+ _context3.t2 = "document/".concat(encodeURIComponent(_this.config.documentAri), "/catchupv2");
340
+ _context3.t3 = {
341
+ version: fromVersion,
342
+ clientId: clientId
343
+ };
346
344
  _context3.t4 = _objectSpread;
347
- _context3.t5 = {};
345
+ _context3.t5 = _objectSpread;
346
+ _context3.t6 = {};
348
347
  if (!_this.config.permissionTokenRefresh) {
349
348
  _context3.next = 15;
350
349
  break;
@@ -352,54 +351,151 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
352
351
  _context3.next = 11;
353
352
  return _this.getChannelToken();
354
353
  case 11:
355
- _context3.t7 = _context3.sent;
356
- _context3.t6 = {
357
- 'x-token': _context3.t7
354
+ _context3.t8 = _context3.sent;
355
+ _context3.t7 = {
356
+ 'x-token': _context3.t8
358
357
  };
359
358
  _context3.next = 16;
360
359
  break;
361
360
  case 15:
362
- _context3.t6 = {};
361
+ _context3.t7 = {};
363
362
  case 16:
364
- _context3.t8 = _context3.t6;
365
- _context3.t9 = (0, _context3.t4)(_context3.t5, _context3.t8);
366
- _context3.t10 = {};
367
- _context3.t11 = {
363
+ _context3.t9 = _context3.t7;
364
+ _context3.t10 = (0, _context3.t5)(_context3.t6, _context3.t9);
365
+ _context3.t11 = {};
366
+ _context3.t12 = {
368
367
  'x-product': (0, _utils.getProduct)(_this.config.productInfo),
369
- 'x-subproduct': (0, _utils.getSubProduct)(_this.config.productInfo),
370
- 'Content-Type': 'application/json'
368
+ 'x-subproduct': (0, _utils.getSubProduct)(_this.config.productInfo)
371
369
  };
372
- _context3.t12 = (0, _context3.t3)(_context3.t9, _context3.t10, _context3.t11);
373
- _context3.t13 = reqBody;
370
+ _context3.t13 = (0, _context3.t4)(_context3.t10, _context3.t11, _context3.t12);
374
371
  _context3.t14 = {
375
- headers: _context3.t12,
376
- method: 'POST',
377
- body: _context3.t13
372
+ headers: _context3.t13
378
373
  };
379
374
  _context3.t15 = {
380
375
  path: _context3.t2,
376
+ queryParams: _context3.t3,
381
377
  requestInit: _context3.t14
382
378
  };
383
- _context3.next = 26;
379
+ _context3.next = 25;
384
380
  return _context3.t0.requestService.call(_context3.t0, _context3.t1, _context3.t15);
385
- case 26:
386
- reconcileResponse = _context3.sent;
387
- return _context3.abrupt("return", reconcileResponse);
388
- case 30:
389
- _context3.prev = 30;
381
+ case 25:
382
+ _yield$utils$requestS2 = _context3.sent;
383
+ steps = _yield$utils$requestS2.steps;
384
+ metadata = _yield$utils$requestS2.metadata;
385
+ return _context3.abrupt("return", {
386
+ steps: steps,
387
+ metadata: metadata
388
+ });
389
+ case 31:
390
+ _context3.prev = 31;
390
391
  _context3.t16 = _context3["catch"](0);
391
- (_this$analyticsHelper7 = _this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 || _this$analyticsHelper7.sendErrorEvent(_context3.t16, 'Error while fetching reconciled document');
392
+ if (!(_context3.t16.code === 404)) {
393
+ _context3.next = 37;
394
+ break;
395
+ }
396
+ errorNotFound = {
397
+ message: 'The requested document is not found',
398
+ data: {
399
+ status: _context3.t16.code,
400
+ code: _internalErrors.INTERNAL_ERROR_CODE.DOCUMENT_NOT_FOUND
401
+ }
402
+ };
403
+ _this.emit('error', errorNotFound);
404
+ return _context3.abrupt("return", {});
405
+ case 37:
406
+ logger("Can't fetch the catchupv2", _context3.t16.message);
407
+ errorCatchupv2 = {
408
+ message: 'Cannot fetch catchupv2 from collab service',
409
+ data: {
410
+ status: _context3.t16.status,
411
+ code: _internalErrors.INTERNAL_ERROR_CODE.CATCHUP_FAILED
412
+ }
413
+ };
414
+ _this.emit('error', errorCatchupv2);
392
415
  throw _context3.t16;
393
- case 34:
416
+ case 41:
394
417
  case "end":
395
418
  return _context3.stop();
396
419
  }
397
- }, _callee3, null, [[0, 30]]);
420
+ }, _callee3, null, [[0, 31]]);
398
421
  }));
399
- return function (_x3) {
422
+ return function (_x3, _x4) {
400
423
  return _ref3.apply(this, arguments);
401
424
  };
402
425
  }());
426
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "fetchReconcile", /*#__PURE__*/function () {
427
+ var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(currentStateDoc) {
428
+ var reqBody, reconcileResponse, _this$analyticsHelper7;
429
+ return _regenerator.default.wrap(function _callee4$(_context4) {
430
+ while (1) switch (_context4.prev = _context4.next) {
431
+ case 0:
432
+ _context4.prev = 0;
433
+ reqBody = JSON.stringify({
434
+ doc: currentStateDoc,
435
+ productId: 'ccollab',
436
+ reason: 'UNKNOWN' // different reason here?
437
+ });
438
+ _context4.t0 = _utilServiceSupport.utils;
439
+ _context4.t1 = _this.config;
440
+ _context4.t2 = "document/".concat(encodeURIComponent(_this.config.documentAri), "/reconcile");
441
+ _context4.t3 = _objectSpread;
442
+ _context4.t4 = _objectSpread;
443
+ _context4.t5 = {};
444
+ if (!_this.config.permissionTokenRefresh) {
445
+ _context4.next = 15;
446
+ break;
447
+ }
448
+ _context4.next = 11;
449
+ return _this.getChannelToken();
450
+ case 11:
451
+ _context4.t7 = _context4.sent;
452
+ _context4.t6 = {
453
+ 'x-token': _context4.t7
454
+ };
455
+ _context4.next = 16;
456
+ break;
457
+ case 15:
458
+ _context4.t6 = {};
459
+ case 16:
460
+ _context4.t8 = _context4.t6;
461
+ _context4.t9 = (0, _context4.t4)(_context4.t5, _context4.t8);
462
+ _context4.t10 = {};
463
+ _context4.t11 = {
464
+ 'x-product': (0, _utils.getProduct)(_this.config.productInfo),
465
+ 'x-subproduct': (0, _utils.getSubProduct)(_this.config.productInfo),
466
+ 'Content-Type': 'application/json'
467
+ };
468
+ _context4.t12 = (0, _context4.t3)(_context4.t9, _context4.t10, _context4.t11);
469
+ _context4.t13 = reqBody;
470
+ _context4.t14 = {
471
+ headers: _context4.t12,
472
+ method: 'POST',
473
+ body: _context4.t13
474
+ };
475
+ _context4.t15 = {
476
+ path: _context4.t2,
477
+ requestInit: _context4.t14
478
+ };
479
+ _context4.next = 26;
480
+ return _context4.t0.requestService.call(_context4.t0, _context4.t1, _context4.t15);
481
+ case 26:
482
+ reconcileResponse = _context4.sent;
483
+ return _context4.abrupt("return", reconcileResponse);
484
+ case 30:
485
+ _context4.prev = 30;
486
+ _context4.t16 = _context4["catch"](0);
487
+ (_this$analyticsHelper7 = _this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 || _this$analyticsHelper7.sendErrorEvent(_context4.t16, 'Error while fetching reconciled document');
488
+ throw _context4.t16;
489
+ case 34:
490
+ case "end":
491
+ return _context4.stop();
492
+ }
493
+ }, _callee4, null, [[0, 30]]);
494
+ }));
495
+ return function (_x5) {
496
+ return _ref4.apply(this, arguments);
497
+ };
498
+ }());
403
499
  /**
404
500
  * Send message to the back-end service over the channel. Timestamp will be added server side.
405
501
  * @throws {NotInitializedError} Channel not initialized
@@ -483,10 +579,10 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
483
579
  var auth;
484
580
  if (permissionTokenRefresh) {
485
581
  auth = /*#__PURE__*/function () {
486
- var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(cb) {
582
+ var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(cb) {
487
583
  var authData, token, _data, authenticationError;
488
- return _regenerator.default.wrap(function _callee4$(_context4) {
489
- while (1) switch (_context4.prev = _context4.next) {
584
+ return _regenerator.default.wrap(function _callee5$(_context5) {
585
+ while (1) switch (_context5.prev = _context5.next) {
490
586
  case 0:
491
587
  // Rebuild authData to ensure values are current
492
588
  authData = {
@@ -495,22 +591,22 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
495
591
  // ESS-1009 Allow to opt-in into 404 response
496
592
  need404: _this2.config.need404
497
593
  };
498
- _context4.prev = 1;
499
- _context4.next = 4;
594
+ _context5.prev = 1;
595
+ _context5.next = 4;
500
596
  return permissionTokenRefresh();
501
597
  case 4:
502
- token = _context4.sent;
598
+ token = _context5.sent;
503
599
  if (token) {
504
600
  authData.token = token;
505
601
  } else {
506
602
  authData.token = undefined;
507
603
  }
508
604
  cb(authData);
509
- _context4.next = 13;
605
+ _context5.next = 13;
510
606
  break;
511
607
  case 9:
512
- _context4.prev = 9;
513
- _context4.t0 = _context4["catch"](1);
608
+ _context5.prev = 9;
609
+ _context5.t0 = _context5["catch"](1);
514
610
  // Pass the error back to the consumers so they can deal with exceptional cases themselves (eg. no permissions because the page was deleted)
515
611
  authenticationError = {
516
612
  message: 'Insufficient editing permissions',
@@ -518,8 +614,8 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
518
614
  status: 403,
519
615
  code: _internalErrors.INTERNAL_ERROR_CODE.TOKEN_PERMISSION_ERROR,
520
616
  meta: {
521
- originalError: _context4.t0,
522
- 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
617
+ originalError: _context5.t0,
618
+ 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
523
619
  // https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/browse/next/packages/native-collab/src/fetchCollabPermissionToken.ts#37
524
620
  }
525
621
  }
@@ -528,20 +624,20 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
528
624
  _this2.emit('error', authenticationError);
529
625
  case 13:
530
626
  case "end":
531
- return _context4.stop();
627
+ return _context5.stop();
532
628
  }
533
- }, _callee4, null, [[1, 9]]);
629
+ }, _callee5, null, [[1, 9]]);
534
630
  }));
535
- return function auth(_x4) {
536
- return _ref4.apply(this, arguments);
631
+ return function auth(_x6) {
632
+ return _ref5.apply(this, arguments);
537
633
  };
538
634
  }();
539
635
  } else {
540
636
  auth = /*#__PURE__*/function () {
541
- var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(cb) {
637
+ var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(cb) {
542
638
  var authData;
543
- return _regenerator.default.wrap(function _callee5$(_context5) {
544
- while (1) switch (_context5.prev = _context5.next) {
639
+ return _regenerator.default.wrap(function _callee6$(_context6) {
640
+ while (1) switch (_context6.prev = _context6.next) {
545
641
  case 0:
546
642
  // Rebuild authData to ensure values are current
547
643
  authData = {
@@ -553,12 +649,12 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
553
649
  cb(authData);
554
650
  case 2:
555
651
  case "end":
556
- return _context5.stop();
652
+ return _context6.stop();
557
653
  }
558
- }, _callee5);
654
+ }, _callee6);
559
655
  }));
560
- return function auth(_x5) {
561
- return _ref5.apply(this, arguments);
656
+ return function auth(_x7) {
657
+ return _ref6.apply(this, arguments);
562
658
  };
563
659
  }();
564
660
  }
@@ -575,9 +671,9 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
575
671
  this.socket.on('steps:added', function (data) {
576
672
  _this2.emit('steps:added', data);
577
673
  });
578
- this.socket.on('participant:telepointer', function (_ref6) {
579
- var timestamp = _ref6.timestamp,
580
- data = _ref6.data;
674
+ this.socket.on('participant:telepointer', function (_ref7) {
675
+ var timestamp = _ref7.timestamp,
676
+ data = _ref7.data;
581
677
  // data is TelepointerPayload without timestamp
582
678
  _this2.emit('participant:telepointer', _objectSpread({
583
679
  timestamp: timestamp
@@ -592,11 +688,11 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
592
688
  this.socket.on('participant:left', function (data) {
593
689
  _this2.emit('participant:left', data);
594
690
  });
595
- this.socket.on('participant:updated', function (_ref7) {
596
- var sessionId = _ref7.sessionId,
597
- timestamp = _ref7.timestamp,
598
- data = _ref7.data,
599
- clientId = _ref7.clientId;
691
+ this.socket.on('participant:updated', function (_ref8) {
692
+ var sessionId = _ref8.sessionId,
693
+ timestamp = _ref8.timestamp,
694
+ data = _ref8.data,
695
+ clientId = _ref8.clientId;
600
696
  _this2.emit('participant:updated', _objectSpread({
601
697
  sessionId: sessionId,
602
698
  timestamp: timestamp,
@@ -612,10 +708,10 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
612
708
  _this2.emit('status', data);
613
709
  });
614
710
  this.socket.on('disconnect', /*#__PURE__*/function () {
615
- var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(reason) {
711
+ var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(reason) {
616
712
  var _this2$analyticsHelpe, reconnectionError;
617
- return _regenerator.default.wrap(function _callee6$(_context6) {
618
- while (1) switch (_context6.prev = _context6.next) {
713
+ return _regenerator.default.wrap(function _callee7$(_context7) {
714
+ while (1) switch (_context7.prev = _context7.next) {
619
715
  case 0:
620
716
  _this2.connected = false;
621
717
  logger("disconnect reason: ".concat(reason));
@@ -640,12 +736,12 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
640
736
  }
641
737
  case 4:
642
738
  case "end":
643
- return _context6.stop();
739
+ return _context7.stop();
644
740
  }
645
- }, _callee6);
741
+ }, _callee7);
646
742
  }));
647
- return function (_x6) {
648
- return _ref8.apply(this, arguments);
743
+ return function (_x8) {
744
+ return _ref9.apply(this, arguments);
649
745
  };
650
746
  }());
651
747
 
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.catchupv2 = void 0;
8
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
+ var _utils = require("../helpers/utils");
11
+ var logger = (0, _utils.createLogger)('Catchupv2', 'red');
12
+ var catchupv2 = exports.catchupv2 = /*#__PURE__*/function () {
13
+ var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(opt) {
14
+ var steps, metadata, fromVersion, _yield$opt$fetchCatch, _opt$analyticsHelper, version, stepsPayload, _opt$analyticsHelper2;
15
+ return _regenerator.default.wrap(function _callee$(_context) {
16
+ while (1) switch (_context.prev = _context.next) {
17
+ case 0:
18
+ fromVersion = opt.getCurrentPmVersion();
19
+ _context.prev = 1;
20
+ _context.next = 4;
21
+ return opt.fetchCatchupv2(fromVersion, opt.clientId);
22
+ case 4:
23
+ _yield$opt$fetchCatch = _context.sent;
24
+ steps = _yield$opt$fetchCatch.steps;
25
+ metadata = _yield$opt$fetchCatch.metadata;
26
+ _context.next = 14;
27
+ break;
28
+ case 9:
29
+ _context.prev = 9;
30
+ _context.t0 = _context["catch"](1);
31
+ (_opt$analyticsHelper = opt.analyticsHelper) === null || _opt$analyticsHelper === void 0 || _opt$analyticsHelper.sendErrorEvent(_context.t0, 'Error while fetching catchupv2 from server');
32
+ logger("Fetch catchupv2 from server failed:", _context.t0.message);
33
+ throw _context.t0;
34
+ case 14:
35
+ _context.prev = 14;
36
+ version = fromVersion + steps.length;
37
+ stepsPayload = {
38
+ version: version,
39
+ steps: steps
40
+ };
41
+ opt.onStepsAdded(stepsPayload);
42
+ opt.updateMetadata(metadata);
43
+ _context.next = 26;
44
+ break;
45
+ case 21:
46
+ _context.prev = 21;
47
+ _context.t1 = _context["catch"](14);
48
+ (_opt$analyticsHelper2 = opt.analyticsHelper) === null || _opt$analyticsHelper2 === void 0 || _opt$analyticsHelper2.sendErrorEvent(_context.t1, 'Failed to apply catchupv2 result in the editor');
49
+ logger("Apply catchupv2 steps failed:", _context.t1.message);
50
+ throw _context.t1;
51
+ case 26:
52
+ case "end":
53
+ return _context.stop();
54
+ }
55
+ }, _callee, null, [[1, 9], [14, 21]]);
56
+ }));
57
+ return function catchupv2(_x) {
58
+ return _ref.apply(this, arguments);
59
+ };
60
+ }();