@atlaskit/editor-synced-block-provider 6.6.0 → 6.6.2
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 +14 -0
- package/dist/cjs/clients/block-service/blockService.js +5 -10
- package/dist/cjs/clients/block-service/blockSubscription.js +3 -9
- package/dist/cjs/providers/block-service/blockServiceAPI.js +5 -7
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +1 -1
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +38 -63
- package/dist/cjs/store-manager/syncBlockStoreManager.js +20 -39
- package/dist/es2019/clients/block-service/blockService.js +9 -12
- package/dist/es2019/clients/block-service/blockSubscription.js +3 -9
- package/dist/es2019/providers/block-service/blockServiceAPI.js +3 -6
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +1 -1
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +39 -67
- package/dist/es2019/store-manager/syncBlockStoreManager.js +13 -32
- package/dist/esm/clients/block-service/blockService.js +5 -10
- package/dist/esm/clients/block-service/blockSubscription.js +3 -9
- package/dist/esm/providers/block-service/blockServiceAPI.js +5 -7
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +1 -1
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +38 -63
- package/dist/esm/store-manager/syncBlockStoreManager.js +20 -39
- package/package.json +4 -19
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-synced-block-provider
|
|
2
2
|
|
|
3
|
+
## 6.6.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 6.6.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`4c459a2718b67`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4c459a2718b67) -
|
|
14
|
+
Clean up synced block feature gates
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 6.6.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
|
@@ -13,7 +13,6 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
|
|
|
13
13
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
14
14
|
var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));
|
|
15
15
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
16
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
17
16
|
var _retry = require("../../utils/retry");
|
|
18
17
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
19
18
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
@@ -421,10 +420,6 @@ var deleteSyncedBlock = exports.deleteSyncedBlock = /*#__PURE__*/function () {
|
|
|
421
420
|
case 10:
|
|
422
421
|
result = _context4.sent;
|
|
423
422
|
if (!(result.errors && result.errors.length > 0)) {
|
|
424
|
-
_context4.next = 17;
|
|
425
|
-
break;
|
|
426
|
-
}
|
|
427
|
-
if (!(0, _platformFeatureFlags.fg)('platform_synced_block_patch_8')) {
|
|
428
423
|
_context4.next = 16;
|
|
429
424
|
break;
|
|
430
425
|
}
|
|
@@ -433,22 +428,22 @@ var deleteSyncedBlock = exports.deleteSyncedBlock = /*#__PURE__*/function () {
|
|
|
433
428
|
return ((_e$extensions = e.extensions) === null || _e$extensions === void 0 ? void 0 : _e$extensions.errorType) === 'RESOURCE_NOT_FOUND';
|
|
434
429
|
});
|
|
435
430
|
if (!allNotFound) {
|
|
436
|
-
_context4.next =
|
|
431
|
+
_context4.next = 15;
|
|
437
432
|
break;
|
|
438
433
|
}
|
|
439
434
|
throw new BlockNotFoundError();
|
|
440
|
-
case
|
|
435
|
+
case 15:
|
|
441
436
|
throw new Error(result.errors.map(function (e) {
|
|
442
437
|
return e.message;
|
|
443
438
|
}).join(', '));
|
|
444
|
-
case
|
|
439
|
+
case 16:
|
|
445
440
|
isDeleted = (_result$data3 = result.data) === null || _result$data3 === void 0 || (_result$data3 = _result$data3.blockService_deleteBlock) === null || _result$data3 === void 0 ? void 0 : _result$data3.deleted;
|
|
446
441
|
if (isDeleted) {
|
|
447
|
-
_context4.next =
|
|
442
|
+
_context4.next = 19;
|
|
448
443
|
break;
|
|
449
444
|
}
|
|
450
445
|
throw new Error('Block deletion failed; deleted flag is false');
|
|
451
|
-
case
|
|
446
|
+
case 19:
|
|
452
447
|
case "end":
|
|
453
448
|
return _context4.stop();
|
|
454
449
|
}
|
|
@@ -8,7 +8,6 @@ exports.subscribeToBlockUpdates = exports.getConnectionDiagnosticsSummary = expo
|
|
|
8
8
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
9
|
var _graphqlWs = require("graphql-ws");
|
|
10
10
|
var _coreUtils = require("@atlaskit/editor-common/core-utils");
|
|
11
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
11
|
var _utils = require("../../utils/utils");
|
|
13
12
|
var GRAPHQL_WS_ENDPOINT = '/gateway/api/graphql/subscriptions';
|
|
14
13
|
var blockServiceClient = null;
|
|
@@ -67,7 +66,7 @@ var getBlockServiceClient = function getBlockServiceClient() {
|
|
|
67
66
|
url: wsUrl,
|
|
68
67
|
lazy: true,
|
|
69
68
|
retryAttempts: 3,
|
|
70
|
-
on:
|
|
69
|
+
on: {
|
|
71
70
|
connecting: function connecting(isRetry) {
|
|
72
71
|
connectionDiagnostics.wasRetry = isRetry;
|
|
73
72
|
connectionDiagnostics.state = 'connecting';
|
|
@@ -90,7 +89,7 @@ var getBlockServiceClient = function getBlockServiceClient() {
|
|
|
90
89
|
connectionDiagnostics.state = 'error';
|
|
91
90
|
connectionDiagnostics.consecutiveFailures += 1;
|
|
92
91
|
}
|
|
93
|
-
}
|
|
92
|
+
}
|
|
94
93
|
});
|
|
95
94
|
}
|
|
96
95
|
return blockServiceClient;
|
|
@@ -208,12 +207,7 @@ var subscribeToBlockUpdates = exports.subscribeToBlockUpdates = function subscri
|
|
|
208
207
|
};
|
|
209
208
|
return error;
|
|
210
209
|
}(function (error) {
|
|
211
|
-
|
|
212
|
-
onError === null || onError === void 0 || onError(new Error(extractGraphQLWSErrorMessage(error)));
|
|
213
|
-
} else {
|
|
214
|
-
var errorMessage = error instanceof Error ? error.message : 'GraphQL subscription error';
|
|
215
|
-
onError === null || onError === void 0 || onError(new Error(errorMessage));
|
|
216
|
-
}
|
|
210
|
+
onError === null || onError === void 0 || onError(new Error(extractGraphQLWSErrorMessage(error)));
|
|
217
211
|
}),
|
|
218
212
|
complete: function complete() {
|
|
219
213
|
// Subscription completed
|
|
@@ -13,7 +13,6 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
|
|
|
13
13
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
14
14
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
15
15
|
var _react = require("react");
|
|
16
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
17
16
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
18
17
|
var _ari = require("../../clients/block-service/ari");
|
|
19
18
|
var _blockService = require("../../clients/block-service/blockService");
|
|
@@ -55,7 +54,7 @@ var mapErrorResponseCode = function mapErrorResponseCode(errorCode) {
|
|
|
55
54
|
case 'NOT_FOUND':
|
|
56
55
|
return _types.SyncBlockError.NotFound;
|
|
57
56
|
case 'EntityNotFound':
|
|
58
|
-
return
|
|
57
|
+
return _types.SyncBlockError.EntityNotFound;
|
|
59
58
|
case 'INVALID_REQUEST':
|
|
60
59
|
return _types.SyncBlockError.InvalidRequest;
|
|
61
60
|
case 'CONFLICT':
|
|
@@ -1060,7 +1059,7 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
1060
1059
|
case 9:
|
|
1061
1060
|
_context0.prev = 9;
|
|
1062
1061
|
_context0.t0 = _context0["catch"](3);
|
|
1063
|
-
if (!(_context0.t0 instanceof _blockService.BlockNotFoundError && this.parentAri
|
|
1062
|
+
if (!(_context0.t0 instanceof _blockService.BlockNotFoundError && this.parentAri)) {
|
|
1064
1063
|
_context0.next = 13;
|
|
1065
1064
|
break;
|
|
1066
1065
|
}
|
|
@@ -1358,11 +1357,10 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
1358
1357
|
block = _step6.value;
|
|
1359
1358
|
successBlock = successBlocks.get(block.resourceId);
|
|
1360
1359
|
if (successBlock) {
|
|
1361
|
-
results.push(
|
|
1362
|
-
resourceId: block.resourceId
|
|
1363
|
-
}, (0, _platformFeatureFlags.fg)('platform_synced_block_patch_10') && {
|
|
1360
|
+
results.push({
|
|
1361
|
+
resourceId: block.resourceId,
|
|
1364
1362
|
status: successBlock.status
|
|
1365
|
-
})
|
|
1363
|
+
});
|
|
1366
1364
|
}
|
|
1367
1365
|
}
|
|
1368
1366
|
} catch (err) {
|
|
@@ -720,7 +720,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
720
720
|
return _regenerator.default.wrap(function _callee3$(_context4) {
|
|
721
721
|
while (1) switch (_context4.prev = _context4.next) {
|
|
722
722
|
case 0:
|
|
723
|
-
if (!(this.viewMode === 'view'
|
|
723
|
+
if (!(this.viewMode === 'view')) {
|
|
724
724
|
_context4.next = 2;
|
|
725
725
|
break;
|
|
726
726
|
}
|
|
@@ -11,10 +11,7 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
|
11
11
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
12
12
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
13
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
|
-
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
15
14
|
var _monitoring = require("@atlaskit/editor-common/monitoring");
|
|
16
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
17
|
-
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
18
15
|
var _types = require("../common/types");
|
|
19
16
|
var _errorHandling = require("../utils/errorHandling");
|
|
20
17
|
var _experienceTracking = require("../utils/experienceTracking");
|
|
@@ -35,7 +32,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
35
32
|
(0, _classCallCheck2.default)(this, SourceSyncBlockStoreManager);
|
|
36
33
|
(0, _defineProperty2.default)(this, "hasReceivedContentChange", false);
|
|
37
34
|
(0, _defineProperty2.default)(this, "setPendingDeletion", function (Ids, value) {
|
|
38
|
-
if (_this.viewMode === 'view'
|
|
35
|
+
if (_this.viewMode === 'view') {
|
|
39
36
|
return;
|
|
40
37
|
}
|
|
41
38
|
var syncBlock = _this.syncBlockCache.get(Ids.resourceId);
|
|
@@ -83,7 +80,8 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
83
80
|
key: "updateSyncBlockData",
|
|
84
81
|
value: function updateSyncBlockData(syncBlockNode, isRemote) {
|
|
85
82
|
try {
|
|
86
|
-
|
|
83
|
+
var _cachedBlock$contentF;
|
|
84
|
+
if (this.viewMode === 'view') {
|
|
87
85
|
return false;
|
|
88
86
|
}
|
|
89
87
|
if (!this.isSourceBlock(syncBlockNode)) {
|
|
@@ -96,36 +94,23 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
96
94
|
throw new Error('Local ID or resource ID is not set');
|
|
97
95
|
}
|
|
98
96
|
var cachedBlock = this.syncBlockCache.get(resourceId);
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
this.hasReceivedContentChange = true;
|
|
109
|
-
}
|
|
110
|
-
var isDirty = !isRemote || !cachedBlock; // if the change is not remote, or the block is not in the cache yet, it's dirty
|
|
111
|
-
this.syncBlockCache.set(resourceId, _objectSpread(_objectSpread({}, syncBlockData), {}, {
|
|
112
|
-
isDirty: isDirty,
|
|
113
|
-
// if the change is from remote, it's not dirty
|
|
114
|
-
contentFragment: syncBlockNode.content
|
|
115
|
-
}, (0, _platformFeatureFlags.fg)('platform_synced_block_patch_10') && {
|
|
116
|
-
status: cachedBlock === null || cachedBlock === void 0 ? void 0 : cachedBlock.status
|
|
117
|
-
}));
|
|
118
|
-
} else {
|
|
119
|
-
var _syncBlockData = (0, _utils.convertSyncBlockPMNodeToSyncBlockData)(syncBlockNode);
|
|
120
|
-
if (cachedBlock && !(0, _isEqual.default)(_syncBlockData.content, cachedBlock.content)) {
|
|
121
|
-
this.hasReceivedContentChange = true;
|
|
122
|
-
}
|
|
123
|
-
this.syncBlockCache.set(resourceId, _objectSpread(_objectSpread({}, _syncBlockData), {}, {
|
|
124
|
-
isDirty: true
|
|
125
|
-
}, (0, _platformFeatureFlags.fg)('platform_synced_block_patch_10') && {
|
|
126
|
-
status: cachedBlock === null || cachedBlock === void 0 ? void 0 : cachedBlock.status
|
|
127
|
-
}));
|
|
97
|
+
|
|
98
|
+
// Fast path: if the PM content fragment hasn't changed, skip serialization entirely
|
|
99
|
+
// Fragment.eq() leverages ProseMirror's structural sharing for O(1) comparison
|
|
100
|
+
if (cachedBlock !== null && cachedBlock !== void 0 && (_cachedBlock$contentF = cachedBlock.contentFragment) !== null && _cachedBlock$contentF !== void 0 && _cachedBlock$contentF.eq(syncBlockNode.content)) {
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
var syncBlockData = (0, _utils.convertSyncBlockPMNodeToSyncBlockData)(syncBlockNode);
|
|
104
|
+
if (cachedBlock && !isRemote) {
|
|
105
|
+
this.hasReceivedContentChange = true;
|
|
128
106
|
}
|
|
107
|
+
var isDirty = !isRemote || !cachedBlock; // if the change is not remote, or the block is not in the cache yet, it's dirty
|
|
108
|
+
this.syncBlockCache.set(resourceId, _objectSpread(_objectSpread({}, syncBlockData), {}, {
|
|
109
|
+
isDirty: isDirty,
|
|
110
|
+
// if the change is from remote, it's not dirty
|
|
111
|
+
contentFragment: syncBlockNode.content,
|
|
112
|
+
status: cachedBlock === null || cachedBlock === void 0 ? void 0 : cachedBlock.status
|
|
113
|
+
}));
|
|
129
114
|
return true;
|
|
130
115
|
} catch (error) {
|
|
131
116
|
var _this$fireAnalyticsEv, _syncBlockNode$attrs2, _syncBlockNode$attrs3;
|
|
@@ -154,7 +139,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
154
139
|
while (1) switch (_context.prev = _context.next) {
|
|
155
140
|
case 0:
|
|
156
141
|
_context.prev = 0;
|
|
157
|
-
if (!(this.viewMode === 'view'
|
|
142
|
+
if (!(this.viewMode === 'view')) {
|
|
158
143
|
_context.next = 3;
|
|
159
144
|
break;
|
|
160
145
|
}
|
|
@@ -225,11 +210,9 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
225
210
|
if (result.resourceId && !result.error) {
|
|
226
211
|
var _this2$fireAnalyticsE;
|
|
227
212
|
// Update cache with the status returned from the backend
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
cachedData.status = result.status;
|
|
232
|
-
}
|
|
213
|
+
var cachedData = _this2.syncBlockCache.get(result.resourceId);
|
|
214
|
+
if (cachedData && result.status) {
|
|
215
|
+
cachedData.status = result.status;
|
|
233
216
|
}
|
|
234
217
|
(_this2$fireAnalyticsE = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE === void 0 || _this2$fireAnalyticsE.call(_this2, (0, _errorHandling.updateSuccessPayload)(result.resourceId, false, (0, _utils.productAttrIfGateOn)(result.resourceId)));
|
|
235
218
|
}
|
|
@@ -274,7 +257,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
274
257
|
}, {
|
|
275
258
|
key: "hasUnsavedChanges",
|
|
276
259
|
value: function hasUnsavedChanges() {
|
|
277
|
-
if (this.viewMode === 'view'
|
|
260
|
+
if (this.viewMode === 'view') {
|
|
278
261
|
return false;
|
|
279
262
|
}
|
|
280
263
|
|
|
@@ -313,16 +296,14 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
313
296
|
}, {
|
|
314
297
|
key: "commitPendingCreation",
|
|
315
298
|
value: function commitPendingCreation(success, resourceId) {
|
|
316
|
-
if (this.viewMode === 'view'
|
|
299
|
+
if (this.viewMode === 'view') {
|
|
317
300
|
return;
|
|
318
301
|
}
|
|
319
302
|
var onCompletion = this.creationCompletionCallbacks.get(resourceId);
|
|
320
303
|
if (onCompletion) {
|
|
321
304
|
this.creationCompletionCallbacks.delete(resourceId);
|
|
322
305
|
onCompletion(success);
|
|
323
|
-
if (success
|
|
324
|
-
exposure: true
|
|
325
|
-
})) {
|
|
306
|
+
if (success) {
|
|
326
307
|
// If creation is successful, set hasReceivedContentChange to true
|
|
327
308
|
// to indicate that there are unsaved changes in the cache
|
|
328
309
|
this.hasReceivedContentChange = true;
|
|
@@ -384,7 +365,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
384
365
|
key: "createBodiedSyncBlockNode",
|
|
385
366
|
value: function createBodiedSyncBlockNode(attrs, node, onCompletion) {
|
|
386
367
|
var _this4 = this;
|
|
387
|
-
if (this.viewMode === 'view'
|
|
368
|
+
if (this.viewMode === 'view') {
|
|
388
369
|
return;
|
|
389
370
|
}
|
|
390
371
|
var resourceId = attrs.resourceId,
|
|
@@ -394,17 +375,14 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
394
375
|
if (!this.dataProvider) {
|
|
395
376
|
throw new Error('Data provider not set');
|
|
396
377
|
}
|
|
397
|
-
if ((0, _platformFeatureFlags.fg)('platform_synced_block_update_refactor')) {
|
|
398
|
-
// add the node to the cache
|
|
399
|
-
this.updateSyncBlockData(node, false);
|
|
400
378
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
379
|
+
// add the node to the cache
|
|
380
|
+
this.updateSyncBlockData(node, false);
|
|
381
|
+
|
|
382
|
+
// Mark the block as unpublished in the cache so it can be cleaned up on cancel
|
|
383
|
+
var cached = this.syncBlockCache.get(resourceId);
|
|
384
|
+
if (cached) {
|
|
385
|
+
cached.status = 'unpublished';
|
|
408
386
|
}
|
|
409
387
|
this.creationCompletionCallbacks.set(resourceId, onCompletion);
|
|
410
388
|
(_this$createExperienc = this.createExperience) === null || _this$createExperienc === void 0 || _this$createExperienc.start({});
|
|
@@ -458,7 +436,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
458
436
|
while (1) switch (_context2.prev = _context2.next) {
|
|
459
437
|
case 0:
|
|
460
438
|
_context2.prev = 0;
|
|
461
|
-
if (!(this.viewMode === 'view'
|
|
439
|
+
if (!(this.viewMode === 'view')) {
|
|
462
440
|
_context2.next = 3;
|
|
463
441
|
break;
|
|
464
442
|
}
|
|
@@ -549,7 +527,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
549
527
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
550
528
|
while (1) switch (_context3.prev = _context3.next) {
|
|
551
529
|
case 0:
|
|
552
|
-
if (!(this.viewMode === 'view'
|
|
530
|
+
if (!(this.viewMode === 'view')) {
|
|
553
531
|
_context3.next = 2;
|
|
554
532
|
break;
|
|
555
533
|
}
|
|
@@ -601,7 +579,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
601
579
|
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
602
580
|
while (1) switch (_context4.prev = _context4.next) {
|
|
603
581
|
case 0:
|
|
604
|
-
if (!(!
|
|
582
|
+
if (!(!this.dataProvider || this.syncBlockCache.size === 0)) {
|
|
605
583
|
_context4.next = 2;
|
|
606
584
|
break;
|
|
607
585
|
}
|
|
@@ -676,9 +654,6 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
676
654
|
}, {
|
|
677
655
|
key: "discardUnpublishedBlocks",
|
|
678
656
|
value: function discardUnpublishedBlocks() {
|
|
679
|
-
if (!(0, _platformFeatureFlags.fg)('platform_synced_block_patch_10')) {
|
|
680
|
-
return Promise.resolve(true);
|
|
681
|
-
}
|
|
682
657
|
var unpublishedBlockIds = Array.from(this.syncBlockCache.entries()).filter(function (_ref3) {
|
|
683
658
|
var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
|
|
684
659
|
_ = _ref4[0],
|
|
@@ -719,7 +694,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
719
694
|
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
720
695
|
while (1) switch (_context5.prev = _context5.next) {
|
|
721
696
|
case 0:
|
|
722
|
-
if (!(this.viewMode === 'view'
|
|
697
|
+
if (!(this.viewMode === 'view')) {
|
|
723
698
|
_context5.next = 2;
|
|
724
699
|
break;
|
|
725
700
|
}
|
|
@@ -12,7 +12,6 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
|
|
|
12
12
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
13
|
var _react = require("react");
|
|
14
14
|
var _monitoring = require("@atlaskit/editor-common/monitoring");
|
|
15
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
15
|
var _ari = require("../clients/block-service/ari");
|
|
17
16
|
var _types = require("../common/types");
|
|
18
17
|
var _errorHandling = require("../utils/errorHandling");
|
|
@@ -47,7 +46,7 @@ var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/functio
|
|
|
47
46
|
value: function () {
|
|
48
47
|
var _fetchReferencesSourceInfo = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(resourceId, blockInstanceId, isSourceSyncBlock) {
|
|
49
48
|
var _this = this;
|
|
50
|
-
var _this$fetchReferences, _response$references, _this$
|
|
49
|
+
var _this$fetchReferences, _response$references, _this$fetchReferences3, _response$references2, response, _this$fetchReferences2, sourceInfoPromises, sourceInfos, sourceSyncBlockData, _this$fireAnalyticsEv;
|
|
51
50
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
52
51
|
while (1) switch (_context2.prev = _context2.next) {
|
|
53
52
|
case 0:
|
|
@@ -75,30 +74,12 @@ var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/functio
|
|
|
75
74
|
});
|
|
76
75
|
case 10:
|
|
77
76
|
if (!(!response.references || ((_response$references = response.references) === null || _response$references === void 0 ? void 0 : _response$references.length) === 0)) {
|
|
78
|
-
_context2.next =
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
if (!(0, _platformFeatureFlags.fg)('platform_synced_block_patch_8')) {
|
|
82
|
-
_context2.next = 15;
|
|
77
|
+
_context2.next = 12;
|
|
83
78
|
break;
|
|
84
79
|
}
|
|
85
80
|
return _context2.abrupt("return", this.getUnregisteredReferences(resourceId, blockInstanceId, isSourceSyncBlock));
|
|
86
|
-
case
|
|
87
|
-
|
|
88
|
-
if (isSourceSyncBlock) {
|
|
89
|
-
(_this$fetchReferences3 = this.fetchReferencesExperience) === null || _this$fetchReferences3 === void 0 || _this$fetchReferences3.success();
|
|
90
|
-
} else {
|
|
91
|
-
(_this$fetchReferences4 = this.fetchReferencesExperience) === null || _this$fetchReferences4 === void 0 || _this$fetchReferences4.failure({
|
|
92
|
-
reason: 'No references found for reference synced block'
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
return _context2.abrupt("return", isSourceSyncBlock ? {
|
|
96
|
-
references: []
|
|
97
|
-
} : {
|
|
98
|
-
error: _types.SyncBlockError.Errored
|
|
99
|
-
});
|
|
100
|
-
case 17:
|
|
101
|
-
(_this$fetchReferences5 = this.fetchReferencesExperience) === null || _this$fetchReferences5 === void 0 || _this$fetchReferences5.success();
|
|
81
|
+
case 12:
|
|
82
|
+
(_this$fetchReferences3 = this.fetchReferencesExperience) === null || _this$fetchReferences3 === void 0 || _this$fetchReferences3.success();
|
|
102
83
|
sourceInfoPromises = ((_response$references2 = response.references) !== null && _response$references2 !== void 0 ? _response$references2 : []).map( /*#__PURE__*/function () {
|
|
103
84
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(reference) {
|
|
104
85
|
var _this$fetchSourceInfo, _this$dataProvider, _this$fetchSourceInfo3;
|
|
@@ -136,13 +117,13 @@ var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/functio
|
|
|
136
117
|
return _ref.apply(this, arguments);
|
|
137
118
|
};
|
|
138
119
|
}());
|
|
139
|
-
_context2.next =
|
|
120
|
+
_context2.next = 16;
|
|
140
121
|
return Promise.all(sourceInfoPromises);
|
|
141
|
-
case
|
|
122
|
+
case 16:
|
|
142
123
|
sourceInfos = _context2.sent;
|
|
143
|
-
_context2.next =
|
|
124
|
+
_context2.next = 19;
|
|
144
125
|
return isSourceSyncBlock ? this.sourceSyncBlockStoreManager.getSyncBlockSourceInfo(blockInstanceId) : this.referenceSyncBlockStoreManager.fetchSyncBlockSourceInfo(resourceId);
|
|
145
|
-
case
|
|
126
|
+
case 19:
|
|
146
127
|
sourceSyncBlockData = _context2.sent;
|
|
147
128
|
if (sourceSyncBlockData) {
|
|
148
129
|
sourceInfos.push(_objectSpread(_objectSpread({}, sourceSyncBlockData), {}, {
|
|
@@ -155,8 +136,8 @@ var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/functio
|
|
|
155
136
|
return _context2.abrupt("return", {
|
|
156
137
|
references: sourceInfos
|
|
157
138
|
});
|
|
158
|
-
case
|
|
159
|
-
_context2.prev =
|
|
139
|
+
case 24:
|
|
140
|
+
_context2.prev = 24;
|
|
160
141
|
_context2.t0 = _context2["catch"](0);
|
|
161
142
|
(0, _monitoring.logException)(_context2.t0, {
|
|
162
143
|
location: 'editor-synced-block-provider/syncBlockStoreManager'
|
|
@@ -165,11 +146,11 @@ var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/functio
|
|
|
165
146
|
return _context2.abrupt("return", {
|
|
166
147
|
error: _types.SyncBlockError.Errored
|
|
167
148
|
});
|
|
168
|
-
case
|
|
149
|
+
case 29:
|
|
169
150
|
case "end":
|
|
170
151
|
return _context2.stop();
|
|
171
152
|
}
|
|
172
|
-
}, _callee2, this, [[0,
|
|
153
|
+
}, _callee2, this, [[0, 24]]);
|
|
173
154
|
}));
|
|
174
155
|
function fetchReferencesSourceInfo(_x, _x2, _x3) {
|
|
175
156
|
return _fetchReferencesSourceInfo.apply(this, arguments);
|
|
@@ -198,10 +179,10 @@ var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/functio
|
|
|
198
179
|
}, {
|
|
199
180
|
key: "destroy",
|
|
200
181
|
value: function destroy() {
|
|
201
|
-
var _this$
|
|
182
|
+
var _this$fetchReferences4, _this$fetchSourceInfo4;
|
|
202
183
|
this.referenceSyncBlockStoreManager.destroy();
|
|
203
184
|
this.sourceSyncBlockStoreManager.destroy();
|
|
204
|
-
(_this$
|
|
185
|
+
(_this$fetchReferences4 = this.fetchReferencesExperience) === null || _this$fetchReferences4 === void 0 || _this$fetchReferences4.abort({
|
|
205
186
|
reason: 'editorDestroyed'
|
|
206
187
|
});
|
|
207
188
|
(_this$fetchSourceInfo4 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo4 === void 0 || _this$fetchSourceInfo4.abort({
|
|
@@ -212,8 +193,8 @@ var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/functio
|
|
|
212
193
|
key: "getUnregisteredReferences",
|
|
213
194
|
value: function () {
|
|
214
195
|
var _getUnregisteredReferences = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(resourceId, blockInstanceId, isSourceSyncBlock) {
|
|
215
|
-
var _this$
|
|
216
|
-
var _this$
|
|
196
|
+
var _this$fetchReferences8;
|
|
197
|
+
var _this$fetchReferences6, referenceResourceId, hasUnregisteredReferenceOnPage, _this$fetchReferences5, _sourceSyncBlockData, _references, sourceSyncBlockReference, referenceSyncBlockReference, references, sourceSyncBlockData, currentPageData, _this$fetchReferences7;
|
|
217
198
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
218
199
|
while (1) switch (_context3.prev = _context3.next) {
|
|
219
200
|
case 0:
|
|
@@ -248,13 +229,13 @@ var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/functio
|
|
|
248
229
|
});
|
|
249
230
|
_references.push(sourceSyncBlockReference, referenceSyncBlockReference);
|
|
250
231
|
}
|
|
251
|
-
(_this$
|
|
232
|
+
(_this$fetchReferences5 = this.fetchReferencesExperience) === null || _this$fetchReferences5 === void 0 || _this$fetchReferences5.success();
|
|
252
233
|
return _context3.abrupt("return", {
|
|
253
234
|
references: _references
|
|
254
235
|
});
|
|
255
236
|
case 11:
|
|
256
237
|
// No remote or local reference exists — show info text with link to doco on how to use Synced Blocks
|
|
257
|
-
(_this$
|
|
238
|
+
(_this$fetchReferences6 = this.fetchReferencesExperience) === null || _this$fetchReferences6 === void 0 || _this$fetchReferences6.success();
|
|
258
239
|
return _context3.abrupt("return", {
|
|
259
240
|
references: []
|
|
260
241
|
});
|
|
@@ -289,14 +270,14 @@ var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/functio
|
|
|
289
270
|
_context3.next = 25;
|
|
290
271
|
break;
|
|
291
272
|
}
|
|
292
|
-
(_this$
|
|
273
|
+
(_this$fetchReferences7 = this.fetchReferencesExperience) === null || _this$fetchReferences7 === void 0 || _this$fetchReferences7.failure({
|
|
293
274
|
reason: 'No references found for reference synced block'
|
|
294
275
|
});
|
|
295
276
|
return _context3.abrupt("return", {
|
|
296
277
|
error: _types.SyncBlockError.Errored
|
|
297
278
|
});
|
|
298
279
|
case 25:
|
|
299
|
-
(_this$
|
|
280
|
+
(_this$fetchReferences8 = this.fetchReferencesExperience) === null || _this$fetchReferences8 === void 0 || _this$fetchReferences8.success();
|
|
300
281
|
return _context3.abrupt("return", {
|
|
301
282
|
references: references
|
|
302
283
|
});
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
1
|
import { fetchWithRetry } from '../../utils/retry';
|
|
3
2
|
export const isBlockContentResponse = response => {
|
|
4
3
|
const content = response.content;
|
|
@@ -410,17 +409,15 @@ export const deleteSyncedBlock = async ({
|
|
|
410
409
|
}
|
|
411
410
|
const result = await response.json();
|
|
412
411
|
if (result.errors && result.errors.length > 0) {
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
throw new BlockNotFoundError();
|
|
423
|
-
}
|
|
412
|
+
const allNotFound = result.errors.every(e => {
|
|
413
|
+
var _e$extensions;
|
|
414
|
+
return ((_e$extensions = e.extensions) === null || _e$extensions === void 0 ? void 0 : _e$extensions.errorType) === 'RESOURCE_NOT_FOUND';
|
|
415
|
+
});
|
|
416
|
+
if (allNotFound) {
|
|
417
|
+
// Throw BlockNotFoundError so the caller can create the block first then retry the delete.
|
|
418
|
+
// Block Service uses soft-deletes: the entry must exist before deletion so a deletion-reason
|
|
419
|
+
// is stored (used to display errors in reference blocks).
|
|
420
|
+
throw new BlockNotFoundError();
|
|
424
421
|
}
|
|
425
422
|
throw new Error(result.errors.map(e => e.message).join(', '));
|
|
426
423
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createClient } from 'graphql-ws';
|
|
2
2
|
import { isSSR } from '@atlaskit/editor-common/core-utils';
|
|
3
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
3
|
import { convertContentUpdatedAt } from '../../utils/utils';
|
|
5
4
|
const GRAPHQL_WS_ENDPOINT = '/gateway/api/graphql/subscriptions';
|
|
6
5
|
let blockServiceClient = null;
|
|
@@ -59,7 +58,7 @@ const getBlockServiceClient = () => {
|
|
|
59
58
|
url: wsUrl,
|
|
60
59
|
lazy: true,
|
|
61
60
|
retryAttempts: 3,
|
|
62
|
-
on:
|
|
61
|
+
on: {
|
|
63
62
|
connecting: isRetry => {
|
|
64
63
|
connectionDiagnostics.wasRetry = isRetry;
|
|
65
64
|
connectionDiagnostics.state = 'connecting';
|
|
@@ -82,7 +81,7 @@ const getBlockServiceClient = () => {
|
|
|
82
81
|
connectionDiagnostics.state = 'error';
|
|
83
82
|
connectionDiagnostics.consecutiveFailures += 1;
|
|
84
83
|
}
|
|
85
|
-
}
|
|
84
|
+
}
|
|
86
85
|
});
|
|
87
86
|
}
|
|
88
87
|
return blockServiceClient;
|
|
@@ -207,12 +206,7 @@ export const subscribeToBlockUpdates = (blockAri, onData, onError) => {
|
|
|
207
206
|
}
|
|
208
207
|
},
|
|
209
208
|
error: error => {
|
|
210
|
-
|
|
211
|
-
onError === null || onError === void 0 ? void 0 : onError(new Error(extractGraphQLWSErrorMessage(error)));
|
|
212
|
-
} else {
|
|
213
|
-
const errorMessage = error instanceof Error ? error.message : 'GraphQL subscription error';
|
|
214
|
-
onError === null || onError === void 0 ? void 0 : onError(new Error(errorMessage));
|
|
215
|
-
}
|
|
209
|
+
onError === null || onError === void 0 ? void 0 : onError(new Error(extractGraphQLWSErrorMessage(error)));
|
|
216
210
|
},
|
|
217
211
|
complete: () => {
|
|
218
212
|
// Subscription completed
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/* eslint-disable require-unicode-regexp */
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
3
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
4
|
import { generateBlockAri, generateBlockAriFromReference } from '../../clients/block-service/ari';
|
|
6
5
|
import { batchRetrieveSyncedBlocks, BlockError, BlockNotFoundError, BlockTimeoutError, createSyncedBlock, deleteSyncedBlock, getReferenceSyncedBlocks, getReferenceSyncedBlocksByBlockAri, getSyncedBlockContent, updateReferenceSyncedBlockOnDocument, updateSyncedBlock, updateSyncedBlocks } from '../../clients/block-service/blockService';
|
|
@@ -36,7 +35,7 @@ const mapErrorResponseCode = errorCode => {
|
|
|
36
35
|
case 'NOT_FOUND':
|
|
37
36
|
return SyncBlockError.NotFound;
|
|
38
37
|
case 'EntityNotFound':
|
|
39
|
-
return
|
|
38
|
+
return SyncBlockError.EntityNotFound;
|
|
40
39
|
case 'INVALID_REQUEST':
|
|
41
40
|
return SyncBlockError.InvalidRequest;
|
|
42
41
|
case 'CONFLICT':
|
|
@@ -712,7 +711,7 @@ class BlockServiceADFWriteProvider {
|
|
|
712
711
|
error: undefined
|
|
713
712
|
};
|
|
714
713
|
} catch (error) {
|
|
715
|
-
if (error instanceof BlockNotFoundError && this.parentAri
|
|
714
|
+
if (error instanceof BlockNotFoundError && this.parentAri) {
|
|
716
715
|
return this.deleteOrphanBlock({
|
|
717
716
|
blockAri,
|
|
718
717
|
resourceId,
|
|
@@ -892,9 +891,7 @@ class BlockServiceADFWriteProvider {
|
|
|
892
891
|
if (successBlock) {
|
|
893
892
|
results.push({
|
|
894
893
|
resourceId: block.resourceId,
|
|
895
|
-
|
|
896
|
-
status: successBlock.status
|
|
897
|
-
})
|
|
894
|
+
status: successBlock.status
|
|
898
895
|
});
|
|
899
896
|
}
|
|
900
897
|
}
|
|
@@ -565,7 +565,7 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
565
565
|
* @returns true if the reference synced blocks are updated successfully, false otherwise
|
|
566
566
|
*/
|
|
567
567
|
async flush() {
|
|
568
|
-
if (this.viewMode === 'view'
|
|
568
|
+
if (this.viewMode === 'view') {
|
|
569
569
|
return false;
|
|
570
570
|
}
|
|
571
571
|
if (!this.isCacheDirty) {
|