@atlaskit/editor-synced-block-provider 3.28.0 → 3.28.1
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 +8 -0
- package/dist/cjs/clients/block-service/blockService.js +118 -310
- package/dist/cjs/clients/confluence/sourceInfo.js +1 -1
- package/dist/cjs/providers/block-service/blockServiceAPI.js +8 -18
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +20 -68
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +29 -84
- package/dist/cjs/store-manager/syncBlockStoreManager.js +1 -2
- package/dist/es2019/clients/block-service/blockService.js +119 -235
- package/dist/es2019/clients/confluence/sourceInfo.js +1 -1
- package/dist/es2019/providers/block-service/blockServiceAPI.js +8 -18
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +34 -80
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +40 -90
- package/dist/es2019/store-manager/syncBlockStoreManager.js +1 -2
- package/dist/esm/clients/block-service/blockService.js +118 -310
- package/dist/esm/clients/confluence/sourceInfo.js +1 -1
- package/dist/esm/providers/block-service/blockServiceAPI.js +8 -18
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +20 -68
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +29 -84
- package/dist/esm/store-manager/syncBlockStoreManager.js +1 -2
- package/dist/types/clients/block-service/blockService.d.ts +3 -6
- package/dist/types/providers/block-service/blockServiceAPI.d.ts +2 -5
- package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +0 -2
- package/dist/types/store-manager/sourceSyncBlockStoreManager.d.ts +0 -14
- package/dist/types-ts4.5/clients/block-service/blockService.d.ts +3 -6
- package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +2 -5
- package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +0 -2
- package/dist/types-ts4.5/store-manager/sourceSyncBlockStoreManager.d.ts +0 -14
- package/package.json +1 -4
|
@@ -242,7 +242,7 @@ export var fetchConfluencePageInfo = /*#__PURE__*/function () {
|
|
|
242
242
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
243
243
|
while (1) switch (_context5.prev = _context5.next) {
|
|
244
244
|
case 0:
|
|
245
|
-
if (!
|
|
245
|
+
if (!isUnpublished) {
|
|
246
246
|
_context5.next = 5;
|
|
247
247
|
break;
|
|
248
248
|
}
|
|
@@ -11,7 +11,6 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
11
11
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
12
12
|
/* eslint-disable require-unicode-regexp */
|
|
13
13
|
import { useMemo } from 'react';
|
|
14
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
15
14
|
import { generateBlockAri, generateBlockAriFromReference } from '../../clients/block-service/ari';
|
|
16
15
|
import { batchRetrieveSyncedBlocks, BlockError, createSyncedBlock, deleteSyncedBlock, getReferenceSyncedBlocks, getReferenceSyncedBlocksByBlockAri, getSyncedBlockContent, updateReferenceSyncedBlockOnDocument, updateSyncedBlock } from '../../clients/block-service/blockService';
|
|
17
16
|
import { subscribeToBlockUpdates as subscribeToBlockUpdatesWS } from '../../clients/block-service/blockSubscription';
|
|
@@ -237,7 +236,6 @@ var _batchFetchData = /*#__PURE__*/function () {
|
|
|
237
236
|
_context2.prev = 5;
|
|
238
237
|
_context2.next = 8;
|
|
239
238
|
return batchRetrieveSyncedBlocks({
|
|
240
|
-
documentAri: parentAri,
|
|
241
239
|
blockIdentifiers: blockIdentifiers
|
|
242
240
|
});
|
|
243
241
|
case 8:
|
|
@@ -432,8 +430,7 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
432
430
|
_context3.prev = 1;
|
|
433
431
|
_context3.next = 4;
|
|
434
432
|
return getSyncedBlockContent({
|
|
435
|
-
blockAri: blockAri
|
|
436
|
-
documentAri: this.parentAri
|
|
433
|
+
blockAri: blockAri
|
|
437
434
|
});
|
|
438
435
|
case 4:
|
|
439
436
|
blockContentResponse = _context3.sent;
|
|
@@ -635,15 +632,13 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
635
632
|
parentAri = _ref5.parentAri,
|
|
636
633
|
parentId = _ref5.parentId,
|
|
637
634
|
product = _ref5.product,
|
|
638
|
-
getVersion = _ref5.getVersion
|
|
639
|
-
isParentUnpublished = _ref5.isParentUnpublished;
|
|
635
|
+
getVersion = _ref5.getVersion;
|
|
640
636
|
_classCallCheck(this, BlockServiceADFWriteProvider);
|
|
641
637
|
this.cloudId = cloudId;
|
|
642
638
|
this.parentAri = parentAri;
|
|
643
639
|
this.parentId = parentId;
|
|
644
640
|
this.product = product;
|
|
645
641
|
this.getVersion = getVersion;
|
|
646
|
-
this.isParentUnpublished = isParentUnpublished;
|
|
647
642
|
}
|
|
648
643
|
|
|
649
644
|
// it will first try to update and if it can't (404) then it will try to create
|
|
@@ -728,7 +723,6 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
728
723
|
key: "createData",
|
|
729
724
|
value: function () {
|
|
730
725
|
var _createData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(data) {
|
|
731
|
-
var _this$isParentUnpubli;
|
|
732
726
|
var resourceId, blockAri, stepVersion, status;
|
|
733
727
|
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
734
728
|
while (1) switch (_context7.prev = _context7.next) {
|
|
@@ -762,7 +756,7 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
762
756
|
_context7.t0 = undefined;
|
|
763
757
|
case 11:
|
|
764
758
|
stepVersion = _context7.t0;
|
|
765
|
-
status =
|
|
759
|
+
status = 'unpublished';
|
|
766
760
|
_context7.prev = 13;
|
|
767
761
|
_context7.next = 16;
|
|
768
762
|
return createSyncedBlock({
|
|
@@ -959,8 +953,7 @@ var createBlockServiceAPIProviders = function createBlockServiceAPIProviders(_re
|
|
|
959
953
|
parentAri = _ref6.parentAri,
|
|
960
954
|
parentId = _ref6.parentId,
|
|
961
955
|
product = _ref6.product,
|
|
962
|
-
getVersion = _ref6.getVersion
|
|
963
|
-
isParentUnpublished = _ref6.isParentUnpublished;
|
|
956
|
+
getVersion = _ref6.getVersion;
|
|
964
957
|
return {
|
|
965
958
|
fetchProvider: new BlockServiceADFFetchProvider({
|
|
966
959
|
cloudId: cloudId,
|
|
@@ -971,8 +964,7 @@ var createBlockServiceAPIProviders = function createBlockServiceAPIProviders(_re
|
|
|
971
964
|
parentAri: parentAri,
|
|
972
965
|
parentId: parentId,
|
|
973
966
|
product: product,
|
|
974
|
-
getVersion: getVersion
|
|
975
|
-
isParentUnpublished: isParentUnpublished
|
|
967
|
+
getVersion: getVersion
|
|
976
968
|
})
|
|
977
969
|
};
|
|
978
970
|
};
|
|
@@ -981,18 +973,16 @@ export var useMemoizedBlockServiceAPIProviders = function useMemoizedBlockServic
|
|
|
981
973
|
parentAri = _ref7.parentAri,
|
|
982
974
|
parentId = _ref7.parentId,
|
|
983
975
|
product = _ref7.product,
|
|
984
|
-
getVersion = _ref7.getVersion
|
|
985
|
-
isParentUnpublished = _ref7.isParentUnpublished;
|
|
976
|
+
getVersion = _ref7.getVersion;
|
|
986
977
|
return useMemo(function () {
|
|
987
978
|
return createBlockServiceAPIProviders({
|
|
988
979
|
cloudId: cloudId,
|
|
989
980
|
parentAri: parentAri,
|
|
990
981
|
parentId: parentId,
|
|
991
982
|
product: product,
|
|
992
|
-
getVersion: getVersion
|
|
993
|
-
isParentUnpublished: isParentUnpublished
|
|
983
|
+
getVersion: getVersion
|
|
994
984
|
});
|
|
995
|
-
}, [cloudId, parentAri, parentId, product, getVersion
|
|
985
|
+
}, [cloudId, parentAri, parentId, product, getVersion]);
|
|
996
986
|
};
|
|
997
987
|
var createBlockServiceFetchOnlyAPIProvider = function createBlockServiceFetchOnlyAPIProvider(_ref8) {
|
|
998
988
|
var cloudId = _ref8.cloudId,
|
|
@@ -11,7 +11,6 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
|
|
|
11
11
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
12
12
|
import isEqual from 'lodash/isEqual';
|
|
13
13
|
import rafSchedule from 'raf-schd';
|
|
14
|
-
import { isSSR } from '@atlaskit/editor-common/core-utils';
|
|
15
14
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
16
15
|
import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
17
16
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -66,12 +65,10 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
66
65
|
});
|
|
67
66
|
});
|
|
68
67
|
}));
|
|
69
|
-
this.syncBlockCache = new Map();
|
|
70
68
|
this.subscriptions = new Map();
|
|
71
69
|
this.titleSubscriptions = new Map();
|
|
72
70
|
this.dataProvider = dataProvider;
|
|
73
71
|
this.syncBlockFetchDataRequests = new Map();
|
|
74
|
-
this.syncBlockSourceInfoRequestsOld = new Map();
|
|
75
72
|
this.syncBlockSourceInfoRequests = new Map();
|
|
76
73
|
this.providerFactories = new Map();
|
|
77
74
|
this.pendingCacheDeletions = new Map();
|
|
@@ -214,16 +211,9 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
214
211
|
}, {
|
|
215
212
|
key: "getInitialSyncBlockData",
|
|
216
213
|
value: function getInitialSyncBlockData(resourceId) {
|
|
217
|
-
var _this$
|
|
214
|
+
var _this$dataProvider;
|
|
218
215
|
var syncBlockNode = createSyncBlockNode('', resourceId);
|
|
219
|
-
|
|
220
|
-
var _this$dataProvider;
|
|
221
|
-
// In SSR, prefer data from data provider cache
|
|
222
|
-
// should not take from store manager cache as it may be in incomplete state
|
|
223
|
-
// will be unified to the same cache later.
|
|
224
|
-
return (_this$dataProvider = this.dataProvider) === null || _this$dataProvider === void 0 || (_this$dataProvider = _this$dataProvider.getNodeDataFromCache(syncBlockNode)) === null || _this$dataProvider === void 0 ? void 0 : _this$dataProvider.data;
|
|
225
|
-
}
|
|
226
|
-
return this.getFromCache(resourceId) || ((_this$dataProvider2 = this.dataProvider) === null || _this$dataProvider2 === void 0 || (_this$dataProvider2 = _this$dataProvider2.getNodeDataFromCache(syncBlockNode)) === null || _this$dataProvider2 === void 0 ? void 0 : _this$dataProvider2.data);
|
|
216
|
+
return (_this$dataProvider = this.dataProvider) === null || _this$dataProvider === void 0 || (_this$dataProvider = _this$dataProvider.getNodeDataFromCache(syncBlockNode)) === null || _this$dataProvider === void 0 ? void 0 : _this$dataProvider.data;
|
|
227
217
|
}
|
|
228
218
|
|
|
229
219
|
/**
|
|
@@ -328,13 +318,13 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
328
318
|
}, {
|
|
329
319
|
key: "setupGraphQLSubscription",
|
|
330
320
|
value: function setupGraphQLSubscription(resourceId) {
|
|
331
|
-
var _this$
|
|
321
|
+
var _this$dataProvider2,
|
|
332
322
|
_this4 = this;
|
|
333
323
|
// Don't set up duplicate subscriptions
|
|
334
324
|
if (this.graphqlSubscriptions.has(resourceId)) {
|
|
335
325
|
return;
|
|
336
326
|
}
|
|
337
|
-
if (!((_this$
|
|
327
|
+
if (!((_this$dataProvider2 = this.dataProvider) !== null && _this$dataProvider2 !== void 0 && _this$dataProvider2.subscribeToBlockUpdates)) {
|
|
338
328
|
return;
|
|
339
329
|
}
|
|
340
330
|
var unsubscribe = this.dataProvider.subscribeToBlockUpdates(resourceId, function (syncBlockInstance) {
|
|
@@ -496,9 +486,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
496
486
|
return Promise.resolve(undefined);
|
|
497
487
|
}
|
|
498
488
|
(_this$fetchSourceInfo = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo === void 0 || _this$fetchSourceInfo.start({});
|
|
499
|
-
|
|
500
|
-
// Only use unpublished endpoint if feature flag is enabled
|
|
501
|
-
var isUnpublished = fg('platform_synced_block_patch_1') && ((_existingSyncBlock$da = existingSyncBlock.data) === null || _existingSyncBlock$da === void 0 ? void 0 : _existingSyncBlock$da.status) === 'unpublished';
|
|
489
|
+
var isUnpublished = ((_existingSyncBlock$da = existingSyncBlock.data) === null || _existingSyncBlock$da === void 0 ? void 0 : _existingSyncBlock$da.status) === 'unpublished';
|
|
502
490
|
var sourceInfoPromise = this.dataProvider.fetchSyncBlockSourceInfo(blockInstanceId, sourceAri, product, this.fireAnalyticsEvent, true,
|
|
503
491
|
// hasAccess
|
|
504
492
|
'edit',
|
|
@@ -779,16 +767,11 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
779
767
|
value: function updateCache(syncBlock) {
|
|
780
768
|
var resourceId = syncBlock.resourceId;
|
|
781
769
|
if (resourceId) {
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
source: 'network'
|
|
788
|
-
});
|
|
789
|
-
} else {
|
|
790
|
-
this.syncBlockCache.set(resourceId, syncBlock);
|
|
791
|
-
}
|
|
770
|
+
var _this$dataProvider3;
|
|
771
|
+
(_this$dataProvider3 = this.dataProvider) === null || _this$dataProvider3 === void 0 || _this$dataProvider3.updateCache(_defineProperty({}, resourceId, syncBlock), {
|
|
772
|
+
strategy: 'merge',
|
|
773
|
+
source: 'network'
|
|
774
|
+
});
|
|
792
775
|
var callbacks = this.subscriptions.get(resourceId);
|
|
793
776
|
if (callbacks) {
|
|
794
777
|
Object.values(callbacks).forEach(function (callback) {
|
|
@@ -810,25 +793,15 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
810
793
|
}, {
|
|
811
794
|
key: "getFromCache",
|
|
812
795
|
value: function getFromCache(resourceId) {
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
var syncBlockNode = createSyncBlockNode('', resourceId);
|
|
817
|
-
return (_this$dataProvider5 = this.dataProvider) === null || _this$dataProvider5 === void 0 || (_this$dataProvider5 = _this$dataProvider5.getNodeDataFromCache(syncBlockNode)) === null || _this$dataProvider5 === void 0 ? void 0 : _this$dataProvider5.data;
|
|
818
|
-
}
|
|
819
|
-
return this.syncBlockCache.get(resourceId);
|
|
796
|
+
var _this$dataProvider4;
|
|
797
|
+
var syncBlockNode = createSyncBlockNode('', resourceId);
|
|
798
|
+
return (_this$dataProvider4 = this.dataProvider) === null || _this$dataProvider4 === void 0 || (_this$dataProvider4 = _this$dataProvider4.getNodeDataFromCache(syncBlockNode)) === null || _this$dataProvider4 === void 0 ? void 0 : _this$dataProvider4.data;
|
|
820
799
|
}
|
|
821
800
|
}, {
|
|
822
801
|
key: "deleteFromCache",
|
|
823
802
|
value: function deleteFromCache(resourceId) {
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
// For dataProvider cache, we update with empty/deleted state
|
|
827
|
-
// The cache is managed per-node basis via resetCache if needed
|
|
828
|
-
// For now, we don't explicitly delete from dataProvider cache
|
|
829
|
-
// as the cache is meant to persist for cache-first-then-network strategy
|
|
830
|
-
(_this$dataProvider6 = this.dataProvider) === null || _this$dataProvider6 === void 0 || _this$dataProvider6.removeFromCache([resourceId]);
|
|
831
|
-
}
|
|
803
|
+
var _this$dataProvider5;
|
|
804
|
+
(_this$dataProvider5 = this.dataProvider) === null || _this$dataProvider5 === void 0 || _this$dataProvider5.removeFromCache([resourceId]);
|
|
832
805
|
this.providerFactories.delete(resourceId);
|
|
833
806
|
}
|
|
834
807
|
}, {
|
|
@@ -850,9 +823,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
850
823
|
}, {
|
|
851
824
|
key: "subscribeToSyncBlock",
|
|
852
825
|
value: function subscribeToSyncBlock(resourceId, localId, callback) {
|
|
853
|
-
var _this$
|
|
854
|
-
_this$dataProvider8,
|
|
855
|
-
_this$dataProvider9,
|
|
826
|
+
var _this$dataProvider6,
|
|
856
827
|
_this0 = this;
|
|
857
828
|
// Cancel any pending cache deletion for this resourceId.
|
|
858
829
|
// This handles the case where a block is moved - the old component unmounts
|
|
@@ -879,23 +850,11 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
879
850
|
var syncBlockNode = createSyncBlockNode(localId, resourceId);
|
|
880
851
|
|
|
881
852
|
// call the callback immediately if we have cached data
|
|
882
|
-
var cachedData =
|
|
883
|
-
(_this$dataProvider7 = this.dataProvider) === null || _this$dataProvider7 === void 0 || (_this$dataProvider7 = _this$dataProvider7.getNodeDataFromCache(syncBlockNode)) === null || _this$dataProvider7 === void 0 ? void 0 : _this$dataProvider7.data : isSSR() // in SSR, prefer data provider cache
|
|
884
|
-
? ((_this$dataProvider8 = this.dataProvider) === null || _this$dataProvider8 === void 0 || (_this$dataProvider8 = _this$dataProvider8.getNodeDataFromCache(syncBlockNode)) === null || _this$dataProvider8 === void 0 ? void 0 : _this$dataProvider8.data) || this.getFromCache(resourceId) : this.getFromCache(resourceId) || ((_this$dataProvider9 = this.dataProvider) === null || _this$dataProvider9 === void 0 || (_this$dataProvider9 = _this$dataProvider9.getNodeDataFromCache(syncBlockNode)) === null || _this$dataProvider9 === void 0 ? void 0 : _this$dataProvider9.data);
|
|
853
|
+
var cachedData = (_this$dataProvider6 = this.dataProvider) === null || _this$dataProvider6 === void 0 || (_this$dataProvider6 = _this$dataProvider6.getNodeDataFromCache(syncBlockNode)) === null || _this$dataProvider6 === void 0 ? void 0 : _this$dataProvider6.data;
|
|
885
854
|
if (cachedData) {
|
|
886
855
|
callback(cachedData);
|
|
887
856
|
} else {
|
|
888
|
-
|
|
889
|
-
this.debouncedBatchedFetchSyncBlocks(resourceId);
|
|
890
|
-
} else {
|
|
891
|
-
this.fetchSyncBlocksData([syncBlockNode]).catch(function (error) {
|
|
892
|
-
var _this0$fireAnalyticsE;
|
|
893
|
-
logException(error, {
|
|
894
|
-
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
895
|
-
});
|
|
896
|
-
(_this0$fireAnalyticsE = _this0.fireAnalyticsEvent) === null || _this0$fireAnalyticsE === void 0 || _this0$fireAnalyticsE.call(_this0, fetchErrorPayload(error.message, resourceId));
|
|
897
|
-
});
|
|
898
|
-
}
|
|
857
|
+
this.debouncedBatchedFetchSyncBlocks(resourceId);
|
|
899
858
|
}
|
|
900
859
|
|
|
901
860
|
// Set up GraphQL subscription if real-time subscriptions are enabled
|
|
@@ -1345,7 +1304,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
1345
1304
|
}, {
|
|
1346
1305
|
key: "destroy",
|
|
1347
1306
|
value: function destroy() {
|
|
1348
|
-
var _this$saveExperience5, _this$fetchExperience0, _this$fetchSourceInfo2;
|
|
1307
|
+
var _this$dataProvider7, _this$saveExperience5, _this$fetchExperience0, _this$fetchSourceInfo2;
|
|
1349
1308
|
// Cancel any queued flush to prevent it from running after destroy
|
|
1350
1309
|
if (this.queuedFlushTimeout) {
|
|
1351
1310
|
clearTimeout(this.queuedFlushTimeout);
|
|
@@ -1354,20 +1313,13 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
1354
1313
|
|
|
1355
1314
|
// Clean up all GraphQL subscriptions first
|
|
1356
1315
|
this.cleanupAllGraphQLSubscriptions();
|
|
1357
|
-
|
|
1358
|
-
var _this$dataProvider0;
|
|
1359
|
-
// Reset cache in dataProvider
|
|
1360
|
-
(_this$dataProvider0 = this.dataProvider) === null || _this$dataProvider0 === void 0 || _this$dataProvider0.resetCache();
|
|
1361
|
-
} else {
|
|
1362
|
-
this.syncBlockCache.clear();
|
|
1363
|
-
}
|
|
1316
|
+
(_this$dataProvider7 = this.dataProvider) === null || _this$dataProvider7 === void 0 || _this$dataProvider7.resetCache();
|
|
1364
1317
|
this.scheduledBatchFetch.cancel();
|
|
1365
1318
|
this.pendingFetchRequests.clear();
|
|
1366
1319
|
this.dataProvider = undefined;
|
|
1367
1320
|
this.subscriptions.clear();
|
|
1368
1321
|
this.titleSubscriptions.clear();
|
|
1369
1322
|
this.syncBlockFetchDataRequests.clear();
|
|
1370
|
-
this.syncBlockSourceInfoRequestsOld.clear();
|
|
1371
1323
|
this.syncBlockSourceInfoRequests.clear();
|
|
1372
1324
|
this.providerFactories.clear();
|
|
1373
1325
|
this.isRefreshingSubscriptions = false;
|
|
@@ -6,7 +6,6 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
6
6
|
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; }
|
|
7
7
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
8
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
9
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
9
|
import { SyncBlockError } from '../common/types';
|
|
11
10
|
import { updateErrorPayload, createErrorPayload, deleteErrorPayload, updateCacheErrorPayload, getSourceInfoErrorPayload, updateSuccessPayload, createSuccessPayload, deleteSuccessPayload, fetchReferencesErrorPayload } from '../utils/errorHandling';
|
|
12
11
|
import { getCreateSourceExperience, getDeleteSourceExperience, getSaveSourceExperience, getFetchSourceInfoExperience } from '../utils/experienceTracking';
|
|
@@ -99,7 +98,7 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
99
98
|
// - are waiting to be deleted to avoid nodes being re-created
|
|
100
99
|
// - haven't been updated since we last flushed
|
|
101
100
|
// - are still pending BE creation
|
|
102
|
-
if (!syncBlockData.pendingDeletion && syncBlockData.isDirty && !
|
|
101
|
+
if (!syncBlockData.pendingDeletion && syncBlockData.isDirty && !_this2.isPendingCreation(syncBlockData.resourceId)) {
|
|
103
102
|
bodiedSyncBlockNodes.push({
|
|
104
103
|
type: 'bodiedSyncBlock',
|
|
105
104
|
attrs: {
|
|
@@ -113,10 +112,10 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
113
112
|
// is still making changes, the new changes might not be saved if they all happen
|
|
114
113
|
// exactly at a time when the writeNodesData is being executed asynchronously.
|
|
115
114
|
syncBlockData.isDirty = false;
|
|
116
|
-
// When flushing, set status to 'active' so the block is published
|
|
117
|
-
var dataToFlush =
|
|
115
|
+
// When flushing, set status to 'active' so the block is published
|
|
116
|
+
var dataToFlush = _objectSpread(_objectSpread({}, syncBlockData), {}, {
|
|
118
117
|
status: 'active'
|
|
119
|
-
})
|
|
118
|
+
});
|
|
120
119
|
bodiedSyncBlockData.push(dataToFlush);
|
|
121
120
|
}
|
|
122
121
|
});
|
|
@@ -190,28 +189,13 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
190
189
|
return _flush.apply(this, arguments);
|
|
191
190
|
}
|
|
192
191
|
return flush;
|
|
193
|
-
}()
|
|
194
|
-
)
|
|
195
|
-
}, {
|
|
196
|
-
key: "registerPendingCreation",
|
|
197
|
-
value: function registerPendingCreation(resourceId) {
|
|
198
|
-
this.pendingResourceId = resourceId;
|
|
199
|
-
}
|
|
192
|
+
}())
|
|
200
193
|
}, {
|
|
201
194
|
key: "isPendingCreation",
|
|
202
195
|
value: function isPendingCreation(resourceId) {
|
|
203
196
|
return this.creationCompletionCallbacks.has(resourceId);
|
|
204
197
|
}
|
|
205
198
|
|
|
206
|
-
/**
|
|
207
|
-
* Register callback function (which inserts node, handles focus etc) to be used later when creation to backend succeed
|
|
208
|
-
*/
|
|
209
|
-
}, {
|
|
210
|
-
key: "registerCreationCallback",
|
|
211
|
-
value: function registerCreationCallback(callback) {
|
|
212
|
-
this.creationCallback = callback;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
199
|
/**
|
|
216
200
|
* Fires callback to insert node (if creation is successful) and clears pending creation data
|
|
217
201
|
* @param success
|
|
@@ -219,47 +203,23 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
219
203
|
}, {
|
|
220
204
|
key: "commitPendingCreation",
|
|
221
205
|
value: function commitPendingCreation(success, resourceId) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
onCompletion(success);
|
|
227
|
-
} else {
|
|
228
|
-
var _this$fireAnalyticsEv3;
|
|
229
|
-
(_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(this, createErrorPayload('creation complete callback missing', resourceId));
|
|
230
|
-
}
|
|
231
|
-
if (success) {
|
|
232
|
-
var _this$fireAnalyticsEv4;
|
|
233
|
-
(_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(this, createSuccessPayload(resourceId || ''));
|
|
234
|
-
} else {
|
|
235
|
-
var _this$fireAnalyticsEv5;
|
|
236
|
-
// Delete the node from cache if fail to create so it's not flushed to BE
|
|
237
|
-
this.syncBlockCache.delete(resourceId || '');
|
|
238
|
-
(_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 || _this$fireAnalyticsEv5.call(this, createErrorPayload('Fail to create bodied sync block', resourceId));
|
|
239
|
-
}
|
|
206
|
+
var onCompletion = this.creationCompletionCallbacks.get(resourceId);
|
|
207
|
+
if (onCompletion) {
|
|
208
|
+
this.creationCompletionCallbacks.delete(resourceId);
|
|
209
|
+
onCompletion(success);
|
|
240
210
|
} else {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
211
|
+
var _this$fireAnalyticsEv3;
|
|
212
|
+
(_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(this, createErrorPayload('creation complete callback missing', resourceId));
|
|
213
|
+
}
|
|
214
|
+
if (success) {
|
|
215
|
+
var _this$fireAnalyticsEv4;
|
|
216
|
+
(_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(this, createSuccessPayload(resourceId || ''));
|
|
217
|
+
} else {
|
|
218
|
+
var _this$fireAnalyticsEv5;
|
|
219
|
+
// Delete the node from cache if fail to create so it's not flushed to BE
|
|
220
|
+
this.syncBlockCache.delete(resourceId || '');
|
|
221
|
+
(_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 || _this$fireAnalyticsEv5.call(this, createErrorPayload('Fail to create bodied sync block', resourceId));
|
|
250
222
|
}
|
|
251
|
-
this.creationCallback = undefined;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
*
|
|
256
|
-
* @returns true if waiting for the result of saving new bodiedSyncBlock to backend
|
|
257
|
-
* Remove this method when cleaning up platform_synced_block_patch_1
|
|
258
|
-
*/
|
|
259
|
-
}, {
|
|
260
|
-
key: "hasPendingCreation",
|
|
261
|
-
value: function hasPendingCreation() {
|
|
262
|
-
return fg('platform_synced_block_patch_1') ? this.creationCompletionCallbacks.size > 0 : !!this.pendingResourceId;
|
|
263
223
|
}
|
|
264
224
|
}, {
|
|
265
225
|
key: "registerConfirmationCallback",
|
|
@@ -309,9 +269,7 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
309
269
|
if (!this.dataProvider) {
|
|
310
270
|
throw new Error('Data provider not set');
|
|
311
271
|
}
|
|
312
|
-
|
|
313
|
-
this.creationCompletionCallbacks.set(resourceId, onCompletion);
|
|
314
|
-
}
|
|
272
|
+
this.creationCompletionCallbacks.set(resourceId, onCompletion);
|
|
315
273
|
(_this$createExperienc = this.createExperience) === null || _this$createExperienc === void 0 || _this$createExperienc.start({});
|
|
316
274
|
this.dataProvider.createNodeData({
|
|
317
275
|
content: [],
|
|
@@ -319,18 +277,10 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
319
277
|
resourceId: resourceId
|
|
320
278
|
}).then(function (result) {
|
|
321
279
|
var resourceId = result.resourceId || '';
|
|
322
|
-
if (resourceId &&
|
|
280
|
+
if (resourceId && !result.error) {
|
|
323
281
|
var _this4$createExperien;
|
|
324
282
|
_this4.commitPendingCreation(true, resourceId);
|
|
325
283
|
(_this4$createExperien = _this4.createExperience) === null || _this4$createExperien === void 0 || _this4$createExperien.success();
|
|
326
|
-
|
|
327
|
-
// Update the sync block data with the node data if it is provided
|
|
328
|
-
// to avoid any race conditions where the data could be missed during a render operation
|
|
329
|
-
if (!fg('platform_synced_block_patch_1')) {
|
|
330
|
-
if (nodeData) {
|
|
331
|
-
_this4.updateSyncBlockData(nodeData);
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
284
|
} else {
|
|
335
285
|
var _this4$createExperien2, _this4$fireAnalyticsE;
|
|
336
286
|
_this4.commitPendingCreation(false, resourceId);
|
|
@@ -350,18 +300,15 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
350
300
|
});
|
|
351
301
|
(_this4$fireAnalyticsE2 = _this4.fireAnalyticsEvent) === null || _this4$fireAnalyticsE2 === void 0 || _this4$fireAnalyticsE2.call(_this4, createErrorPayload(error.message, resourceId));
|
|
352
302
|
});
|
|
353
|
-
if (!fg('platform_synced_block_patch_1')) {
|
|
354
|
-
this.registerPendingCreation(resourceId);
|
|
355
|
-
}
|
|
356
303
|
} catch (error) {
|
|
357
|
-
var _this$
|
|
358
|
-
if (
|
|
304
|
+
var _this$fireAnalyticsEv6;
|
|
305
|
+
if (this.isPendingCreation(resourceId)) {
|
|
359
306
|
this.commitPendingCreation(false, resourceId);
|
|
360
307
|
}
|
|
361
308
|
logException(error, {
|
|
362
309
|
location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
|
|
363
310
|
});
|
|
364
|
-
(_this$
|
|
311
|
+
(_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 || _this$fireAnalyticsEv6.call(this, createErrorPayload(error.message));
|
|
365
312
|
}
|
|
366
313
|
}
|
|
367
314
|
}, {
|
|
@@ -572,11 +519,11 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
572
519
|
return sourceInfo;
|
|
573
520
|
});
|
|
574
521
|
} catch (error) {
|
|
575
|
-
var _this$
|
|
522
|
+
var _this$fireAnalyticsEv7;
|
|
576
523
|
logException(error, {
|
|
577
524
|
location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
|
|
578
525
|
});
|
|
579
|
-
(_this$
|
|
526
|
+
(_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 || _this$fireAnalyticsEv7.call(this, getSourceInfoErrorPayload(error.message));
|
|
580
527
|
return Promise.resolve(undefined);
|
|
581
528
|
}
|
|
582
529
|
}
|
|
@@ -589,11 +536,11 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
589
536
|
}
|
|
590
537
|
return this.dataProvider.fetchReferences(resourceId, true);
|
|
591
538
|
} catch (error) {
|
|
592
|
-
var _this$
|
|
539
|
+
var _this$fireAnalyticsEv8;
|
|
593
540
|
logException(error, {
|
|
594
541
|
location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
|
|
595
542
|
});
|
|
596
|
-
(_this$
|
|
543
|
+
(_this$fireAnalyticsEv8 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv8 === void 0 || _this$fireAnalyticsEv8.call(this, fetchReferencesErrorPayload(error.message));
|
|
597
544
|
return Promise.resolve({
|
|
598
545
|
error: SyncBlockError.Errored
|
|
599
546
|
});
|
|
@@ -605,9 +552,7 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
605
552
|
var _this$saveExperience4, _this$createExperienc2, _this$deleteExperienc4, _this$fetchSourceInfo2;
|
|
606
553
|
this.syncBlockCache.clear();
|
|
607
554
|
this.confirmationCallback = undefined;
|
|
608
|
-
this.pendingResourceId = undefined;
|
|
609
555
|
this.creationCompletionCallbacks.clear();
|
|
610
|
-
this.creationCallback = undefined;
|
|
611
556
|
this.dataProvider = undefined;
|
|
612
557
|
(_this$saveExperience4 = this.saveExperience) === null || _this$saveExperience4 === void 0 || _this$saveExperience4.abort({
|
|
613
558
|
reason: 'editorDestroyed'
|
|
@@ -7,7 +7,6 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
7
7
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
8
|
import { useMemo } from 'react';
|
|
9
9
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
10
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
10
|
import { getProductFromSourceAri } from '../clients/block-service/ari';
|
|
12
11
|
import { SyncBlockError } from '../common/types';
|
|
13
12
|
import { fetchReferencesErrorPayload } from '../utils/errorHandling';
|
|
@@ -28,7 +27,7 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
28
27
|
this.sourceSyncBlockStoreManager = new SourceSyncBlockStoreManager(dataProvider);
|
|
29
28
|
this.referenceSyncBlockStoreManager = new ReferenceSyncBlockStoreManager(dataProvider);
|
|
30
29
|
this.dataProvider = dataProvider;
|
|
31
|
-
this.referenceSyncBlockStoreManager.setRealTimeSubscriptionsEnabled(
|
|
30
|
+
this.referenceSyncBlockStoreManager.setRealTimeSubscriptionsEnabled(true);
|
|
32
31
|
}
|
|
33
32
|
return _createClass(SyncBlockStoreManager, [{
|
|
34
33
|
key: "fetchReferencesSourceInfo",
|
|
@@ -67,7 +67,6 @@ export declare const isBlockContentResponse: (response: BlockContentResponse | E
|
|
|
67
67
|
export declare const getReferenceSyncedBlocks: (documentAri: string) => Promise<ReferenceSyncedBlockResponse>;
|
|
68
68
|
export type GetSyncedBlockContentRequest = {
|
|
69
69
|
blockAri: string;
|
|
70
|
-
documentAri?: string;
|
|
71
70
|
};
|
|
72
71
|
export type DeleteSyncedBlockRequest = {
|
|
73
72
|
blockAri: string;
|
|
@@ -99,7 +98,6 @@ type UpdateReferenceSyncedBlockOnDocumentRequest = {
|
|
|
99
98
|
};
|
|
100
99
|
export type BatchRetrieveSyncedBlocksRequest = {
|
|
101
100
|
blockIdentifiers: BlockIdentifier[];
|
|
102
|
-
documentAri: string;
|
|
103
101
|
};
|
|
104
102
|
type BlockIdentifier = {
|
|
105
103
|
blockAri: string;
|
|
@@ -125,13 +123,12 @@ export declare const getSyncedBlockContent: ({ blockAri, }: GetSyncedBlockConten
|
|
|
125
123
|
/**
|
|
126
124
|
* Batch retrieves multiple synced blocks by their ARIs.
|
|
127
125
|
*
|
|
128
|
-
* Calls the Block Service API
|
|
129
|
-
* or GraphQL query `blockService_batchRetrieveBlocks` when feature flag is enabled
|
|
126
|
+
* Calls the Block Service GraphQL API: `blockService_batchRetrieveBlocks`
|
|
130
127
|
*
|
|
131
|
-
* @param
|
|
128
|
+
* @param blockIdentifiers - Array of block identifiers to retrieve
|
|
132
129
|
* @returns A promise containing arrays of successfully fetched blocks and any errors encountered
|
|
133
130
|
*/
|
|
134
|
-
export declare const batchRetrieveSyncedBlocks: ({ blockIdentifiers,
|
|
131
|
+
export declare const batchRetrieveSyncedBlocks: ({ blockIdentifiers, }: BatchRetrieveSyncedBlocksRequest) => Promise<BatchRetrieveSyncedBlocksResponse>;
|
|
135
132
|
export declare const deleteSyncedBlock: ({ blockAri, deleteReason, }: DeleteSyncedBlockRequest) => Promise<void>;
|
|
136
133
|
export declare const updateSyncedBlock: ({ blockAri, content, stepVersion, status, }: UpdateSyncedBlockRequest) => Promise<void>;
|
|
137
134
|
export declare const createSyncedBlock: ({ blockAri, blockInstanceId, sourceAri, product, content, stepVersion, status, }: CreateSyncedBlockRequest) => Promise<BlockContentResponse>;
|
|
@@ -64,7 +64,6 @@ declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
|
|
|
64
64
|
interface BlockServiceADFWriteProviderProps {
|
|
65
65
|
cloudId: string;
|
|
66
66
|
getVersion?: () => Promise<number | undefined>;
|
|
67
|
-
isParentUnpublished?: () => boolean;
|
|
68
67
|
parentAri: string | undefined;
|
|
69
68
|
parentId?: string;
|
|
70
69
|
product: SyncBlockProduct;
|
|
@@ -76,10 +75,9 @@ declare class BlockServiceADFWriteProvider implements ADFWriteProvider {
|
|
|
76
75
|
private cloudId;
|
|
77
76
|
private parentId?;
|
|
78
77
|
private getVersion?;
|
|
79
|
-
private isParentUnpublished?;
|
|
80
78
|
product: SyncBlockProduct;
|
|
81
79
|
parentAri: string | undefined;
|
|
82
|
-
constructor({ cloudId, parentAri, parentId, product, getVersion,
|
|
80
|
+
constructor({ cloudId, parentAri, parentId, product, getVersion, }: BlockServiceADFWriteProviderProps);
|
|
83
81
|
writeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
84
82
|
createData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
85
83
|
deleteData(resourceId: string, deleteReason: string | undefined): Promise<DeleteSyncBlockResult>;
|
|
@@ -90,12 +88,11 @@ declare class BlockServiceADFWriteProvider implements ADFWriteProvider {
|
|
|
90
88
|
interface BlockServiceAPIProvidersProps {
|
|
91
89
|
cloudId: string;
|
|
92
90
|
getVersion?: () => Promise<number | undefined>;
|
|
93
|
-
isParentUnpublished?: () => boolean;
|
|
94
91
|
parentAri: string | undefined;
|
|
95
92
|
parentId?: string;
|
|
96
93
|
product: SyncBlockProduct;
|
|
97
94
|
}
|
|
98
|
-
export declare const useMemoizedBlockServiceAPIProviders: ({ cloudId, parentAri, parentId, product, getVersion,
|
|
95
|
+
export declare const useMemoizedBlockServiceAPIProviders: ({ cloudId, parentAri, parentId, product, getVersion, }: BlockServiceAPIProvidersProps) => {
|
|
99
96
|
fetchProvider: BlockServiceADFFetchProvider;
|
|
100
97
|
writeProvider: BlockServiceADFWriteProvider;
|
|
101
98
|
};
|
|
@@ -6,14 +6,12 @@ import { type ResourceId, type SyncBlockNode, type SyncBlockPrefetchData } from
|
|
|
6
6
|
import type { SyncBlockInstance, SubscriptionCallback, SyncBlockDataProvider, TitleSubscriptionCallback, SyncBlockSourceInfo } from '../providers/types';
|
|
7
7
|
export declare class ReferenceSyncBlockStoreManager {
|
|
8
8
|
private dataProvider?;
|
|
9
|
-
private syncBlockCache;
|
|
10
9
|
private isCacheDirty;
|
|
11
10
|
private subscriptions;
|
|
12
11
|
private titleSubscriptions;
|
|
13
12
|
private providerFactories;
|
|
14
13
|
private fireAnalyticsEvent?;
|
|
15
14
|
private syncBlockFetchDataRequests;
|
|
16
|
-
private syncBlockSourceInfoRequestsOld;
|
|
17
15
|
private syncBlockSourceInfoRequests;
|
|
18
16
|
private isRefreshingSubscriptions;
|
|
19
17
|
private pendingCacheDeletions;
|