@atlaskit/editor-synced-block-provider 3.16.0 → 3.17.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @atlaskit/editor-synced-block-provider
2
2
 
3
+ ## 3.17.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`251219994ffd0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/251219994ffd0) -
8
+ Retrieve NCS step version from the editor actions
9
+
10
+ ### Patch Changes
11
+
12
+ - [`87775069f24dc`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/87775069f24dc) -
13
+ Update update sync block references endpoint to be keepalive
14
+ - Updated dependencies
15
+
3
16
  ## 3.16.0
4
17
 
5
18
  ### Minor Changes
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.updateSyncedBlock = exports.updateReferenceSyncedBlockOnDocument = exports.isBlockContentResponse = exports.getSyncedBlockContent = exports.getReferenceSyncedBlocksByBlockAri = exports.getReferenceSyncedBlocks = exports.deleteSyncedBlock = exports.createSyncedBlock = exports.batchRetrieveSyncedBlocks = exports.BlockError = void 0;
8
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
10
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
11
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
12
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
@@ -15,6 +16,8 @@ var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/w
15
16
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
16
17
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
17
18
  var _retry = require("../../utils/retry");
19
+ 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; }
20
+ 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; }
18
21
  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)); }
19
22
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
20
23
  var isBlockContentResponse = exports.isBlockContentResponse = function isBlockContentResponse(response) {
@@ -346,13 +349,15 @@ var updateReferenceSyncedBlockOnDocument = exports.updateReferenceSyncedBlockOnD
346
349
  case 0:
347
350
  documentAri = _ref10.documentAri, blocks = _ref10.blocks, _ref10$noContent = _ref10.noContent, noContent = _ref10$noContent === void 0 ? true : _ref10$noContent;
348
351
  _context7.next = 3;
349
- return (0, _retry.fetchWithRetry)("".concat(BLOCK_SERVICE_API_URL, "/block/document/").concat(encodeURIComponent(documentAri), "/references?noContent=").concat(noContent), {
352
+ return (0, _retry.fetchWithRetry)("".concat(BLOCK_SERVICE_API_URL, "/block/document/").concat(encodeURIComponent(documentAri), "/references?noContent=").concat(noContent), _objectSpread({
350
353
  method: 'PUT',
351
354
  headers: COMMON_HEADERS,
352
355
  body: JSON.stringify({
353
356
  blocks: blocks
354
357
  })
355
- });
358
+ }, (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding') ? {
359
+ keepalive: true
360
+ } : {}));
356
361
  case 3:
357
362
  response = _context7.sent;
358
363
  if (response.ok) {
@@ -651,39 +651,52 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
651
651
  product: this.product,
652
652
  resourceId: resourceId
653
653
  });
654
- stepVersion = this.getVersion ? this.getVersion() : undefined;
655
- _context5.prev = 5;
656
- _context5.next = 8;
654
+ if (!this.getVersion) {
655
+ _context5.next = 10;
656
+ break;
657
+ }
658
+ _context5.next = 7;
659
+ return this.getVersion();
660
+ case 7:
661
+ _context5.t0 = _context5.sent;
662
+ _context5.next = 11;
663
+ break;
664
+ case 10:
665
+ _context5.t0 = undefined;
666
+ case 11:
667
+ stepVersion = _context5.t0;
668
+ _context5.prev = 12;
669
+ _context5.next = 15;
657
670
  return (0, _blockService.updateSyncedBlock)({
658
671
  blockAri: blockAri,
659
672
  content: JSON.stringify(data.content),
660
673
  stepVersion: stepVersion
661
674
  });
662
- case 8:
675
+ case 15:
663
676
  return _context5.abrupt("return", {
664
677
  resourceId: resourceId
665
678
  });
666
- case 11:
667
- _context5.prev = 11;
668
- _context5.t0 = _context5["catch"](5);
669
- if (!(_context5.t0 instanceof _blockService.BlockError)) {
670
- _context5.next = 15;
679
+ case 18:
680
+ _context5.prev = 18;
681
+ _context5.t1 = _context5["catch"](12);
682
+ if (!(_context5.t1 instanceof _blockService.BlockError)) {
683
+ _context5.next = 22;
671
684
  break;
672
685
  }
673
686
  return _context5.abrupt("return", {
674
- error: mapBlockError(_context5.t0),
687
+ error: mapBlockError(_context5.t1),
675
688
  resourceId: resourceId
676
689
  });
677
- case 15:
690
+ case 22:
678
691
  return _context5.abrupt("return", {
679
- error: (0, _errorHandling.stringifyError)(_context5.t0),
692
+ error: (0, _errorHandling.stringifyError)(_context5.t1),
680
693
  resourceId: resourceId
681
694
  });
682
- case 16:
695
+ case 23:
683
696
  case "end":
684
697
  return _context5.stop();
685
698
  }
