@atlaskit/collab-provider 9.18.0 → 9.18.2

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.
Files changed (49) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/analytics/analytics-helper.js +2 -2
  3. package/dist/cjs/channel.js +14 -12
  4. package/dist/cjs/document/document-service.js +7 -6
  5. package/dist/cjs/errors/{error-types.js → custom-errors.js} +1 -68
  6. package/dist/cjs/errors/error-code-mapper.js +27 -26
  7. package/dist/cjs/errors/internal-errors.js +40 -0
  8. package/dist/cjs/errors/ncs-errors.js +37 -0
  9. package/dist/cjs/provider/commit-step.js +3 -3
  10. package/dist/cjs/provider/index.js +14 -13
  11. package/dist/cjs/version-wrapper.js +1 -1
  12. package/dist/es2019/analytics/analytics-helper.js +1 -1
  13. package/dist/es2019/channel.js +3 -1
  14. package/dist/es2019/document/document-service.js +2 -1
  15. package/dist/es2019/errors/custom-errors.js +92 -0
  16. package/dist/es2019/errors/error-code-mapper.js +2 -2
  17. package/dist/es2019/errors/internal-errors.js +39 -0
  18. package/dist/es2019/errors/ncs-errors.js +34 -0
  19. package/dist/es2019/provider/commit-step.js +1 -1
  20. package/dist/es2019/provider/index.js +2 -1
  21. package/dist/es2019/version-wrapper.js +1 -1
  22. package/dist/esm/analytics/analytics-helper.js +1 -1
  23. package/dist/esm/channel.js +3 -1
  24. package/dist/esm/document/document-service.js +2 -1
  25. package/dist/esm/errors/{error-types.js → custom-errors.js} +0 -73
  26. package/dist/esm/errors/error-code-mapper.js +2 -2
  27. package/dist/esm/errors/internal-errors.js +39 -0
  28. package/dist/esm/errors/ncs-errors.js +34 -0
  29. package/dist/esm/provider/commit-step.js +1 -1
  30. package/dist/esm/provider/index.js +2 -1
  31. package/dist/esm/version-wrapper.js +1 -1
  32. package/dist/types/document/document-service.d.ts +1 -1
  33. package/dist/types/errors/custom-errors.d.ts +56 -0
  34. package/dist/types/errors/error-code-mapper.d.ts +2 -2
  35. package/dist/types/errors/internal-errors.d.ts +90 -0
  36. package/dist/types/errors/ncs-errors.d.ts +172 -0
  37. package/dist/types/provider/commit-step.d.ts +1 -1
  38. package/dist/types/types.d.ts +1 -1
  39. package/dist/types-ts4.5/document/document-service.d.ts +1 -1
  40. package/dist/types-ts4.5/errors/custom-errors.d.ts +56 -0
  41. package/dist/types-ts4.5/errors/error-code-mapper.d.ts +2 -2
  42. package/dist/types-ts4.5/errors/internal-errors.d.ts +90 -0
  43. package/dist/types-ts4.5/errors/ncs-errors.d.ts +172 -0
  44. package/dist/types-ts4.5/provider/commit-step.d.ts +1 -1
  45. package/dist/types-ts4.5/types.d.ts +1 -1
  46. package/package.json +2 -2
  47. package/dist/es2019/errors/error-types.js +0 -165
  48. package/dist/types/errors/error-types.d.ts +0 -315
  49. package/dist/types-ts4.5/errors/error-types.d.ts +0 -315
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/collab-provider
2
2
 
3
+ ## 9.18.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#58763](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/58763) [`0fdbd64522bf`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0fdbd64522bf) - update ADF schema
8
+
9
+ ## 9.18.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [#58105](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/58105) [`515950be7f0b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/515950be7f0b) - Split errors into multiple files
14
+
3
15
  ## 9.18.0
4
16
 
5
17
  ### Minor Changes
@@ -13,7 +13,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
13
13
  var _const = require("../helpers/const");
14
14
  var _versionWrapper = require("../version-wrapper");
15
15
  var _singleton = require("../connectivity/singleton");
16
- var _errorTypes = require("../errors/error-types");
16
+ var _customErrors = require("../errors/custom-errors");
17
17
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
18
18
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
19
19
  var EVENT_SUBJECT = 'collab';
