@atlaskit/editor-synced-block-provider 4.2.5 → 4.2.6

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,13 @@
1
1
  # @atlaskit/editor-synced-block-provider
2
2
 
3
+ ## 4.2.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [`9039c3cc043e0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9039c3cc043e0) -
8
+ Editor-5990-Fixed-deleting-source-synced-block-on-copied-page-throw-error"
9
+ - Updated dependencies
10
+
3
11
  ## 4.2.5
4
12
 
5
13
  ### Patch Changes
@@ -13,6 +13,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
13
13
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
14
14
  var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));
15
15
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
16
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
17
  var _retry = require("../../utils/retry");
17
18
  function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
18
19
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
@@ -375,7 +376,7 @@ var batchRetrieveSyncedBlocks = exports.batchRetrieveSyncedBlocks = /*#__PURE__*
375
376
  var deleteSyncedBlock = exports.deleteSyncedBlock = /*#__PURE__*/function () {
376
377
  var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(_ref6) {
377
378
  var _result$data3;
378
- var blockAri, deleteReason, bodyData, url, response, result, isDeleted;
379
+ var blockAri, deleteReason, bodyData, url, response, result, allNotFound, isDeleted;
379
380
  return _regenerator.default.wrap(function _callee4$(_context4) {
380
381
  while (1) switch (_context4.prev = _context4.next) {
381
382
  case 0:
@@ -404,20 +405,34 @@ var deleteSyncedBlock = exports.deleteSyncedBlock = /*#__PURE__*/function () {
404
405
  case 10:
405
406
  result = _context4.sent;
406
407
  if (!(result.errors && result.errors.length > 0)) {
407
- _context4.next = 13;
408
+ _context4.next = 17;
408
409
  break;
409
410
  }
411
+ if (!(0, _platformFeatureFlags.fg)('platform_synced_block_patch_8')) {
412
+ _context4.next = 16;
413
+ break;
414
+ }
415
+ allNotFound = result.errors.every(function (e) {
416
+ var _e$extensions;
417
+ return ((_e$extensions = e.extensions) === null || _e$extensions === void 0 ? void 0 : _e$extensions.errorType) === 'RESOURCE_NOT_FOUND';
418
+ });
419
+ if (!allNotFound) {
420
+ _context4.next = 16;
421
+ break;
422
+ }
423
+ return _context4.abrupt("return");
424
+ case 16:
410
425
  throw new Error(result.errors.map(function (e) {
411
426
  return e.message;
412
427
  }).join(', '));
413
- case 13:
428
+ case 17:
414
429
  isDeleted = (_result$data3 = result.data) === null || _result$data3 === void 0 || (_result$data3 = _result$data3.blockService_deleteBlock) === null || _result$data3 === void 0 ? void 0 : _result$data3.deleted;
415
430
  if (isDeleted) {
416
- _context4.next = 16;
431
+ _context4.next = 20;
417
432
  break;
418
433
  }
419
434
  throw new Error('Block deletion failed; deleted flag is false');
420
- case 16:
435
+ case 20:
421
436
  case "end":
422
437
  return _context4.stop();
423
438
  }
@@ -1,3 +1,4 @@
1
+ import { fg } from '@atlaskit/platform-feature-flags';
1
2
  import { fetchWithRetry } from '../../utils/retry';
2
3
  export const isBlockContentResponse = response => {
3
4
  const content = response.content;
@@ -397,6 +398,18 @@ export const deleteSyncedBlock = async ({
397
398
  }
398
399
  const result = await response.json();
399
400
  if (result.errors && result.errors.length > 0) {
401
+ if (fg('platform_synced_block_patch_8')) {
402
+ const allNotFound = result.errors.every(e => {
403
+ var _e$extensions;
404
+ return ((_e$extensions = e.extensions) === null || _e$extensions === void 0 ? void 0 : _e$extensions.errorType) === 'RESOURCE_NOT_FOUND';
405
+ });
406
+ if (allNotFound) {
407
+ // do not throw an error, return early
408
+ // as if the block is not found, it is likely an orphan from a page copy.
409
+ // delete the synced block should just delete the block from the ADF, no need to delete it from the block service as it does not exist.
410
+ return;
411
+ }
412
+ }
400
413
  throw new Error(result.errors.map(e => e.message).join(', '));
401
414
  }
402
415
  const isDeleted = (_result$data3 = result.data) === null || _result$data3 === void 0 ? void 0 : (_result$data3$blockSe = _result$data3.blockService_deleteBlock) === null || _result$data3$blockSe === void 0 ? void 0 : _result$data3$blockSe.deleted;
@@ -8,6 +8,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
8
8
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
9
9
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
10
10
  import _regeneratorRuntime from "@babel/runtime/regenerator";
11
+ import { fg } from '@atlaskit/platform-feature-flags';
11
12
  import { fetchWithRetry } from '../../utils/retry';
12
13
  export var isBlockContentResponse = function isBlockContentResponse(response) {
13
14
  var content = response.content;
@@ -368,7 +369,7 @@ export var batchRetrieveSyncedBlocks = /*#__PURE__*/function () {
368
369
  export var deleteSyncedBlock = /*#__PURE__*/function () {
369
370
  var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref6) {
370
371
  var _result$data3;
371
- var blockAri, deleteReason, bodyData, url, response, result, isDeleted;
372
+ var blockAri, deleteReason, bodyData, url, response, result, allNotFound, isDeleted;
372
373
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
373
374
  while (1) switch (_context4.prev = _context4.next) {
374
375
  case 0:
@@ -397,20 +398,34 @@ export var deleteSyncedBlock = /*#__PURE__*/function () {
397
398
  case 10:
398
399
  result = _context4.sent;
399
400
  if (!(result.errors && result.errors.length > 0)) {
400
- _context4.next = 13;
401
+ _context4.next = 17;
401
402
  break;
402
403
  }
404
+ if (!fg('platform_synced_block_patch_8')) {
405
+ _context4.next = 16;
406
+ break;
407
+ }
408
+ allNotFound = result.errors.every(function (e) {
409
+ var _e$extensions;
410
+ return ((_e$extensions = e.extensions) === null || _e$extensions === void 0 ? void 0 : _e$extensions.errorType) === 'RESOURCE_NOT_FOUND';
411
+ });
412
+ if (!allNotFound) {
413
+ _context4.next = 16;
414
+ break;
415
+ }
416
+ return _context4.abrupt("return");
417
+ case 16:
403
418
  throw new Error(result.errors.map(function (e) {
404
419
  return e.message;
405
420
  }).join(', '));
406
- case 13:
421
+ case 17:
407
422
  isDeleted = (_result$data3 = result.data) === null || _result$data3 === void 0 || (_result$data3 = _result$data3.blockService_deleteBlock) === null || _result$data3 === void 0 ? void 0 : _result$data3.deleted;
408
423
  if (isDeleted) {
409
- _context4.next = 16;
424
+ _context4.next = 20;
410
425
  break;
411
426
  }
412
427
  throw new Error('Block deletion failed; deleted flag is false');
413
- case 16:
428
+ case 20:
414
429
  case "end":
415
430
  return _context4.stop();
416
431
  }
package/package.json CHANGED
@@ -81,7 +81,7 @@
81
81
  }
82
82
  },
83
83
  "name": "@atlaskit/editor-synced-block-provider",
84
- "version": "4.2.5",
84
+ "version": "4.2.6",
85
85
  "description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
86
86
  "author": "Atlassian Pty Ltd",
87
87
  "license": "Apache-2.0",
@@ -94,6 +94,9 @@
94
94
  },
95
95
  "platform_synced_block_patch_7": {
96
96
  "type": "boolean"
97
+ },
98
+ "platform_synced_block_patch_8": {
99
+ "type": "boolean"
97
100
  }
98
101
  }
99
102
  }