686
- }, _callee5, this, [[5, 11]]);
699
+ }, _callee5, this, [[12, 18]]);
687
700
  }));
688
701
  function writeData(_x5) {
689
702
  return _writeData.apply(this, arguments);
@@ -714,10 +727,23 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
714
727
  product: this.product,
715
728
  resourceId: resourceId
716
729
  });
717
- stepVersion = this.getVersion ? this.getVersion() : undefined;
730
+ if (!this.getVersion) {
731
+ _context6.next = 10;
732
+ break;
733
+ }
734
+ _context6.next = 7;
735
+ return this.getVersion();
736
+ case 7:
737
+ _context6.t0 = _context6.sent;
738
+ _context6.next = 11;
739
+ break;
740
+ case 10:
741
+ _context6.t0 = undefined;
742
+ case 11:
743
+ stepVersion = _context6.t0;
718
744
  status = (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding') ? (_this$isParentUnpubli = this.isParentUnpublished) !== null && _this$isParentUnpubli !== void 0 && _this$isParentUnpubli.call(this) ? 'unpublished' : data.status || 'active' : undefined;
719
- _context6.prev = 6;
720
- _context6.next = 9;
745
+ _context6.prev = 13;
746
+ _context6.next = 16;
721
747
  return (0, _blockService.createSyncedBlock)({
722
748
  blockAri: blockAri,
723
749
  blockInstanceId: data.blockInstanceId,
@@ -727,31 +753,31 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
727
753
  stepVersion: stepVersion,
728
754
  status: status
729
755
  });
730
- case 9:
756
+ case 16:
731
757
  return _context6.abrupt("return", {
732
758
  resourceId: resourceId
733
759
  });
734
- case 12:
735
- _context6.prev = 12;
736
- _context6.t0 = _context6["catch"](6);
737
- if (!(_context6.t0 instanceof _blockService.BlockError)) {
738
- _context6.next = 16;
760
+ case 19:
761
+ _context6.prev = 19;
762
+ _context6.t1 = _context6["catch"](13);
763
+ if (!(_context6.t1 instanceof _blockService.BlockError)) {
764
+ _context6.next = 23;
739
765
  break;
740
766
  }
741
767
  return _context6.abrupt("return", {
742
- error: mapBlockError(_context6.t0),
768
+ error: mapBlockError(_context6.t1),
743
769
  resourceId: resourceId
744
770
  });
745
- case 16:
771
+ case 23:
746
772
  return _context6.abrupt("return", {
747
- error: (0, _errorHandling.stringifyError)(_context6.t0),
773
+ error: (0, _errorHandling.stringifyError)(_context6.t1),
748
774
  resourceId: resourceId
749
775
  });
750
- case 17:
776
+ case 24:
751
777
  case "end":
752
778
  return _context6.stop();
753
779
  }
754
- }, _callee6, this, [[6, 12]]);
780
+ }, _callee6, this, [[13, 19]]);
755
781
  }));
756
782
  function createData(_x6) {
757
783
  return _createData.apply(this, arguments);
@@ -219,7 +219,10 @@ export const updateReferenceSyncedBlockOnDocument = async ({
219
219
  headers: COMMON_HEADERS,
220
220
  body: JSON.stringify({
221
221
  blocks
222
- })
222
+ }),
223
+ ...(fg('platform_synced_block_dogfooding') ? {
224
+ keepalive: true
225
+ } : {})
223
226
  });
224
227
  if (!response.ok) {
225
228
  throw new BlockError(response.status);
@@ -479,7 +479,7 @@ class BlockServiceADFWriteProvider {
479
479
  product: this.product,
480
480
  resourceId
481
481
  });
