@atlaskit/editor-synced-block-provider 3.31.2 → 3.32.0

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 (63) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/clients/block-service/blockService.js +21 -21
  3. package/dist/cjs/clients/confluence/fetchMediaToken.js +1 -2
  4. package/dist/cjs/clients/confluence/sourceInfo.js +27 -176
  5. package/dist/cjs/hooks/useFetchSyncBlockData.js +2 -9
  6. package/dist/cjs/hooks/useFetchSyncBlockTitle.js +8 -40
  7. package/dist/cjs/providers/block-service/blockServiceAPI.js +28 -41
  8. package/dist/cjs/providers/syncBlockProvider.js +22 -51
  9. package/dist/cjs/providers/types.js +3 -0
  10. package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +14 -29
  11. package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +1 -1
  12. package/dist/cjs/store-manager/syncBlockStoreManager.js +3 -15
  13. package/dist/cjs/store-manager/syncBlockSubscriptionManager.js +2 -2
  14. package/dist/cjs/utils/errorHandling.js +1 -10
  15. package/dist/cjs/utils/resolveSyncBlockInstance.js +11 -12
  16. package/dist/cjs/utils/retry.js +2 -23
  17. package/dist/es2019/clients/block-service/blockService.js +21 -21
  18. package/dist/es2019/clients/confluence/fetchMediaToken.js +1 -2
  19. package/dist/es2019/clients/confluence/sourceInfo.js +8 -126
  20. package/dist/es2019/hooks/useFetchSyncBlockData.js +1 -9
  21. package/dist/es2019/hooks/useFetchSyncBlockTitle.js +4 -33
  22. package/dist/es2019/providers/block-service/blockServiceAPI.js +18 -31
  23. package/dist/es2019/providers/syncBlockProvider.js +7 -29
  24. package/dist/es2019/providers/types.js +4 -0
  25. package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +27 -41
  26. package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +1 -1
  27. package/dist/es2019/store-manager/syncBlockStoreManager.js +3 -13
  28. package/dist/es2019/store-manager/syncBlockSubscriptionManager.js +2 -2
  29. package/dist/es2019/utils/errorHandling.js +1 -10
  30. package/dist/es2019/utils/resolveSyncBlockInstance.js +11 -12
  31. package/dist/es2019/utils/retry.js +2 -21
  32. package/dist/esm/clients/block-service/blockService.js +21 -21
  33. package/dist/esm/clients/confluence/fetchMediaToken.js +1 -2
  34. package/dist/esm/clients/confluence/sourceInfo.js +25 -176
  35. package/dist/esm/hooks/useFetchSyncBlockData.js +2 -9
  36. package/dist/esm/hooks/useFetchSyncBlockTitle.js +8 -40
  37. package/dist/esm/providers/block-service/blockServiceAPI.js +28 -41
  38. package/dist/esm/providers/syncBlockProvider.js +22 -51
  39. package/dist/esm/providers/types.js +4 -0
  40. package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +14 -29
  41. package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +1 -1
  42. package/dist/esm/store-manager/syncBlockStoreManager.js +3 -15
  43. package/dist/esm/store-manager/syncBlockSubscriptionManager.js +2 -2
  44. package/dist/esm/utils/errorHandling.js +1 -10
  45. package/dist/esm/utils/resolveSyncBlockInstance.js +11 -12
  46. package/dist/esm/utils/retry.js +2 -23
  47. package/dist/types/clients/block-service/blockService.d.ts +3 -0
  48. package/dist/types/clients/confluence/sourceInfo.d.ts +1 -3
  49. package/dist/types/index.d.ts +1 -1
  50. package/dist/types/providers/block-service/blockServiceAPI.d.ts +5 -3
  51. package/dist/types/providers/syncBlockProvider.d.ts +2 -3
  52. package/dist/types/providers/types.d.ts +13 -3
  53. package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +1 -1
  54. package/dist/types/store-manager/syncBlockStoreManager.d.ts +1 -1
  55. package/dist/types-ts4.5/clients/block-service/blockService.d.ts +3 -0
  56. package/dist/types-ts4.5/clients/confluence/sourceInfo.d.ts +1 -3
  57. package/dist/types-ts4.5/index.d.ts +1 -1
  58. package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +5 -3
  59. package/dist/types-ts4.5/providers/syncBlockProvider.d.ts +2 -3
  60. package/dist/types-ts4.5/providers/types.d.ts +13 -3
  61. package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +1 -1
  62. package/dist/types-ts4.5/store-manager/syncBlockStoreManager.d.ts +1 -1
  63. package/package.json +3 -10
@@ -11,7 +11,6 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
11
11
  import _regeneratorRuntime from "@babel/runtime/regenerator";
12
12
  /* eslint-disable require-unicode-regexp */
13
13
  import { useMemo } from 'react';
14
- import { fg } from '@atlaskit/platform-feature-flags';
15
14
  import { generateBlockAri as _generateBlockAri, generateBlockAriFromReference } from '../../clients/block-service/ari';
16
15
  import { batchRetrieveSyncedBlocks, BlockError, createSyncedBlock, deleteSyncedBlock, getReferenceSyncedBlocks, getReferenceSyncedBlocksByBlockAri, getSyncedBlockContent, updateReferenceSyncedBlockOnDocument, updateSyncedBlock, updateSyncedBlocks } from '../../clients/block-service/blockService';
