@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.
- package/CHANGELOG.md +15 -0
- package/dist/cjs/clients/block-service/blockService.js +107 -107
- package/dist/cjs/clients/confluence/fetchMediaToken.js +21 -21
- package/dist/cjs/clients/confluence/sourceInfo.js +24 -24
- package/dist/cjs/clients/jira/fetchMediaToken.js +21 -21
- package/dist/cjs/clients/jira/sourceInfo.js +24 -24
- package/dist/cjs/hooks/useFetchSyncBlockData.js +18 -18
- package/dist/cjs/providers/block-service/blockServiceAPI.js +322 -321
- package/dist/cjs/providers/syncBlockProvider.js +49 -48
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +75 -75
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +77 -78
- package/dist/cjs/store-manager/syncBlockStoreManager.js +41 -41
- package/dist/cjs/store-manager/syncBlockSubscriptionManager.js +7 -18
- package/dist/cjs/utils/resourceId.js +2 -1
- package/dist/cjs/utils/retry.js +8 -8
- package/dist/cjs/utils/utils.js +4 -3
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +1 -1
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +1 -2
- package/dist/es2019/store-manager/syncBlockSubscriptionManager.js +7 -18
- package/dist/es2019/utils/utils.js +1 -2
- package/dist/esm/clients/block-service/blockService.js +107 -107
- package/dist/esm/clients/confluence/fetchMediaToken.js +21 -21
- package/dist/esm/clients/confluence/sourceInfo.js +24 -24
- package/dist/esm/clients/jira/fetchMediaToken.js +21 -21
- package/dist/esm/clients/jira/sourceInfo.js +24 -24
- package/dist/esm/hooks/useFetchSyncBlockData.js +18 -18
- package/dist/esm/providers/block-service/blockServiceAPI.js +321 -320
- package/dist/esm/providers/syncBlockProvider.js +49 -48
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +75 -75
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +77 -78
- package/dist/esm/store-manager/syncBlockStoreManager.js +41 -41
- package/dist/esm/store-manager/syncBlockSubscriptionManager.js +7 -18
- package/dist/esm/utils/resourceId.js +2 -1
- package/dist/esm/utils/retry.js +8 -8
- package/dist/esm/utils/utils.js +1 -2
- package/package.json +5 -8
|
@@ -10,7 +10,6 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
10
10
|
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
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) { _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; }
|
|
12
12
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
13
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
14
13
|
import { SyncBlockError } from '../common/types';
|
|
15
14
|
import { updateErrorPayload, createErrorPayload, deleteErrorPayload, updateCacheErrorPayload, getSourceInfoErrorPayload, updateSuccessPayload, createSuccessPayload, deleteSuccessPayload, fetchReferencesErrorPayload } from '../utils/errorHandling';
|
|
16
15
|
import { getCreateSourceExperience, getDeleteSourceExperience, getSaveSourceExperience, getFetchSourceInfoExperience } from '../utils/experienceTracking';
|
|
@@ -159,19 +158,19 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
159
158
|
value: (function () {
|
|
160
159
|
var _flush = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
161
160
|
var _this2 = this;
|
|
162
|
-
var _this$saveExperience, timedOut, timeoutId, timeout, _iterator, _step, resourceId, bodiedSyncBlockNodes, bodiedSyncBlockData, writeResults, _this$saveExperience2, _this$saveExperience3, _this$fireAnalyticsEv2, _this$flushCompletion;
|
|
163
|
-
return _regeneratorRuntime.wrap(function
|
|
161
|
+
var _this$saveExperience, timedOut, timeoutId, timeout, _iterator, _step, resourceId, bodiedSyncBlockNodes, bodiedSyncBlockData, writeResults, _this$saveExperience2, _this$saveExperience3, _this$fireAnalyticsEv2, _this$flushCompletion, _t;
|
|
162
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
164
163
|
while (1) switch (_context.prev = _context.next) {
|
|
165
164
|
case 0:
|
|
166
165
|
_context.prev = 0;
|
|
167
166
|
if (!(this.viewMode === 'view')) {
|
|
168
|
-
_context.next =
|
|
167
|
+
_context.next = 1;
|
|
169
168
|
break;
|
|
170
169
|
}
|
|
171
170
|
return _context.abrupt("return", true);
|
|
172
|
-
case
|
|
173
|
-
if (!(this.pendingCreationPromises.size > 0
|
|
174
|
-
_context.next =
|
|
171
|
+
case 1:
|
|
172
|
+
if (!(this.pendingCreationPromises.size > 0)) {
|
|
173
|
+
_context.next = 3;
|
|
175
174
|
break;
|
|
176
175
|
}
|
|
177
176
|
timedOut = false;
|
|
@@ -181,9 +180,9 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
181
180
|
resolve();
|
|
182
181
|
}, FLUSH_CREATION_AWAIT_TIMEOUT_MS);
|
|
183
182
|
});
|
|
184
|
-
_context.next =
|
|
183
|
+
_context.next = 2;
|
|
185
184
|
return Promise.race([Promise.all(this.pendingCreationPromises.values()), timeout]);
|
|
186
|
-
case
|
|
185
|
+
case 2:
|
|
187
186
|
if (timeoutId !== undefined) {
|
|
188
187
|
clearTimeout(timeoutId);
|
|
189
188
|
}
|
|
@@ -202,7 +201,7 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
202
201
|
_iterator.f();
|
|
203
202
|
}
|
|
204
203
|
}
|
|
205
|
-
case
|
|
204
|
+
case 3:
|
|
206
205
|
bodiedSyncBlockNodes = [];
|
|
207
206
|
bodiedSyncBlockData = [];
|
|
208
207
|
Array.from(this.syncBlockCache.values()).forEach(function (syncBlockData) {
|
|
@@ -232,21 +231,21 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
232
231
|
}
|
|
233
232
|
});
|
|
234
233
|
if (!(bodiedSyncBlockNodes.length === 0)) {
|
|
235
|
-
_context.next =
|
|
234
|
+
_context.next = 4;
|
|
236
235
|
break;
|
|
237
236
|
}
|
|
238
237
|
return _context.abrupt("return", Promise.resolve(true));
|
|
239
|
-
case
|
|
238
|
+
case 4:
|
|
240
239
|
if (this.dataProvider) {
|
|
241
|
-
_context.next =
|
|
240
|
+
_context.next = 5;
|
|
242
241
|
break;
|
|
243
242
|
}
|
|
244
243
|
throw new Error('Data provider not set');
|
|
245
|
-
case
|
|
244
|
+
case 5:
|
|
246
245
|
(_this$saveExperience = this.saveExperience) === null || _this$saveExperience === void 0 || _this$saveExperience.start({});
|
|
247
|
-
_context.next =
|
|
246
|
+
_context.next = 6;
|
|
248
247
|
return this.dataProvider.writeNodesData(bodiedSyncBlockNodes, bodiedSyncBlockData);
|
|
249
|
-
case
|
|
248
|
+
case 6:
|
|
250
249
|
writeResults = _context.sent;
|
|
251
250
|
writeResults.forEach(function (result) {
|
|
252
251
|
// set isDirty to true for cases where it failed to save the sync block to the BE
|
|
@@ -260,7 +259,7 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
260
259
|
if (!writeResults.every(function (result) {
|
|
261
260
|
return result.resourceId && !result.error;
|
|
262
261
|
})) {
|
|
263
|
-
_context.next =
|
|
262
|
+
_context.next = 7;
|
|
264
263
|
break;
|
|
265
264
|
}
|
|
266
265
|
(_this$saveExperience2 = this.saveExperience) === null || _this$saveExperience2 === void 0 || _this$saveExperience2.success();
|
|
@@ -276,7 +275,7 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
276
275
|
}
|
|
277
276
|
});
|
|
278
277
|
return _context.abrupt("return", true);
|
|
279
|
-
case
|
|
278
|
+
case 7:
|
|
280
279
|
(_this$saveExperience3 = this.saveExperience) === null || _this$saveExperience3 === void 0 || _this$saveExperience3.failure();
|
|
281
280
|
writeResults.filter(function (result) {
|
|
282
281
|
return !result.resourceId || result.error;
|
|
@@ -285,27 +284,27 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
285
284
|
(_this2$fireAnalyticsE2 = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE2 === void 0 || _this2$fireAnalyticsE2.call(_this2, updateErrorPayload(result.error || 'Failed to write data', result.resourceId, getSourceProductFromResourceIdSafe(result.resourceId)));
|
|
286
285
|
});
|
|
287
286
|
return _context.abrupt("return", false);
|
|
288
|
-
case
|
|
289
|
-
_context.next =
|
|
287
|
+
case 8:
|
|
288
|
+
_context.next = 10;
|
|
290
289
|
break;
|
|
291
|
-
case
|
|
292
|
-
_context.prev =
|
|
293
|
-
|
|
294
|
-
logException(
|
|
290
|
+
case 9:
|
|
291
|
+
_context.prev = 9;
|
|
292
|
+
_t = _context["catch"](0);
|
|
293
|
+
logException(_t, {
|
|
295
294
|
location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
|
|
296
295
|
});
|
|
297
296
|
// Top-level flush failure is not tied to a single resourceId.
|
|
298
|
-
(_this$fireAnalyticsEv2 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 || _this$fireAnalyticsEv2.call(this, updateErrorPayload(
|
|
297
|
+
(_this$fireAnalyticsEv2 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 || _this$fireAnalyticsEv2.call(this, updateErrorPayload(_t.message));
|
|
299
298
|
return _context.abrupt("return", false);
|
|
300
|
-
case
|
|
301
|
-
_context.prev =
|
|
299
|
+
case 10:
|
|
300
|
+
_context.prev = 10;
|
|
302
301
|
(_this$flushCompletion = this.flushCompletionCallback) === null || _this$flushCompletion === void 0 || _this$flushCompletion.call(this);
|
|
303
|
-
return _context.finish(
|
|
304
|
-
case
|
|
302
|
+
return _context.finish(10);
|
|
303
|
+
case 11:
|
|
305
304
|
case "end":
|
|
306
305
|
return _context.stop();
|
|
307
306
|
}
|
|
308
|
-
}, _callee, this, [[0,
|
|
307
|
+
}, _callee, this, [[0, 9, 10, 11]]);
|
|
309
308
|
}));
|
|
310
309
|
function flush() {
|
|
311
310
|
return _flush.apply(this, arguments);
|
|
@@ -502,32 +501,32 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
502
501
|
value: function () {
|
|
503
502
|
var _delete2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(syncBlockIds, onDelete, onDeleteCompleted, reason) {
|
|
504
503
|
var _this5 = this;
|
|
505
|
-
var _this$deleteExperienc, results, callback, isDeleteSuccessful, _this$deleteExperienc2, _this$deleteExperienc3;
|
|
506
|
-
return _regeneratorRuntime.wrap(function
|
|
504
|
+
var _this$deleteExperienc, results, callback, isDeleteSuccessful, _this$deleteExperienc2, _this$deleteExperienc3, _t2;
|
|
505
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
507
506
|
while (1) switch (_context2.prev = _context2.next) {
|
|
508
507
|
case 0:
|
|
509
508
|
_context2.prev = 0;
|
|
510
509
|
if (!(this.viewMode === 'view')) {
|
|
511
|
-
_context2.next =
|
|
510
|
+
_context2.next = 1;
|
|
512
511
|
break;
|
|
513
512
|
}
|
|
514
513
|
return _context2.abrupt("return", false);
|
|
515
|
-
case
|
|
514
|
+
case 1:
|
|
516
515
|
if (this.dataProvider) {
|
|
517
|
-
_context2.next =
|
|
516
|
+
_context2.next = 2;
|
|
518
517
|
break;
|
|
519
518
|
}
|
|
520
519
|
throw new Error('Data provider not set');
|
|
521
|
-
case
|
|
520
|
+
case 2:
|
|
522
521
|
syncBlockIds.forEach(function (Ids) {
|
|
523
522
|
_this5.setPendingDeletion(Ids, true);
|
|
524
523
|
});
|
|
525
524
|
(_this$deleteExperienc = this.deleteExperience) === null || _this$deleteExperienc === void 0 || _this$deleteExperienc.start({});
|
|
526
|
-
_context2.next =
|
|
525
|
+
_context2.next = 3;
|
|
527
526
|
return this.dataProvider.deleteNodesData(syncBlockIds.map(function (attrs) {
|
|
528
527
|
return attrs.resourceId;
|
|
529
528
|
}), reason);
|
|
530
|
-
case
|
|
529
|
+
case 3:
|
|
531
530
|
results = _context2.sent;
|
|
532
531
|
isDeleteSuccessful = results.every(function (result) {
|
|
533
532
|
return result.success;
|
|
@@ -561,24 +560,24 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
561
560
|
}
|
|
562
561
|
syncBlockIds.forEach(callback);
|
|
563
562
|
return _context2.abrupt("return", isDeleteSuccessful);
|
|
564
|
-
case
|
|
565
|
-
_context2.prev =
|
|
566
|
-
|
|
563
|
+
case 4:
|
|
564
|
+
_context2.prev = 4;
|
|
565
|
+
_t2 = _context2["catch"](0);
|
|
567
566
|
syncBlockIds.forEach(function (Ids) {
|
|
568
567
|
var _this5$fireAnalyticsE4;
|
|
569
568
|
_this5.setPendingDeletion(Ids, false);
|
|
570
|
-
(_this5$fireAnalyticsE4 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE4 === void 0 || _this5$fireAnalyticsE4.call(_this5, deleteErrorPayload(
|
|
569
|
+
(_this5$fireAnalyticsE4 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE4 === void 0 || _this5$fireAnalyticsE4.call(_this5, deleteErrorPayload(_t2.message, Ids.resourceId, getSourceProductFromResourceIdSafe(Ids.resourceId)));
|
|
571
570
|
});
|
|
572
|
-
logException(
|
|
571
|
+
logException(_t2, {
|
|
573
572
|
location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
|
|
574
573
|
});
|
|
575
574
|
onDeleteCompleted(false);
|
|
576
575
|
return _context2.abrupt("return", false);
|
|
577
|
-
case
|
|
576
|
+
case 5:
|
|
578
577
|
case "end":
|
|
579
578
|
return _context2.stop();
|
|
580
579
|
}
|
|
581
|
-
}, _callee2, this, [[0,
|
|
580
|
+
}, _callee2, this, [[0, 4]]);
|
|
582
581
|
}));
|
|
583
582
|
function _delete(_x, _x2, _x3, _x4) {
|
|
584
583
|
return _delete2.apply(this, arguments);
|
|
@@ -595,29 +594,29 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
595
594
|
value: function () {
|
|
596
595
|
var _retryDeletion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
597
596
|
var _this$deletionRetryIn, syncBlockIds, onDelete, onDeleteCompleted, deletionReason;
|
|
598
|
-
return _regeneratorRuntime.wrap(function
|
|
597
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
599
598
|
while (1) switch (_context3.prev = _context3.next) {
|
|
600
599
|
case 0:
|
|
601
600
|
if (!(this.viewMode === 'view')) {
|
|
602
|
-
_context3.next =
|
|
601
|
+
_context3.next = 1;
|
|
603
602
|
break;
|
|
604
603
|
}
|
|
605
604
|
return _context3.abrupt("return", Promise.resolve());
|
|
606
|
-
case
|
|
605
|
+
case 1:
|
|
607
606
|
if (this.deletionRetryInfo) {
|
|
608
|
-
_context3.next =
|
|
607
|
+
_context3.next = 2;
|
|
609
608
|
break;
|
|
610
609
|
}
|
|
611
610
|
return _context3.abrupt("return", Promise.resolve());
|
|
612
|
-
case
|
|
611
|
+
case 2:
|
|
613
612
|
_this$deletionRetryIn = this.deletionRetryInfo, syncBlockIds = _this$deletionRetryIn.syncBlockIds, onDelete = _this$deletionRetryIn.onDelete, onDeleteCompleted = _this$deletionRetryIn.onDeleteCompleted, deletionReason = _this$deletionRetryIn.deletionReason;
|
|
614
613
|
if (!this.confirmationCallback) {
|
|
615
|
-
_context3.next =
|
|
614
|
+
_context3.next = 3;
|
|
616
615
|
break;
|
|
617
616
|
}
|
|
618
|
-
_context3.next =
|
|
617
|
+
_context3.next = 3;
|
|
619
618
|
return this.delete(syncBlockIds, onDelete, onDeleteCompleted, deletionReason);
|
|
620
|
-
case
|
|
619
|
+
case 3:
|
|
621
620
|
case "end":
|
|
622
621
|
return _context3.stop();
|
|
623
622
|
}
|
|
@@ -646,16 +645,16 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
646
645
|
value: (function () {
|
|
647
646
|
var _fetchAndCacheStatuses = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
648
647
|
var _this6 = this;
|
|
649
|
-
var sourceToReferenceMap, syncBlockNodes, results, _iterator2, _step2, _sourceToReferenceMap, _result$data, result, sourceResourceId, cached;
|
|
650
|
-
return _regeneratorRuntime.wrap(function
|
|
648
|
+
var sourceToReferenceMap, syncBlockNodes, results, _iterator2, _step2, _sourceToReferenceMap, _result$data, result, sourceResourceId, cached, _t3;
|
|
649
|
+
return _regeneratorRuntime.wrap(function (_context4) {
|
|
651
650
|
while (1) switch (_context4.prev = _context4.next) {
|
|
652
651
|
case 0:
|
|
653
652
|
if (!(!this.dataProvider || this.syncBlockCache.size === 0)) {
|
|
654
|
-
_context4.next =
|
|
653
|
+
_context4.next = 1;
|
|
655
654
|
break;
|
|
656
655
|
}
|
|
657
656
|
return _context4.abrupt("return");
|
|
658
|
-
case
|
|
657
|
+
case 1:
|
|
659
658
|
// Source blocks have plain UUID resourceIds, but fetchNodesData internally uses
|
|
660
659
|
// generateBlockAriFromReference which expects reference-format resourceIds
|
|
661
660
|
// (e.g. "confluence-page/pageId/uuid"). We convert source resourceIds to reference
|
|
@@ -677,10 +676,10 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
677
676
|
}
|
|
678
677
|
};
|
|
679
678
|
});
|
|
680
|
-
_context4.prev =
|
|
681
|
-
_context4.next =
|
|
679
|
+
_context4.prev = 2;
|
|
680
|
+
_context4.next = 3;
|
|
682
681
|
return this.dataProvider.fetchNodesData(syncBlockNodes);
|
|
683
|
-
case
|
|
682
|
+
case 3:
|
|
684
683
|
results = _context4.sent;
|
|
685
684
|
_iterator2 = _createForOfIteratorHelper(results);
|
|
686
685
|
try {
|
|
@@ -698,16 +697,16 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
698
697
|
} finally {
|
|
699
698
|
_iterator2.f();
|
|
700
699
|
}
|
|
701
|
-
_context4.next =
|
|
700
|
+
_context4.next = 5;
|
|
702
701
|
break;
|
|
703
|
-
case
|
|
704
|
-
_context4.prev =
|
|
705
|
-
|
|
706
|
-
case
|
|
702
|
+
case 4:
|
|
703
|
+
_context4.prev = 4;
|
|
704
|
+
_t3 = _context4["catch"](2);
|
|
705
|
+
case 5:
|
|
707
706
|
case "end":
|
|
708
707
|
return _context4.stop();
|
|
709
708
|
}
|
|
710
|
-
}, _callee4, this, [[
|
|
709
|
+
}, _callee4, this, [[2, 4]]);
|
|
711
710
|
}));
|
|
712
711
|
function fetchAndCacheStatuses() {
|
|
713
712
|
return _fetchAndCacheStatuses.apply(this, arguments);
|
|
@@ -762,30 +761,30 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
762
761
|
value: (function () {
|
|
763
762
|
var _deleteSyncBlocksWithConfirmation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(syncBlockIds, deletionReason, onDelete, onDeleteCompleted, destroyCallback) {
|
|
764
763
|
var confirmed, isDeleteSuccessful;
|
|
765
|
-
return _regeneratorRuntime.wrap(function
|
|
764
|
+
return _regeneratorRuntime.wrap(function (_context5) {
|
|
766
765
|
while (1) switch (_context5.prev = _context5.next) {
|
|
767
766
|
case 0:
|
|
768
767
|
if (!(this.viewMode === 'view')) {
|
|
769
|
-
_context5.next =
|
|
768
|
+
_context5.next = 1;
|
|
770
769
|
break;
|
|
771
770
|
}
|
|
772
771
|
return _context5.abrupt("return", Promise.resolve());
|
|
773
|
-
case
|
|
772
|
+
case 1:
|
|
774
773
|
if (!this.confirmationCallback) {
|
|
775
|
-
_context5.next =
|
|
774
|
+
_context5.next = 5;
|
|
776
775
|
break;
|
|
777
776
|
}
|
|
778
|
-
_context5.next =
|
|
777
|
+
_context5.next = 2;
|
|
779
778
|
return this.confirmationCallback(syncBlockIds, deletionReason);
|
|
780
|
-
case
|
|
779
|
+
case 2:
|
|
781
780
|
confirmed = _context5.sent;
|
|
782
781
|
if (!confirmed) {
|
|
783
|
-
_context5.next =
|
|
782
|
+
_context5.next = 4;
|
|
784
783
|
break;
|
|
785
784
|
}
|
|
786
|
-
_context5.next =
|
|
785
|
+
_context5.next = 3;
|
|
787
786
|
return this.delete(syncBlockIds, onDelete, onDeleteCompleted, deletionReason);
|
|
788
|
-
case
|
|
787
|
+
case 3:
|
|
789
788
|
isDeleteSuccessful = _context5.sent;
|
|
790
789
|
if (!isDeleteSuccessful) {
|
|
791
790
|
// If deletion failed, save deletion info for potential retry
|
|
@@ -799,11 +798,11 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
799
798
|
} else {
|
|
800
799
|
destroyCallback();
|
|
801
800
|
}
|
|
802
|
-
_context5.next =
|
|
801
|
+
_context5.next = 5;
|
|
803
802
|
break;
|
|
804
|
-
case
|
|
803
|
+
case 4:
|
|
805
804
|
destroyCallback();
|
|
806
|
-
case
|
|
805
|
+
case 5:
|
|
807
806
|
case "end":
|
|
808
807
|
return _context5.stop();
|
|
809
808
|
}
|
|
@@ -40,24 +40,24 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
40
40
|
value: function () {
|
|
41
41
|
var _fetchReferencesSourceInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resourceId, blockInstanceId, isSourceSyncBlock) {
|
|
42
42
|
var _this = this;
|
|
43
|
-
var _this$fetchReferences, _response$references, _this$fetchReferences3, _response$references2, response, _this$fetchReferences2, sourceInfoPromises, sourceInfos, sourceSyncBlockData, _this$fireAnalyticsEv;
|
|
44
|
-
return _regeneratorRuntime.wrap(function
|
|
43
|
+
var _this$fetchReferences, _response$references, _this$fetchReferences3, _response$references2, response, _this$fetchReferences2, sourceInfoPromises, sourceInfos, sourceSyncBlockData, _this$fireAnalyticsEv, _t;
|
|
44
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
45
45
|
while (1) switch (_context2.prev = _context2.next) {
|
|
46
46
|
case 0:
|
|
47
47
|
_context2.prev = 0;
|
|
48
48
|
if (this.dataProvider) {
|
|
49
|
-
_context2.next =
|
|
49
|
+
_context2.next = 1;
|
|
50
50
|
break;
|
|
51
51
|
}
|
|
52
52
|
throw new Error('Data provider not set');
|
|
53
|
-
case
|
|
53
|
+
case 1:
|
|
54
54
|
(_this$fetchReferences = this.fetchReferencesExperience) === null || _this$fetchReferences === void 0 || _this$fetchReferences.start();
|
|
55
|
-
_context2.next =
|
|
55
|
+
_context2.next = 2;
|
|
56
56
|
return this.dataProvider.fetchReferences(resourceId, isSourceSyncBlock);
|
|
57
|
-
case
|
|
57
|
+
case 2:
|
|
58
58
|
response = _context2.sent;
|
|
59
59
|
if (!response.error) {
|
|
60
|
-
_context2.next =
|
|
60
|
+
_context2.next = 3;
|
|
61
61
|
break;
|
|
62
62
|
}
|
|
63
63
|
(_this$fetchReferences2 = this.fetchReferencesExperience) === null || _this$fetchReferences2 === void 0 || _this$fetchReferences2.failure({
|
|
@@ -66,42 +66,42 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
66
66
|
return _context2.abrupt("return", {
|
|
67
67
|
error: response.error
|
|
68
68
|
});
|
|
69
|
-
case
|
|
69
|
+
case 3:
|
|
70
70
|
if (!(!response.references || ((_response$references = response.references) === null || _response$references === void 0 ? void 0 : _response$references.length) === 0)) {
|
|
71
|
-
_context2.next =
|
|
71
|
+
_context2.next = 4;
|
|
72
72
|
break;
|
|
73
73
|
}
|
|
74
74
|
return _context2.abrupt("return", this.getUnregisteredReferences(resourceId, blockInstanceId, isSourceSyncBlock));
|
|
75
|
-
case
|
|
75
|
+
case 4:
|
|
76
76
|
(_this$fetchReferences3 = this.fetchReferencesExperience) === null || _this$fetchReferences3 === void 0 || _this$fetchReferences3.success();
|
|
77
77
|
sourceInfoPromises = ((_response$references2 = response.references) !== null && _response$references2 !== void 0 ? _response$references2 : []).map( /*#__PURE__*/function () {
|
|
78
78
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(reference) {
|
|
79
79
|
var _this$fetchSourceInfo, _this$dataProvider, _this$fetchSourceInfo3;
|
|
80
80
|
var sourceInfo, _this$fetchSourceInfo2;
|
|
81
|
-
return _regeneratorRuntime.wrap(function
|
|
81
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
82
82
|
while (1) switch (_context.prev = _context.next) {
|
|
83
83
|
case 0:
|
|
84
84
|
(_this$fetchSourceInfo = _this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo === void 0 || _this$fetchSourceInfo.start();
|
|
85
|
-
_context.next =
|
|
85
|
+
_context.next = 1;
|
|
86
86
|
return (_this$dataProvider = _this.dataProvider) === null || _this$dataProvider === void 0 ? void 0 : _this$dataProvider.fetchSyncBlockSourceInfo(reference.blockInstanceId || '', reference.documentAri, getProductFromSourceAri(reference.documentAri), reference.hasAccess);
|
|
87
|
-
case
|
|
87
|
+
case 1:
|
|
88
88
|
sourceInfo = _context.sent;
|
|
89
89
|
if (sourceInfo) {
|
|
90
|
-
_context.next =
|
|
90
|
+
_context.next = 2;
|
|
91
91
|
break;
|
|
92
92
|
}
|
|
93
93
|
(_this$fetchSourceInfo2 = _this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo2 === void 0 || _this$fetchSourceInfo2.failure({
|
|
94
94
|
reason: "no source info returned for ari: ".concat(reference.documentAri)
|
|
95
95
|
});
|
|
96
96
|
return _context.abrupt("return", undefined);
|
|
97
|
-
case
|
|
97
|
+
case 2:
|
|
98
98
|
(_this$fetchSourceInfo3 = _this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo3 === void 0 || _this$fetchSourceInfo3.success();
|
|
99
99
|
return _context.abrupt("return", _objectSpread(_objectSpread({}, sourceInfo), {}, {
|
|
100
100
|
onSameDocument: reference.onSameDocument,
|
|
101
101
|
hasAccess: reference.hasAccess,
|
|
102
102
|
productType: sourceInfo.productType
|
|
103
103
|
}));
|
|
104
|
-
case
|
|
104
|
+
case 3:
|
|
105
105
|
case "end":
|
|
106
106
|
return _context.stop();
|
|
107
107
|
}
|
|
@@ -111,13 +111,13 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
111
111
|
return _ref.apply(this, arguments);
|
|
112
112
|
};
|
|
113
113
|
}());
|
|
114
|
-
_context2.next =
|
|
114
|
+
_context2.next = 5;
|
|
115
115
|
return Promise.all(sourceInfoPromises);
|
|
116
|
-
case
|
|
116
|
+
case 5:
|
|
117
117
|
sourceInfos = _context2.sent;
|
|
118
|
-
_context2.next =
|
|
118
|
+
_context2.next = 6;
|
|
119
119
|
return isSourceSyncBlock ? this.sourceSyncBlockStoreManager.getSyncBlockSourceInfo(blockInstanceId) : this.referenceSyncBlockStoreManager.fetchSyncBlockSourceInfo(resourceId);
|
|
120
|
-
case
|
|
120
|
+
case 6:
|
|
121
121
|
sourceSyncBlockData = _context2.sent;
|
|
122
122
|
if (sourceSyncBlockData) {
|
|
123
123
|
sourceInfos.push(_objectSpread(_objectSpread({}, sourceSyncBlockData), {}, {
|
|
@@ -130,21 +130,21 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
130
130
|
return _context2.abrupt("return", {
|
|
131
131
|
references: sourceInfos
|
|
132
132
|
});
|
|
133
|
-
case
|
|
134
|
-
_context2.prev =
|
|
135
|
-
|
|
136
|
-
logException(
|
|
133
|
+
case 7:
|
|
134
|
+
_context2.prev = 7;
|
|
135
|
+
_t = _context2["catch"](0);
|
|
136
|
+
logException(_t, {
|
|
137
137
|
location: 'editor-synced-block-provider/syncBlockStoreManager'
|
|
138
138
|
});
|
|
139
|
-
(_this$fireAnalyticsEv = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv === void 0 || _this$fireAnalyticsEv.call(this, fetchReferencesErrorPayload(
|
|
139
|
+
(_this$fireAnalyticsEv = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv === void 0 || _this$fireAnalyticsEv.call(this, fetchReferencesErrorPayload(_t.message, resourceId, getSourceProductFromResourceIdSafe(resourceId)));
|
|
140
140
|
return _context2.abrupt("return", {
|
|
141
141
|
error: SyncBlockError.Errored
|
|
142
142
|
});
|
|
143
|
-
case
|
|
143
|
+
case 8:
|
|
144
144
|
case "end":
|
|
145
145
|
return _context2.stop();
|
|
146
146
|
}
|
|
147
|
-
}, _callee2, this, [[0,
|
|
147
|
+
}, _callee2, this, [[0, 7]]);
|
|
148
148
|
}));
|
|
149
149
|
function fetchReferencesSourceInfo(_x, _x2, _x3) {
|
|
150
150
|
return _fetchReferencesSourceInfo.apply(this, arguments);
|
|
@@ -189,11 +189,11 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
189
189
|
var _getUnregisteredReferences = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(resourceId, blockInstanceId, isSourceSyncBlock) {
|
|
190
190
|
var _this$fetchReferences8;
|
|
191
191
|
var _this$fetchReferences6, referenceResourceId, hasUnregisteredReferenceOnPage, _this$fetchReferences5, _sourceSyncBlockData, _references, sourceSyncBlockReference, referenceSyncBlockReference, references, sourceSyncBlockData, currentPageData, _this$fetchReferences7;
|
|
192
|
-
return _regeneratorRuntime.wrap(function
|
|
192
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
193
193
|
while (1) switch (_context3.prev = _context3.next) {
|
|
194
194
|
case 0:
|
|
195
195
|
if (!isSourceSyncBlock) {
|
|
196
|
-
_context3.next =
|
|
196
|
+
_context3.next = 3;
|
|
197
197
|
break;
|
|
198
198
|
}
|
|
199
199
|
// Verify that a reference sync block for this specific source actually
|
|
@@ -202,12 +202,12 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
202
202
|
referenceResourceId = this.referenceSyncBlockStoreManager.generateResourceIdForReference(resourceId);
|
|
203
203
|
hasUnregisteredReferenceOnPage = this.referenceSyncBlockStoreManager.getSubscribedResourceIds().includes(referenceResourceId);
|
|
204
204
|
if (!hasUnregisteredReferenceOnPage) {
|
|
205
|
-
_context3.next =
|
|
205
|
+
_context3.next = 2;
|
|
206
206
|
break;
|
|
207
207
|
}
|
|
208
|
-
_context3.next =
|
|
208
|
+
_context3.next = 1;
|
|
209
209
|
return this.sourceSyncBlockStoreManager.getSyncBlockSourceInfo(blockInstanceId);
|
|
210
|
-
case
|
|
210
|
+
case 1:
|
|
211
211
|
_sourceSyncBlockData = _context3.sent;
|
|
212
212
|
_references = [];
|
|
213
213
|
if (_sourceSyncBlockData) {
|
|
@@ -227,20 +227,20 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
227
227
|
return _context3.abrupt("return", {
|
|
228
228
|
references: _references
|
|
229
229
|
});
|
|
230
|
-
case
|
|
230
|
+
case 2:
|
|
231
231
|
// No remote or local reference exists — show info text with link to doco on how to use Synced Blocks
|
|
232
232
|
(_this$fetchReferences6 = this.fetchReferencesExperience) === null || _this$fetchReferences6 === void 0 || _this$fetchReferences6.success();
|
|
233
233
|
return _context3.abrupt("return", {
|
|
234
234
|
references: []
|
|
235
235
|
});
|
|
236
|
-
case
|
|
236
|
+
case 3:
|
|
237
237
|
// Though no references registered yet for this reference sync block,
|
|
238
238
|
// still show the source and the current page itself since they are known
|
|
239
239
|
// but not saved yet.
|
|
240
240
|
references = [];
|
|
241
|
-
_context3.next =
|
|
241
|
+
_context3.next = 4;
|
|
242
242
|
return this.referenceSyncBlockStoreManager.fetchSyncBlockSourceInfo(resourceId);
|
|
243
|
-
case
|
|
243
|
+
case 4:
|
|
244
244
|
sourceSyncBlockData = _context3.sent;
|
|
245
245
|
if (sourceSyncBlockData) {
|
|
246
246
|
references.push(_objectSpread(_objectSpread({}, sourceSyncBlockData), {}, {
|
|
@@ -249,9 +249,9 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
249
249
|
isSource: true
|
|
250
250
|
}));
|
|
251
251
|
}
|
|
252
|
-
_context3.next =
|
|
252
|
+
_context3.next = 5;
|
|
253
253
|
return this.referenceSyncBlockStoreManager.fetchSyncBlockSourceInfoByLocalId(blockInstanceId);
|
|
254
|
-
case
|
|
254
|
+
case 5:
|
|
255
255
|
currentPageData = _context3.sent;
|
|
256
256
|
if (currentPageData) {
|
|
257
257
|
references.push(_objectSpread(_objectSpread({}, currentPageData), {}, {
|
|
@@ -261,7 +261,7 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
261
261
|
}));
|
|
262
262
|
}
|
|
263
263
|
if (!(references.length === 0)) {
|
|
264
|
-
_context3.next =
|
|
264
|
+
_context3.next = 6;
|
|
265
265
|
break;
|
|
266
266
|
}
|
|
267
267
|
(_this$fetchReferences7 = this.fetchReferencesExperience) === null || _this$fetchReferences7 === void 0 || _this$fetchReferences7.failure({
|
|
@@ -270,12 +270,12 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
270
270
|
return _context3.abrupt("return", {
|
|
271
271
|
error: SyncBlockError.Errored
|
|
272
272
|
});
|
|
273
|
-
case
|
|
273
|
+
case 6:
|
|
274
274
|
(_this$fetchReferences8 = this.fetchReferencesExperience) === null || _this$fetchReferences8 === void 0 || _this$fetchReferences8.success();
|
|
275
275
|
return _context3.abrupt("return", {
|
|
276
276
|
references: references
|
|
277
277
|
});
|
|
278
|
-
case
|
|
278
|
+
case 7:
|
|
279
279
|
case "end":
|
|
280
280
|
return _context3.stop();
|
|
281
281
|
}
|
|
@@ -7,7 +7,6 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
7
7
|
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; }
|
|
8
8
|
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; }
|
|
9
9
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
10
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
10
|
import { fetchErrorPayload, fetchSuccessPayload } from '../utils/errorHandling';
|
|
12
11
|
import { resolveSyncBlockInstance } from '../utils/resolveSyncBlockInstance';
|
|
13
12
|
import { getSourceProductFromResourceIdSafe } from '../utils/utils';
|
|
@@ -246,7 +245,6 @@ export var SyncBlockSubscriptionManager = /*#__PURE__*/function () {
|
|
|
246
245
|
if (!(dataProvider !== null && dataProvider !== void 0 && dataProvider.subscribeToBlockUpdates)) {
|
|
247
246
|
return;
|
|
248
247
|
}
|
|
249
|
-
var reconnectEnabled = fg('platform_synced_block_patch_12');
|
|
250
248
|
var unsubscribe = dataProvider.subscribeToBlockUpdates(resourceId, function (syncBlockInstance) {
|
|
251
249
|
_this5.handleGraphQLUpdate(syncBlockInstance);
|
|
252
250
|
}, function (error) {
|
|
@@ -255,12 +253,10 @@ export var SyncBlockSubscriptionManager = /*#__PURE__*/function () {
|
|
|
255
253
|
location: 'editor-synced-block-provider/syncBlockSubscriptionManager/graphql-subscription'
|
|
256
254
|
});
|
|
257
255
|
(_this5$deps$getFireAn = _this5.deps.getFireAnalyticsEvent()) === null || _this5$deps$getFireAn === void 0 || _this5$deps$getFireAn(fetchErrorPayload(error.message, resourceId, getSourceProductFromResourceIdSafe(resourceId)));
|
|
258
|
-
if (reconnectEnabled) {
|
|
259
|
-
_this5.handleSubscriptionTerminated(resourceId);
|
|
260
|
-
}
|
|
261
|
-
}, reconnectEnabled ? function () {
|
|
262
256
|
_this5.handleSubscriptionTerminated(resourceId);
|
|
263
|
-
}
|
|
257
|
+
}, function () {
|
|
258
|
+
_this5.handleSubscriptionTerminated(resourceId);
|
|
259
|
+
});
|
|
264
260
|
if (unsubscribe) {
|
|
265
261
|
this.graphqlSubscriptions.set(resourceId, unsubscribe);
|
|
266
262
|
}
|
|
@@ -372,10 +368,8 @@ export var SyncBlockSubscriptionManager = /*#__PURE__*/function () {
|
|
|
372
368
|
unsubscribe();
|
|
373
369
|
this.graphqlSubscriptions.delete(resourceId);
|
|
374
370
|
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
this.retryAttempts.delete(resourceId);
|
|
378
|
-
}
|
|
371
|
+
this.cancelPendingRetry(resourceId);
|
|
372
|
+
this.retryAttempts.delete(resourceId);
|
|
379
373
|
}
|
|
380
374
|
}, {
|
|
381
375
|
key: "setupSubscriptionsForAllBlocks",
|
|
@@ -409,9 +403,7 @@ export var SyncBlockSubscriptionManager = /*#__PURE__*/function () {
|
|
|
409
403
|
_iterator3.f();
|
|
410
404
|
}
|
|
411
405
|
this.graphqlSubscriptions.clear();
|
|
412
|
-
|
|
413
|
-
this.cancelAllPendingRetries();
|
|
414
|
-
}
|
|
406
|
+
this.cancelAllPendingRetries();
|
|
415
407
|
}
|
|
416
408
|
}, {
|
|
417
409
|
key: "destroy",
|
|
@@ -453,10 +445,7 @@ export var SyncBlockSubscriptionManager = /*#__PURE__*/function () {
|
|
|
453
445
|
var resolved = existing ? resolveSyncBlockInstance(existing, syncBlockInstance) : syncBlockInstance;
|
|
454
446
|
this.deps.updateCache(resolved);
|
|
455
447
|
if (!syncBlockInstance.error) {
|
|
456
|
-
|
|
457
|
-
if (fg('platform_synced_block_patch_12')) {
|
|
458
|
-
this.resetRetryCount(syncBlockInstance.resourceId);
|
|
459
|
-
}
|
|
448
|
+
this.resetRetryCount(syncBlockInstance.resourceId);
|
|
460
449
|
var callbacks = this.subscriptions.get(syncBlockInstance.resourceId);
|
|
461
450
|
var localIds = callbacks ? Object.keys(callbacks) : [];
|
|
462
451
|
localIds.forEach(function (localId) {
|