482
- const stepVersion = this.getVersion ? this.getVersion() : undefined;
482
+ const stepVersion = this.getVersion ? await this.getVersion() : undefined;
483
483
  try {
484
484
  // Try update existing block's content
485
485
  await updateSyncedBlock({
@@ -519,7 +519,7 @@ class BlockServiceADFWriteProvider {
519
519
  product: this.product,
520
520
  resourceId
521
521
  });
522
- const stepVersion = this.getVersion ? this.getVersion() : undefined;
522
+ const stepVersion = this.getVersion ? await this.getVersion() : undefined;
523
523
  const status = fg('platform_synced_block_dogfooding') ? (_this$isParentUnpubli = this.isParentUnpublished) !== null && _this$isParentUnpubli !== void 0 && _this$isParentUnpubli.call(this) ? 'unpublished' : data.status || 'active' : undefined;
524
524
  try {
525
525
  await createSyncedBlock({
@@ -1,3 +1,4 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
1
2
  import _createClass from "@babel/runtime/helpers/createClass";
2
3
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
4
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
@@ -5,6 +6,8 @@ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
5
6
  import _inherits from "@babel/runtime/helpers/inherits";
6
7
  import _wrapNativeSuper from "@babel/runtime/helpers/wrapNativeSuper";
7
8
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
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; }
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) { _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
11
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
9
12
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
10
13
  import _regeneratorRuntime from "@babel/runtime/regenerator";
@@ -339,13 +342,15 @@ export var updateReferenceSyncedBlockOnDocument = /*#__PURE__*/function () {
339
342
  case 0:
340
343
  documentAri = _ref10.documentAri, blocks = _ref10.blocks, _ref10$noContent = _ref10.noContent, noContent = _ref10$noContent === void 0 ? true : _ref10$noContent;
341
344
  _context7.next = 3;
342
- return fetchWithRetry("".concat(BLOCK_SERVICE_API_URL, "/block/document/").concat(encodeURIComponent(documentAri), "/references?noContent=").concat(noContent), {
345
+ return fetchWithRetry("".concat(BLOCK_SERVICE_API_URL, "/block/document/").concat(encodeURIComponent(documentAri), "/references?noContent=").concat(noContent), _objectSpread({
343
346
  method: 'PUT',
344
347
  headers: COMMON_HEADERS,
345
348
  body: JSON.stringify({
346
349
  blocks: blocks
347
350
  })
348
- });
351
+ }, fg('platform_synced_block_dogfooding') ? {
352
+ keepalive: true
353
+ } : {}));
349
354
  case 3:
350
355
  response = _context7.sent;
351
356
  if (response.ok) {
@@ -645,39 +645,52 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
645
645
  product: this.product,
646
646
  resourceId: resourceId
647
647
  });
648
- stepVersion = this.getVersion ? this.getVersion() : undefined;
649
- _context5.prev = 5;
650
- _context5.next = 8;
648
+ if (!this.getVersion) {
649
+ _context5.next = 10;
650
+ break;
651
+ }
652
+ _context5.next = 7;
653
+ return this.getVersion();
654
+ case 7:
655
+ _context5.t0 = _context5.sent;
656
+ _context5.next = 11;
657
+ break;
658
+ case 10:
659
+ _context5.t0 = undefined;
660
+ case 11:
661
+ stepVersion = _context5.t0;
662
+ _context5.prev = 12;
663
+ _context5.next = 15;
651
664
  return updateSyncedBlock({
652
665
  blockAri: blockAri,
653
666
  content: JSON.stringify(data.content),
654
667
  stepVersion: stepVersion
655
668
  });
656
- case 8:
669
+ case 15:
657
670
  return _context5.abrupt("return", {
658
671
  resourceId: resourceId
659
672
  });
660
- case 11:
661
- _context5.prev = 11;
662
- _context5.t0 = _context5["catch"](5);
663
- if (!(_context5.t0 instanceof BlockError)) {
664
- _context5.next = 15;
673
+ case 18:
674
+ _context5.prev = 18;
675
+ _context5.t1 = _context5["catch"](12);
676
+ if (!(_context5.t1 instanceof BlockError)) {
677
+ _context5.next = 22;
665
678
  break;
666
679
  }
667
680
  return _context5.abrupt("return", {
668
- error: mapBlockError(_context5.t0),
681
+ error: mapBlockError(_context5.t1),
669
682
  resourceId: resourceId
670
683
  });
671
- case 15:
684
+ case 22:
672
685
  return _context5.abrupt("return", {
673
- error: stringifyError(_context5.t0),
686
+ error: stringifyError(_context5.t1),
674
687
  resourceId: resourceId
675
688
  });
676
- case 16:
689
+ case 23:
677
690
  case "end":
678
691
  return _context5.stop();
679
692
  }
680
- }, _callee5, this, [[5, 11]]);
693
+ }, _callee5, this, [[12, 18]]);
681
694
  }));
682
695
  function writeData(_x5) {
683
696
  return _writeData.apply(this, arguments);
@@ -708,10 +721,23 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
708
721
  product: this.product,
709
722
  resourceId: resourceId
710
723
  });