17
16
  import { subscribeToBlockUpdates as subscribeToBlockUpdatesWS } from '../../clients/block-service/blockSubscription';
@@ -200,10 +199,11 @@ export var extractResourceIdFromBlockAri = function extractResourceIdFromBlockAr
200
199
  * @param cloudId - The cloudId of the block. E.G the cloudId of the confluence page, or the cloudId of the Jira instance
201
200
  * @param parentAri - The ARI of the parent of the block. E.G the ARI of the confluence page, or the ARI of the Jira work item
202
201
  * @param blockNodeIdentifiers - Array of block node identifiers to fetch
202
+ * @param config - Optional batch fetch configuration
203
203
  * @returns Array of SyncBlockInstance results
204
204
  */
205
205
  var _batchFetchData = /*#__PURE__*/function () {
206
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(cloudId, parentAri, blockNodeIdentifiers) {
206
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(cloudId, parentAri, blockNodeIdentifiers, config) {
207
207
  var blockIdentifiers, validResourceIds, processedResourceIds, response, results, _iterator, _step, blockContentResponse, resourceId, content, deletionReason, sourceAri, blockAri, contentUpdatedAt, blockInstanceId, product, status, syncedBlockData, _iterator2, _step2, errorResponse, _resourceId, _iterator3, _step3, blockNodeIdentifier;
208
208
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
209
209
  while (1) switch (_context2.prev = _context2.next) {
@@ -237,7 +237,8 @@ var _batchFetchData = /*#__PURE__*/function () {
237
237
  _context2.prev = 5;
238
238
  _context2.next = 8;
239
239
  return batchRetrieveSyncedBlocks({
240
- blockIdentifiers: blockIdentifiers
240
+ blockIdentifiers: blockIdentifiers,
241
+ config: config
241
242
  });
242
243
  case 8:
243
244
  response = _context2.sent;
@@ -295,22 +296,13 @@ var _batchFetchData = /*#__PURE__*/function () {
295
296
  resourceId: resourceId
296
297
  });
297
298
  } catch (_unused3) {
298
- if (fg('platform_synced_block_patch_3')) {
299
- results.push({
300
- error: {
301
- type: SyncBlockError.Errored,
302
- reason: "parsing JSON content response failed for resourceId: ".concat(resourceId, " localId: ").concat(blockAri)
303
- },
304
- resourceId: resourceId
305
- });
306
- } else {
307
- results.push({
308
- error: {
309
- type: SyncBlockError.Errored
310
- },
311
- resourceId: resourceId
312
- });
313
- }
299
+ results.push({
300
+ error: {
301
+ type: SyncBlockError.Errored,
302
+ reason: "parsing JSON content response failed for resourceId: ".concat(resourceId, " localId: ").concat(blockAri)
303
+ },
304
+ resourceId: resourceId
305
+ });
314
306
  }
315
307
  case 25:
316
308
  _context2.next = 14;
@@ -350,11 +342,9 @@ var _batchFetchData = /*#__PURE__*/function () {
350
342
  case 44:
351
343
  processedResourceIds.add(_resourceId);
352
344
  results.push({
353
- error: fg('platform_synced_block_patch_3') ? {
345
+ error: {
354
346
  type: mapErrorResponseCode(errorResponse.code),
355
347
  reason: errorResponse.reason
356
- } : {
357
- type: mapErrorResponseCode(errorResponse.code)
358
348
  },
359
349
  resourceId: _resourceId
360
350
  });
@@ -400,7 +390,7 @@ var _batchFetchData = /*#__PURE__*/function () {
400
390
  return {
401
391
  error: {
402
392
  type: _context2.t2 instanceof BlockError ? mapBlockError(_context2.t2) : SyncBlockError.Errored,
403
- reason: fg('platform_synced_block_patch_3') ? _context2.t2.message : undefined
393
+ reason: _context2.t2.message
404
394
  },
405
395
  resourceId: blockNodeIdentifier.resourceId
406
396
  };
@@ -411,7 +401,7 @@ var _batchFetchData = /*#__PURE__*/function () {
411
401
  }
412
402
  }, _callee2, null, [[5, 61], [12, 29, 32, 35], [37, 50, 53, 56]]);
413
403
  }));
414
- return function batchFetchData(_x2, _x3, _x4) {
404
+ return function batchFetchData(_x2, _x3, _x4, _x5) {
415
405
  return _ref3.apply(this, arguments);
416
406
  };
417
407
  }();
@@ -576,7 +566,7 @@ export var writeDataBatch = /*#__PURE__*/function () {
576
566
  }
577
567
  }, _callee3, null, [[2, 31], [13, 22, 25, 28]]);
578
568
  }));
579
- return function writeDataBatch(_x5, _x6, _x7, _x8, _x9, _x0) {
569
+ return function writeDataBatch(_x6, _x7, _x8, _x9, _x0, _x1) {
580
570
  return _ref4.apply(this, arguments);
581
571
  };
582
572
  }();
@@ -651,21 +641,17 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
651
641
  break;
