@atlaskit/editor-synced-block-provider 3.14.2 → 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 +11 -0
- package/dist/cjs/clients/block-service/blockService.js +12 -9
- package/dist/cjs/providers/block-service/blockServiceAPI.js +28 -18
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +61 -23
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +27 -5
- package/dist/cjs/store-manager/syncBlockStoreManager.js +53 -22
- package/dist/cjs/utils/experienceTracking.js +18 -1
- package/dist/es2019/clients/block-service/blockService.js +5 -1
- package/dist/es2019/providers/block-service/blockServiceAPI.js +17 -7
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +68 -34
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +27 -6
- package/dist/es2019/store-manager/syncBlockStoreManager.js +36 -2
- package/dist/es2019/utils/experienceTracking.js +17 -0
- package/dist/esm/clients/block-service/blockService.js +12 -9
- package/dist/esm/providers/block-service/blockServiceAPI.js +28 -18
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +61 -23
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +28 -6
- package/dist/esm/store-manager/syncBlockStoreManager.js +53 -22
- package/dist/esm/utils/experienceTracking.js +17 -0
- package/dist/types/clients/block-service/blockService.d.ts +3 -2
- package/dist/types/providers/block-service/blockServiceAPI.d.ts +5 -2
- package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +9 -0
- package/dist/types/store-manager/sourceSyncBlockStoreManager.d.ts +1 -0
- 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 +3 -2
- package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +5 -2
- package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +9 -0
- package/dist/types-ts4.5/store-manager/sourceSyncBlockStoreManager.d.ts +1 -0
- 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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @atlaskit/editor-synced-block-provider
|
|
2
2
|
|
|
3
|
+
## 3.14.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`7702ea47c5329`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7702ea47c5329) -
|
|
8
|
+
[ux] Show editor flag when unpublished sync block is pasted
|
|
9
|
+
- [`2a9dfb4b326e6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2a9dfb4b326e6) -
|
|
10
|
+
EDITOR-4698 add missing analytics for fetch references, graphql subsciption update, reference sync
|
|
11
|
+
block insert and delete success
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
3
14
|
## 3.14.2
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -292,11 +292,11 @@ var updateSyncedBlock = exports.updateSyncedBlock = /*#__PURE__*/function () {
|
|
|
292
292
|
}();
|
|
293
293
|
var createSyncedBlock = exports.createSyncedBlock = /*#__PURE__*/function () {
|
|
294
294
|
var _ref1 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(_ref0) {
|
|
295
|
-
var blockAri, blockInstanceId, sourceAri, product, content, stepVersion, requestBody, response;
|
|
295
|
+
var blockAri, blockInstanceId, sourceAri, product, content, stepVersion, status, requestBody, response;
|
|
296
296
|
return _regenerator.default.wrap(function _callee6$(_context6) {
|
|
297
297
|
while (1) switch (_context6.prev = _context6.next) {
|
|
298
298
|
case 0:
|
|
299
|
-
blockAri = _ref0.blockAri, blockInstanceId = _ref0.blockInstanceId, sourceAri = _ref0.sourceAri, product = _ref0.product, content = _ref0.content, stepVersion = _ref0.stepVersion;
|
|
299
|
+
blockAri = _ref0.blockAri, blockInstanceId = _ref0.blockInstanceId, sourceAri = _ref0.sourceAri, product = _ref0.product, content = _ref0.content, stepVersion = _ref0.stepVersion, status = _ref0.status;
|
|
300
300
|
requestBody = {
|
|
301
301
|
blockAri: blockAri,
|
|
302
302
|
blockInstanceId: blockInstanceId,
|
|
@@ -307,25 +307,28 @@ var createSyncedBlock = exports.createSyncedBlock = /*#__PURE__*/function () {
|
|
|
307
307
|
if (stepVersion !== undefined) {
|
|
308
308
|
requestBody.stepVersion = stepVersion;
|
|
309
309
|
}
|
|
310
|
-
|
|
310
|
+
if (status !== undefined && (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
311
|
+
requestBody.status = status;
|
|
312
|
+
}
|
|
313
|
+
_context6.next = 6;
|
|
311
314
|
return (0, _retry.fetchWithRetry)("".concat(BLOCK_SERVICE_API_URL, "/block"), {
|
|
312
315
|
method: 'POST',
|
|
313
316
|
headers: COMMON_HEADERS,
|
|
314
317
|
body: JSON.stringify(requestBody)
|
|
315
318
|
});
|
|
316
|
-
case
|
|
319
|
+
case 6:
|
|
317
320
|
response = _context6.sent;
|
|
318
321
|
if (response.ok) {
|
|
319
|
-
_context6.next =
|
|
322
|
+
_context6.next = 9;
|
|
320
323
|
break;
|
|
321
324
|
}
|
|
322
325
|
throw new BlockError(response.status);
|
|
323
|
-
case
|
|
324
|
-
_context6.next =
|
|
326
|
+
case 9:
|
|
327
|
+
_context6.next = 11;
|
|
325
328
|
return response.json();
|
|
326
|
-
case 10:
|
|
327
|
-
return _context6.abrupt("return", _context6.sent);
|
|
328
329
|
case 11:
|
|
330
|
+
return _context6.abrupt("return", _context6.sent);
|
|
331
|
+
case 12:
|
|
329
332
|
case "end":
|
|
330
333
|
return _context6.stop();
|
|
331
334
|
}
|
|
@@ -12,6 +12,7 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
|
|
|
12
12
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
13
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
14
14
|
var _react = require("react");
|
|
15
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
16
|
var _ari = require("../../clients/block-service/ari");
|
|
16
17
|
var _blockService = require("../../clients/block-service/blockService");
|
|
17
18
|
var _blockSubscription = require("../../clients/block-service/blockSubscription");
|
|
@@ -615,13 +616,15 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
615
616
|
parentAri = _ref4.parentAri,
|
|
616
617
|
parentId = _ref4.parentId,
|
|
617
618
|
product = _ref4.product,
|
|
618
|
-
getVersion = _ref4.getVersion
|
|
619
|
+
getVersion = _ref4.getVersion,
|
|
620
|
+
isParentUnpublished = _ref4.isParentUnpublished;
|
|
619
621
|
(0, _classCallCheck2.default)(this, BlockServiceADFWriteProvider);
|
|
620
622
|
this.cloudId = cloudId;
|
|
621
623
|
this.parentAri = parentAri;
|
|
622
624
|
this.parentId = parentId;
|
|
623
625
|
this.product = product;
|
|
624
626
|
this.getVersion = getVersion;
|
|
627
|
+
this.isParentUnpublished = isParentUnpublished;
|
|
625
628
|
}
|
|
626
629
|
|
|
627
630
|
// it will first try to update and if it can't (404) then it will try to create
|
|
@@ -691,7 +694,8 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
691
694
|
key: "createData",
|
|
692
695
|
value: function () {
|
|
693
696
|
var _createData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(data) {
|
|
694
|
-
var
|
|
697
|
+
var _this$isParentUnpubli;
|
|
698
|
+
var resourceId, blockAri, stepVersion, status;
|
|
695
699
|
return _regenerator.default.wrap(function _callee6$(_context6) {
|
|
696
700
|
while (1) switch (_context6.prev = _context6.next) {
|
|
697
701
|
case 0:
|
|
@@ -711,41 +715,43 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
711
715
|
resourceId: resourceId
|
|
712
716
|
});
|
|
713
717
|
stepVersion = this.getVersion ? this.getVersion() : undefined;
|
|
714
|
-
|
|
715
|
-
_context6.
|
|
718
|
+
status = (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding') ? (_this$isParentUnpubli = this.isParentUnpublished) !== null && _this$isParentUnpubli !== void 0 && _this$isParentUnpubli.call(this) ? 'unpublished' : data.status || 'active' : undefined;
|
|
719
|
+
_context6.prev = 6;
|
|
720
|
+
_context6.next = 9;
|
|
716
721
|
return (0, _blockService.createSyncedBlock)({
|
|
717
722
|
blockAri: blockAri,
|
|
718
723
|
blockInstanceId: data.blockInstanceId,
|
|
719
724
|
sourceAri: this.parentAri,
|
|
720
725
|
product: this.product,
|
|
721
726
|
content: JSON.stringify(data.content),
|
|
722
|
-
stepVersion: stepVersion
|
|
727
|
+
stepVersion: stepVersion,
|
|
728
|
+
status: status
|
|
723
729
|
});
|
|
724
|
-
case
|
|
730
|
+
case 9:
|
|
725
731
|
return _context6.abrupt("return", {
|
|
726
732
|
resourceId: resourceId
|
|
727
733
|
});
|
|
728
|
-
case
|
|
729
|
-
_context6.prev =
|
|
730
|
-
_context6.t0 = _context6["catch"](
|
|
734
|
+
case 12:
|
|
735
|
+
_context6.prev = 12;
|
|
736
|
+
_context6.t0 = _context6["catch"](6);
|
|
731
737
|
if (!(_context6.t0 instanceof _blockService.BlockError)) {
|
|
732
|
-
_context6.next =
|
|
738
|
+
_context6.next = 16;
|
|
733
739
|
break;
|
|
734
740
|
}
|
|
735
741
|
return _context6.abrupt("return", {
|
|
736
742
|
error: mapBlockError(_context6.t0),
|
|
737
743
|
resourceId: resourceId
|
|
738
744
|
});
|
|
739
|
-
case
|
|
745
|
+
case 16:
|
|
740
746
|
return _context6.abrupt("return", {
|
|
741
747
|
error: (0, _errorHandling.stringifyError)(_context6.t0),
|
|
742
748
|
resourceId: resourceId
|
|
743
749
|
});
|
|
744
|
-
case
|
|
750
|
+
case 17:
|
|
745
751
|
case "end":
|
|
746
752
|
return _context6.stop();
|
|
747
753
|
}
|
|
748
|
-
}, _callee6, this, [[
|
|
754
|
+
}, _callee6, this, [[6, 12]]);
|
|
749
755
|
}));
|
|
750
756
|
function createData(_x6) {
|
|
751
757
|
return _createData.apply(this, arguments);
|
|
@@ -906,7 +912,8 @@ var createBlockServiceAPIProviders = function createBlockServiceAPIProviders(_re
|
|
|
906
912
|
parentAri = _ref5.parentAri,
|
|
907
913
|
parentId = _ref5.parentId,
|
|
908
914
|
product = _ref5.product,
|
|
909
|
-
getVersion = _ref5.getVersion
|
|
915
|
+
getVersion = _ref5.getVersion,
|
|
916
|
+
isParentUnpublished = _ref5.isParentUnpublished;
|
|
910
917
|
return {
|
|
911
918
|
fetchProvider: new BlockServiceADFFetchProvider({
|
|
912
919
|
cloudId: cloudId,
|
|
@@ -917,7 +924,8 @@ var createBlockServiceAPIProviders = function createBlockServiceAPIProviders(_re
|
|
|
917
924
|
parentAri: parentAri,
|
|
918
925
|
parentId: parentId,
|
|
919
926
|
product: product,
|
|
920
|
-
getVersion: getVersion
|
|
927
|
+
getVersion: getVersion,
|
|
928
|
+
isParentUnpublished: isParentUnpublished
|
|
921
929
|
})
|
|
922
930
|
};
|
|
923
931
|
};
|
|
@@ -926,16 +934,18 @@ var useMemoizedBlockServiceAPIProviders = exports.useMemoizedBlockServiceAPIProv
|
|
|
926
934
|
parentAri = _ref6.parentAri,
|
|
927
935
|
parentId = _ref6.parentId,
|
|
928
936
|
product = _ref6.product,
|
|
929
|
-
getVersion = _ref6.getVersion
|
|
937
|
+
getVersion = _ref6.getVersion,
|
|
938
|
+
isParentUnpublished = _ref6.isParentUnpublished;
|
|
930
939
|
return (0, _react.useMemo)(function () {
|
|
931
940
|
return createBlockServiceAPIProviders({
|
|
932
941
|
cloudId: cloudId,
|
|
933
942
|
parentAri: parentAri,
|
|
934
943
|
parentId: parentId,
|
|
935
944
|
product: product,
|
|
936
|
-
getVersion: getVersion
|
|
945
|
+
getVersion: getVersion,
|
|
946
|
+
isParentUnpublished: isParentUnpublished
|
|
937
947
|
});
|
|
938
|
-
}, [cloudId, parentAri, parentId, product, getVersion]);
|
|
948
|
+
}, [cloudId, parentAri, parentId, product, getVersion, isParentUnpublished]);
|
|
939
949
|
};
|
|
940
950
|
var createBlockServiceFetchOnlyAPIProvider = function createBlockServiceFetchOnlyAPIProvider(_ref7) {
|
|
941
951
|
var cloudId = _ref7.cloudId,
|
|
@@ -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
|
}
|
|
@@ -551,14 +577,26 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
551
577
|
hasUnexpectedError = false;
|
|
552
578
|
hasExpectedError = false;
|
|
553
579
|
data.forEach(function (syncBlockInstance) {
|
|
580
|
+
var _resolvedSyncBlockIns;
|
|
554
581
|
if (!syncBlockInstance.resourceId) {
|
|
555
|
-
var _this5$fireAnalyticsE, _syncBlockInstance$
|
|
556
|
-
(_this5$fireAnalyticsE = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE === void 0 || _this5$fireAnalyticsE.call(_this5, (0, _errorHandling.fetchErrorPayload)(((_syncBlockInstance$
|
|
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'));
|
|
557
584
|
return;
|
|
558
585
|
}
|
|
559
586
|
var existingSyncBlock = _this5.getFromCache(syncBlockInstance.resourceId);
|
|
560
587
|
var resolvedSyncBlockInstance = existingSyncBlock ? (0, _resolveSyncBlockInstance.resolveSyncBlockInstance)(existingSyncBlock, syncBlockInstance) : syncBlockInstance;
|
|
561
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
|
+
}
|
|
562
600
|
if (syncBlockInstance.error) {
|
|
563
601
|
var _this5$fireAnalyticsE2;
|
|
564
602
|
(_this5$fireAnalyticsE2 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE2 === void 0 || _this5$fireAnalyticsE2.call(_this5, (0, _errorHandling.fetchErrorPayload)(syncBlockInstance.error.type, syncBlockInstance.resourceId));
|
|
@@ -569,8 +607,8 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
569
607
|
}
|
|
570
608
|
return;
|
|
571
609
|
} else if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
572
|
-
var _this5$fireAnalyticsE3, _syncBlockInstance$
|
|
573
|
-
(_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));
|
|
574
612
|
}
|
|
575
613
|
_this5.fetchSyncBlockSourceInfo(resolvedSyncBlockInstance.resourceId);
|
|
576
614
|
});
|
|
@@ -781,11 +819,11 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
781
819
|
}
|
|
782
820
|
return this.subscribeToSyncBlock(resourceId, localId, callback);
|
|
783
821
|
} catch (error) {
|
|
784
|
-
var _this$
|
|
822
|
+
var _this$fireAnalyticsEv6;
|
|
785
823
|
(0, _monitoring.logException)(error, {
|
|
786
824
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
787
825
|
});
|
|
788
|
-
(_this$
|
|
826
|
+
(_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 || _this$fireAnalyticsEv6.call(this, (0, _errorHandling.fetchErrorPayload)(error.message));
|
|
789
827
|
return function () {};
|
|
790
828
|
}
|
|
791
829
|
}
|
|
@@ -809,12 +847,12 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
809
847
|
key: "getProviderFactory",
|
|
810
848
|
value: function getProviderFactory(resourceId) {
|
|
811
849
|
if (!this.dataProvider) {
|
|
812
|
-
var _this$
|
|
850
|
+
var _this$fireAnalyticsEv7;
|
|
813
851
|
var error = new Error('Data provider not set');
|
|
814
852
|
(0, _monitoring.logException)(error, {
|
|
815
853
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
816
854
|
});
|
|
817
|
-
(_this$
|
|
855
|
+
(_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 || _this$fireAnalyticsEv7.call(this, (0, _errorHandling.fetchErrorPayload)(error.message));
|
|
818
856
|
return undefined;
|
|
819
857
|
}
|
|
820
858
|
var _this$dataProvider$ge = this.dataProvider.getSyncedBlockRendererProviderOptions(),
|
|
@@ -843,11 +881,11 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
843
881
|
try {
|
|
844
882
|
this.retrieveDynamicProviders(resourceId, providerFactory, providerCreator);
|
|
845
883
|
} catch (error) {
|
|
846
|
-
var _this$
|
|
884
|
+
var _this$fireAnalyticsEv8;
|
|
847
885
|
(0, _monitoring.logException)(error, {
|
|
848
886
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
849
887
|
});
|
|
850
|
-
(_this$
|
|
888
|
+
(_this$fireAnalyticsEv8 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv8 === void 0 || _this$fireAnalyticsEv8.call(this, (0, _errorHandling.fetchErrorPayload)(error.message, resourceId));
|
|
851
889
|
}
|
|
852
890
|
}
|
|
853
891
|
return providerFactory;
|
|
@@ -907,8 +945,8 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
907
945
|
return;
|
|
908
946
|
}
|
|
909
947
|
if (!syncBlock.data.sourceAri || !syncBlock.data.product) {
|
|
910
|
-
var _this$
|
|
911
|
-
(_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'));
|
|
912
950
|
return;
|
|
913
951
|
}
|
|
914
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);
|
|
@@ -958,7 +996,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
958
996
|
key: "flush",
|
|
959
997
|
value: (function () {
|
|
960
998
|
var _flush = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
961
|
-
var success, blocks, _this$saveExperience, updateResult, _this$
|
|
999
|
+
var success, blocks, _this$saveExperience, updateResult, _this$fireAnalyticsEv0, _this$saveExperience2, _this$fireAnalyticsEv1, _this$saveExperience3, _this$saveExperience4;
|
|
962
1000
|
return _regenerator.default.wrap(function _callee3$(_context4) {
|
|
963
1001
|
while (1) switch (_context4.prev = _context4.next) {
|
|
964
1002
|
case 0:
|
|
@@ -1019,7 +1057,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1019
1057
|
reason: updateResult.error || 'Failed to update reference synced blocks on the document'
|
|
1020
1058
|
});
|
|
1021
1059
|
}
|
|
1022
|
-
(_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'));
|
|
1023
1061
|
}
|
|
1024
1062
|
_context4.next = 26;
|
|
1025
1063
|
break;
|
|
@@ -1035,7 +1073,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1035
1073
|
reason: _context4.t0.message
|
|
1036
1074
|
});
|
|
1037
1075
|
}
|
|
1038
|
-
(_this$
|
|
1076
|
+
(_this$fireAnalyticsEv1 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv1 === void 0 || _this$fireAnalyticsEv1.call(this, (0, _errorHandling.updateReferenceErrorPayload)(_context4.t0.message));
|
|
1039
1077
|
case 26:
|
|
1040
1078
|
_context4.prev = 26;
|
|
1041
1079
|
if (!success) {
|
|
@@ -1080,13 +1118,13 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1080
1118
|
});
|
|
1081
1119
|
this.providerFactories.clear();
|
|
1082
1120
|
(_this$saveExperience5 = this.saveExperience) === null || _this$saveExperience5 === void 0 || _this$saveExperience5.abort({
|
|
1083
|
-
reason: '
|
|
1121
|
+
reason: 'editorDestroyed'
|
|
1084
1122
|
});
|
|
1085
1123
|
(_this$fetchExperience5 = this.fetchExperience) === null || _this$fetchExperience5 === void 0 || _this$fetchExperience5.abort({
|
|
1086
|
-
reason: '
|
|
1124
|
+
reason: 'editorDestroyed'
|
|
1087
1125
|
});
|
|
1088
1126
|
(_this$fetchSourceInfo2 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo2 === void 0 || _this$fetchSourceInfo2.abort({
|
|
1089
|
-
reason: '
|
|
1127
|
+
reason: 'editorDestroyed'
|
|
1090
1128
|
});
|
|
1091
1129
|
this.fireAnalyticsEvent = undefined;
|
|
1092
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",
|
|
@@ -541,11 +542,29 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
541
542
|
}, {
|
|
542
543
|
key: "getSyncBlockSourceInfo",
|
|
543
544
|
value: function getSyncBlockSourceInfo(localId) {
|
|
545
|
+
var _this6 = this;
|
|
544
546
|
try {
|
|
545
547
|
if (!this.dataProvider) {
|
|
546
548
|
throw new Error('Data provider not set');
|
|
547
549
|
}
|
|
548
|
-
|
|
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
|
+
});
|
|
549
568
|
} catch (error) {
|
|
550
569
|
var _this$fireAnalyticsEv6;
|
|
551
570
|
(0, _monitoring.logException)(error, {
|
|
@@ -577,20 +596,23 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
577
596
|
}, {
|
|
578
597
|
key: "destroy",
|
|
579
598
|
value: function destroy() {
|
|
580
|
-
var _this$saveExperience4, _this$createExperienc2, _this$deleteExperienc4;
|
|
599
|
+
var _this$saveExperience4, _this$createExperienc2, _this$deleteExperienc4, _this$fetchSourceInfo2;
|
|
581
600
|
this.syncBlockCache.clear();
|
|
582
601
|
this.confirmationCallback = undefined;
|
|
583
602
|
this.pendingResourceId = undefined;
|
|
584
603
|
this.creationCallback = undefined;
|
|
585
604
|
this.dataProvider = undefined;
|
|
586
605
|
(_this$saveExperience4 = this.saveExperience) === null || _this$saveExperience4 === void 0 || _this$saveExperience4.abort({
|
|
587
|
-
reason: '
|
|
606
|
+
reason: 'editorDestroyed'
|
|
588
607
|
});
|
|
589
608
|
(_this$createExperienc2 = this.createExperience) === null || _this$createExperienc2 === void 0 || _this$createExperienc2.abort({
|
|
590
|
-
reason: '
|
|
609
|
+
reason: 'editorDestroyed'
|
|
591
610
|
});
|
|
592
611
|
(_this$deleteExperienc4 = this.deleteExperience) === null || _this$deleteExperienc4 === void 0 || _this$deleteExperienc4.abort({
|
|
593
|
-
reason: '
|
|
612
|
+
reason: 'editorDestroyed'
|
|
613
|
+
});
|
|
614
|
+
(_this$fetchSourceInfo2 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo2 === void 0 || _this$fetchSourceInfo2.abort({
|
|
615
|
+
reason: 'editorDestroyed'
|
|
594
616
|
});
|
|
595
617
|
this.clearPendingDeletion();
|
|
596
618
|
}
|