@atlaskit/collab-provider 9.5.2 → 9.6.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/collab-provider
2
2
 
3
+ ## 9.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`979e3ad2b67`](https://bitbucket.org/atlassian/atlassian-frontend/commits/979e3ad2b67) - NO-ISSUE: add data portal links and fix a broken analytics error event
8
+
9
+ ## 9.6.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`7ef82ea1810`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7ef82ea1810) - ESS-3718: export ProviderParticipant for JWM
14
+
3
15
  ## 9.5.2
4
16
 
5
17
  ### Patch Changes
@@ -382,7 +382,7 @@ var DocumentService = /*#__PURE__*/function () {
382
382
  * @throws {Error} Couldn't sync the steps after retrying 30 times
383
383
  */
384
384
  (0, _defineProperty2.default)(this, "commitUnconfirmedSteps", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
385
- var unconfirmedSteps, _this$analyticsHelper19, count, unconfirmedTrs, lastTr, isLastTrConfirmed, nextUnconfirmedSteps, nextUnconfirmedTrs, _this$getUnconfirmedS, _this$analyticsHelper18, state, unconfirmedStepsInfoUGCRemoved, measure, _this$analyticsHelper20, _this$analyticsHelper21, _measure3;
385
+ var unconfirmedSteps, _this$analyticsHelper18, count, unconfirmedTrs, lastTr, isLastTrConfirmed, nextUnconfirmedSteps, nextUnconfirmedTrs, _this$getUnconfirmedS, state, unconfirmedStepsInfoUGCRemoved, _error2, measure, _this$analyticsHelper19, _this$analyticsHelper20, _measure3;
386
386
  return _regenerator.default.wrap(function _callee4$(_context4) {
387
387
  while (1) switch (_context4.prev = _context4.next) {
388
388
  case 0:
@@ -435,16 +435,16 @@ var DocumentService = /*#__PURE__*/function () {
435
435
  unconfirmedStepsInfoUGCRemoved = (_this$getUnconfirmedS = _this.getUnconfirmedSteps()) === null || _this$getUnconfirmedS === void 0 ? void 0 : _this$getUnconfirmedS.map(function (step) {
436
436
  return (0, _utils.getStepUGCFreeDetails)(step);
437
437
  });
438
- (_this$analyticsHelper18 = _this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 ? void 0 : _this$analyticsHelper18.sendErrorEvent({
439
- unconfirmedStepsInfo: unconfirmedStepsInfoUGCRemoved
440
- }, "Can't sync up with Collab Service: unable to send unconfirmed steps and max retry reached");
441
- throw new Error("Can't sync up with Collab Service");
438
+ _error2 = new _errorTypes.CantSyncUpError("Can't sync up with Collab Service: unable to send unconfirmed steps and max retry reached", {
439
+ unconfirmedStepsInfo: unconfirmedStepsInfoUGCRemoved ? unconfirmedStepsInfoUGCRemoved.toString() : 'Unable to generate UGC removed step info'
440
+ });
441
+ throw _error2;
442
442
  case 19:
443
443
  _context4.next = 8;
444
444
  break;
445
445
  case 21:
446
446
  measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
447
- (_this$analyticsHelper19 = _this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 ? void 0 : _this$analyticsHelper19.sendActionEvent(_const.EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, _const.EVENT_STATUS.SUCCESS, {
447
+ (_this$analyticsHelper18 = _this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 ? void 0 : _this$analyticsHelper18.sendActionEvent(_const.EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, _const.EVENT_STATUS.SUCCESS, {
448
448
  latency: measure === null || measure === void 0 ? void 0 : measure.duration,
449
449
  // upon success, emit the total number of unconfirmed steps we synced
450
450
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
@@ -456,11 +456,11 @@ var DocumentService = /*#__PURE__*/function () {
456
456
  _context4.prev = 25;
457
457
  _context4.t0 = _context4["catch"](1);
458
458
  _measure3 = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
459
- (_this$analyticsHelper20 = _this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 ? void 0 : _this$analyticsHelper20.sendActionEvent(_const.EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, _const.EVENT_STATUS.FAILURE, {
459
+ (_this$analyticsHelper19 = _this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 ? void 0 : _this$analyticsHelper19.sendActionEvent(_const.EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, _const.EVENT_STATUS.FAILURE, {
460
460
  latency: _measure3 === null || _measure3 === void 0 ? void 0 : _measure3.duration,
461
461
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
462
462
  });
463
- (_this$analyticsHelper21 = _this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 ? void 0 : _this$analyticsHelper21.sendErrorEvent(_context4.t0, 'Error while committing unconfirmed steps');
463
+ (_this$analyticsHelper20 = _this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 ? void 0 : _this$analyticsHelper20.sendErrorEvent(_context4.t0, 'Error while committing unconfirmed steps');
464
464
  throw _context4.t0;
465
465
  case 31:
466
466
  case "end":
@@ -469,17 +469,17 @@ var DocumentService = /*#__PURE__*/function () {
469
469
  }, _callee4, null, [[1, 25]]);
470
470
  })));
471
471
  (0, _defineProperty2.default)(this, "onStepRejectedError", function () {
472
- var _this$analyticsHelper22;
472
+ var _this$analyticsHelper21;
473
473
  _this.stepRejectCounter++;
474
474
  logger("Steps rejected (tries=".concat(_this.stepRejectCounter, ")"));
475
- (_this$analyticsHelper22 = _this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 ? void 0 : _this$analyticsHelper22.sendActionEvent(_const.EVENT_ACTION.SEND_STEPS_RETRY, _const.EVENT_STATUS.INFO, {
475
+ (_this$analyticsHelper21 = _this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 ? void 0 : _this$analyticsHelper21.sendActionEvent(_const.EVENT_ACTION.SEND_STEPS_RETRY, _const.EVENT_STATUS.INFO, {
476
476
  count: _this.stepRejectCounter
477
477
  });
478
478
  var maxRetries = _this.aggressiveCatchup ? _this.failedStepsBeforeCatchupOnPublish : _provider.MAX_STEP_REJECTED_ERROR;
479
479
  if (_this.stepRejectCounter >= maxRetries) {
480
- var _this$analyticsHelper23;
480
+ var _this$analyticsHelper22;
481
481
  logger("The steps were rejected too many times (tries=".concat(_this.stepRejectCounter, ", limit=").concat(_provider.MAX_STEP_REJECTED_ERROR, "). Trying to catch-up."));
482
- (_this$analyticsHelper23 = _this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 ? void 0 : _this$analyticsHelper23.sendActionEvent(_const.EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, _const.EVENT_STATUS.INFO);
482
+ (_this$analyticsHelper22 = _this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 ? void 0 : _this$analyticsHelper22.sendActionEvent(_const.EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, _const.EVENT_STATUS.INFO);
483
483
  _this.throttledCatchup();
484
484
  } else {
485
485
  // If committing steps failed try again automatically in 1s
@@ -552,9 +552,9 @@ var DocumentService = /*#__PURE__*/function () {
552
552
  }, 100);
553
553
  }
554
554
  } catch (error) {
555
- var _this$analyticsHelper24;
555
+ var _this$analyticsHelper23;
556
556
  logger("Processing steps failed with error: ".concat(error, ". Triggering catch up call."));
557
- (_this$analyticsHelper24 = this.analyticsHelper) === null || _this$analyticsHelper24 === void 0 ? void 0 : _this$analyticsHelper24.sendErrorEvent(error, 'Error while processing steps');
557
+ (_this$analyticsHelper23 = this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 ? void 0 : _this$analyticsHelper23.sendErrorEvent(error, 'Error while processing steps');
558
558
  this.throttledCatchup();
559
559
  }
560
560
  }
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.UpdateDocumentError = exports.SetTitleError = exports.SetMetadataError = exports.SetEditorWidthError = exports.SendTransactionError = exports.ProviderInitialisationError = exports.PROVIDER_ERROR_CODE = exports.NotInitializedError = exports.NotConnectedError = exports.NCS_ERROR_CODE = exports.INTERNAL_ERROR_CODE = exports.GetFinalAcknowledgedStateError = exports.GetCurrentStateError = exports.DestroyError = exports.CustomError = void 0;
7
+ exports.UpdateDocumentError = exports.SetTitleError = exports.SetMetadataError = exports.SetEditorWidthError = exports.SendTransactionError = exports.ProviderInitialisationError = exports.PROVIDER_ERROR_CODE = exports.NotInitializedError = exports.NotConnectedError = exports.NCS_ERROR_CODE = exports.INTERNAL_ERROR_CODE = exports.GetFinalAcknowledgedStateError = exports.GetCurrentStateError = exports.DestroyError = exports.CustomError = exports.CantSyncUpError = void 0;
8
8
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
9
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
10
  var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
@@ -375,4 +375,17 @@ var UpdateDocumentError = /*#__PURE__*/function (_CustomError11) {
375
375
  }
376
376
  return (0, _createClass2.default)(UpdateDocumentError);
377
377
  }(CustomError);
378
- exports.UpdateDocumentError = UpdateDocumentError;
378
+ exports.UpdateDocumentError = UpdateDocumentError;
379
+ var CantSyncUpError = /*#__PURE__*/function (_CustomError12) {
380
+ (0, _inherits2.default)(CantSyncUpError, _CustomError12);
381
+ var _super13 = _createSuper(CantSyncUpError);
382
+ function CantSyncUpError(message, extraAttributes) {
383
+ var _this13;
384
+ (0, _classCallCheck2.default)(this, CantSyncUpError);
385
+ _this13 = _super13.call(this, message, undefined, extraAttributes);
386
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this13), "name", 'CantSyncUpError');
387
+ return _this13;
388
+ }
389
+ return (0, _createClass2.default)(CantSyncUpError);
390
+ }(CustomError);
391
+ exports.CantSyncUpError = CantSyncUpError;
@@ -20,7 +20,7 @@ var EVENT_ACTION = /*#__PURE__*/function (EVENT_ACTION) {
20
20
  EVENT_ACTION["CATCHUP_AFTER_MAX_SEND_STEPS_RETRY"] = "catchupAfterMaxSendStepsRetry";
21
21
  EVENT_ACTION["DROPPED_STEPS"] = "droppedStepInCatchup";
22
22
  return EVENT_ACTION;
23
- }({});
23
+ }({}); // https://data-portal.internal.atlassian.com/analytics/registry/53724
24
24
  exports.EVENT_ACTION = EVENT_ACTION;
25
25
  var EVENT_STATUS = /*#__PURE__*/function (EVENT_STATUS) {
26
26
  EVENT_STATUS["SUCCESS"] = "SUCCESS";
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.version = exports.nextMajorVersion = exports.name = void 0;
7
7
  var name = "@atlaskit/collab-provider";
8
8
  exports.name = name;
9
- var version = "9.5.2";
9
+ var version = "9.6.1";
10
10
  exports.version = version;
11
11
  var nextMajorVersion = function nextMajorVersion() {
12
12
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/collab-provider",
3
- "version": "9.5.2",
3
+ "version": "9.6.1",
4
4
  "sideEffects": false
5
5
  }
@@ -9,7 +9,7 @@ import { JSONTransformer } from '@atlaskit/editor-json-transformer';
9
9
  import { MAX_STEP_REJECTED_ERROR } from '../provider';
10
10
  import { catchup } from './catchup';
11
11
  import { StepQueueState } from './step-queue-state';
12
- import { INTERNAL_ERROR_CODE, UpdateDocumentError } from '../errors/error-types';
12
+ import { CantSyncUpError, INTERNAL_ERROR_CODE, UpdateDocumentError } from '../errors/error-types';
13
13
  const CATCHUP_THROTTLE = 1 * 1000; // 1 second
14
14
 
15
15
  const noop = () => {};
@@ -329,7 +329,7 @@ export class DocumentService {
329
329
  const unconfirmedSteps = this.getUnconfirmedSteps();
330
330
  try {
331
331
  if (unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length) {
332
- var _this$analyticsHelper19;
332
+ var _this$analyticsHelper18;
333
333
  startMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, this.analyticsHelper);
334
334
  let count = 0;
335
335
  // We use origins here as steps can be rebased. When steps are rebased a new step is created.
@@ -350,7 +350,7 @@ export class DocumentService {
350
350
  isLastTrConfirmed = true;
351
351
  }
352
352
  if (!isLastTrConfirmed && count++ >= ACK_MAX_TRY) {
353
- var _this$getUnconfirmedS, _this$analyticsHelper18;
353
+ var _this$getUnconfirmedS;
354
354
  if (this.onSyncUpError) {
355
355
  const state = this.getState();
356
356
  this.onSyncUpError({
@@ -362,42 +362,42 @@ export class DocumentService {
362
362
  });
363
363
  }
364
364
  const unconfirmedStepsInfoUGCRemoved = (_this$getUnconfirmedS = this.getUnconfirmedSteps()) === null || _this$getUnconfirmedS === void 0 ? void 0 : _this$getUnconfirmedS.map(step => getStepUGCFreeDetails(step));
365
- (_this$analyticsHelper18 = this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 ? void 0 : _this$analyticsHelper18.sendErrorEvent({
366
- unconfirmedStepsInfo: unconfirmedStepsInfoUGCRemoved
367
- }, "Can't sync up with Collab Service: unable to send unconfirmed steps and max retry reached");
368
- throw new Error("Can't sync up with Collab Service");
365
+ const error = new CantSyncUpError("Can't sync up with Collab Service: unable to send unconfirmed steps and max retry reached", {
366
+ unconfirmedStepsInfo: unconfirmedStepsInfoUGCRemoved ? unconfirmedStepsInfoUGCRemoved.toString() : 'Unable to generate UGC removed step info'
367
+ });
368
+ throw error;
369
369
  }
370
370
  }
371
371
  const measure = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, this.analyticsHelper);
372
- (_this$analyticsHelper19 = this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 ? void 0 : _this$analyticsHelper19.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.SUCCESS, {
372
+ (_this$analyticsHelper18 = this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 ? void 0 : _this$analyticsHelper18.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.SUCCESS, {
373
373
  latency: measure === null || measure === void 0 ? void 0 : measure.duration,
374
374
  // upon success, emit the total number of unconfirmed steps we synced
375
375
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
376
376
  });
377
377
  }
378
378
  } catch (error) {
379
- var _this$analyticsHelper20, _this$analyticsHelper21;
379
+ var _this$analyticsHelper19, _this$analyticsHelper20;
380
380
  const measure = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, this.analyticsHelper);
381
- (_this$analyticsHelper20 = this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 ? void 0 : _this$analyticsHelper20.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.FAILURE, {
381
+ (_this$analyticsHelper19 = this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 ? void 0 : _this$analyticsHelper19.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.FAILURE, {
382
382
  latency: measure === null || measure === void 0 ? void 0 : measure.duration,
383
383
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
384
384
  });
385
- (_this$analyticsHelper21 = this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 ? void 0 : _this$analyticsHelper21.sendErrorEvent(error, 'Error while committing unconfirmed steps');
385
+ (_this$analyticsHelper20 = this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 ? void 0 : _this$analyticsHelper20.sendErrorEvent(error, 'Error while committing unconfirmed steps');
386
386
  throw error;
387
387
  }
388
388
  });
389
389
  _defineProperty(this, "onStepRejectedError", () => {
390
- var _this$analyticsHelper22;
390
+ var _this$analyticsHelper21;
391
391
  this.stepRejectCounter++;
392
392
  logger(`Steps rejected (tries=${this.stepRejectCounter})`);
393
- (_this$analyticsHelper22 = this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 ? void 0 : _this$analyticsHelper22.sendActionEvent(EVENT_ACTION.SEND_STEPS_RETRY, EVENT_STATUS.INFO, {
393
+ (_this$analyticsHelper21 = this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 ? void 0 : _this$analyticsHelper21.sendActionEvent(EVENT_ACTION.SEND_STEPS_RETRY, EVENT_STATUS.INFO, {
394
394
  count: this.stepRejectCounter
395
395
  });
396
396
  let maxRetries = this.aggressiveCatchup ? this.failedStepsBeforeCatchupOnPublish : MAX_STEP_REJECTED_ERROR;
397
397
  if (this.stepRejectCounter >= maxRetries) {
398
- var _this$analyticsHelper23;
398
+ var _this$analyticsHelper22;
399
399
  logger(`The steps were rejected too many times (tries=${this.stepRejectCounter}, limit=${MAX_STEP_REJECTED_ERROR}). Trying to catch-up.`);
400
- (_this$analyticsHelper23 = this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 ? void 0 : _this$analyticsHelper23.sendActionEvent(EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, EVENT_STATUS.INFO);
400
+ (_this$analyticsHelper22 = this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 ? void 0 : _this$analyticsHelper22.sendActionEvent(EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, EVENT_STATUS.INFO);
401
401
  this.throttledCatchup();
402
402
  } else {
403
403
  // If committing steps failed try again automatically in 1s
@@ -462,9 +462,9 @@ export class DocumentService {
462
462
  setTimeout(() => this.sendStepsFromCurrentState(), 100);
463
463
  }
464
464
  } catch (error) {
465
- var _this$analyticsHelper24;
465
+ var _this$analyticsHelper23;
466
466
  logger(`Processing steps failed with error: ${error}. Triggering catch up call.`);
467
- (_this$analyticsHelper24 = this.analyticsHelper) === null || _this$analyticsHelper24 === void 0 ? void 0 : _this$analyticsHelper24.sendErrorEvent(error, 'Error while processing steps');
467
+ (_this$analyticsHelper23 = this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 ? void 0 : _this$analyticsHelper23.sendErrorEvent(error, 'Error while processing steps');
468
468
  this.throttledCatchup();
469
469
  }
470
470
  }
@@ -245,4 +245,10 @@ export class UpdateDocumentError extends CustomError {
245
245
  super(message, undefined, extraAttributes);
246
246
  _defineProperty(this, "name", 'UpdateDocumentError');
247
247
  }
248
+ }
249
+ export class CantSyncUpError extends CustomError {
250
+ constructor(message, extraAttributes) {
251
+ super(message, undefined, extraAttributes);
252
+ _defineProperty(this, "name", 'CantSyncUpError');
253
+ }
248
254
  }
@@ -14,7 +14,7 @@ export let EVENT_ACTION = /*#__PURE__*/function (EVENT_ACTION) {
14
14
  EVENT_ACTION["CATCHUP_AFTER_MAX_SEND_STEPS_RETRY"] = "catchupAfterMaxSendStepsRetry";
15
15
  EVENT_ACTION["DROPPED_STEPS"] = "droppedStepInCatchup";
16
16
  return EVENT_ACTION;
17
- }({});
17
+ }({}); // https://data-portal.internal.atlassian.com/analytics/registry/53724
18
18
  export let EVENT_STATUS = /*#__PURE__*/function (EVENT_STATUS) {
19
19
  EVENT_STATUS["SUCCESS"] = "SUCCESS";
20
20
  EVENT_STATUS["FAILURE"] = "FAILURE";
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/collab-provider";
2
- export const version = "9.5.2";
2
+ export const version = "9.6.1";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/collab-provider",
3
- "version": "9.5.2",
3
+ "version": "9.6.1",
4
4
  "sideEffects": false
5
5
  }
@@ -15,7 +15,7 @@ import { JSONTransformer } from '@atlaskit/editor-json-transformer';
15
15
  import { MAX_STEP_REJECTED_ERROR } from '../provider';
16
16
  import { catchup } from './catchup';
17
17
  import { StepQueueState } from './step-queue-state';
18
- import { INTERNAL_ERROR_CODE, UpdateDocumentError } from '../errors/error-types';
18
+ import { CantSyncUpError, INTERNAL_ERROR_CODE, UpdateDocumentError } from '../errors/error-types';
19
19
  var CATCHUP_THROTTLE = 1 * 1000; // 1 second
20
20
 
21
21
  var noop = function noop() {};
@@ -375,7 +375,7 @@ export var DocumentService = /*#__PURE__*/function () {
375
375
  * @throws {Error} Couldn't sync the steps after retrying 30 times
376
376
  */
377
377
  _defineProperty(this, "commitUnconfirmedSteps", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
378
- var unconfirmedSteps, _this$analyticsHelper19, count, unconfirmedTrs, lastTr, isLastTrConfirmed, nextUnconfirmedSteps, nextUnconfirmedTrs, _this$getUnconfirmedS, _this$analyticsHelper18, state, unconfirmedStepsInfoUGCRemoved, measure, _this$analyticsHelper20, _this$analyticsHelper21, _measure3;
378
+ var unconfirmedSteps, _this$analyticsHelper18, count, unconfirmedTrs, lastTr, isLastTrConfirmed, nextUnconfirmedSteps, nextUnconfirmedTrs, _this$getUnconfirmedS, state, unconfirmedStepsInfoUGCRemoved, _error2, measure, _this$analyticsHelper19, _this$analyticsHelper20, _measure3;
379
379
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
380
380
  while (1) switch (_context4.prev = _context4.next) {
381
381
  case 0:
@@ -428,16 +428,16 @@ export var DocumentService = /*#__PURE__*/function () {
428
428
  unconfirmedStepsInfoUGCRemoved = (_this$getUnconfirmedS = _this.getUnconfirmedSteps()) === null || _this$getUnconfirmedS === void 0 ? void 0 : _this$getUnconfirmedS.map(function (step) {
429
429
  return getStepUGCFreeDetails(step);
430
430
  });
431
- (_this$analyticsHelper18 = _this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 ? void 0 : _this$analyticsHelper18.sendErrorEvent({
432
- unconfirmedStepsInfo: unconfirmedStepsInfoUGCRemoved
433
- }, "Can't sync up with Collab Service: unable to send unconfirmed steps and max retry reached");
434
- throw new Error("Can't sync up with Collab Service");
431
+ _error2 = new CantSyncUpError("Can't sync up with Collab Service: unable to send unconfirmed steps and max retry reached", {
432
+ unconfirmedStepsInfo: unconfirmedStepsInfoUGCRemoved ? unconfirmedStepsInfoUGCRemoved.toString() : 'Unable to generate UGC removed step info'
433
+ });
434
+ throw _error2;
435
435
  case 19:
436
436
  _context4.next = 8;
437
437
  break;
438
438
  case 21:
439
439
  measure = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
440
- (_this$analyticsHelper19 = _this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 ? void 0 : _this$analyticsHelper19.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.SUCCESS, {
440
+ (_this$analyticsHelper18 = _this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 ? void 0 : _this$analyticsHelper18.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.SUCCESS, {
441
441
  latency: measure === null || measure === void 0 ? void 0 : measure.duration,
442
442
  // upon success, emit the total number of unconfirmed steps we synced
443
443
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
@@ -449,11 +449,11 @@ export var DocumentService = /*#__PURE__*/function () {
449
449
  _context4.prev = 25;
450
450
  _context4.t0 = _context4["catch"](1);
451
451
  _measure3 = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
452
- (_this$analyticsHelper20 = _this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 ? void 0 : _this$analyticsHelper20.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.FAILURE, {
452
+ (_this$analyticsHelper19 = _this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 ? void 0 : _this$analyticsHelper19.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.FAILURE, {
453
453
  latency: _measure3 === null || _measure3 === void 0 ? void 0 : _measure3.duration,
454
454
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
455
455
  });
456
- (_this$analyticsHelper21 = _this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 ? void 0 : _this$analyticsHelper21.sendErrorEvent(_context4.t0, 'Error while committing unconfirmed steps');
456
+ (_this$analyticsHelper20 = _this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 ? void 0 : _this$analyticsHelper20.sendErrorEvent(_context4.t0, 'Error while committing unconfirmed steps');
457
457
  throw _context4.t0;
458
458
  case 31:
459
459
  case "end":
@@ -462,17 +462,17 @@ export var DocumentService = /*#__PURE__*/function () {
462
462
  }, _callee4, null, [[1, 25]]);
463
463
  })));
464
464
  _defineProperty(this, "onStepRejectedError", function () {
465
- var _this$analyticsHelper22;
465
+ var _this$analyticsHelper21;
466
466
  _this.stepRejectCounter++;
467
467
  logger("Steps rejected (tries=".concat(_this.stepRejectCounter, ")"));
468
- (_this$analyticsHelper22 = _this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 ? void 0 : _this$analyticsHelper22.sendActionEvent(EVENT_ACTION.SEND_STEPS_RETRY, EVENT_STATUS.INFO, {
468
+ (_this$analyticsHelper21 = _this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 ? void 0 : _this$analyticsHelper21.sendActionEvent(EVENT_ACTION.SEND_STEPS_RETRY, EVENT_STATUS.INFO, {
469
469
  count: _this.stepRejectCounter
470
470
  });
471
471
  var maxRetries = _this.aggressiveCatchup ? _this.failedStepsBeforeCatchupOnPublish : MAX_STEP_REJECTED_ERROR;
472
472
  if (_this.stepRejectCounter >= maxRetries) {
473
- var _this$analyticsHelper23;
473
+ var _this$analyticsHelper22;
474
474
  logger("The steps were rejected too many times (tries=".concat(_this.stepRejectCounter, ", limit=").concat(MAX_STEP_REJECTED_ERROR, "). Trying to catch-up."));
475
- (_this$analyticsHelper23 = _this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 ? void 0 : _this$analyticsHelper23.sendActionEvent(EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, EVENT_STATUS.INFO);
475
+ (_this$analyticsHelper22 = _this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 ? void 0 : _this$analyticsHelper22.sendActionEvent(EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, EVENT_STATUS.INFO);
476
476
  _this.throttledCatchup();
477
477
  } else {
478
478
  // If committing steps failed try again automatically in 1s
@@ -545,9 +545,9 @@ export var DocumentService = /*#__PURE__*/function () {
545
545
  }, 100);
546
546
  }
547
547
  } catch (error) {
548
- var _this$analyticsHelper24;
548
+ var _this$analyticsHelper23;
549
549
  logger("Processing steps failed with error: ".concat(error, ". Triggering catch up call."));
550
- (_this$analyticsHelper24 = this.analyticsHelper) === null || _this$analyticsHelper24 === void 0 ? void 0 : _this$analyticsHelper24.sendErrorEvent(error, 'Error while processing steps');
550
+ (_this$analyticsHelper23 = this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 ? void 0 : _this$analyticsHelper23.sendErrorEvent(error, 'Error while processing steps');
551
551
  this.throttledCatchup();
552
552
  }
553
553
  }
@@ -361,4 +361,16 @@ export var UpdateDocumentError = /*#__PURE__*/function (_CustomError11) {
361
361
  return _this12;
362
362
  }
363
363
  return _createClass(UpdateDocumentError);
364
+ }(CustomError);
365
+ export var CantSyncUpError = /*#__PURE__*/function (_CustomError12) {
366
+ _inherits(CantSyncUpError, _CustomError12);
367
+ var _super13 = _createSuper(CantSyncUpError);
368
+ function CantSyncUpError(message, extraAttributes) {
369
+ var _this13;
370
+ _classCallCheck(this, CantSyncUpError);
371
+ _this13 = _super13.call(this, message, undefined, extraAttributes);
372
+ _defineProperty(_assertThisInitialized(_this13), "name", 'CantSyncUpError');
373
+ return _this13;
374
+ }
375
+ return _createClass(CantSyncUpError);
364
376
  }(CustomError);
@@ -14,7 +14,7 @@ export var EVENT_ACTION = /*#__PURE__*/function (EVENT_ACTION) {
14
14
  EVENT_ACTION["CATCHUP_AFTER_MAX_SEND_STEPS_RETRY"] = "catchupAfterMaxSendStepsRetry";
15
15
  EVENT_ACTION["DROPPED_STEPS"] = "droppedStepInCatchup";
16
16
  return EVENT_ACTION;
17
- }({});
17
+ }({}); // https://data-portal.internal.atlassian.com/analytics/registry/53724
18
18
  export var EVENT_STATUS = /*#__PURE__*/function (EVENT_STATUS) {
19
19
  EVENT_STATUS["SUCCESS"] = "SUCCESS";
20
20
  EVENT_STATUS["FAILURE"] = "FAILURE";
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/collab-provider";
2
- export var version = "9.5.2";
2
+ export var version = "9.6.1";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/collab-provider",
3
- "version": "9.5.2",
3
+ "version": "9.6.1",
4
4
  "sideEffects": false
5
5
  }
@@ -1,4 +1,4 @@
1
- import { DocumentUpdateErrorAttributes } from '../helpers/const';
1
+ import { CantSyncUpErrorAttributes, DocumentUpdateErrorAttributes } from '../helpers/const';
2
2
  export declare enum INTERNAL_ERROR_CODE {
3
3
  TOKEN_PERMISSION_ERROR = "TOKEN_PERMISSION_ERROR",
4
4
  RECONNECTION_NETWORK_ISSUE = "RECONNECTION_NETWORK_ISSUE",
@@ -480,4 +480,8 @@ export declare class UpdateDocumentError extends CustomError {
480
480
  name: string;
481
481
  constructor(message: string, extraAttributes: DocumentUpdateErrorAttributes);
482
482
  }
483
+ export declare class CantSyncUpError extends CustomError {
484
+ name: string;
485
+ constructor(message: string, extraAttributes: CantSyncUpErrorAttributes);
486
+ }
483
487
  export {};
@@ -32,6 +32,9 @@ export type DocumentUpdateErrorAttributes = {
32
32
  docHasContent?: boolean;
33
33
  isDocContentValid?: boolean;
34
34
  };
35
+ export type CantSyncUpErrorAttributes = {
36
+ unconfirmedStepsInfo: string;
37
+ };
35
38
  export type ErrorAnalyticsEvent = {
36
39
  eventAction: EVENT_ACTION.ERROR;
37
40
  attributes: {
@@ -1,4 +1,4 @@
1
1
  export { Provider } from './provider';
2
- export type { CollabParticipant, CollabEventInitData, CollabEventRemoteData, CollabEventConnectionData, CollabEventConnectingData, CollabEventDisconnectedData, CollabEventPresenceData, CollabEventTelepointerData, CollabEventLocalStepData, ResolvedEditorState, CollabConnectedPayload, CollabDisconnectedPayload, CollabInitPayload, CollabDataPayload, CollabTelepointerPayload, CollabPresencePayload, CollabMetadataPayload, CollabLocalStepsPayload, CollabEvents, CollabSendableSelection, CollabEditProvider, SyncUpErrorFunction, NewCollabSyncUpErrorAttributes, Socket, } from './types';
2
+ export type { CollabParticipant, CollabEventInitData, CollabEventRemoteData, CollabEventConnectionData, CollabEventConnectingData, CollabEventDisconnectedData, CollabEventPresenceData, CollabEventTelepointerData, CollabEventLocalStepData, ResolvedEditorState, CollabConnectedPayload, CollabDisconnectedPayload, CollabInitPayload, CollabDataPayload, CollabTelepointerPayload, CollabPresencePayload, CollabMetadataPayload, CollabLocalStepsPayload, CollabEvents, CollabSendableSelection, CollabEditProvider, SyncUpErrorFunction, NewCollabSyncUpErrorAttributes, Socket, ProviderParticipant, } from './types';
3
3
  export type { ProviderError } from './errors/error-types';
4
4
  export { PROVIDER_ERROR_CODE } from './errors/error-types';
@@ -152,6 +152,6 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
152
152
  /**
153
153
  *
154
154
  */
155
- getParticipants: () => import("../participants/participants-helper").ProviderParticipant[];
155
+ getParticipants: () => import("../types").ProviderParticipant[];
156
156
  }
157
157
  export {};
@@ -8,6 +8,7 @@ import type { ProviderError } from './errors/error-types';
8
8
  import { JSONDocNode } from '@atlaskit/editor-json-transformer';
9
9
  import { GetUserType } from './participants/participants-helper';
10
10
  import AnalyticsHelper from './analytics/analytics-helper';
11
+ export type { ProviderParticipant } from './participants/participants-helper';
11
12
  export interface CollabParticipant {
12
13
  lastActive: number;
13
14
  sessionId: string;
@@ -328,4 +329,3 @@ export type NewCollabSyncUpErrorAttributes = {
328
329
  version: number;
329
330
  };
330
331
  export type SyncUpErrorFunction = (attributes: NewCollabSyncUpErrorAttributes) => void;
331
- export {};
@@ -1,4 +1,4 @@
1
- import { DocumentUpdateErrorAttributes } from '../helpers/const';
1
+ import { CantSyncUpErrorAttributes, DocumentUpdateErrorAttributes } from '../helpers/const';
2
2
  export declare enum INTERNAL_ERROR_CODE {
3
3
  TOKEN_PERMISSION_ERROR = "TOKEN_PERMISSION_ERROR",
4
4
  RECONNECTION_NETWORK_ISSUE = "RECONNECTION_NETWORK_ISSUE",
@@ -480,4 +480,8 @@ export declare class UpdateDocumentError extends CustomError {
480
480
  name: string;
481
481
  constructor(message: string, extraAttributes: DocumentUpdateErrorAttributes);
482
482
  }
483
+ export declare class CantSyncUpError extends CustomError {
484
+ name: string;
485
+ constructor(message: string, extraAttributes: CantSyncUpErrorAttributes);
486
+ }
483
487
  export {};
@@ -32,6 +32,9 @@ export type DocumentUpdateErrorAttributes = {
32
32
  docHasContent?: boolean;
33
33
  isDocContentValid?: boolean;
34
34
  };
35
+ export type CantSyncUpErrorAttributes = {
36
+ unconfirmedStepsInfo: string;
37
+ };
35
38
  export type ErrorAnalyticsEvent = {
36
39
  eventAction: EVENT_ACTION.ERROR;
37
40
  attributes: {
@@ -1,4 +1,4 @@
1
1
  export { Provider } from './provider';
2
- export type { CollabParticipant, CollabEventInitData, CollabEventRemoteData, CollabEventConnectionData, CollabEventConnectingData, CollabEventDisconnectedData, CollabEventPresenceData, CollabEventTelepointerData, CollabEventLocalStepData, ResolvedEditorState, CollabConnectedPayload, CollabDisconnectedPayload, CollabInitPayload, CollabDataPayload, CollabTelepointerPayload, CollabPresencePayload, CollabMetadataPayload, CollabLocalStepsPayload, CollabEvents, CollabSendableSelection, CollabEditProvider, SyncUpErrorFunction, NewCollabSyncUpErrorAttributes, Socket, } from './types';
2
+ export type { CollabParticipant, CollabEventInitData, CollabEventRemoteData, CollabEventConnectionData, CollabEventConnectingData, CollabEventDisconnectedData, CollabEventPresenceData, CollabEventTelepointerData, CollabEventLocalStepData, ResolvedEditorState, CollabConnectedPayload, CollabDisconnectedPayload, CollabInitPayload, CollabDataPayload, CollabTelepointerPayload, CollabPresencePayload, CollabMetadataPayload, CollabLocalStepsPayload, CollabEvents, CollabSendableSelection, CollabEditProvider, SyncUpErrorFunction, NewCollabSyncUpErrorAttributes, Socket, ProviderParticipant, } from './types';
3
3
  export type { ProviderError } from './errors/error-types';
4
4
  export { PROVIDER_ERROR_CODE } from './errors/error-types';
@@ -152,6 +152,6 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
152
152
  /**
153
153
  *
154
154
  */
155
- getParticipants: () => import("../participants/participants-helper").ProviderParticipant[];
155
+ getParticipants: () => import("../types").ProviderParticipant[];
156
156
  }
157
157
  export {};
@@ -8,6 +8,7 @@ import type { ProviderError } from './errors/error-types';
8
8
  import { JSONDocNode } from '@atlaskit/editor-json-transformer';
9
9
  import { GetUserType } from './participants/participants-helper';
10
10
  import AnalyticsHelper from './analytics/analytics-helper';
11
+ export type { ProviderParticipant } from './participants/participants-helper';
11
12
  export interface CollabParticipant {
12
13
  lastActive: number;
13
14
  sessionId: string;
@@ -328,4 +329,3 @@ export type NewCollabSyncUpErrorAttributes = {
328
329
  version: number;
329
330
  };
330
331
  export type SyncUpErrorFunction = (attributes: NewCollabSyncUpErrorAttributes) => void;
331
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/collab-provider",
3
- "version": "9.5.2",
3
+ "version": "9.6.1",
4
4
  "description": "A provider for collaborative editing.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -36,7 +36,7 @@
36
36
  "dependencies": {
37
37
  "@atlaskit/analytics-gas-types": "^5.1.0",
38
38
  "@atlaskit/analytics-listeners": "^8.7.0",
39
- "@atlaskit/editor-json-transformer": "^8.9.0",
39
+ "@atlaskit/editor-json-transformer": "^8.10.0",
40
40
  "@atlaskit/prosemirror-collab": "^0.2.0",
41
41
  "@atlaskit/ufo": "^0.2.0",
42
42
  "@atlaskit/util-service-support": "^6.2.0",
@@ -61,9 +61,9 @@
61
61
  }
62
62
  },
63
63
  "devDependencies": {
64
- "@atlaskit/adf-schema": "^26.0.0",
64
+ "@atlaskit/adf-schema": "^26.1.0",
65
65
  "@atlaskit/analytics-listeners": "^8.7.0",
66
- "@atlaskit/editor-test-helpers": "^18.8.0",
66
+ "@atlaskit/editor-test-helpers": "^18.9.0",
67
67
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
68
68
  "prosemirror-model": "1.16.0",
69
69
  "prosemirror-state": "1.3.4",
package/report.api.md CHANGED
@@ -563,7 +563,7 @@ export type ProviderError =
563
563
  | ProviderDocumentUpdateError;
564
564
 
565
565
  // @public (undocumented)
566
- type ProviderParticipant = CollabParticipant & {
566
+ export type ProviderParticipant = CollabParticipant & {
567
567
  userId: string;
568
568
  clientId: number | string;
569
569
  email: string;
@@ -1,581 +0,0 @@
1
- ## API Report File for "@atlaskit/collab-provider"
2
-
3
- > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
-
5
- ```ts
6
-
7
- import type { AnalyticsWebClient } from '@atlaskit/analytics-listeners';
8
- import type { EditorState } from 'prosemirror-state';
9
- import { JSONDocNode } from '@atlaskit/editor-json-transformer';
10
- import type { Manager } from 'socket.io-client';
11
- import type { Step } from 'prosemirror-transform';
12
- import type { Transaction } from 'prosemirror-state';
13
-
14
- // @public (undocumented)
15
- type AuthCallback = (cb: (data: InitAndAuthData) => void) => void;
16
-
17
- // @public (undocumented)
18
- type BaseEvents = Pick<CollabEditProvider<CollabEvents>, 'send' | 'sendMessage' | 'setup'>;
19
-
20
- // @public (undocumented)
21
- type CollabCommitStatusEventPayload = {
22
- status: 'attempt' | 'failure' | 'success';
23
- version: number;
24
- };
25
-
26
- // @public (undocumented)
27
- export type CollabConnectedPayload = CollabEventConnectionData;
28
-
29
- // @public (undocumented)
30
- type CollabConnectingPayload = CollabEventConnectingData;
31
-
32
- // @public (undocumented)
33
- export interface CollabDataPayload extends CollabEventRemoteData {
34
- // (undocumented)
35
- json: StepJson[];
36
- // (undocumented)
37
- userIds: (number | string)[];
38
- // (undocumented)
39
- version: number;
40
- }
41
-
42
- // @public (undocumented)
43
- export interface CollabDisconnectedPayload {
44
- // (undocumented)
45
- reason: DisconnectReason;
46
- // (undocumented)
47
- sid: string;
48
- }
49
-
50
- // @public (undocumented)
51
- export interface CollabEditProvider<Events extends CollabEvents = CollabEvents> {
52
- // (undocumented)
53
- getFinalAcknowledgedState(): Promise<ResolvedEditorState>;
54
- // (undocumented)
55
- initialize(getState: () => any, createStep: (json: object) => Step): this;
56
- // (undocumented)
57
- off(evt: keyof Events, handler: (...args: any) => void): this;
58
- // (undocumented)
59
- on(evt: keyof Events, handler: (...args: any) => void): this;
60
- // (undocumented)
61
- send(tr: Transaction, oldState: EditorState, newState: EditorState): void;
62
- // (undocumented)
63
- sendMessage<K extends keyof Events>(data: {
64
- type: K;
65
- } & Events[K]): void;
66
- // (undocumented)
67
- setup(props: {
68
- getState?: () => EditorState;
69
- onSyncUpError?: SyncUpErrorFunction;
70
- }): this;
71
- // (undocumented)
72
- unsubscribeAll(evt: keyof Events): this;
73
- }
74
-
75
- // @public (undocumented)
76
- export interface CollabEventConnectingData {
77
- // (undocumented)
78
- initial: boolean;
79
- }
80
-
81
- // @public (undocumented)
82
- export interface CollabEventConnectionData {
83
- // (undocumented)
84
- initial: boolean;
85
- // (undocumented)
86
- sid: string;
87
- }
88
-
89
- // @public (undocumented)
90
- export interface CollabEventDisconnectedData {
91
- // (undocumented)
92
- reason: 'CLIENT_DISCONNECT' | 'SERVER_DISCONNECT' | 'SOCKET_CLOSED' | 'SOCKET_ERROR' | 'SOCKET_TIMEOUT' | 'UNKNOWN_DISCONNECT';
93
- // (undocumented)
94
- sid: string;
95
- }
96
-
97
- // @public (undocumented)
98
- export interface CollabEventInitData {
99
- // (undocumented)
100
- doc?: any;
101
- // (undocumented)
102
- json?: any;
103
- // (undocumented)
104
- reserveCursor?: boolean;
105
- // (undocumented)
106
- sid?: string;
107
- // (undocumented)
108
- version?: number;
109
- }
110
-
111
- // @public (undocumented)
112
- export interface CollabEventLocalStepData {
113
- // (undocumented)
114
- steps: Array<Step>;
115
- }
116
-
117
- // @public (undocumented)
118
- export interface CollabEventPresenceData {
119
- // (undocumented)
120
- joined?: CollabParticipant[];
121
- // (undocumented)
122
- left?: {
123
- sessionId: string;
124
- }[];
125
- }
126
-
127
- // @public (undocumented)
128
- export interface CollabEventRemoteData {
129
- // (undocumented)
130
- json?: any;
131
- // (undocumented)
132
- newState?: EditorState;
133
- // (undocumented)
134
- userIds?: (number | string)[];
135
- }
136
-
137
- // @public (undocumented)
138
- export interface CollabEvents {
139
- // (undocumented)
140
- 'commit-status': CollabCommitStatusEventPayload;
141
- // (undocumented)
142
- 'local-steps': CollabLocalStepsPayload;
143
- // (undocumented)
144
- 'metadata:changed': CollabMetadataPayload;
145
- // (undocumented)
146
- connected: CollabConnectedPayload;
147
- // (undocumented)
148
- connecting: CollabConnectingPayload;
149
- // (undocumented)
150
- data: CollabDataPayload;
151
- // (undocumented)
152
- disconnected: CollabDisconnectedPayload;
153
- // (undocumented)
154
- entity: any;
155
- // (undocumented)
156
- error: ProviderError;
157
- // (undocumented)
158
- init: CollabInitPayload;
159
- // (undocumented)
160
- presence: CollabPresencePayload;
161
- // (undocumented)
162
- telepointer: CollabTelepointerPayload;
163
- }
164
-
165
- // @public (undocumented)
166
- export interface CollabEventTelepointerData {
167
- // (undocumented)
168
- selection: CollabSendableSelection;
169
- // (undocumented)
170
- sessionId: string;
171
- // (undocumented)
172
- type: 'telepointer';
173
- }
174
-
175
- // @public (undocumented)
176
- export interface CollabInitPayload extends CollabEventInitData {
177
- // (undocumented)
178
- doc: any;
179
- // (undocumented)
180
- metadata?: Metadata_2;
181
- // (undocumented)
182
- reserveCursor?: boolean;
183
- // (undocumented)
184
- version: number;
185
- }
186
-
187
- // @public (undocumented)
188
- export type CollabLocalStepsPayload = {
189
- steps: readonly Step[];
190
- };
191
-
192
- // @public (undocumented)
193
- export type CollabMetadataPayload = Metadata_2;
194
-
195
- // @public (undocumented)
196
- export interface CollabParticipant {
197
- // (undocumented)
198
- avatar: string;
199
- // (undocumented)
200
- cursorPos?: number;
201
- // (undocumented)
202
- lastActive: number;
203
- // (undocumented)
204
- name: string;
205
- // (undocumented)
206
- sessionId: string;
207
- }
208
-
209
- // @public (undocumented)
210
- export type CollabPresencePayload = CollabEventPresenceData;
211
-
212
- // @public (undocumented)
213
- export interface CollabSendableSelection {
214
- // (undocumented)
215
- anchor?: number | string;
216
- // (undocumented)
217
- head?: number | string;
218
- // (undocumented)
219
- type: 'nodeSelection' | 'textSelection';
220
- }
221
-
222
- // @public (undocumented)
223
- export type CollabTelepointerPayload = CollabEventTelepointerData;
224
-
225
- // @public (undocumented)
226
- interface Config {
227
- analyticsClient?: AnalyticsWebClient;
228
- // (undocumented)
229
- cacheToken?: boolean;
230
- // (undocumented)
231
- createSocket: (path: string, auth?: AuthCallback | InitAndAuthData, productInfo?: ProductInformation) => Socket;
232
- // (undocumented)
233
- documentAri: string;
234
- enableErrorOnFailedDocumentApply?: boolean;
235
- failedStepLimitBeforeCatchupOnPublish?: number;
236
- // (undocumented)
237
- featureFlags?: {
238
- [key: string]: boolean;
239
- };
240
- // (undocumented)
241
- getAnalyticsWebClient?: Promise<AnalyticsWebClient>;
242
- // (undocumented)
243
- getUser?: GetUserType;
244
- // (undocumented)
245
- initialDraft?: InitialDraft;
246
- // (undocumented)
247
- lifecycle?: Lifecycle;
248
- // (undocumented)
249
- need404?: boolean;
250
- permissionTokenRefresh?: () => Promise<null | string>;
251
- // (undocumented)
252
- productInfo?: ProductInformation;
253
- // (undocumented)
254
- storage?: Storage_2;
255
- throwOnNotConnected?: boolean;
256
- // (undocumented)
257
- url: string;
258
- }
259
-
260
- // @public (undocumented)
261
- enum DisconnectReason {
262
- // (undocumented)
263
- CLIENT_DISCONNECT = "CLIENT_DISCONNECT",
264
- // (undocumented)
265
- SERVER_DISCONNECT = "SERVER_DISCONNECT",
266
- // (undocumented)
267
- SOCKET_CLOSED = "SOCKET_CLOSED",
268
- // (undocumented)
269
- SOCKET_ERROR = "SOCKET_ERROR",
270
- // (undocumented)
271
- SOCKET_TIMEOUT = "SOCKET_TIMEOUT",
272
- // (undocumented)
273
- UNKNOWN_DISCONNECT = "UNKNOWN_DISCONNECT"
274
- }
275
-
276
- // @public
277
- type DocumentNotFound = {
278
- code: PROVIDER_ERROR_CODE.DOCUMENT_NOT_FOUND;
279
- message: string;
280
- recoverable: boolean;
281
- status?: number;
282
- };
283
-
284
- // @public
285
- type DocumentNotRestore = {
286
- code: PROVIDER_ERROR_CODE.DOCUMENT_RESTORE_ERROR;
287
- message: string;
288
- recoverable: boolean;
289
- status?: number;
290
- };
291
-
292
- // @public (undocumented)
293
- class Emitter<T = any> {
294
- protected emit<K extends keyof T>(evt: K, data: T[K]): this;
295
- off<K extends keyof T>(evt: K, handler: (args: T[K]) => void): this;
296
- on<K extends keyof T>(evt: K, handler: (args: T[K]) => void): this;
297
- unsubscribeAll<K extends keyof T>(evt?: K): this;
298
- }
299
-
300
- // @public (undocumented)
301
- type EventHandler = () => void;
302
-
303
- // @public
304
- type FailToSave = {
305
- code: PROVIDER_ERROR_CODE.FAIL_TO_SAVE;
306
- message: string;
307
- recoverable: boolean;
308
- status?: number;
309
- };
310
-
311
- // @public (undocumented)
312
- type GetUserType = ((userId: string) => Promise<Pick<ProviderParticipant, 'avatar' | 'email' | 'name' | 'userId'>>) | undefined;
313
-
314
- // @public (undocumented)
315
- interface InitAndAuthData {
316
- // (undocumented)
317
- initialized: boolean;
318
- // (undocumented)
319
- need404?: boolean;
320
- // (undocumented)
321
- token?: string;
322
- }
323
-
324
- // @public (undocumented)
325
- interface InitialDraft {
326
- // (undocumented)
327
- document: JSONDocNode;
328
- // (undocumented)
329
- metadata?: Metadata_2;
330
- // (undocumented)
331
- timestamp?: number;
332
- // (undocumented)
333
- version: number;
334
- }
335
-
336
- // @public
337
- type InitialisationError = {
338
- code: PROVIDER_ERROR_CODE.INITIALISATION_ERROR;
339
- message: string;
340
- recoverable: boolean;
341
- status?: number;
342
- };
343
-
344
- // @public
345
- type InsufficientEditingPermission = {
346
- code: PROVIDER_ERROR_CODE.NO_PERMISSION_ERROR;
347
- message: string;
348
- recoverable: boolean;
349
- reason?: string;
350
- status?: number;
351
- };
352
-
353
- // @public
354
- type InternalServiceError = {
355
- code: PROVIDER_ERROR_CODE.INTERNAL_SERVICE_ERROR;
356
- message: string;
357
- recoverable: boolean;
358
- reason: string;
359
- status?: number;
360
- };
361
-
362
- // @public
363
- type InvalidProviderConfiguration = {
364
- code: PROVIDER_ERROR_CODE.INVALID_PROVIDER_CONFIGURATION;
365
- message: string;
366
- recoverable: boolean;
367
- reason: string;
368
- status?: number;
369
- };
370
-
371
- // @public
372
- type InvalidUserToken = {
373
- code: PROVIDER_ERROR_CODE.INVALID_USER_TOKEN;
374
- message: string;
375
- recoverable: boolean;
376
- status?: number;
377
- };
378
-
379
- // @public (undocumented)
380
- interface Lifecycle {
381
- // (undocumented)
382
- on(event: LifecycleEvents, handler: EventHandler): void;
383
- }
384
-
385
- // @public (undocumented)
386
- type LifecycleEvents = 'restore' | 'save';
387
-
388
- // @public
389
- type Locked = {
390
- code: PROVIDER_ERROR_CODE.LOCKED;
391
- message: string;
392
- recoverable: boolean;
393
- status?: number;
394
- };
395
-
396
- // @public (undocumented)
397
- type MarkJson = {
398
- type: string;
399
- attrs: {
400
- [key: string]: any;
401
- };
402
- };
403
-
404
- // @public (undocumented)
405
- interface Metadata_2 {
406
- // (undocumented)
407
- [key: string]: boolean | number | string;
408
- }
409
-
410
- // @public
411
- type NetworkIssue = {
412
- code: PROVIDER_ERROR_CODE.NETWORK_ISSUE;
413
- message: string;
414
- recoverable: boolean;
415
- status?: number;
416
- };
417
-
418
- // @public (undocumented)
419
- export type NewCollabSyncUpErrorAttributes = {
420
- lengthOfUnconfirmedSteps?: number;
421
- tries: number;
422
- maxRetries: number;
423
- clientId?: number | string;
424
- version: number;
425
- };
426
-
427
- // @public (undocumented)
428
- type NodeJson = {
429
- type: string;
430
- attrs: {
431
- [key: string]: any;
432
- };
433
- content: NodeJson[];
434
- marks: MarkJson[];
435
- text?: string;
436
- };
437
-
438
- // @public (undocumented)
439
- type ProductInformation = {
440
- product: string;
441
- subProduct?: string;
442
- };
443
-
444
- // @public (undocumented)
445
- export class Provider extends Emitter<CollabEvents> implements BaseEvents {
446
- constructor(config: Config);
447
- destroy(): this;
448
- // @deprecated
449
- disconnect(): this;
450
- getCurrentState: () => Promise<ResolvedEditorState>;
451
- getFinalAcknowledgedState: () => Promise<ResolvedEditorState>;
452
- getMetadata: () => Metadata_2;
453
- // (undocumented)
454
- getParticipants: () => ProviderParticipant[];
455
- // (undocumented)
456
- getStatePromiseResolve: (value: PromiseLike<void> | void) => void;
457
- // (undocumented)
458
- getUnconfirmedSteps: () => readonly Step[] | undefined;
459
- // @deprecated
460
- initialize(getState: () => EditorState): this;
461
- send(_tr: Transaction | null, _oldState: EditorState | null, newState: EditorState): void;
462
- sendMessage(data: CollabTelepointerPayload): void;
463
- // @deprecated
464
- setEditorWidth(editorWidth: string, broadcast?: boolean): void;
465
- setMetadata(metadata: Metadata_2): void;
466
- // @deprecated
467
- setTitle(title: string, broadcast?: boolean): void;
468
- setup({ getState, onSyncUpError, }: {
469
- getState?: () => EditorState;
470
- onSyncUpError?: SyncUpErrorFunction;
471
- }): this;
472
- // @deprecated
473
- unsubscribeAll(): this;
474
- }
475
-
476
- // @public (undocumented)
477
- export enum PROVIDER_ERROR_CODE {
478
- // (undocumented)
479
- DOCUMENT_NOT_FOUND = "DOCUMENT_NOT_FOUND",
480
- // (undocumented)
481
- DOCUMENT_RESTORE_ERROR = "DOCUMENT_RESTORE_ERROR",
482
- // (undocumented)
483
- DOCUMENT_UPDATE_ERROR = "DOCUMENT_UPDATE_ERROR",
484
- // (undocumented)
485
- FAIL_TO_SAVE = "FAIL_TO_SAVE",
486
- // (undocumented)
487
- INITIALISATION_ERROR = "INITIALISATION_ERROR",
488
- // (undocumented)
489
- INTERNAL_SERVICE_ERROR = "INTERNAL_SERVICE_ERROR",
490
- // (undocumented)
491
- INVALID_PROVIDER_CONFIGURATION = "INVALID_PROVIDER_CONFIGURATION",
492
- // (undocumented)
493
- INVALID_USER_TOKEN = "INVALID_USER_TOKEN",
494
- // (undocumented)
495
- LOCKED = "LOCKED",
496
- // (undocumented)
497
- NETWORK_ISSUE = "NETWORK_ISSUE",
498
- // (undocumented)
499
- NO_PERMISSION_ERROR = "NO_PERMISSION_ERROR"
500
- }
501
-
502
- // @public (undocumented)
503
- type ProviderDocumentUpdateError = {
504
- code: PROVIDER_ERROR_CODE.DOCUMENT_UPDATE_ERROR;
505
- message: 'The provider failed to apply changes to the editor';
506
- recoverable: boolean;
507
- status?: number;
508
- };
509
-
510
- // @public
511
- export type ProviderError = DocumentNotFound | DocumentNotRestore | FailToSave | InitialisationError | InsufficientEditingPermission | InternalServiceError | InvalidProviderConfiguration | InvalidUserToken | Locked | NetworkIssue | ProviderDocumentUpdateError;
512
-
513
- // @public (undocumented)
514
- type ProviderParticipant = CollabParticipant & {
515
- userId: string;
516
- clientId: number | string;
517
- email: string;
518
- };
519
-
520
- // @public (undocumented)
521
- export type ResolvedEditorState<T = any> = {
522
- content: JSONDocNode | T;
523
- title: null | string;
524
- stepVersion: number;
525
- };
526
-
527
- // @public (undocumented)
528
- interface SimpleEventEmitter {
529
- // (undocumented)
530
- on(event: string, fn: Function): SimpleEventEmitter;
531
- }
532
-
533
- // @public (undocumented)
534
- type SliceJson = {
535
- content: NodeJson[];
536
- openStart: number;
537
- openEnd: number;
538
- };
539
-
540
- // @public (undocumented)
541
- export interface Socket extends SimpleEventEmitter {
542
- // (undocumented)
543
- close(): Socket;
544
- // (undocumented)
545
- connect(): Socket;
546
- // (undocumented)
547
- emit(event: string, ...args: any[]): Socket;
548
- // (undocumented)
549
- id: string;
550
- // (undocumented)
551
- io?: Manager;
552
- }
553
-
554
- // @public (undocumented)
555
- type StepJson = {
556
- stepType?: string;
557
- from?: number;
558
- to?: number;
559
- slice?: SliceJson;
560
- clientId: number | string;
561
- userId: string;
562
- createdAt?: number;
563
- structure?: boolean;
564
- };
565
-
566
- // @public (undocumented)
567
- interface Storage_2 {
568
- // (undocumented)
569
- delete(key: string): Promise<void>;
570
- // (undocumented)
571
- get(key: string): Promise<string>;
572
- // (undocumented)
573
- set(key: string, value: string): Promise<void>;
574
- }
575
-
576
- // @public (undocumented)
577
- export type SyncUpErrorFunction = (attributes: NewCollabSyncUpErrorAttributes) => void;
578
-
579
- // (No @packageDocumentation comment for this package)
580
-
581
- ```