652
642
  }
653
643
  return _context5.abrupt("return", {
654
- error: fg('platform_synced_block_patch_3') ? {
644
+ error: {
655
645
  type: mapBlockError(_context5.t0),
656
646
  reason: _context5.t0.message
657
- } : {
658
- type: mapBlockError(_context5.t0)
659
647
  },
660
648
  resourceId: resourceId
661
649
  });
662
650
  case 16:
663
651
  return _context5.abrupt("return", {
664
- error: fg('platform_synced_block_patch_3') ? {
652
+ error: {
665
653
  type: SyncBlockError.Errored,
666
654
  reason: _context5.t0.message
667
- } : {
668
- type: SyncBlockError.Errored
669
655
  },
670
656
  resourceId: resourceId
671
657
  });
@@ -675,7 +661,7 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
675
661
  }
676
662
  }, _callee4, this, [[1, 12]]);
677
663
  }));
678
- function fetchData(_x1) {
664
+ function fetchData(_x10) {
679
665
  return _fetchData.apply(this, arguments);
680
666
  }
681
667
  return fetchData;
@@ -740,7 +726,7 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
740
726
  }
741
727
  }, _callee5, this, [[0, 11]]);
742
728
  }));
743
- function fetchReferences(_x10) {
729
+ function fetchReferences(_x11) {
744
730
  return _fetchReferences.apply(this, arguments);
745
731
  }
746
732
  return fetchReferences;
@@ -748,17 +734,18 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
748
734
  /**
749
735
  * Batch fetches multiple synced blocks by their resource IDs.
750
736
  * @param blockNodeIdentifiers - Array of block node identifiers to fetch
737
+ * @param config - Optional batch fetch configuration
751
738
  * @returns Array of SyncBlockInstance results
752
739
  */
753
740
  }, {
754
741
  key: "batchFetchData",
755
742
  value: (function () {
756
- var _batchFetchData2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(blockNodeIdentifiers) {
743
+ var _batchFetchData2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(blockNodeIdentifiers, config) {
757
744
  return _regeneratorRuntime.wrap(function _callee6$(_context7) {
758
745
  while (1) switch (_context7.prev = _context7.next) {
759
746
  case 0:
760
747
  _context7.next = 2;
761
- return _batchFetchData(this.cloudId, this.parentAri, blockNodeIdentifiers);
748
+ return _batchFetchData(this.cloudId, this.parentAri, blockNodeIdentifiers, config);
762
749
  case 2:
763
750
  return _context7.abrupt("return", _context7.sent);
764
751
  case 3:
@@ -767,7 +754,7 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
767
754
  }
768
755
  }, _callee6, this);
769
756
  }));
770
- function batchFetchData(_x11) {
757
+ function batchFetchData(_x12, _x13) {
771
758
  return _batchFetchData2.apply(this, arguments);
772
759
  }
773
760
  return batchFetchData;
@@ -899,7 +886,7 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
899
886
  }
900
887
  }, _callee7, this, [[12, 19]]);
901
888
  }));
902
- function writeData(_x12) {
889
+ function writeData(_x14) {
903
890
  return _writeData.apply(this, arguments);
904
891
  }
905
892
  return writeData;
@@ -979,7 +966,7 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
979
966
  }
980
967
  }, _callee8, this, [[13, 19]]);
981
968
  }));
982
- function createData(_x13) {
969
+ function createData(_x15) {
983
970
  return _createData.apply(this, arguments);
984
971
  }
985
972
  return createData;
@@ -1053,7 +1040,7 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
1053
1040
  }
1054
1041
  }, _callee9, this, [[3, 9]]);
1055
1042
  }));
1056
- function deleteData(_x14, _x15) {
1043
+ function deleteData(_x16, _x17) {
1057
1044
  return _deleteData.apply(this, arguments);
1058
1045
  }
1059
1046
  return deleteData;
@@ -1136,7 +1123,7 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
1136
1123
  }
1137
1124
  }, _callee0, this, [[2, 8]]);
1138
1125
  }));
1139
- function updateReferenceData(_x16, _x17) {
1126
+ function updateReferenceData(_x18, _x19) {
1140
1127
  return _updateReferenceData.apply(this, arguments);
1141
1128
  }
1142
1129
  return updateReferenceData;
@@ -1302,7 +1289,7 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
1302
1289
  }
1303
1290
  }, _callee1, this, [[10, 39], [21, 30, 33, 36]]);
1304
1291
  }));
