@atlaskit/editor-synced-block-provider 6.6.9 → 6.6.11

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 (36) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/clients/block-service/blockService.js +107 -107
  3. package/dist/cjs/clients/confluence/fetchMediaToken.js +21 -21
  4. package/dist/cjs/clients/confluence/sourceInfo.js +24 -24
  5. package/dist/cjs/clients/jira/fetchMediaToken.js +21 -21
  6. package/dist/cjs/clients/jira/sourceInfo.js +24 -24
  7. package/dist/cjs/hooks/useFetchSyncBlockData.js +18 -18
  8. package/dist/cjs/providers/block-service/blockServiceAPI.js +322 -321
  9. package/dist/cjs/providers/syncBlockProvider.js +49 -48
  10. package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +75 -75
  11. package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +77 -78
  12. package/dist/cjs/store-manager/syncBlockStoreManager.js +41 -41
  13. package/dist/cjs/store-manager/syncBlockSubscriptionManager.js +7 -18
  14. package/dist/cjs/utils/resourceId.js +2 -1
  15. package/dist/cjs/utils/retry.js +8 -8
  16. package/dist/cjs/utils/utils.js +4 -3
  17. package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +1 -1
  18. package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +1 -2
  19. package/dist/es2019/store-manager/syncBlockSubscriptionManager.js +7 -18
  20. package/dist/es2019/utils/utils.js +1 -2
  21. package/dist/esm/clients/block-service/blockService.js +107 -107
  22. package/dist/esm/clients/confluence/fetchMediaToken.js +21 -21
  23. package/dist/esm/clients/confluence/sourceInfo.js +24 -24
  24. package/dist/esm/clients/jira/fetchMediaToken.js +21 -21
  25. package/dist/esm/clients/jira/sourceInfo.js +24 -24
  26. package/dist/esm/hooks/useFetchSyncBlockData.js +18 -18
  27. package/dist/esm/providers/block-service/blockServiceAPI.js +321 -320
  28. package/dist/esm/providers/syncBlockProvider.js +49 -48
  29. package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +75 -75
  30. package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +77 -78
  31. package/dist/esm/store-manager/syncBlockStoreManager.js +41 -41
  32. package/dist/esm/store-manager/syncBlockSubscriptionManager.js +7 -18
  33. package/dist/esm/utils/resourceId.js +2 -1
  34. package/dist/esm/utils/retry.js +8 -8
  35. package/dist/esm/utils/utils.js +1 -2
  36. package/package.json +5 -8
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.parseResourceId = exports.createResourceIdForReference = void 0;
8
8
  var _toArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toArray"));
9
9
  var _consts = require("../common/consts");
10
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
10
11
  var isSyncBlockProduct = function isSyncBlockProduct(product) {
11
12
  return _consts.SYNC_BLOCK_PRODUCTS.includes(product);
12
13
  };
