@atlaskit/editor-synced-block-provider 3.14.1 → 3.14.3
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 +22 -0
- package/dist/cjs/clients/block-service/blockService.js +21 -16
- package/dist/cjs/hooks/useFetchSyncBlockData.js +3 -1
- package/dist/cjs/providers/block-service/blockServiceAPI.js +75 -36
- package/dist/cjs/providers/syncBlockProvider.js +10 -6
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +65 -26
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +68 -28
- package/dist/cjs/store-manager/syncBlockStoreManager.js +54 -23
- package/dist/cjs/utils/experienceTracking.js +18 -1
- package/dist/cjs/utils/resolveSyncBlockInstance.js +2 -1
- package/dist/es2019/clients/block-service/blockService.js +10 -3
- package/dist/es2019/hooks/useFetchSyncBlockData.js +3 -1
- package/dist/es2019/providers/block-service/blockServiceAPI.js +62 -23
- package/dist/es2019/providers/syncBlockProvider.js +8 -4
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +71 -36
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +55 -17
- package/dist/es2019/store-manager/syncBlockStoreManager.js +37 -3
- package/dist/es2019/utils/experienceTracking.js +17 -0
- package/dist/es2019/utils/resolveSyncBlockInstance.js +2 -1
- package/dist/esm/clients/block-service/blockService.js +21 -16
- package/dist/esm/hooks/useFetchSyncBlockData.js +3 -1
- package/dist/esm/providers/block-service/blockServiceAPI.js +75 -36
- package/dist/esm/providers/syncBlockProvider.js +10 -6
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +65 -26
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +70 -30
- package/dist/esm/store-manager/syncBlockStoreManager.js +54 -23
- package/dist/esm/utils/experienceTracking.js +17 -0
- package/dist/esm/utils/resolveSyncBlockInstance.js +2 -1
- package/dist/types/clients/block-service/blockService.d.ts +7 -4
- package/dist/types/common/types.d.ts +4 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/providers/block-service/blockServiceAPI.d.ts +6 -3
- package/dist/types/providers/syncBlockProvider.d.ts +2 -2
- package/dist/types/providers/types.d.ts +8 -4
- package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +9 -0
- package/dist/types/store-manager/sourceSyncBlockStoreManager.d.ts +5 -3
- package/dist/types/store-manager/syncBlockStoreManager.d.ts +2 -0
- package/dist/types/utils/experienceTracking.d.ts +8 -0
- package/dist/types-ts4.5/clients/block-service/blockService.d.ts +7 -4
- package/dist/types-ts4.5/common/types.d.ts +4 -0
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +6 -3
- package/dist/types-ts4.5/providers/syncBlockProvider.d.ts +2 -2
- package/dist/types-ts4.5/providers/types.d.ts +8 -4
- package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +9 -0
- package/dist/types-ts4.5/store-manager/sourceSyncBlockStoreManager.d.ts +5 -3
- package/dist/types-ts4.5/store-manager/syncBlockStoreManager.d.ts +2 -0
- package/dist/types-ts4.5/utils/experienceTracking.d.ts +8 -0
- package/package.json +2 -2
|
@@ -33,6 +33,10 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
33
33
|
var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
34
34
|
// Listeners for subscription changes (used by React components to know when to update)
|
|
35
35
|
|
|
36
|
+
// Track newly added sync blocks (resourceIds that were just subscribed to without cached data)
|
|
37
|
+
|
|
38
|
+
// Callback to notify when an unpublished sync block is detected
|
|
39
|
+
|
|
36
40
|
function ReferenceSyncBlockStoreManager(dataProvider) {
|
|
37
41
|
(0, _classCallCheck2.default)(this, ReferenceSyncBlockStoreManager);
|
|
38
42
|
// Keeps track of addition and deletion of reference synced blocks on the document
|
|
@@ -53,6 +57,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
53
57
|
this.pendingCacheDeletions = new Map();
|
|
54
58
|
this.graphqlSubscriptions = new Map();
|
|
55
59
|
this.subscriptionChangeListeners = new Set();
|
|
60
|
+
this.newlyAddedSyncBlocks = new Set();
|
|
56
61
|
}
|
|
57
62
|
|
|
58
63
|
/**
|
|
@@ -157,6 +162,22 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
157
162
|
this.fetchSourceInfoExperience = (0, _experienceTracking.getFetchSourceInfoExperience)(fireAnalyticsEvent);
|
|
158
163
|
this.saveExperience = (0, _experienceTracking.getSaveReferenceExperience)(fireAnalyticsEvent);
|
|
159
164
|
}
|
|
165
|
+
}, {
|
|
166
|
+
key: "setOnUnpublishedSyncBlockDetected",
|
|
167
|
+
value: function setOnUnpublishedSyncBlockDetected(callback) {
|
|
168
|
+
this.onUnpublishedSyncBlockDetected = callback;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Mark a sync block as newly added to the document.
|
|
173
|
+
* This should be called when a sync block node is added via a transaction.
|
|
174
|
+
* @param resourceId - The resource ID of the newly added sync block
|
|
175
|
+
*/
|
|
176
|
+
}, {
|
|
177
|
+
key: "markAsNewlyAdded",
|
|
178
|
+
value: function markAsNewlyAdded(resourceId) {
|
|
179
|
+
this.newlyAddedSyncBlocks.add(resourceId);
|
|
180
|
+
}
|
|
160
181
|
}, {
|
|
161
182
|
key: "generateResourceIdForReference",
|
|
162
183
|
value: function generateResourceIdForReference(sourceId) {
|
|
@@ -312,13 +333,18 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
312
333
|
key: "handleGraphQLSubscriptionUpdate",
|
|
313
334
|
value: function handleGraphQLSubscriptionUpdate(syncBlockInstance) {
|
|
314
335
|
if (!syncBlockInstance.resourceId) {
|
|
315
|
-
|
|
336
|
+
throw new Error('Sync block instance provided to graphql subscription update missing resource id');
|
|
316
337
|
}
|
|
317
338
|
var existingSyncBlock = this.getFromCache(syncBlockInstance.resourceId);
|
|
318
339
|
var resolvedSyncBlockInstance = existingSyncBlock ? (0, _resolveSyncBlockInstance.resolveSyncBlockInstance)(existingSyncBlock, syncBlockInstance) : syncBlockInstance;
|
|
319
340
|
this.updateCache(resolvedSyncBlockInstance);
|
|
320
341
|
if (!syncBlockInstance.error) {
|
|
342
|
+
var _this$fireAnalyticsEv2, _syncBlockInstance$da, _syncBlockInstance$da2;
|
|
343
|
+
(_this$fireAnalyticsEv2 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 || _this$fireAnalyticsEv2.call(this, (0, _errorHandling.fetchSuccessPayload)(syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.resourceId, syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.blockInstanceId, syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.product));
|
|
321
344
|
this.fetchSyncBlockSourceInfo(resolvedSyncBlockInstance.resourceId);
|
|
345
|
+
} else {
|
|
346
|
+
var _this$fireAnalyticsEv3, _syncBlockInstance$er;
|
|
347
|
+
(_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(this, (0, _errorHandling.fetchErrorPayload)((_syncBlockInstance$er = syncBlockInstance.error) === null || _syncBlockInstance$er === void 0 ? void 0 : _syncBlockInstance$er.type, syncBlockInstance.resourceId));
|
|
322
348
|
}
|
|
323
349
|
}
|
|
324
350
|
|
|
@@ -420,8 +446,8 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
420
446
|
}
|
|
421
447
|
}
|
|
422
448
|
if (!sourceAri || !product || !blockInstanceId) {
|
|
423
|
-
var _this$
|
|
424
|
-
(_this$
|
|
449
|
+
var _this$fireAnalyticsEv4;
|
|
450
|
+
(_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(this, (0, _errorHandling.getSourceInfoErrorPayload)('SourceAri, product or blockInstanceId missing', resourceId));
|
|
425
451
|
return Promise.resolve(undefined);
|
|
426
452
|
}
|
|
427
453
|
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
@@ -480,11 +506,11 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
480
506
|
this.syncBlockSourceInfoRequestsOld.set(resourceId, true);
|
|
481
507
|
}
|
|
482
508
|
} catch (error) {
|
|
483
|
-
var _this$
|
|
509
|
+
var _this$fireAnalyticsEv5;
|
|
484
510
|
(0, _monitoring.logException)(error, {
|
|
485
511
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
486
512
|
});
|
|
487
|
-
(_this$
|
|
513
|
+
(_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 || _this$fireAnalyticsEv5.call(this, (0, _errorHandling.getSourceInfoErrorPayload)(error.message, resourceId));
|
|
488
514
|
}
|
|
489
515
|
return Promise.resolve(undefined);
|
|
490
516
|
}
|
|
@@ -512,11 +538,12 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
512
538
|
// Don't fetch for not_found error since the source is already deleted
|
|
513
539
|
nodesToFetch = [];
|
|
514
540
|
syncBlockNodes.forEach(function (node) {
|
|
541
|
+
var _existingSyncBlock$er;
|
|
515
542
|
if (_this5.syncBlockFetchDataRequests.get(node.attrs.resourceId)) {
|
|
516
543
|
return;
|
|
517
544
|
}
|
|
518
545
|
var existingSyncBlock = _this5.getFromCache(node.attrs.resourceId);
|
|
519
|
-
if ((existingSyncBlock === null || existingSyncBlock === void 0 ? void 0 :
|
|
546
|
+
if ((existingSyncBlock === null || existingSyncBlock === void 0 || (_existingSyncBlock$er = existingSyncBlock.error) === null || _existingSyncBlock$er === void 0 ? void 0 : _existingSyncBlock$er.type) === _types.SyncBlockError.NotFound) {
|
|
520
547
|
return;
|
|
521
548
|
}
|
|
522
549
|
nodesToFetch.push(node);
|
|
@@ -550,26 +577,38 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
550
577
|
hasUnexpectedError = false;
|
|
551
578
|
hasExpectedError = false;
|
|
552
579
|
data.forEach(function (syncBlockInstance) {
|
|
580
|
+
var _resolvedSyncBlockIns;
|
|
553
581
|
if (!syncBlockInstance.resourceId) {
|
|
554
|
-
var _this5$fireAnalyticsE;
|
|
555
|
-
(_this5$fireAnalyticsE = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE === void 0 || _this5$fireAnalyticsE.call(_this5, (0, _errorHandling.fetchErrorPayload)(syncBlockInstance.error || 'Returned sync block instance does not have resource id'));
|
|
582
|
+
var _this5$fireAnalyticsE, _syncBlockInstance$er2;
|
|
583
|
+
(_this5$fireAnalyticsE = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE === void 0 || _this5$fireAnalyticsE.call(_this5, (0, _errorHandling.fetchErrorPayload)(((_syncBlockInstance$er2 = syncBlockInstance.error) === null || _syncBlockInstance$er2 === void 0 ? void 0 : _syncBlockInstance$er2.type) || 'Returned sync block instance does not have resource id'));
|
|
556
584
|
return;
|
|
557
585
|
}
|
|
558
586
|
var existingSyncBlock = _this5.getFromCache(syncBlockInstance.resourceId);
|
|
559
587
|
var resolvedSyncBlockInstance = existingSyncBlock ? (0, _resolveSyncBlockInstance.resolveSyncBlockInstance)(existingSyncBlock, syncBlockInstance) : syncBlockInstance;
|
|
560
588
|
_this5.updateCache(resolvedSyncBlockInstance);
|
|
589
|
+
|
|
590
|
+
// Check if this is a newly added unpublished sync block and notify
|
|
591
|
+
// Only trigger for sync blocks that were just added (not refreshed or loaded on page init)
|
|
592
|
+
if (!syncBlockInstance.error && ((_resolvedSyncBlockIns = resolvedSyncBlockInstance.data) === null || _resolvedSyncBlockIns === void 0 ? void 0 : _resolvedSyncBlockIns.status) === 'unpublished' && _this5.newlyAddedSyncBlocks.has(syncBlockInstance.resourceId) && _this5.onUnpublishedSyncBlockDetected && (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
593
|
+
// Remove from newly added set after checking to prevent duplicate flags
|
|
594
|
+
_this5.newlyAddedSyncBlocks.delete(syncBlockInstance.resourceId);
|
|
595
|
+
_this5.onUnpublishedSyncBlockDetected(resolvedSyncBlockInstance.resourceId);
|
|
596
|
+
} else if (_this5.newlyAddedSyncBlocks.has(syncBlockInstance.resourceId)) {
|
|
597
|
+
// Remove from newly added set even if not unpublished (to clean up)
|
|
598
|
+
_this5.newlyAddedSyncBlocks.delete(syncBlockInstance.resourceId);
|
|
599
|
+
}
|
|
561
600
|
if (syncBlockInstance.error) {
|
|
562
601
|
var _this5$fireAnalyticsE2;
|
|
563
|
-
(_this5$fireAnalyticsE2 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE2 === void 0 || _this5$fireAnalyticsE2.call(_this5, (0, _errorHandling.fetchErrorPayload)(syncBlockInstance.error, syncBlockInstance.resourceId));
|
|
564
|
-
if (syncBlockInstance.error === _types.SyncBlockError.NotFound || syncBlockInstance.error === _types.SyncBlockError.Forbidden) {
|
|
602
|
+
(_this5$fireAnalyticsE2 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE2 === void 0 || _this5$fireAnalyticsE2.call(_this5, (0, _errorHandling.fetchErrorPayload)(syncBlockInstance.error.type, syncBlockInstance.resourceId));
|
|
603
|
+
if (syncBlockInstance.error.type === _types.SyncBlockError.NotFound || syncBlockInstance.error.type === _types.SyncBlockError.Forbidden) {
|
|
565
604
|
hasExpectedError = true;
|
|
566
605
|
} else if (syncBlockInstance.error) {
|
|
567
606
|
hasUnexpectedError = true;
|
|
568
607
|
}
|
|
569
608
|
return;
|
|
570
609
|
} else if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
571
|
-
var _this5$fireAnalyticsE3, _syncBlockInstance$
|
|
572
|
-
(_this5$fireAnalyticsE3 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE3 === void 0 || _this5$fireAnalyticsE3.call(_this5, (0, _errorHandling.fetchSuccessPayload)(syncBlockInstance.resourceId, (_syncBlockInstance$
|
|
610
|
+
var _this5$fireAnalyticsE3, _syncBlockInstance$da3, _syncBlockInstance$da4;
|
|
611
|
+
(_this5$fireAnalyticsE3 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE3 === void 0 || _this5$fireAnalyticsE3.call(_this5, (0, _errorHandling.fetchSuccessPayload)(syncBlockInstance.resourceId, (_syncBlockInstance$da3 = syncBlockInstance.data) === null || _syncBlockInstance$da3 === void 0 ? void 0 : _syncBlockInstance$da3.blockInstanceId, (_syncBlockInstance$da4 = syncBlockInstance.data) === null || _syncBlockInstance$da4 === void 0 ? void 0 : _syncBlockInstance$da4.product));
|
|
573
612
|
}
|
|
574
613
|
_this5.fetchSyncBlockSourceInfo(resolvedSyncBlockInstance.resourceId);
|
|
575
614
|
});
|
|
@@ -780,11 +819,11 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
780
819
|
}
|
|
781
820
|
return this.subscribeToSyncBlock(resourceId, localId, callback);
|
|
782
821
|
} catch (error) {
|
|
783
|
-
var _this$
|
|
822
|
+
var _this$fireAnalyticsEv6;
|
|
784
823
|
(0, _monitoring.logException)(error, {
|
|
785
824
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
786
825
|
});
|
|
787
|
-
(_this$
|
|
826
|
+
(_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 || _this$fireAnalyticsEv6.call(this, (0, _errorHandling.fetchErrorPayload)(error.message));
|
|
788
827
|
return function () {};
|
|
789
828
|
}
|
|
790
829
|
}
|
|
@@ -808,12 +847,12 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
808
847
|
key: "getProviderFactory",
|
|
809
848
|
value: function getProviderFactory(resourceId) {
|
|
810
849
|
if (!this.dataProvider) {
|
|
811
|
-
var _this$
|
|
850
|
+
var _this$fireAnalyticsEv7;
|
|
812
851
|
var error = new Error('Data provider not set');
|
|
813
852
|
(0, _monitoring.logException)(error, {
|
|
814
853
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
815
854
|
});
|
|
816
|
-
(_this$
|
|
855
|
+
(_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 || _this$fireAnalyticsEv7.call(this, (0, _errorHandling.fetchErrorPayload)(error.message));
|
|
817
856
|
return undefined;
|
|
818
857
|
}
|
|
819
858
|
var _this$dataProvider$ge = this.dataProvider.getSyncedBlockRendererProviderOptions(),
|
|
@@ -842,11 +881,11 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
842
881
|
try {
|
|
843
882
|
this.retrieveDynamicProviders(resourceId, providerFactory, providerCreator);
|
|
844
883
|
} catch (error) {
|
|
845
|
-
var _this$
|
|
884
|
+
var _this$fireAnalyticsEv8;
|
|
846
885
|
(0, _monitoring.logException)(error, {
|
|
847
886
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
848
887
|
});
|
|
849
|
-
(_this$
|
|
888
|
+
(_this$fireAnalyticsEv8 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv8 === void 0 || _this$fireAnalyticsEv8.call(this, (0, _errorHandling.fetchErrorPayload)(error.message, resourceId));
|
|
850
889
|
}
|
|
851
890
|
}
|
|
852
891
|
return providerFactory;
|
|
@@ -906,8 +945,8 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
906
945
|
return;
|
|
907
946
|
}
|
|
908
947
|
if (!syncBlock.data.sourceAri || !syncBlock.data.product) {
|
|
909
|
-
var _this$
|
|
910
|
-
(_this$
|
|
948
|
+
var _this$fireAnalyticsEv9;
|
|
949
|
+
(_this$fireAnalyticsEv9 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv9 === void 0 || _this$fireAnalyticsEv9.call(this, (0, _errorHandling.fetchErrorPayload)('Sync block source ari or product not found'));
|
|
911
950
|
return;
|
|
912
951
|
}
|
|
913
952
|
var parentInfo = this.dataProvider.retrieveSyncBlockParentInfo((_syncBlock$data2 = syncBlock.data) === null || _syncBlock$data2 === void 0 ? void 0 : _syncBlock$data2.sourceAri, (_syncBlock$data3 = syncBlock.data) === null || _syncBlock$data3 === void 0 ? void 0 : _syncBlock$data3.product);
|
|
@@ -957,7 +996,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
957
996
|
key: "flush",
|
|
958
997
|
value: (function () {
|
|
959
998
|
var _flush = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
960
|
-
var success, blocks, _this$saveExperience, updateResult, _this$
|
|
999
|
+
var success, blocks, _this$saveExperience, updateResult, _this$fireAnalyticsEv0, _this$saveExperience2, _this$fireAnalyticsEv1, _this$saveExperience3, _this$saveExperience4;
|
|
961
1000
|
return _regenerator.default.wrap(function _callee3$(_context4) {
|
|
962
1001
|
while (1) switch (_context4.prev = _context4.next) {
|
|
963
1002
|
case 0:
|
|
@@ -1018,7 +1057,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1018
1057
|
reason: updateResult.error || 'Failed to update reference synced blocks on the document'
|
|
1019
1058
|
});
|
|
1020
1059
|
}
|
|
1021
|
-
(_this$
|
|
1060
|
+
(_this$fireAnalyticsEv0 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv0 === void 0 || _this$fireAnalyticsEv0.call(this, (0, _errorHandling.updateReferenceErrorPayload)(updateResult.error || 'Failed to update reference synced blocks on the document'));
|
|
1022
1061
|
}
|
|
1023
1062
|
_context4.next = 26;
|
|
1024
1063
|
break;
|
|
@@ -1034,7 +1073,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1034
1073
|
reason: _context4.t0.message
|
|
1035
1074
|
});
|
|
1036
1075
|
}
|
|
1037
|
-
(_this$
|
|
1076
|
+
(_this$fireAnalyticsEv1 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv1 === void 0 || _this$fireAnalyticsEv1.call(this, (0, _errorHandling.updateReferenceErrorPayload)(_context4.t0.message));
|
|
1038
1077
|
case 26:
|
|
1039
1078
|
_context4.prev = 26;
|
|
1040
1079
|
if (!success) {
|
|
@@ -1079,13 +1118,13 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1079
1118
|
});
|
|
1080
1119
|
this.providerFactories.clear();
|
|
1081
1120
|
(_this$saveExperience5 = this.saveExperience) === null || _this$saveExperience5 === void 0 || _this$saveExperience5.abort({
|
|
1082
|
-
reason: '
|
|
1121
|
+
reason: 'editorDestroyed'
|
|
1083
1122
|
});
|
|
1084
1123
|
(_this$fetchExperience5 = this.fetchExperience) === null || _this$fetchExperience5 === void 0 || _this$fetchExperience5.abort({
|
|
1085
|
-
reason: '
|
|
1124
|
+
reason: 'editorDestroyed'
|
|
1086
1125
|
});
|
|
1087
1126
|
(_this$fetchSourceInfo2 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo2 === void 0 || _this$fetchSourceInfo2.abort({
|
|
1088
|
-
reason: '
|
|
1127
|
+
reason: 'editorDestroyed'
|
|
1089
1128
|
});
|
|
1090
1129
|
this.fireAnalyticsEvent = undefined;
|
|
1091
1130
|
}
|
|
@@ -43,6 +43,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
43
43
|
this.createExperience = (0, _experienceTracking.getCreateSourceExperience)(fireAnalyticsEvent);
|
|
44
44
|
this.saveExperience = (0, _experienceTracking.getSaveSourceExperience)(fireAnalyticsEvent);
|
|
45
45
|
this.deleteExperience = (0, _experienceTracking.getDeleteSourceExperience)(fireAnalyticsEvent);
|
|
46
|
+
this.fetchSourceInfoExperience = (0, _experienceTracking.getFetchSourceInfoExperience)(fireAnalyticsEvent);
|
|
46
47
|
}
|
|
47
48
|
}, {
|
|
48
49
|
key: "isSourceBlock",
|
|
@@ -135,10 +136,9 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
135
136
|
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
136
137
|
(_this$saveExperience = this.saveExperience) === null || _this$saveExperience === void 0 || _this$saveExperience.start({});
|
|
137
138
|
}
|
|
138
|
-
;
|
|
139
|
-
_context.next = 12;
|
|
139
|
+
_context.next = 11;
|
|
140
140
|
return this.dataProvider.writeNodesData(bodiedSyncBlockNodes, bodiedSyncBlockData);
|
|
141
|
-
case
|
|
141
|
+
case 11:
|
|
142
142
|
writeResults = _context.sent;
|
|
143
143
|
writeResults.forEach(function (result) {
|
|
144
144
|
// set isDirty to true for cases where it failed to save the sync block to the BE
|
|
@@ -152,7 +152,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
152
152
|
if (!writeResults.every(function (result) {
|
|
153
153
|
return result.resourceId && !result.error;
|
|
154
154
|
})) {
|
|
155
|
-
_context.next =
|
|
155
|
+
_context.next = 18;
|
|
156
156
|
break;
|
|
157
157
|
}
|
|
158
158
|
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
@@ -164,9 +164,8 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
164
164
|
}
|
|
165
165
|
});
|
|
166
166
|
}
|
|
167
|
-
;
|
|
168
167
|
return _context.abrupt("return", true);
|
|
169
|
-
case
|
|
168
|
+
case 18:
|
|
170
169
|
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
171
170
|
(_this$saveExperience3 = this.saveExperience) === null || _this$saveExperience3 === void 0 || _this$saveExperience3.failure();
|
|
172
171
|
}
|
|
@@ -177,22 +176,22 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
177
176
|
(_this2$fireAnalyticsE2 = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE2 === void 0 || _this2$fireAnalyticsE2.call(_this2, (0, _errorHandling.updateErrorPayload)(result.error || 'Failed to write data', result.resourceId));
|
|
178
177
|
});
|
|
179
178
|
return _context.abrupt("return", false);
|
|
180
|
-
case
|
|
181
|
-
_context.next =
|
|
179
|
+
case 21:
|
|
180
|
+
_context.next = 28;
|
|
182
181
|
break;
|
|
183
|
-
case
|
|
184
|
-
_context.prev =
|
|
182
|
+
case 23:
|
|
183
|
+
_context.prev = 23;
|
|
185
184
|
_context.t0 = _context["catch"](0);
|
|
186
185
|
(0, _monitoring.logException)(_context.t0, {
|
|
187
186
|
location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
|
|
188
187
|
});
|
|
189
188
|
(_this$fireAnalyticsEv2 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 || _this$fireAnalyticsEv2.call(this, (0, _errorHandling.updateErrorPayload)(_context.t0.message));
|
|
190
189
|
return _context.abrupt("return", false);
|
|
191
|
-
case
|
|
190
|
+
case 28:
|
|
192
191
|
case "end":
|
|
193
192
|
return _context.stop();
|
|
194
193
|
}
|
|
195
|
-
}, _callee, this, [[0,
|
|
194
|
+
}, _callee, this, [[0, 23]]);
|
|
196
195
|
}));
|
|
197
196
|
function flush() {
|
|
198
197
|
return _flush.apply(this, arguments);
|
|
@@ -345,7 +344,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
345
344
|
}, {
|
|
346
345
|
key: "delete",
|
|
347
346
|
value: function () {
|
|
348
|
-
var _delete2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(syncBlockIds, onDelete, onDeleteCompleted) {
|
|
347
|
+
var _delete2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(syncBlockIds, onDelete, onDeleteCompleted, reason) {
|
|
349
348
|
var _this5 = this;
|
|
350
349
|
var _this$deleteExperienc, results, callback, isDeleteSuccessful, _this$deleteExperienc2, _this$deleteExperienc3;
|
|
351
350
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
@@ -367,7 +366,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
367
366
|
_context2.next = 7;
|
|
368
367
|
return this.dataProvider.deleteNodesData(syncBlockIds.map(function (attrs) {
|
|
369
368
|
return attrs.resourceId;
|
|
370
|
-
}));
|
|
369
|
+
}), reason);
|
|
371
370
|
case 7:
|
|
372
371
|
results = _context2.sent;
|
|
373
372
|
isDeleteSuccessful = results.every(function (result) {
|
|
@@ -432,7 +431,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
432
431
|
}
|
|
433
432
|
}, _callee2, this, [[0, 15]]);
|
|
434
433
|
}));
|
|
435
|
-
function _delete(_x, _x2, _x3) {
|
|
434
|
+
function _delete(_x, _x2, _x3, _x4) {
|
|
436
435
|
return _delete2.apply(this, arguments);
|
|
437
436
|
}
|
|
438
437
|
return _delete;
|
|
@@ -446,7 +445,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
446
445
|
key: "retryDeletion",
|
|
447
446
|
value: function () {
|
|
448
447
|
var _retryDeletion = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
449
|
-
var _this$deletionRetryIn, syncBlockIds, onDelete, onDeleteCompleted;
|
|
448
|
+
var _this$deletionRetryIn, syncBlockIds, onDelete, onDeleteCompleted, deletionReason;
|
|
450
449
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
451
450
|
while (1) switch (_context3.prev = _context3.next) {
|
|
452
451
|
case 0:
|
|
@@ -456,13 +455,13 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
456
455
|
}
|
|
457
456
|
return _context3.abrupt("return", Promise.resolve());
|
|
458
457
|
case 2:
|
|
459
|
-
_this$deletionRetryIn = this.deletionRetryInfo, syncBlockIds = _this$deletionRetryIn.syncBlockIds, onDelete = _this$deletionRetryIn.onDelete, onDeleteCompleted = _this$deletionRetryIn.onDeleteCompleted;
|
|
458
|
+
_this$deletionRetryIn = this.deletionRetryInfo, syncBlockIds = _this$deletionRetryIn.syncBlockIds, onDelete = _this$deletionRetryIn.onDelete, onDeleteCompleted = _this$deletionRetryIn.onDeleteCompleted, deletionReason = _this$deletionRetryIn.deletionReason;
|
|
460
459
|
if (!this.confirmationCallback) {
|
|
461
460
|
_context3.next = 6;
|
|
462
461
|
break;
|
|
463
462
|
}
|
|
464
463
|
_context3.next = 6;
|
|
465
|
-
return this.delete(syncBlockIds, onDelete, onDeleteCompleted);
|
|
464
|
+
return this.delete(syncBlockIds, onDelete, onDeleteCompleted, deletionReason);
|
|
466
465
|
case 6:
|
|
467
466
|
case "end":
|
|
468
467
|
return _context3.stop();
|
|
@@ -492,7 +491,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
492
491
|
}, {
|
|
493
492
|
key: "deleteSyncBlocksWithConfirmation",
|
|
494
493
|
value: (function () {
|
|
495
|
-
var _deleteSyncBlocksWithConfirmation = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(syncBlockIds, onDelete, onDeleteCompleted, destroyCallback) {
|
|
494
|
+
var _deleteSyncBlocksWithConfirmation = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(syncBlockIds, deletionReason, onDelete, onDeleteCompleted, destroyCallback) {
|
|
496
495
|
var confirmed, isDeleteSuccessful;
|
|
497
496
|
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
498
497
|
while (1) switch (_context4.prev = _context4.next) {
|
|
@@ -502,7 +501,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
502
501
|
break;
|
|
503
502
|
}
|
|
504
503
|
_context4.next = 3;
|
|
505
|
-
return this.confirmationCallback(syncBlockIds
|
|
504
|
+
return this.confirmationCallback(syncBlockIds, deletionReason);
|
|
506
505
|
case 3:
|
|
507
506
|
confirmed = _context4.sent;
|
|
508
507
|
if (!confirmed) {
|
|
@@ -510,7 +509,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
510
509
|
break;
|
|
511
510
|
}
|
|
512
511
|
_context4.next = 7;
|
|
513
|
-
return this.delete(syncBlockIds, onDelete, onDeleteCompleted);
|
|
512
|
+
return this.delete(syncBlockIds, onDelete, onDeleteCompleted, deletionReason);
|
|
514
513
|
case 7:
|
|
515
514
|
isDeleteSuccessful = _context4.sent;
|
|
516
515
|
if (!isDeleteSuccessful) {
|
|
@@ -519,7 +518,8 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
519
518
|
syncBlockIds: syncBlockIds,
|
|
520
519
|
onDelete: onDelete,
|
|
521
520
|
onDeleteCompleted: onDeleteCompleted,
|
|
522
|
-
destroyCallback: destroyCallback
|
|
521
|
+
destroyCallback: destroyCallback,
|
|
522
|
+
deletionReason: deletionReason
|
|
523
523
|
};
|
|
524
524
|
} else {
|
|
525
525
|
destroyCallback();
|
|
@@ -534,7 +534,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
534
534
|
}
|
|
535
535
|
}, _callee4, this);
|
|
536
536
|
}));
|
|
537
|
-
function deleteSyncBlocksWithConfirmation(
|
|
537
|
+
function deleteSyncBlocksWithConfirmation(_x5, _x6, _x7, _x8, _x9) {
|
|
538
538
|
return _deleteSyncBlocksWithConfirmation.apply(this, arguments);
|
|
539
539
|
}
|
|
540
540
|
return deleteSyncBlocksWithConfirmation;
|
|
@@ -542,11 +542,29 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
542
542
|
}, {
|
|
543
543
|
key: "getSyncBlockSourceInfo",
|
|
544
544
|
value: function getSyncBlockSourceInfo(localId) {
|
|
545
|
+
var _this6 = this;
|
|
545
546
|
try {
|
|
546
547
|
if (!this.dataProvider) {
|
|
547
548
|
throw new Error('Data provider not set');
|
|
548
549
|
}
|
|
549
|
-
|
|
550
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
551
|
+
var _this$fetchSourceInfo;
|
|
552
|
+
(_this$fetchSourceInfo = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo === void 0 || _this$fetchSourceInfo.start();
|
|
553
|
+
}
|
|
554
|
+
return this.dataProvider.fetchSyncBlockSourceInfo(localId, undefined, undefined, this.fireAnalyticsEvent).then(function (sourceInfo) {
|
|
555
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
556
|
+
if (!sourceInfo) {
|
|
557
|
+
var _this6$fetchSourceInf;
|
|
558
|
+
(_this6$fetchSourceInf = _this6.fetchSourceInfoExperience) === null || _this6$fetchSourceInf === void 0 || _this6$fetchSourceInf.failure({
|
|
559
|
+
reason: "No source info returned"
|
|
560
|
+
});
|
|
561
|
+
} else {
|
|
562
|
+
var _this6$fetchSourceInf2;
|
|
563
|
+
(_this6$fetchSourceInf2 = _this6.fetchSourceInfoExperience) === null || _this6$fetchSourceInf2 === void 0 || _this6$fetchSourceInf2.success();
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
return sourceInfo;
|
|
567
|
+
});
|
|
550
568
|
} catch (error) {
|
|
551
569
|
var _this$fireAnalyticsEv6;
|
|
552
570
|
(0, _monitoring.logException)(error, {
|
|
@@ -556,23 +574,45 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
556
574
|
return Promise.resolve(undefined);
|
|
557
575
|
}
|
|
558
576
|
}
|
|
577
|
+
}, {
|
|
578
|
+
key: "fetchReferences",
|
|
579
|
+
value: function fetchReferences(resourceId) {
|
|
580
|
+
try {
|
|
581
|
+
if (!this.dataProvider) {
|
|
582
|
+
throw new Error('Data provider not set');
|
|
583
|
+
}
|
|
584
|
+
return this.dataProvider.fetchReferences(resourceId, true);
|
|
585
|
+
} catch (error) {
|
|
586
|
+
var _this$fireAnalyticsEv7;
|
|
587
|
+
(0, _monitoring.logException)(error, {
|
|
588
|
+
location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
|
|
589
|
+
});
|
|
590
|
+
(_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 || _this$fireAnalyticsEv7.call(this, (0, _errorHandling.fetchReferencesErrorPayload)(error.message));
|
|
591
|
+
return Promise.resolve({
|
|
592
|
+
error: _types.SyncBlockError.Errored
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
}
|
|
559
596
|
}, {
|
|
560
597
|
key: "destroy",
|
|
561
598
|
value: function destroy() {
|
|
562
|
-
var _this$saveExperience4, _this$createExperienc2, _this$deleteExperienc4;
|
|
599
|
+
var _this$saveExperience4, _this$createExperienc2, _this$deleteExperienc4, _this$fetchSourceInfo2;
|
|
563
600
|
this.syncBlockCache.clear();
|
|
564
601
|
this.confirmationCallback = undefined;
|
|
565
602
|
this.pendingResourceId = undefined;
|
|
566
603
|
this.creationCallback = undefined;
|
|
567
604
|
this.dataProvider = undefined;
|
|
568
605
|
(_this$saveExperience4 = this.saveExperience) === null || _this$saveExperience4 === void 0 || _this$saveExperience4.abort({
|
|
569
|
-
reason: '
|
|
606
|
+
reason: 'editorDestroyed'
|
|
570
607
|
});
|
|
571
608
|
(_this$createExperienc2 = this.createExperience) === null || _this$createExperienc2 === void 0 || _this$createExperienc2.abort({
|
|
572
|
-
reason: '
|
|
609
|
+
reason: 'editorDestroyed'
|
|
573
610
|
});
|
|
574
611
|
(_this$deleteExperienc4 = this.deleteExperience) === null || _this$deleteExperienc4 === void 0 || _this$deleteExperienc4.abort({
|
|
575
|
-
reason: '
|
|
612
|
+
reason: 'editorDestroyed'
|
|
613
|
+
});
|
|
614
|
+
(_this$fetchSourceInfo2 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo2 === void 0 || _this$fetchSourceInfo2.abort({
|
|
615
|
+
reason: 'editorDestroyed'
|
|
576
616
|
});
|
|
577
617
|
this.clearPendingDeletion();
|
|
578
618
|
}
|