1305
- function writeDataBatch(_x18) {
1292
+ function writeDataBatch(_x20) {
1306
1293
  return _writeDataBatch.apply(this, arguments);
1307
1294
  }
1308
1295
  return writeDataBatch;
@@ -12,8 +12,6 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
12
12
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
13
13
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
14
14
  import { useMemo, useRef } from 'react';
15
- import { fg } from '@atlaskit/platform-feature-flags';
16
- import { conditionalHooksFactory } from '@atlaskit/platform-feature-flags-react';
17
15
  import { getProductFromSourceAri } from '../clients/block-service/ari';
18
16
  import { getPageIdAndTypeFromConfluencePageAri } from '../clients/confluence/ari';
19
17
  import { fetchConfluencePageInfo } from '../clients/confluence/sourceInfo';
@@ -112,11 +110,9 @@ export var SyncedBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
112
110
  return data;
113
111
  }, function (error) {
114
112
  return {
115
- error: fg('platform_synced_block_patch_3') ? {
113
+ error: {
116
114
  type: SyncBlockError.Errored,
117
115
  reason: error
118
- } : {
119
- type: SyncBlockError.Errored
120
116
  },
121
117
  resourceId: blockIdentifier.resourceId
122
118
  };
@@ -164,7 +160,7 @@ export var SyncedBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
164
160
  }
165
161
  return _context2.abrupt("return", Promise.reject(new Error('Write provider not set')));
166
162
  case 2:
167
- if (!(this.writeProvider.writeDataBatch && fg('platform_synced_block_patch_4'))) {
163
+ if (!this.writeProvider.writeDataBatch) {
168
164
  _context2.next = 12;
169
165
  break;
170
166
  }
@@ -309,11 +305,9 @@ export var SyncedBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
309
305
  }, {
310
306
  key: "fetchSyncBlockSourceInfo",
311
307
  value: (function () {
312
- var _fetchSyncBlockSourceInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(localId, sourceAri, sourceProduct, fireAnalyticsEvent) {
308
+ var _fetchSyncBlockSourceInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(localId, sourceAri, sourceProduct) {
313
309
  var _this$writeProvider, _this$writeProvider3;
314
310
  var hasAccess,
315
- urlType,
316
- isUnpublished,
317
311
  ari,
318
312
  product,
319
313
  _this$writeProvider2,
@@ -323,59 +317,57 @@ export var SyncedBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
323
317
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
324
318
  while (1) switch (_context4.prev = _context4.next) {
325
319
  case 0:
326
- hasAccess = _args4.length > 4 && _args4[4] !== undefined ? _args4[4] : true;
327
- urlType = _args4.length > 5 && _args4[5] !== undefined ? _args4[5] : 'edit';
328
- isUnpublished = _args4.length > 6 ? _args4[6] : undefined;
320
+ hasAccess = _args4.length > 3 && _args4[3] !== undefined ? _args4[3] : true;
329
321
  ari = sourceAri !== null && sourceAri !== void 0 ? sourceAri : (_this$writeProvider = this.writeProvider) === null || _this$writeProvider === void 0 ? void 0 : _this$writeProvider.parentAri;
330
322
  product = sourceProduct !== null && sourceProduct !== void 0 ? sourceProduct : getProductFromSourceAri(ari);
331
323
  if (!(!ari || !product)) {
332
- _context4.next = 7;
324
+ _context4.next = 5;
333
325
  break;
334
326
  }
335
327
  return _context4.abrupt("return", Promise.reject(new Error('Source ari or source product is undefined')));
336
- case 7:
328
+ case 5:
337
329
  _context4.t0 = product;
338
- _context4.next = _context4.t0 === 'confluence-page' ? 10 : _context4.t0 === 'jira-work-item' ? 16 : 22;
330
+ _context4.next = _context4.t0 === 'confluence-page' ? 8 : _context4.t0 === 'jira-work-item' ? 14 : 20;
339
331
  break;
332
+ case 8:
333
+ _context4.next = 10;
334
+ return fetchConfluencePageInfo(ari, hasAccess, localId);
340
335
  case 10:
341
- _context4.next = 12;
342
- return fetchConfluencePageInfo(ari, hasAccess, urlType, localId, isUnpublished);
343
- case 12:
344
336
  _sourceInfo = _context4.sent;
345
337
  if (_sourceInfo) {
346
- _context4.next = 15;
338
+ _context4.next = 13;
347
339
  break;
348
340
  }
349
341
  return _context4.abrupt("return", Promise.resolve(undefined));
350
- case 15:
342
+ case 13:
351
343
  return _context4.abrupt("return", _objectSpread(_objectSpread({}, _sourceInfo), {}, {
352
344
  onSameDocument: ((_this$writeProvider2 = this.writeProvider) === null || _this$writeProvider2 === void 0 ? void 0 : _this$writeProvider2.parentAri) === ari,
353
345
  productType: product
354
346
  }));
355
- case 16:
356
- _context4.next = 18;
347
+ case 14:
348
+ _context4.next = 16;
357
349
  return fetchJiraWorkItemInfo(ari, hasAccess);
358
- case 18:
350
+ case 16:
359
351
  sourceInfo = _context4.sent;
360
352
  if (sourceInfo) {
361
- _context4.next = 21;
353
+ _context4.next = 19;
362
354
  break;
363
355
  }
364
356
  return _context4.abrupt("return", Promise.resolve(undefined));
365
- case 21:
357
+ case 19:
366
358
  return _context4.abrupt("return", _objectSpread(_objectSpread({}, sourceInfo), {}, {
367
359
  onSameDocument: ((_this$writeProvider3 = this.writeProvider) === null || _this$writeProvider3 === void 0 ? void 0 : _this$writeProvider3.parentAri) === ari,
368
360
  productType: product
369
361
  }));
370
- case 22:
362
+ case 20:
371
363
  return _context4.abrupt("return", Promise.reject(new Error("".concat(product, " source product not supported"))));
372
- case 23:
364
+ case 21:
373
365
  case "end":
374
366
  return _context4.stop();
375
367
  }
376
368
  }, _callee4, this);
377
369
  }));
378
- function fetchSyncBlockSourceInfo(_x6, _x7, _x8, _x9) {
370
+ function fetchSyncBlockSourceInfo(_x6, _x7, _x8) {
379
371
  return _fetchSyncBlockSourceInfo.apply(this, arguments);
380
372
  }
381
373
  return fetchSyncBlockSourceInfo;
@@ -477,7 +469,7 @@ var createSyncedBlockProvider = function createSyncedBlockProvider(_ref) {
477
469
  writeProvider = _ref.writeProvider;
478
470
  return new SyncedBlockProvider(fetchProvider, writeProvider);
479
471
  };
480
- var useMemoizedSyncedBlockProviderBase = function useMemoizedSyncedBlockProviderBase(_ref2) {
472
+ export var useMemoizedSyncedBlockProvider = function useMemoizedSyncedBlockProvider(_ref2) {
481
473
  var fetchProvider = _ref2.fetchProvider,
482
474
  writeProvider = _ref2.writeProvider,
483
475
  providerOptions = _ref2.providerOptions,
@@ -488,24 +480,6 @@ var useMemoizedSyncedBlockProviderBase = function useMemoizedSyncedBlockProvider
488
480
  writeProvider: writeProvider
489
481
  });
490
482
  }, [fetchProvider, writeProvider]);