@@ -78,7 +78,7 @@ var AnalyticsHelper = exports.default = /*#__PURE__*/function () {
78
78
  value: function sendErrorEvent(error, errorMessage) {
79
79
  var _data$code, _data, _data$status, _data2;
80
80
  var errorExtraAttributes = {};
81
- if (error instanceof _errorTypes.CustomError) {
81
+ if (error instanceof _customErrors.CustomError) {
82
82
  errorExtraAttributes = error.getExtraErrorEventAttributes() || {};
83
83
  }
84
84
  var errorAnalyticsEvent = {
@@ -23,7 +23,9 @@ var _reconnectHelper = _interopRequireDefault(require("./connectivity/reconnect-
23
23
  var _ufo = require("./analytics/ufo");
24
24
  var _disconnectedReasonMapper = require("./disconnected-reason-mapper");
25
25
  var _network = _interopRequireDefault(require("./connectivity/network"));
26
- var _errorTypes = require("./errors/error-types");
26
+ var _internalErrors = require("./errors/internal-errors");
27
+ var _ncsErrors = require("./errors/ncs-errors");
28
+ var _customErrors = require("./errors/custom-errors");
27
29
  var _socketMessageMetrics = require("./helpers/socket-message-metrics");
28
30
  var _featureFlags = require("./feature-flags");
29
31
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
@@ -116,7 +118,7 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
116
118
  message: (_message = error.message) !== null && _message !== void 0 ? _message : 'Connection error without message',
117
119
  data: _objectSpread({
118
120
  // @ts-expect-error I bet we'll see some connection errors, for the Socket IO errors
119
- code: (_errorData$code = errorData === null || errorData === void 0 ? void 0 : errorData.code) !== null && _errorData$code !== void 0 ? _errorData$code : _errorTypes.INTERNAL_ERROR_CODE.CONNECTION_ERROR
121
+ code: (_errorData$code = errorData === null || errorData === void 0 ? void 0 : errorData.code) !== null && _errorData$code !== void 0 ? _errorData$code : _internalErrors.INTERNAL_ERROR_CODE.CONNECTION_ERROR
120
122
  }, errorData)
121
123
  };
122
124
  _this.emit('error', connectionError);
@@ -130,7 +132,7 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
130
132
  var reconnectionError = {
131
133
  message: 'Reconnection failed 8 times when browser was offline, likely there was a network issue',
132
134
  data: {
133
- code: _errorTypes.INTERNAL_ERROR_CODE.RECONNECTION_NETWORK_ISSUE
135
+ code: _internalErrors.INTERNAL_ERROR_CODE.RECONNECTION_NETWORK_ISSUE
134
136
  }
135
137
  };
136
138
  _this.emit('error', reconnectionError);
@@ -305,7 +307,7 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
305
307
  message: 'The requested document is not found',
306
308
  data: {
307
309
  status: _context.t20.code,
308
- code: _errorTypes.INTERNAL_ERROR_CODE.DOCUMENT_NOT_FOUND
310
+ code: _internalErrors.INTERNAL_ERROR_CODE.DOCUMENT_NOT_FOUND
309
311
  }
310
312
  };
311
313
  _this.emit('error', errorNotFound);
@@ -318,7 +320,7 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
318
320
  message: 'Cannot fetch catchup from collab service',
319
321
  data: {
320
322
  status: _context.t20.status,
321
- code: _errorTypes.INTERNAL_ERROR_CODE.CATCHUP_FAILED
323
+ code: _internalErrors.INTERNAL_ERROR_CODE.CATCHUP_FAILED
322
324
  }
323
325
  };
324
326
  _this.emit('error', errorCatchup);
@@ -446,11 +448,11 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
446
448
  */
447
449
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "broadcast", function (type, data, callback) {
448
450
  if (!_this.socket) {
449
- throw new _errorTypes.NotInitializedError('Cannot broadcast, not initialized yet');
451
+ throw new _customErrors.NotInitializedError('Cannot broadcast, not initialized yet');
450
452
  }
451
453
  if (!_this.connected) {
452
454
  if (_this.config.throwOnNotConnected) {
453
- throw new _errorTypes.NotConnectedError('Cannot broadcast, currently offline.');
455
+ throw new _customErrors.NotConnectedError('Cannot broadcast, currently offline.');
454
456
  }
455
457
  return;
456
458
  }
@@ -465,11 +467,11 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
465
467
  */
466
468
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "sendMetadata", function (metadata) {
467
469
  if (!_this.socket) {
468
- throw new _errorTypes.NotInitializedError('Cannot send metadata, not initialized yet');
470
+ throw new _customErrors.NotInitializedError('Cannot send metadata, not initialized yet');
469
471
  }
470
472
  if (!_this.connected) {
471
473
  if (_this.config.throwOnNotConnected) {
472
- throw new _errorTypes.NotConnectedError('Cannot send metadata, currently offline.');
474
+ throw new _customErrors.NotConnectedError('Cannot send metadata, currently offline.');
473
475
  }
474
476
  }
475
477
  _this.socket.emit('metadata', metadata);
@@ -568,7 +570,7 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
568
570
  message: 'Insufficient editing permissions',
569
571
  data: {
570
572
  status: 403,
571
- code: _errorTypes.INTERNAL_ERROR_CODE.TOKEN_PERMISSION_ERROR,
573
+ code: _internalErrors.INTERNAL_ERROR_CODE.TOKEN_PERMISSION_ERROR,
572
574
  meta: {
573
575
  originalError: _context3.t0,
574
576
  reason: _context3.t0 === null || _context3.t0 === void 0 || (_data = _context3.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
@@ -672,7 +674,7 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
672
674
  message: 'Caught error during reconnection',
673
675
  data: {
674
676
  status: 500,
675
- code: _errorTypes.INTERNAL_ERROR_CODE.RECONNECTION_ERROR
677
+ code: _internalErrors.INTERNAL_ERROR_CODE.RECONNECTION_ERROR
676
678
  }
677
679
  };
678
680
  _this2.emit('error', reconnectionError);
@@ -761,7 +763,7 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
761
763
  var rateLimitError = {
762
764
  message: 'Rate limited',
763
765
  data: {
764
- code: _errorTypes.NCS_ERROR_CODE.RATE_LIMIT_ERROR,
766
+ code: _ncsErrors.NCS_ERROR_CODE.RATE_LIMIT_ERROR,
765
767
  status: 500,
766
768
  meta: {
767
769
  rateLimitType: rateLimitType,
@@ -20,8 +20,9 @@ var _editorJsonTransformer = require("@atlaskit/editor-json-transformer");
20
20
  var _provider = require("../provider");
21
21
  var _catchup = require("./catchup");
22
22
  var _stepQueueState = require("./step-queue-state");
23
+ var _internalErrors = require("../errors/internal-errors");
23
24
  var _featureFlags = require("../feature-flags");
24
- var _errorTypes = require("../errors/error-types");
25
+ var _customErrors = require("../errors/custom-errors");
25
26
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
26
27
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
27
28
  var CATCHUP_THROTTLE = 1 * 1000; // 1 second
@@ -234,7 +235,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
234
235
  data: {
235
236
  status: 500,
236
237
  // Meaningless, remove when we review error structure
237
- code: _errorTypes.INTERNAL_ERROR_CODE.ADD_STEPS_ERROR
238
+ code: _internalErrors.INTERNAL_ERROR_CODE.ADD_STEPS_ERROR
238
239
  }
239
240
  });
240
241
  }
@@ -281,7 +282,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
281
282
  data: {
282
283
  status: 500,
283
284
  // Meaningless, remove when we review error structure
284
- code: _errorTypes.INTERNAL_ERROR_CODE.DOCUMENT_RESTORE_ERROR
285
+ code: _internalErrors.INTERNAL_ERROR_CODE.DOCUMENT_RESTORE_ERROR
285
286
  }
286
287
  });
287
288
  }
@@ -362,7 +363,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
362
363
  var isDocContentValid = _this.validatePMJSONDocument(doc);
363
364
  if (_this.getCurrentPmVersion() !== version) {
364
365
  var _doc$content, _this$analyticsHelper17;
365
- var _error = new _errorTypes.UpdateDocumentError('Failed to update the document', {
366
+ var _error = new _customErrors.UpdateDocumentError('Failed to update the document', {
366
367
  newVersion: version,
367
368
  editorVersion: updatedVersion,
368
369
  isDocTruthy: !!doc,
@@ -374,7 +375,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
374
375
  _this.onErrorHandled({
375
376
  message: 'The provider failed to apply changes to the editor',
376
377
  data: {
377
- code: _errorTypes.INTERNAL_ERROR_CODE.DOCUMENT_UPDATE_ERROR,
378
+ code: _internalErrors.INTERNAL_ERROR_CODE.DOCUMENT_UPDATE_ERROR,
378
379
  meta: {
379
380
  newVersion: version,
380
381
  editorVersion: updatedVersion
@@ -480,7 +481,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
480
481
  unconfirmedStepsInfoUGCRemoved = (_this$getUnconfirmedS = _this.getUnconfirmedSteps()) === null || _this$getUnconfirmedS === void 0 ? void 0 : _this$getUnconfirmedS.map(function (step) {
481
482
  return (0, _utils.getStepUGCFreeDetails)(step);
482
483
  });
483
- _error2 = new _errorTypes.CantSyncUpError("Can't sync up with Collab Service: unable to send unconfirmed steps and max retry reached", {
484
+ _error2 = new _customErrors.CantSyncUpError("Can't sync up with Collab Service: unable to send unconfirmed steps and max retry reached", {
484
485
  unconfirmedStepsInfo: unconfirmedStepsInfoUGCRemoved ? unconfirmedStepsInfoUGCRemoved.toString() : 'Unable to generate UGC removed step info'
485
486
  });
486
487
  throw _error2;
@@ -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.NotInitializedError = exports.NotConnectedError = exports.NCS_ERROR_CODE = exports.INTERNAL_ERROR_CODE = exports.GetFinalAcknowledgedStateError = exports.GetCurrentStateError = exports.DestroyError = exports.CustomError = exports.CantSyncUpError = void 0;
7
+ exports.UpdateDocumentError = exports.SetTitleError = exports.SetMetadataError = exports.SetEditorWidthError = exports.SendTransactionError = exports.ProviderInitialisationError = exports.NotInitializedError = exports.NotConnectedError = 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"));
@@ -15,73 +15,6 @@ var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/w
15
15
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
16
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
17
17
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
18
- // Internal error codes (generated by collab provider)
19
- var INTERNAL_ERROR_CODE = exports.INTERNAL_ERROR_CODE = /*#__PURE__*/function (INTERNAL_ERROR_CODE) {
20
- INTERNAL_ERROR_CODE["TOKEN_PERMISSION_ERROR"] = "TOKEN_PERMISSION_ERROR";
21
- INTERNAL_ERROR_CODE["RECONNECTION_NETWORK_ISSUE"] = "RECONNECTION_NETWORK_ISSUE";
22
- INTERNAL_ERROR_CODE["CONNECTION_ERROR"] = "CONNECTION_ERROR";
23
- INTERNAL_ERROR_CODE["RECONNECTION_ERROR"] = "RECONNECTION_ERROR";
24
- INTERNAL_ERROR_CODE["DOCUMENT_NOT_FOUND"] = "DOCUMENT_NOT_FOUND";
25
- INTERNAL_ERROR_CODE["CATCHUP_FAILED"] = "CATCHUP_FAILED";
26
- INTERNAL_ERROR_CODE["DOCUMENT_RESTORE_ERROR"] = "DOCUMENT_RESTORE_ERROR";
27
- INTERNAL_ERROR_CODE["ADD_STEPS_ERROR"] = "ADD_STEPS_ERROR";
28
- INTERNAL_ERROR_CODE["DOCUMENT_UPDATE_ERROR"] = "DOCUMENT_UPDATE_ERROR";
29
- return INTERNAL_ERROR_CODE;
30
- }({}); // NCS error coded (generated by NCS)
31
- var NCS_ERROR_CODE = exports.NCS_ERROR_CODE = /*#__PURE__*/function (NCS_ERROR_CODE) {
32
- NCS_ERROR_CODE["HEAD_VERSION_UPDATE_FAILED"] = "HEAD_VERSION_UPDATE_FAILED";
33
- NCS_ERROR_CODE["VERSION_NUMBER_ALREADY_EXISTS"] = "VERSION_NUMBER_ALREADY_EXISTS";
34
- NCS_ERROR_CODE["INSUFFICIENT_EDITING_PERMISSION"] = "INSUFFICIENT_EDITING_PERMISSION";
35
- NCS_ERROR_CODE["FORBIDDEN_USER_TOKEN"] = "FORBIDDEN_USER_TOKEN";
36
- NCS_ERROR_CODE["DOCUMENT_NOT_FOUND"] = "DOCUMENT_NOT_FOUND";
37
- NCS_ERROR_CODE["INIT_DATA_LOAD_FAILED"] = "INIT_DATA_LOAD_FAILED";
38
- NCS_ERROR_CODE["ERROR_MAPPING_ERROR"] = "ERROR_MAPPING_ERROR";
39
- NCS_ERROR_CODE["NAMESPACE_INVALID"] = "NAMESPACE_INVALID";
40
- NCS_ERROR_CODE["NAMESPACE_NOT_FOUND"] = "NAMESPACE_NOT_FOUND";
41
- NCS_ERROR_CODE["TENANT_INSTANCE_MAINTENANCE"] = "TENANT_INSTANCE_MAINTENANCE";
42
- NCS_ERROR_CODE["LOCKED_DOCUMENT"] = "LOCKED_DOCUMENT";
43
- NCS_ERROR_CODE["EMPTY_BROADCAST"] = "EMPTY_BROADCAST";
44
- NCS_ERROR_CODE["DYNAMO_ERROR"] = "DYNAMO_ERROR";
45
- NCS_ERROR_CODE["INVALID_ACTIVATION_ID"] = "INVALID_ACTIVATION_ID";
46
- NCS_ERROR_CODE["INVALID_DOCUMENT_ARI"] = "INVALID_DOCUMENT_ARI";
47
- NCS_ERROR_CODE["INVALID_CLOUD_ID"] = "INVALID_CLOUD_ID";
48
- NCS_ERROR_CODE["RATE_LIMIT_ERROR"] = "RATE_LIMIT_ERROR";
49
- return NCS_ERROR_CODE;
50
- }({}); // TODO: Import emitted error codes from NCS
51
- // NCS Errors
52
- // - Step rejection errors
53
- // - Permission errors
54
- // - Page missing / TTL errors
55
- // - Server errors
56
- // - Less common back-end errors
57
- // Provider Errors
58
- // Channel Errors
59
- /**
60
- * When we try to apply state updates to the editor, if that fails to apply the user can enter an invalid state where no
61
- * changes can be saved to NCS.
62
- */
63
- /**
64
- * The client is trying to send too many messages or messages that are too large. This not expected to be a standard
65
- * operating condition and should only ever indicate a frontend bug.
66
- */
67
- /**
68
- * A union of all possible internal errors, that are mapped to another error if being emitted to the editor.
69
- */
70
- /*
71
- * This is what a generic ProviderError type would look like:
72
- * type ProviderError = {
73
- * // Unique code, identifies the specific emitted error
74
- * // Also exposed as a PROVIDER_ERROR_CODE enum to allow subscribers to use them
75
- * code: PROVIDER_ERROR_CODE;
76
- * // Informative message describing what went wrong
77
- * message: string;
78
- * // Flag indicating whether an error is recoverable or not
79
- * // used by consumers to disable the provider and show an error message
80
- * recoverable: boolean;
81
- * // A reason code used to give more detail about why a certain error was thrown
82
- * reason?: string;
83
- * }
84
- */
85
18
  // Custom Errors
86
19
  var CustomError = exports.CustomError = /*#__PURE__*/function (_Error) {
87
20
  (0, _inherits2.default)(CustomError, _Error);
@@ -4,7 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.errorCodeMapper = void 0;
7
- var _errorTypes = require("./error-types");
7
+ var _ncsErrors = require("./ncs-errors");
8
+ var _internalErrors = require("./internal-errors");
8
9
  var _collab = require("@atlaskit/editor-common/collab");
9
10
  /*
10
11
  * Maps internal collab provider errors to an emitted error format
@@ -12,17 +13,17 @@ var _collab = require("@atlaskit/editor-common/collab");
12
13
  var errorCodeMapper = exports.errorCodeMapper = function errorCodeMapper(error) {
13
14
  var _error$data, _error$data2, _error$data3, _error$data4;
14
15
  switch ((_error$data = error.data) === null || _error$data === void 0 ? void 0 : _error$data.code) {
15
- case _errorTypes.NCS_ERROR_CODE.HEAD_VERSION_UPDATE_FAILED:
16
- case _errorTypes.NCS_ERROR_CODE.VERSION_NUMBER_ALREADY_EXISTS:
16
+ case _ncsErrors.NCS_ERROR_CODE.HEAD_VERSION_UPDATE_FAILED:
17
+ case _ncsErrors.NCS_ERROR_CODE.VERSION_NUMBER_ALREADY_EXISTS:
17
18
  // This should never be called with these errors
18
19
  return;
19
- case _errorTypes.INTERNAL_ERROR_CODE.ADD_STEPS_ERROR:
20
- case _errorTypes.INTERNAL_ERROR_CODE.RECONNECTION_ERROR:
21
- case _errorTypes.INTERNAL_ERROR_CODE.CONNECTION_ERROR:
20
+ case _internalErrors.INTERNAL_ERROR_CODE.ADD_STEPS_ERROR:
21
+ case _internalErrors.INTERNAL_ERROR_CODE.RECONNECTION_ERROR:
22
+ case _internalErrors.INTERNAL_ERROR_CODE.CONNECTION_ERROR:
22
23
  // These errors shouldn't be emitted, we're hoping the provider self-recovers over time
23
24
  return;
24
- case _errorTypes.NCS_ERROR_CODE.INSUFFICIENT_EDITING_PERMISSION:
25
- case _errorTypes.INTERNAL_ERROR_CODE.TOKEN_PERMISSION_ERROR:
25
+ case _ncsErrors.NCS_ERROR_CODE.INSUFFICIENT_EDITING_PERMISSION:
26
+ case _internalErrors.INTERNAL_ERROR_CODE.TOKEN_PERMISSION_ERROR:
26
27
  return {
27
28
  code: _collab.PROVIDER_ERROR_CODE.NO_PERMISSION_ERROR,
28
29
  message: 'User does not have permissions to access this document or document is not found',
@@ -30,66 +31,66 @@ var errorCodeMapper = exports.errorCodeMapper = function errorCodeMapper(error)
30
31
  recoverable: true,
31
32
  status: 403
32
33
  };
33
- case _errorTypes.NCS_ERROR_CODE.FORBIDDEN_USER_TOKEN:
34
+ case _ncsErrors.NCS_ERROR_CODE.FORBIDDEN_USER_TOKEN:
34
35
  return {
35
36
  code: _collab.PROVIDER_ERROR_CODE.INVALID_USER_TOKEN,
36
37
  message: 'The user token was invalid',
37
38
  recoverable: true,
38
39
  status: 403
39
40
  };
40
- case _errorTypes.INTERNAL_ERROR_CODE.DOCUMENT_NOT_FOUND:
41
+ case _internalErrors.INTERNAL_ERROR_CODE.DOCUMENT_NOT_FOUND:
41
42
  return {
42
43
  code: _collab.PROVIDER_ERROR_CODE.DOCUMENT_NOT_FOUND,
43
44
  message: 'The requested document is not found',
44
45
  recoverable: true,
45
46
  status: 404
46
47
  };
47
- case _errorTypes.NCS_ERROR_CODE.TENANT_INSTANCE_MAINTENANCE:
48
- case _errorTypes.NCS_ERROR_CODE.LOCKED_DOCUMENT:
48
+ case _ncsErrors.NCS_ERROR_CODE.TENANT_INSTANCE_MAINTENANCE:
49
+ case _ncsErrors.NCS_ERROR_CODE.LOCKED_DOCUMENT:
49
50
  return {
50
51
  code: _collab.PROVIDER_ERROR_CODE.LOCKED,
51
52
  message: 'The document is currently not available, please try again later',
52
53
  recoverable: true
53
54
  };
54
- case _errorTypes.NCS_ERROR_CODE.DYNAMO_ERROR:
55
+ case _ncsErrors.NCS_ERROR_CODE.DYNAMO_ERROR:
55
56
  return {
56
57
  code: _collab.PROVIDER_ERROR_CODE.FAIL_TO_SAVE,
57
58
  message: 'Collab service is not able to save changes',
58
59
  recoverable: false,
59
60
  status: 500
60
61
  };
61
- case _errorTypes.INTERNAL_ERROR_CODE.DOCUMENT_RESTORE_ERROR:
62
+ case _internalErrors.INTERNAL_ERROR_CODE.DOCUMENT_RESTORE_ERROR:
62
63
  return {
63
64
  code: _collab.PROVIDER_ERROR_CODE.DOCUMENT_RESTORE_ERROR,
64
65
  message: 'Collab service unable to restore document',
65
66
  recoverable: false,
66
67
  status: 500
67
68
  };
68
- case _errorTypes.NCS_ERROR_CODE.INIT_DATA_LOAD_FAILED:
69
+ case _ncsErrors.NCS_ERROR_CODE.INIT_DATA_LOAD_FAILED:
69
70
  return {
70
71
  code: _collab.PROVIDER_ERROR_CODE.INITIALISATION_ERROR,
71
72
  message: "The initial document couldn't be loaded from the collab service",
72
73
  recoverable: false,
73
74
  status: 500
74
75
  };
75
- case _errorTypes.INTERNAL_ERROR_CODE.DOCUMENT_UPDATE_ERROR:
76
+ case _internalErrors.INTERNAL_ERROR_CODE.DOCUMENT_UPDATE_ERROR:
76
77
  return {
77
78
  code: _collab.PROVIDER_ERROR_CODE.DOCUMENT_UPDATE_ERROR,
78
79
  message: 'The provider failed to apply changes to the editor',
79
80
  recoverable: false,
80
81
  status: 500
81
82
  };
82
- case _errorTypes.INTERNAL_ERROR_CODE.RECONNECTION_NETWORK_ISSUE:
83
+ case _internalErrors.INTERNAL_ERROR_CODE.RECONNECTION_NETWORK_ISSUE:
83
84
  return {
84
85
  code: _collab.PROVIDER_ERROR_CODE.NETWORK_ISSUE,
85
86
  message: "Couldn't reconnect to the collab service due to network issues",
86
87
  recoverable: true,
87
88
  status: 500
88
89
  };
89
- case _errorTypes.NCS_ERROR_CODE.NAMESPACE_INVALID:
90
- case _errorTypes.NCS_ERROR_CODE.INVALID_ACTIVATION_ID:
91
- case _errorTypes.NCS_ERROR_CODE.INVALID_DOCUMENT_ARI:
92
- case _errorTypes.NCS_ERROR_CODE.INVALID_CLOUD_ID:
90
+ case _ncsErrors.NCS_ERROR_CODE.NAMESPACE_INVALID:
91
+ case _ncsErrors.NCS_ERROR_CODE.INVALID_ACTIVATION_ID:
92
+ case _ncsErrors.NCS_ERROR_CODE.INVALID_DOCUMENT_ARI:
93
+ case _ncsErrors.NCS_ERROR_CODE.INVALID_CLOUD_ID:
93
94
  return {
94
95
  code: _collab.PROVIDER_ERROR_CODE.INVALID_PROVIDER_CONFIGURATION,
95
96
  message: 'Invalid provider configuration',
@@ -97,9 +98,9 @@ var errorCodeMapper = exports.errorCodeMapper = function errorCodeMapper(error)
97
98
  reason: (_error$data2 = error.data) === null || _error$data2 === void 0 ? void 0 : _error$data2.code,
98
99
  status: 400
99
100
  };
100
- case _errorTypes.NCS_ERROR_CODE.NAMESPACE_NOT_FOUND:
101
- case _errorTypes.NCS_ERROR_CODE.ERROR_MAPPING_ERROR:
102
- case _errorTypes.NCS_ERROR_CODE.EMPTY_BROADCAST:
101
+ case _ncsErrors.NCS_ERROR_CODE.NAMESPACE_NOT_FOUND:
102
+ case _ncsErrors.NCS_ERROR_CODE.ERROR_MAPPING_ERROR:
103
+ case _ncsErrors.NCS_ERROR_CODE.EMPTY_BROADCAST:
103
104
  return {
104
105
  code: _collab.PROVIDER_ERROR_CODE.INTERNAL_SERVICE_ERROR,
105
106
  message: 'Collab Provider experienced an unrecoverable error',
@@ -107,7 +108,7 @@ var errorCodeMapper = exports.errorCodeMapper = function errorCodeMapper(error)
107
108
  reason: (_error$data3 = error.data) === null || _error$data3 === void 0 ? void 0 : _error$data3.code,
108
109
  status: 500
109
110
  };
110
- case _errorTypes.INTERNAL_ERROR_CODE.CATCHUP_FAILED:
111
+ case _internalErrors.INTERNAL_ERROR_CODE.CATCHUP_FAILED:
111
112
  return {
112
113
  code: _collab.PROVIDER_ERROR_CODE.INTERNAL_SERVICE_ERROR,
113
114
  message: 'Collab Provider experienced an unrecoverable error',
@@ -115,7 +116,7 @@ var errorCodeMapper = exports.errorCodeMapper = function errorCodeMapper(error)
115
116
  reason: (_error$data4 = error.data) === null || _error$data4 === void 0 ? void 0 : _error$data4.code,
116
117
  status: 500
117
118
  };
118
- case _errorTypes.NCS_ERROR_CODE.RATE_LIMIT_ERROR:
119
+ case _ncsErrors.NCS_ERROR_CODE.RATE_LIMIT_ERROR:
119
120
  return {
120
121
  code: _collab.PROVIDER_ERROR_CODE.FAIL_TO_SAVE,
121
122
  message: 'Document rate limit',
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.INTERNAL_ERROR_CODE = void 0;
7
+ var INTERNAL_ERROR_CODE = exports.INTERNAL_ERROR_CODE = /*#__PURE__*/function (INTERNAL_ERROR_CODE) {
8
+ INTERNAL_ERROR_CODE["TOKEN_PERMISSION_ERROR"] = "TOKEN_PERMISSION_ERROR";
9
+ INTERNAL_ERROR_CODE["RECONNECTION_NETWORK_ISSUE"] = "RECONNECTION_NETWORK_ISSUE";
10
+ INTERNAL_ERROR_CODE["CONNECTION_ERROR"] = "CONNECTION_ERROR";
11
+ INTERNAL_ERROR_CODE["RECONNECTION_ERROR"] = "RECONNECTION_ERROR";
12
+ INTERNAL_ERROR_CODE["DOCUMENT_NOT_FOUND"] = "DOCUMENT_NOT_FOUND";
13
+ INTERNAL_ERROR_CODE["CATCHUP_FAILED"] = "CATCHUP_FAILED";
14
+ INTERNAL_ERROR_CODE["DOCUMENT_RESTORE_ERROR"] = "DOCUMENT_RESTORE_ERROR";
15
+ INTERNAL_ERROR_CODE["ADD_STEPS_ERROR"] = "ADD_STEPS_ERROR";
16
+ INTERNAL_ERROR_CODE["DOCUMENT_UPDATE_ERROR"] = "DOCUMENT_UPDATE_ERROR";
17
+ return INTERNAL_ERROR_CODE;
18
+ }({}); // Channel Errors
19
+ /**
20
+ * When we try to apply state updates to the editor, if that fails to apply the user can enter an invalid state where no
21
+ * changes can be saved to NCS.
22
+ */
23
+ /**
24
+ * A union of all possible internal errors, that are mapped to another error if being emitted to the editor.
25
+ */
26
+ /*
27
+ * This is what a generic ProviderError type would look like:
28
+ * type ProviderError = {
29
+ * // Unique code, identifies the specific emitted error
30
+ * // Also exposed as a PROVIDER_ERROR_CODE enum to allow subscribers to use them
31
+ * code: PROVIDER_ERROR_CODE;
32
+ * // Informative message describing what went wrong
33
+ * message: string;
34
+ * // Flag indicating whether an error is recoverable or not
35
+ * // used by consumers to disable the provider and show an error message
36
+ * recoverable: boolean;
37
+ * // A reason code used to give more detail about why a certain error was thrown
38
+ * reason?: string;
39
+ * }
40
+ */
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.NCS_ERROR_CODE = void 0;
7
+ // NCS error coded (generated by NCS)
8
+ var NCS_ERROR_CODE = exports.NCS_ERROR_CODE = /*#__PURE__*/function (NCS_ERROR_CODE) {
9
+ NCS_ERROR_CODE["HEAD_VERSION_UPDATE_FAILED"] = "HEAD_VERSION_UPDATE_FAILED";
10
+ NCS_ERROR_CODE["VERSION_NUMBER_ALREADY_EXISTS"] = "VERSION_NUMBER_ALREADY_EXISTS";
11
+ NCS_ERROR_CODE["INSUFFICIENT_EDITING_PERMISSION"] = "INSUFFICIENT_EDITING_PERMISSION";
12
+ NCS_ERROR_CODE["FORBIDDEN_USER_TOKEN"] = "FORBIDDEN_USER_TOKEN";
13
+ NCS_ERROR_CODE["DOCUMENT_NOT_FOUND"] = "DOCUMENT_NOT_FOUND";
14
+ NCS_ERROR_CODE["INIT_DATA_LOAD_FAILED"] = "INIT_DATA_LOAD_FAILED";
15
+ NCS_ERROR_CODE["ERROR_MAPPING_ERROR"] = "ERROR_MAPPING_ERROR";
16
+ NCS_ERROR_CODE["NAMESPACE_INVALID"] = "NAMESPACE_INVALID";
17
+ NCS_ERROR_CODE["NAMESPACE_NOT_FOUND"] = "NAMESPACE_NOT_FOUND";
18
+ NCS_ERROR_CODE["TENANT_INSTANCE_MAINTENANCE"] = "TENANT_INSTANCE_MAINTENANCE";
19
+ NCS_ERROR_CODE["LOCKED_DOCUMENT"] = "LOCKED_DOCUMENT";
20
+ NCS_ERROR_CODE["EMPTY_BROADCAST"] = "EMPTY_BROADCAST";
21
+ NCS_ERROR_CODE["DYNAMO_ERROR"] = "DYNAMO_ERROR";
22
+ NCS_ERROR_CODE["INVALID_ACTIVATION_ID"] = "INVALID_ACTIVATION_ID";
23
+ NCS_ERROR_CODE["INVALID_DOCUMENT_ARI"] = "INVALID_DOCUMENT_ARI";
24
+ NCS_ERROR_CODE["INVALID_CLOUD_ID"] = "INVALID_CLOUD_ID";
25
+ NCS_ERROR_CODE["RATE_LIMIT_ERROR"] = "RATE_LIMIT_ERROR";
26
+ return NCS_ERROR_CODE;
27
+ }({}); // TODO: Import emitted error codes from NCS
28
+ // NCS Errors
29
+ // - Step rejection errors
30
+ // - Permission errors
31
+ // - Page missing / TTL errors
32
+ // - Server errors
33
+ // - Less common back-end errors
34
+ /**
35
+ * The client is trying to send too many messages or messages that are too large. This not expected to be a standard
36
+ * operating condition and should only ever indicate a frontend bug.
37
+ */
@@ -10,7 +10,7 @@ var _countBy = _interopRequireDefault(require("lodash/countBy"));
10
10
  var _throttle = _interopRequireDefault(require("lodash/throttle"));
11
11
  var _const = require("../helpers/const");
12
12
  var _types = require("../types");
13
- var _errorTypes = require("../errors/error-types");
13
+ var _ncsErrors = require("../errors/ncs-errors");
14
14
  var _utils = require("../helpers/utils");
15
15
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
16
16
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -92,7 +92,7 @@ var commitStepQueue = exports.commitStepQueue = function commitStepQueue(_ref) {
92
92
  // User tried committing steps but they were rejected because:
93
93
  // - HEAD_VERSION_UPDATE_FAILED: the collab service's latest stored step tail version didn't correspond to the head version of the first step submitted
94
94
  // - VERSION_NUMBER_ALREADY_EXISTS: while storing the steps there was a conflict meaning someone else wrote steps into the database more quickly
95
- type: response.error.data.code === _errorTypes.NCS_ERROR_CODE.HEAD_VERSION_UPDATE_FAILED || response.error.data.code === _errorTypes.NCS_ERROR_CODE.VERSION_NUMBER_ALREADY_EXISTS ? _const.ADD_STEPS_TYPE.REJECTED : _const.ADD_STEPS_TYPE.ERROR,
95
+ type: response.error.data.code === _ncsErrors.NCS_ERROR_CODE.HEAD_VERSION_UPDATE_FAILED || response.error.data.code === _ncsErrors.NCS_ERROR_CODE.VERSION_NUMBER_ALREADY_EXISTS ? _const.ADD_STEPS_TYPE.REJECTED : _const.ADD_STEPS_TYPE.ERROR,
96
96
  latency: latency
97
97
  });
98
98
  analyticsHelper === null || analyticsHelper === void 0 || analyticsHelper.sendErrorEvent(response.error, 'Error while adding steps - Acknowledgement Error');
@@ -171,7 +171,7 @@ var commitStep = exports.commitStep = function commitStep(_ref2) {
171
171
  // User tried committing steps but they were rejected because:
172
172
  // - HEAD_VERSION_UPDATE_FAILED: the collab service's latest stored step tail version didn't correspond to the head version of the first step submitted
173
173
  // - VERSION_NUMBER_ALREADY_EXISTS: while storing the steps there was a conflict meaning someone else wrote steps into the database more quickly
174
- type: response.error.data.code === _errorTypes.NCS_ERROR_CODE.HEAD_VERSION_UPDATE_FAILED || response.error.data.code === _errorTypes.NCS_ERROR_CODE.VERSION_NUMBER_ALREADY_EXISTS ? _const.ADD_STEPS_TYPE.REJECTED : _const.ADD_STEPS_TYPE.ERROR,
174
+ type: response.error.data.code === _ncsErrors.NCS_ERROR_CODE.HEAD_VERSION_UPDATE_FAILED || response.error.data.code === _ncsErrors.NCS_ERROR_CODE.VERSION_NUMBER_ALREADY_EXISTS ? _const.ADD_STEPS_TYPE.REJECTED : _const.ADD_STEPS_TYPE.ERROR,
175
175
  latency: latency
176
176
  });
177
177
  analyticsHelper === null || analyticsHelper === void 0 || analyticsHelper.sendErrorEvent(response.error, 'Error while adding steps - Acknowledgement Error');