711
- stepVersion = this.getVersion ? this.getVersion() : undefined;
724
+ if (!this.getVersion) {
725
+ _context6.next = 10;
726
+ break;
727
+ }
728
+ _context6.next = 7;
729
+ return this.getVersion();
730
+ case 7:
731
+ _context6.t0 = _context6.sent;
732
+ _context6.next = 11;
733
+ break;
734
+ case 10:
735
+ _context6.t0 = undefined;
736
+ case 11:
737
+ stepVersion = _context6.t0;
712
738
  status = fg('platform_synced_block_dogfooding') ? (_this$isParentUnpubli = this.isParentUnpublished) !== null && _this$isParentUnpubli !== void 0 && _this$isParentUnpubli.call(this) ? 'unpublished' : data.status || 'active' : undefined;
713
- _context6.prev = 6;
714
- _context6.next = 9;
739
+ _context6.prev = 13;
740
+ _context6.next = 16;
715
741
  return createSyncedBlock({
716
742
  blockAri: blockAri,
717
743
  blockInstanceId: data.blockInstanceId,
@@ -721,31 +747,31 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
721
747
  stepVersion: stepVersion,
722
748
  status: status
723
749
  });
724
- case 9:
750
+ case 16:
725
751
  return _context6.abrupt("return", {
726
752
  resourceId: resourceId
727
753
  });
728
- case 12:
729
- _context6.prev = 12;
730
- _context6.t0 = _context6["catch"](6);
731
- if (!(_context6.t0 instanceof BlockError)) {
732
- _context6.next = 16;
754
+ case 19:
755
+ _context6.prev = 19;
756
+ _context6.t1 = _context6["catch"](13);
757
+ if (!(_context6.t1 instanceof BlockError)) {
758
+ _context6.next = 23;
733
759
  break;
734
760
  }
735
761
  return _context6.abrupt("return", {
736
- error: mapBlockError(_context6.t0),
762
+ error: mapBlockError(_context6.t1),
737
763
  resourceId: resourceId
738
764
  });
739
- case 16:
765
+ case 23:
740
766
  return _context6.abrupt("return", {
741
- error: stringifyError(_context6.t0),
767
+ error: stringifyError(_context6.t1),
742
768
  resourceId: resourceId
743
769
  });
744
- case 17:
770
+ case 24:
745
771
  case "end":
746
772
  return _context6.stop();
747
773
  }
748
- }, _callee6, this, [[6, 12]]);
774
+ }, _callee6, this, [[13, 19]]);
749
775
  }));
750
776
  function createData(_x6) {
751
777
  return _createData.apply(this, arguments);
@@ -55,7 +55,7 @@ declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
55
55
  }
56
56
  interface BlockServiceADFWriteProviderProps {
57
57
  cloudId: string;
58
- getVersion?: () => number | undefined;
58
+ getVersion?: () => Promise<number | undefined>;
59
59
  isParentUnpublished?: () => boolean;
60
60
  parentAri: string | undefined;
61
61
  parentId?: string;
@@ -81,7 +81,7 @@ declare class BlockServiceADFWriteProvider implements ADFWriteProvider {
81
81
  }
82
82
  interface BlockServiceAPIProvidersProps {
83
83
  cloudId: string;
84
- getVersion?: () => number | undefined;
84
+ getVersion?: () => Promise<number | undefined>;
85
85
  isParentUnpublished?: () => boolean;
86
86
  parentAri: string | undefined;
87
87
  parentId?: string;
@@ -55,7 +55,7 @@ declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
55
55
  }
56
56
  interface BlockServiceADFWriteProviderProps {
57
57
  cloudId: string;
58
- getVersion?: () => number | undefined;
58
+ getVersion?: () => Promise<number | undefined>;
59
59
  isParentUnpublished?: () => boolean;
60
60
  parentAri: string | undefined;
61
61
  parentId?: string;
@@ -81,7 +81,7 @@ declare class BlockServiceADFWriteProvider implements ADFWriteProvider {
81
81
  }
82
82
  interface BlockServiceAPIProvidersProps {
83
83
  cloudId: string;
84
- getVersion?: () => number | undefined;
84
+ getVersion?: () => Promise<number | undefined>;
85
85
  isParentUnpublished?: () => boolean;
86
86
  parentAri: string | undefined;
87
87
  parentId?: string;
package/package.json CHANGED
@@ -78,7 +78,7 @@
78
78
  }
79
79
  },
80
80
  "name": "@atlaskit/editor-synced-block-provider",
81
- "version": "3.16.0",
81
+ "version": "3.17.0",
82
82
  "description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
83
83
  "author": "Atlassian Pty Ltd",
84
84
  "license": "Apache-2.0",