491
- syncBlockProvider.setProviderOptions(providerOptions);
492
- var ssrData = getSSRData ? getSSRData() : undefined;
493
- if (ssrData) {
494
- syncBlockProvider.setSSRData(ssrData);
495
- }
496
- return syncBlockProvider;
497
- };
498
- var useMemoizedSyncedBlockProviderPatched = function useMemoizedSyncedBlockProviderPatched(_ref3) {
499
- var fetchProvider = _ref3.fetchProvider,
500
- writeProvider = _ref3.writeProvider,
501
- providerOptions = _ref3.providerOptions,
502
- getSSRData = _ref3.getSSRData;
503
- var syncBlockProvider = useMemo(function () {
504
- return createSyncedBlockProvider({
505
- fetchProvider: fetchProvider,
506
- writeProvider: writeProvider
507
- });
508
- }, [fetchProvider, writeProvider]);
509
483
  var prevProviderOptionsRef = useRef(undefined);
510
484
  if (providerOptions !== prevProviderOptionsRef.current) {
511
485
  prevProviderOptionsRef.current = providerOptions;
@@ -520,7 +494,4 @@ var useMemoizedSyncedBlockProviderPatched = function useMemoizedSyncedBlockProvi
520
494
  }
521
495
  }
522
496
  return syncBlockProvider;
523
- };
524
- export var useMemoizedSyncedBlockProvider = conditionalHooksFactory(function () {
525
- return fg('platform_synced_block_patch_4');
526
- }, useMemoizedSyncedBlockProviderPatched, useMemoizedSyncedBlockProviderBase);
497
+ };
@@ -13,6 +13,10 @@ import { NodeDataProvider } from '@atlaskit/node-data-provider';
13
13
  * This will be used in both data processing and rendering contexts.
14
14
  */
15
15
 
16
+ /**
17
+ * Configuration options for batch fetch operations
18
+ */
19
+
16
20
  export var SyncBlockDataProviderInterface = /*#__PURE__*/function (_NodeDataProvider) {
17
21
  function SyncBlockDataProviderInterface() {
18
22
  _classCallCheck(this, SyncBlockDataProviderInterface);
@@ -458,10 +458,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
458
458
  value: function handleGraphQLSubscriptionUpdate(syncBlockInstance) {
459
459
  var _this5 = this;
460
460
  if (!syncBlockInstance.resourceId) {
461
- if (fg('platform_synced_block_patch_4')) {
462
- return;
463
- }
464
- throw new Error('Sync block instance provided to graphql subscription update missing resource id');
461
+ return;
465
462
  }
466
463
  var existingSyncBlock = this.getFromCache(syncBlockInstance.resourceId);
467
464
  var resolvedSyncBlockInstance = existingSyncBlock ? resolveSyncBlockInstance(existingSyncBlock, syncBlockInstance) : syncBlockInstance;
@@ -475,8 +472,8 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
475
472
  });
476
473
  this.fetchSyncBlockSourceInfo(resolvedSyncBlockInstance.resourceId);
477
474
  } else {
478
- var _syncBlockInstance$er, _syncBlockInstance$er2, _syncBlockInstance$er3, _this$fireAnalyticsEv3;
479
- var errorMessage = fg('platform_synced_block_patch_3') ? ((_syncBlockInstance$er = syncBlockInstance.error) === null || _syncBlockInstance$er === void 0 ? void 0 : _syncBlockInstance$er.reason) || ((_syncBlockInstance$er2 = syncBlockInstance.error) === null || _syncBlockInstance$er2 === void 0 ? void 0 : _syncBlockInstance$er2.type) : (_syncBlockInstance$er3 = syncBlockInstance.error) === null || _syncBlockInstance$er3 === void 0 ? void 0 : _syncBlockInstance$er3.type;
475
+ var _syncBlockInstance$er, _syncBlockInstance$er2, _this$fireAnalyticsEv3;
476
+ var errorMessage = ((_syncBlockInstance$er = syncBlockInstance.error) === null || _syncBlockInstance$er === void 0 ? void 0 : _syncBlockInstance$er.reason) || ((_syncBlockInstance$er2 = syncBlockInstance.error) === null || _syncBlockInstance$er2 === void 0 ? void 0 : _syncBlockInstance$er2.type);
480
477
  (_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(this, fetchErrorPayload(errorMessage, syncBlockInstance.resourceId));
481
478
  }
482
479
  }