@@ -45,7 +46,7 @@ var parseResourceId = exports.parseResourceId = function parseResourceId(resourc
45
46
  product = _resourceId$split2[0],
46
47
  contentId = _resourceId$split2[1],
47
48
  uuid = _resourceId$split2[2],
48
- rest = _resourceId$split2.slice(3);
49
+ rest = _arrayLikeToArray(_resourceId$split2).slice(3);
49
50
 
50
51
  // invalid if any part is missing or there are extra parts
51
52
  if (!product || !contentId || !uuid || rest.length > 0) {
@@ -35,32 +35,32 @@ var _fetchWithRetry = exports.fetchWithRetry = /*#__PURE__*/function () {
35
35
  parsedDelay,
36
36
  retryDelay,
37
37
  _args = arguments;
38
- return _regenerator.default.wrap(function _callee$(_context) {
38
+ return _regenerator.default.wrap(function (_context) {
39
39
  while (1) switch (_context.prev = _context.next) {
40
40
  case 0:
41
41
  retriesRemaining = _args.length > 2 && _args[2] !== undefined ? _args[2] : 3;
42
42
  delay = _args.length > 3 && _args[3] !== undefined ? _args[3] : 1000;
43
- _context.next = 4;
43
+ _context.next = 1;
44
44
  return fetch(url, options);
45
- case 4:
45
+ case 1:
46
46
  response = _context.sent;
47
47
  shouldRetry = !response.ok && response.status === 429 && retriesRemaining > 1;
48
48
  if (shouldRetry) {
49
- _context.next = 8;
49
+ _context.next = 2;
50
50
  break;
51
51
  }
52
52
  return _context.abrupt("return", response);
53
- case 8:
53
+ case 2:
54
54
  retryAfter = response.headers.get('Retry-After');
55
55
  parsedDelay = (_ref2 = retryAfter ? parseRetryAfter(retryAfter) : undefined) !== null && _ref2 !== void 0 ? _ref2 : delay;
56
56
  retryDelay = Math.min(parsedDelay, MAX_RETRY_DELAY);
57
- _context.next = 13;
57
+ _context.next = 3;
58
58
  return new Promise(function (resolve) {
59
59
  return setTimeout(resolve, retryDelay);
60
60
  });
61
- case 13:
61
+ case 3:
62
62
  return _context.abrupt("return", _fetchWithRetry(url, options, retriesRemaining - 1, delay * 2));
63
- case 14:
63
+ case 4:
64
64
  case "end":
65
65
  return _context.stop();
66
66
  }
@@ -6,9 +6,10 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.stripAnnotationMarksFromJSONContent = exports.getSourceProductFromResourceIdSafe = exports.getContentIdAndProductFromResourceId = exports.createSyncBlockNode = exports.convertSyncBlockPMNodeToSyncBlockData = exports.convertSyncBlockJSONNodeToSyncBlockNode = exports.convertPMNodesToSyncBlockNodes = exports.convertPMNodeToSyncBlockNode = exports.convertContentUpdatedAt = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
9
  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; }
11
- 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; } /* eslint-disable require-unicode-regexp */
10
+ 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; }
11
+ /* eslint-disable require-unicode-regexp */
12
+
12
13
  var _stripAnnotationMarksFromJSONContent = exports.stripAnnotationMarksFromJSONContent = function stripAnnotationMarksFromJSONContent(content) {
13
14
  var strippedContent;
14
15
  content.forEach(function (contentNode, index) {
@@ -54,7 +55,7 @@ var convertSyncBlockPMNodeToSyncBlockData = exports.convertSyncBlockPMNodeToSync
54
55
  var content = node.content.toJSON();
55
56
  return {
56
57
  blockInstanceId: node.attrs.localId,
57
- content: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_12') ? _stripAnnotationMarksFromJSONContent(content) : content,
58
+ content: content ? _stripAnnotationMarksFromJSONContent(content) : content,
58
59
  resourceId: node.attrs.resourceId
59
60
  };
60
61
  };
@@ -153,7 +153,7 @@ export class ReferenceSyncBlockStoreManager {
153
153
  }
154
154
  stripAnnotationMarksFromReferenceData(syncBlock) {
155
155
  var _syncBlock$data;
156
- if (!fg('platform_synced_block_patch_12') || !((_syncBlock$data = syncBlock.data) !== null && _syncBlock$data !== void 0 && _syncBlock$data.content)) {
156
+ if (!((_syncBlock$data = syncBlock.data) !== null && _syncBlock$data !== void 0 && _syncBlock$data.content)) {
157
157
  return syncBlock;
158
158
  }
159
159
  const content = stripAnnotationMarksFromJSONContent(syncBlock.data.content);
@@ -1,6 +1,5 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { logException } from '@atlaskit/editor-common/monitoring';
3
- import { fg } from '@atlaskit/platform-feature-flags';
4
3
  import { SyncBlockError } from '../common/types';
5
4
  import { updateErrorPayload, createErrorPayload, deleteErrorPayload, updateCacheErrorPayload, getSourceInfoErrorPayload, updateSuccessPayload, createSuccessPayload, deleteSuccessPayload, fetchReferencesErrorPayload } from '../utils/errorHandling';
6
5
  import { getCreateSourceExperience, getDeleteSourceExperience, getSaveSourceExperience, getFetchSourceInfoExperience } from '../utils/experienceTracking';
@@ -152,7 +151,7 @@ export class SourceSyncBlockStoreManager {
152
151
  // `commitPendingCreation()` can trigger a follow-up flush once that
153
152
  // specific creation completes.
154
153
  // See EDITOR-7112.
155
- if (this.pendingCreationPromises.size > 0 && fg('platform_synced_block_patch_12')) {
154
+ if (this.pendingCreationPromises.size > 0) {
156
155
  let timedOut = false;
157
156
  let timeoutId;
158
157
  const timeout = new Promise(resolve => {
@@ -1,6 +1,5 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { logException } from '@atlaskit/editor-common/monitoring';
3
- import { fg } from '@atlaskit/platform-feature-flags';
4
3
  import { fetchErrorPayload, fetchSuccessPayload } from '../utils/errorHandling';
5
4
  import { resolveSyncBlockInstance } from '../utils/resolveSyncBlockInstance';
6
5
  import { getSourceProductFromResourceIdSafe } from '../utils/utils';
@@ -216,7 +215,6 @@ export class SyncBlockSubscriptionManager {
216
215
  if (!(dataProvider !== null && dataProvider !== void 0 && dataProvider.subscribeToBlockUpdates)) {
217
216
  return;
218
217
  }
219
- const reconnectEnabled = fg('platform_synced_block_patch_12');
220
218
  const unsubscribe = dataProvider.subscribeToBlockUpdates(resourceId, syncBlockInstance => {
221
219
  this.handleGraphQLUpdate(syncBlockInstance);
222
220
  }, error => {
@@ -225,12 +223,10 @@ export class SyncBlockSubscriptionManager {
225
223
  location: 'editor-synced-block-provider/syncBlockSubscriptionManager/graphql-subscription'
226
224
  });
227
225
  (_this$deps$getFireAna2 = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna2 === void 0 ? void 0 : _this$deps$getFireAna2(fetchErrorPayload(error.message, resourceId, getSourceProductFromResourceIdSafe(resourceId)));
228
- if (reconnectEnabled) {
229
- this.handleSubscriptionTerminated(resourceId);
230
- }
231
- }, reconnectEnabled ? () => {
232
226
  this.handleSubscriptionTerminated(resourceId);
233
- } : undefined);
227
+ }, () => {
228
+ this.handleSubscriptionTerminated(resourceId);
229
+ });
234
230
  if (unsubscribe) {
235
231
  this.graphqlSubscriptions.set(resourceId, unsubscribe);
236
232
  }
@@ -320,10 +316,8 @@ export class SyncBlockSubscriptionManager {
320
316
  unsubscribe();
321
317
  this.graphqlSubscriptions.delete(resourceId);
322
318
  }
323
- if (fg('platform_synced_block_patch_12')) {
324
- this.cancelPendingRetry(resourceId);
325
- this.retryAttempts.delete(resourceId);
326
- }
319
+ this.cancelPendingRetry(resourceId);
320
+ this.retryAttempts.delete(resourceId);
327
321
  }
328
322
  setupSubscriptionsForAllBlocks() {
329
323
  for (const resourceId of this.subscriptions.keys()) {
@@ -335,9 +329,7 @@ export class SyncBlockSubscriptionManager {
335
329
  unsubscribe();
336
330
  }
337
331
  this.graphqlSubscriptions.clear();
338
- if (fg('platform_synced_block_patch_12')) {
339
- this.cancelAllPendingRetries();
340
- }
332
+ this.cancelAllPendingRetries();
341
333
  }
342
334
  destroy() {
343
335
  this.cleanupAll();
@@ -363,10 +355,7 @@ export class SyncBlockSubscriptionManager {
363
355
  const resolved = existing ? resolveSyncBlockInstance(existing, syncBlockInstance) : syncBlockInstance;
364
356
  this.deps.updateCache(resolved);
365
357
  if (!syncBlockInstance.error) {
366
- // Successful data delivery means the subscription is healthy — reset retry counter
367
- if (fg('platform_synced_block_patch_12')) {
368
- this.resetRetryCount(syncBlockInstance.resourceId);
369
- }
358
+ this.resetRetryCount(syncBlockInstance.resourceId);
370
359
  const callbacks = this.subscriptions.get(syncBlockInstance.resourceId);
371
360
  const localIds = callbacks ? Object.keys(callbacks) : [];
372
361
  localIds.forEach(localId => {
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable require-unicode-regexp */
2
2
 
3
- import { fg } from '@atlaskit/platform-feature-flags';
4
3
  export const stripAnnotationMarksFromJSONContent = content => {
5
4
  var _strippedContent3;
6
5
  let strippedContent;
@@ -45,7 +44,7 @@ export const convertSyncBlockPMNodeToSyncBlockData = node => {
45
44
  const content = node.content.toJSON();
46
45
  return {
47
46
  blockInstanceId: node.attrs.localId,
48
- content: fg('platform_synced_block_patch_12') ? stripAnnotationMarksFromJSONContent(content) : content,
47
+ content: content ? stripAnnotationMarksFromJSONContent(content) : content,
49
48
  resourceId: node.attrs.resourceId
50
49
  };
51
50
  };