@@ -551,12 +548,11 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
551
548
  key: "fetchSyncBlockSourceInfoBySourceAri",
552
549
  value: function fetchSyncBlockSourceInfoBySourceAri(sourceAri) {
553
550
  var hasAccess = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
554
- var urlType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'view';
555
551
  try {
556
552
  if (!this.dataProvider) {
557
553
  throw new Error('Data provider not set');
558
554
  }
559
- var sourceInfo = this.dataProvider.fetchSyncBlockSourceInfo(undefined, sourceAri, undefined, undefined, hasAccess, urlType);
555
+ var sourceInfo = this.dataProvider.fetchSyncBlockSourceInfo(undefined, sourceAri, undefined, hasAccess);
560
556
  return sourceInfo;
561
557
  } catch (error) {
562
558
  var _this$fireAnalyticsEv4;
@@ -572,7 +568,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
572
568
  value: function fetchSyncBlockSourceInfo(resourceId) {
573
569
  var _this6 = this;
574
570
  try {
575
- var _this$fetchSourceInfo, _existingSyncBlock$da;
571
+ var _this$fetchSourceInfo;
576
572
  if (!resourceId || !this.dataProvider) {
577
573
  throw new Error('Data provider or resourceId not set');
578
574
  }
@@ -609,12 +605,8 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
609
605
  return Promise.resolve(undefined);
610
606
  }
611
607
  (_this$fetchSourceInfo = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo === void 0 || _this$fetchSourceInfo.start({});
612
- var isUnpublished = ((_existingSyncBlock$da = existingSyncBlock.data) === null || _existingSyncBlock$da === void 0 ? void 0 : _existingSyncBlock$da.status) === 'unpublished';
613
- var sourceInfoPromise = this.dataProvider.fetchSyncBlockSourceInfo(blockInstanceId, sourceAri, product, this.fireAnalyticsEvent, true,
614
- // hasAccess
615
- 'edit',
616
- // urlType
617
- isUnpublished).then(function (sourceInfo) {
608
+ var sourceInfoPromise = this.dataProvider.fetchSyncBlockSourceInfo(blockInstanceId, sourceAri, product, true // hasAccess
609
+ ).then(function (sourceInfo) {
618
610
  if (!sourceInfo) {
619
611
  var _this6$fetchSourceInf, _this6$fireAnalyticsE;
620
612
  (_this6$fetchSourceInf = _this6.fetchSourceInfoExperience) === null || _this6$fetchSourceInf === void 0 || _this6$fetchSourceInf.failure({
@@ -828,8 +820,8 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
828
820
  data.forEach(function (syncBlockInstance) {
829
821
  var _resolvedSyncBlockIns;
830
822
  if (!syncBlockInstance.resourceId) {
831
- var _syncBlockInstance$er4, _syncBlockInstance$er5, _syncBlockInstance$er6, _this9$fireAnalyticsE;
832
- var payload = fg('platform_synced_block_patch_3') ? ((_syncBlockInstance$er4 = syncBlockInstance.error) === null || _syncBlockInstance$er4 === void 0 ? void 0 : _syncBlockInstance$er4.reason) || ((_syncBlockInstance$er5 = syncBlockInstance.error) === null || _syncBlockInstance$er5 === void 0 ? void 0 : _syncBlockInstance$er5.type) || 'Returned sync block instance does not have resource id' : ((_syncBlockInstance$er6 = syncBlockInstance.error) === null || _syncBlockInstance$er6 === void 0 ? void 0 : _syncBlockInstance$er6.type) || 'Returned sync block instance does not have resource id';
823
+ var _syncBlockInstance$er3, _syncBlockInstance$er4, _this9$fireAnalyticsE;
824
+ var payload = ((_syncBlockInstance$er3 = syncBlockInstance.error) === null || _syncBlockInstance$er3 === void 0 ? void 0 : _syncBlockInstance$er3.reason) || ((_syncBlockInstance$er4 = syncBlockInstance.error) === null || _syncBlockInstance$er4 === void 0 ? void 0 : _syncBlockInstance$er4.type) || 'Returned sync block instance does not have resource id';
833
825
  (_this9$fireAnalyticsE = _this9.fireAnalyticsEvent) === null || _this9$fireAnalyticsE === void 0 || _this9$fireAnalyticsE.call(_this9, fetchErrorPayload(payload));
834
826
  return;
835
827
  }
@@ -848,13 +840,8 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
848
840
  _this9.newlyAddedSyncBlocks.delete(syncBlockInstance.resourceId);
849
841
  }
850
842
  if (syncBlockInstance.error) {
851
- if (fg('platform_synced_block_patch_3')) {
852
- var _this9$fireAnalyticsE2;
853
- (_this9$fireAnalyticsE2 = _this9.fireAnalyticsEvent) === null || _this9$fireAnalyticsE2 === void 0 || _this9$fireAnalyticsE2.call(_this9, fetchErrorPayload(syncBlockInstance.error.reason || syncBlockInstance.error.type, syncBlockInstance.resourceId));
854
- } else {
855
- var _this9$fireAnalyticsE3;
856
- (_this9$fireAnalyticsE3 = _this9.fireAnalyticsEvent) === null || _this9$fireAnalyticsE3 === void 0 || _this9$fireAnalyticsE3.call(_this9, fetchErrorPayload(syncBlockInstance.error.type, syncBlockInstance.resourceId));
857
- }
843
+ var _this9$fireAnalyticsE2;
844
+ (_this9$fireAnalyticsE2 = _this9.fireAnalyticsEvent) === null || _this9$fireAnalyticsE2 === void 0 || _this9$fireAnalyticsE2.call(_this9, fetchErrorPayload(syncBlockInstance.error.reason || syncBlockInstance.error.type, syncBlockInstance.resourceId));
858
845
  if (syncBlockInstance.error.type === SyncBlockError.NotFound || syncBlockInstance.error.type === SyncBlockError.Forbidden) {
859
846
  hasExpectedError = true;
860
847
  } else if (syncBlockInstance.error) {
@@ -865,8 +852,8 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
865
852
  var callbacks = _this9.subscriptions.get(syncBlockInstance.resourceId);
866
853
  var localIds = callbacks ? Object.keys(callbacks) : [];
867
854
  localIds.forEach(function (localId) {
868
- var _this9$fireAnalyticsE4, _syncBlockInstance$da2;
869
- (_this9$fireAnalyticsE4 = _this9.fireAnalyticsEvent) === null || _this9$fireAnalyticsE4 === void 0 || _this9$fireAnalyticsE4.call(_this9, fetchSuccessPayload(syncBlockInstance.resourceId, localId, (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.product));
855
+ var _this9$fireAnalyticsE3, _syncBlockInstance$da2;
856
+ (_this9$fireAnalyticsE3 = _this9.fireAnalyticsEvent) === null || _this9$fireAnalyticsE3 === void 0 || _this9$fireAnalyticsE3.call(_this9, fetchSuccessPayload(syncBlockInstance.resourceId, localId, (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.product));
870
857
  });
871
858
  _this9.fetchSyncBlockSourceInfo(resolvedSyncBlockInstance.resourceId);
872
859
  });
@@ -906,9 +893,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
906
893
  callback(syncBlock);
907
894
  });
908
895
  }
909
- if (fg('platform_synced_block_patch_3')) {
910
- this.updateSessionCache(resourceId);
911
- }
896
+ this.updateSessionCache(resourceId);
912
897
  }
913
898
  }
914
899
  }, {
@@ -522,7 +522,7 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
522
522
  throw new Error('Data provider not set');
523
523
  }
524
524
  (_this$fetchSourceInfo = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo === void 0 || _this$fetchSourceInfo.start();
525
- return this.dataProvider.fetchSyncBlockSourceInfo(localId, undefined, undefined, this.fireAnalyticsEvent).then(function (sourceInfo) {
525
+ return this.dataProvider.fetchSyncBlockSourceInfo(localId, undefined, undefined).then(function (sourceInfo) {
526
526
  if (!sourceInfo) {
527
527
  var _this6$fetchSourceInf;
528
528
  (_this6$fetchSourceInf = _this6.fetchSourceInfoExperience) === null || _this6$fetchSourceInf === void 0 || _this6$fetchSourceInf.failure({
@@ -7,8 +7,6 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
7
7
  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) { _defineProperty(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; }
8
8
  import { useMemo, useRef } from 'react';
9
9
  import { logException } from '@atlaskit/editor-common/monitoring';
10
- import { fg } from '@atlaskit/platform-feature-flags';
11
- import { conditionalHooksFactory } from '@atlaskit/platform-feature-flags-react';
12
10
  import { getProductFromSourceAri } from '../clients/block-service/ari';
13
11
  import { SyncBlockError } from '../common/types';
14
12
  import { fetchReferencesErrorPayload } from '../utils/errorHandling';
@@ -91,7 +89,7 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
91
89
  case 0:
92
90
  (_this$fetchSourceInfo = _this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo === void 0 || _this$fetchSourceInfo.start();
93
91
  _context.next = 3;
94
- return (_this$dataProvider = _this.dataProvider) === null || _this$dataProvider === void 0 ? void 0 : _this$dataProvider.fetchSyncBlockSourceInfo(reference.blockInstanceId || '', reference.documentAri, getProductFromSourceAri(reference.documentAri), _this.fireAnalyticsEvent, reference.hasAccess, 'view');
92
+ return (_this$dataProvider = _this.dataProvider) === null || _this$dataProvider === void 0 ? void 0 : _this$dataProvider.fetchSyncBlockSourceInfo(reference.blockInstanceId || '', reference.documentAri, getProductFromSourceAri(reference.documentAri), reference.hasAccess);
95
93
  case 3:
96
94
  sourceInfo = _context.sent;
97
95
  if (sourceInfo) {
@@ -196,14 +194,7 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
196
194
  var createSyncBlockStoreManager = function createSyncBlockStoreManager(dataProvider) {
197
195
  return new SyncBlockStoreManager(dataProvider);
198
196
  };
199
- var useMemoizedSyncBlockStoreManagerBase = function useMemoizedSyncBlockStoreManagerBase(dataProvider, fireAnalyticsEvent) {
200
- var syncBlockStoreManager = useMemo(function () {
201
- return createSyncBlockStoreManager(dataProvider);
202
- }, [dataProvider]);
203
- syncBlockStoreManager.setFireAnalyticsEvent(fireAnalyticsEvent);
204
- return syncBlockStoreManager;
205
- };
206
- var useMemoizedSyncBlockStoreManagerPatched = function useMemoizedSyncBlockStoreManagerPatched(dataProvider, fireAnalyticsEvent) {
197
+ export var useMemoizedSyncBlockStoreManager = function useMemoizedSyncBlockStoreManager(dataProvider, fireAnalyticsEvent) {
207
198
  var syncBlockStoreManager = useMemo(function () {
208
199
  return createSyncBlockStoreManager(dataProvider);
209
200
  }, [dataProvider]);
@@ -213,7 +204,4 @@ var useMemoizedSyncBlockStoreManagerPatched = function useMemoizedSyncBlockStore
213
204
  syncBlockStoreManager.setFireAnalyticsEvent(fireAnalyticsEvent);
214
205
  }
215
206
  return syncBlockStoreManager;
216
- };
217
- export var useMemoizedSyncBlockStoreManager = conditionalHooksFactory(function () {
218
- return fg('platform_synced_block_patch_4');
219
- }, useMemoizedSyncBlockStoreManagerPatched, useMemoizedSyncBlockStoreManagerBase);
207
+ };
@@ -182,8 +182,8 @@ export var SyncBlockSubscriptionManager = /*#__PURE__*/function () {
182
182
  });
183
183
  this.deps.fetchSyncBlockSourceInfo(resolved.resourceId);
184
184
  } else {
185
- var _syncBlockInstance$er, _syncBlockInstance$er2, _syncBlockInstance$er3, _this$deps$getFireAna;
186
- var errorMessage = fg('platform_synced_block_patch_3') ? ((_syncBlockInstance$er = syncBlockInstance.error) === null || _syncBlockInstance$er === void 0 ? void 0 : _syncBlockInstance$er.reason) || ((_syncBlockInstance$er2 = syncBlockInstance.error) === null || _syncBlockInstance$er2 === void 0 ? void 0 : _syncBlockInstance$er2.type) : (_syncBlockInstance$er3 = syncBlockInstance.error) === null || _syncBlockInstance$er3 === void 0 ? void 0 : _syncBlockInstance$er3.type;
185
+ var _syncBlockInstance$er, _syncBlockInstance$er2, _this$deps$getFireAna;
186
+ var errorMessage = ((_syncBlockInstance$er = syncBlockInstance.error) === null || _syncBlockInstance$er === void 0 ? void 0 : _syncBlockInstance$er.reason) || ((_syncBlockInstance$er2 = syncBlockInstance.error) === null || _syncBlockInstance$er2 === void 0 ? void 0 : _syncBlockInstance$er2.type);
187
187
  (_this$deps$getFireAna = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna === void 0 || _this$deps$getFireAna(fetchErrorPayload(errorMessage, syncBlockInstance.resourceId));
188
188
  }
189
189
  }
@@ -2,7 +2,6 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  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; }
3
3
  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) { _defineProperty(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; }
4
4
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
5
- import { fg } from '@atlaskit/platform-feature-flags';
6
5
  export var stringifyError = function stringifyError(error) {
7
6
  try {
8
7
  return JSON.stringify(error);
@@ -64,7 +63,7 @@ export var fetchSuccessPayload = function fetchSuccessPayload(resourceId, blockI
64
63
  };
65
64
  };
66
65
  export var createSuccessPayload = function createSuccessPayload(resourceId) {
67
- return fg('platform_synced_block_patch_3') ? {
66
+ return {
68
67
  action: ACTION.INSERTED,
69
68
  actionSubject: ACTION_SUBJECT.DOCUMENT,
70
69
  actionSubjectId: ACTION_SUBJECT_ID.BODIED_SYNCED_BLOCK,
@@ -72,14 +71,6 @@ export var createSuccessPayload = function createSuccessPayload(resourceId) {
72
71
  attributes: {
73
72
  resourceId: resourceId
74
73
  }
75
- } : {
76
- action: ACTION.INSERTED,
77
- actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
78
- actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK_CREATE,
79
- eventType: EVENT_TYPE.OPERATIONAL,
80
- attributes: {
81
- resourceId: resourceId
82
- }
83
74
  };
84
75
  };
85
76
  export var createSuccessPayloadNew = function createSuccessPayloadNew(resourceId) {