@atlaskit/editor-synced-block-provider 3.14.1 → 3.14.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 +11 -0
- package/dist/cjs/clients/block-service/blockService.js +9 -7
- package/dist/cjs/hooks/useFetchSyncBlockData.js +3 -1
- package/dist/cjs/providers/block-service/blockServiceAPI.js +47 -18
- package/dist/cjs/providers/syncBlockProvider.js +10 -6
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +6 -5
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +41 -23
- package/dist/cjs/store-manager/syncBlockStoreManager.js +1 -1
- package/dist/cjs/utils/resolveSyncBlockInstance.js +2 -1
- package/dist/es2019/clients/block-service/blockService.js +5 -2
- package/dist/es2019/hooks/useFetchSyncBlockData.js +3 -1
- package/dist/es2019/providers/block-service/blockServiceAPI.js +45 -16
- package/dist/es2019/providers/syncBlockProvider.js +8 -4
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +6 -5
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +28 -11
- package/dist/es2019/store-manager/syncBlockStoreManager.js +1 -1
- package/dist/es2019/utils/resolveSyncBlockInstance.js +2 -1
- package/dist/esm/clients/block-service/blockService.js +9 -7
- package/dist/esm/hooks/useFetchSyncBlockData.js +3 -1
- package/dist/esm/providers/block-service/blockServiceAPI.js +47 -18
- package/dist/esm/providers/syncBlockProvider.js +10 -6
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +6 -5
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +42 -24
- package/dist/esm/store-manager/syncBlockStoreManager.js +1 -1
- package/dist/esm/utils/resolveSyncBlockInstance.js +2 -1
- package/dist/types/clients/block-service/blockService.d.ts +4 -2
- package/dist/types/common/types.d.ts +4 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/providers/block-service/blockServiceAPI.d.ts +1 -1
- package/dist/types/providers/syncBlockProvider.d.ts +2 -2
- package/dist/types/providers/types.d.ts +8 -4
- package/dist/types/store-manager/sourceSyncBlockStoreManager.d.ts +4 -3
- package/dist/types-ts4.5/clients/block-service/blockService.d.ts +4 -2
- package/dist/types-ts4.5/common/types.d.ts +4 -0
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +1 -1
- package/dist/types-ts4.5/providers/syncBlockProvider.d.ts +2 -2
- package/dist/types-ts4.5/providers/types.d.ts +8 -4
- package/dist/types-ts4.5/store-manager/sourceSyncBlockStoreManager.d.ts +4 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @atlaskit/editor-synced-block-provider
|
|
2
2
|
|
|
3
|
+
## 3.14.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`28434cbe03f1e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/28434cbe03f1e) -
|
|
8
|
+
[ux] [EDITOR-2851]
|
|
9
|
+
- Implement unsync feature for source sync block
|
|
10
|
+
- Update deletion confirmation modal and reference block UI after source deletion
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
3
14
|
## 3.14.1
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -13,6 +13,7 @@ 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");
|
|
16
17
|
var _retry = require("../../utils/retry");
|
|
17
18
|
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)); }
|
|
18
19
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
@@ -225,24 +226,25 @@ var batchRetrieveSyncedBlocks = exports.batchRetrieveSyncedBlocks = /*#__PURE__*
|
|
|
225
226
|
}();
|
|
226
227
|
var deleteSyncedBlock = exports.deleteSyncedBlock = /*#__PURE__*/function () {
|
|
227
228
|
var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(_ref6) {
|
|
228
|
-
var blockAri, response;
|
|
229
|
+
var blockAri, deleteReason, url, response;
|
|
229
230
|
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
230
231
|
while (1) switch (_context4.prev = _context4.next) {
|
|
231
232
|
case 0:
|
|
232
|
-
blockAri = _ref6.blockAri;
|
|
233
|
-
|
|
234
|
-
|
|
233
|
+
blockAri = _ref6.blockAri, deleteReason = _ref6.deleteReason;
|
|
234
|
+
url = deleteReason && (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding') ? "".concat(BLOCK_SERVICE_API_URL, "/block/").concat(encodeURIComponent(blockAri), "?deletionReason=").concat(encodeURIComponent(deleteReason)) : "".concat(BLOCK_SERVICE_API_URL, "/block/").concat(encodeURIComponent(blockAri));
|
|
235
|
+
_context4.next = 4;
|
|
236
|
+
return (0, _retry.fetchWithRetry)(url, {
|
|
235
237
|
method: 'DELETE',
|
|
236
238
|
headers: COMMON_HEADERS
|
|
237
239
|
});
|
|
238
|
-
case
|
|
240
|
+
case 4:
|
|
239
241
|
response = _context4.sent;
|
|
240
242
|
if (response.ok) {
|
|
241
|
-
_context4.next =
|
|
243
|
+
_context4.next = 7;
|
|
242
244
|
break;
|
|
243
245
|
}
|
|
244
246
|
throw new BlockError(response.status);
|
|
245
|
-
case
|
|
247
|
+
case 7:
|
|
246
248
|
case "end":
|
|
247
249
|
return _context4.stop();
|
|
248
250
|
}
|
|
@@ -90,7 +90,9 @@ var useFetchSyncBlockData = exports.useFetchSyncBlockData = function useFetchSyn
|
|
|
90
90
|
setFetchState({
|
|
91
91
|
syncBlockInstance: {
|
|
92
92
|
resourceId: resourceId || '',
|
|
93
|
-
error:
|
|
93
|
+
error: {
|
|
94
|
+
type: _types.SyncBlockError.Errored
|
|
95
|
+
}
|
|
94
96
|
},
|
|
95
97
|
isLoading: false
|
|
96
98
|
});
|
|
@@ -153,7 +153,9 @@ var fetchReferences = exports.fetchReferences = /*#__PURE__*/function () {
|
|
|
153
153
|
if (!resourceId) {
|
|
154
154
|
// could not extract resourceId from blockAri, return InvalidContent error
|
|
155
155
|
return {
|
|
156
|
-
error:
|
|
156
|
+
error: {
|
|
157
|
+
type: _types.SyncBlockError.InvalidContent
|
|
158
|
+
},
|
|
157
159
|
resourceId: blockContentResponse.blockAri
|
|
158
160
|
};
|
|
159
161
|
}
|
|
@@ -164,14 +166,18 @@ var fetchReferences = exports.fetchReferences = /*#__PURE__*/function () {
|
|
|
164
166
|
} catch (_unused2) {
|
|
165
167
|
// JSON parsing error, return InvalidContent error
|
|
166
168
|
return {
|
|
167
|
-
error:
|
|
169
|
+
error: {
|
|
170
|
+
type: _types.SyncBlockError.InvalidContent
|
|
171
|
+
},
|
|
168
172
|
resourceId: blockContentResponse.blockAri
|
|
169
173
|
};
|
|
170
174
|
}
|
|
171
175
|
});
|
|
172
176
|
errorInstances = (errors || []).map(function (errorBlock) {
|
|
173
177
|
return {
|
|
174
|
-
error:
|
|
178
|
+
error: {
|
|
179
|
+
type: _types.SyncBlockError.Errored
|
|
180
|
+
},
|
|
175
181
|
resourceId: errorBlock.blockAri
|
|
176
182
|
};
|
|
177
183
|
});
|
|
@@ -226,7 +232,10 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
226
232
|
break;
|
|
227
233
|
}
|
|
228
234
|
return _context2.abrupt("return", {
|
|
229
|
-
error:
|
|
235
|
+
error: {
|
|
236
|
+
type: _types.SyncBlockError.NotFound,
|
|
237
|
+
reason: blockContentResponse.deletionReason
|
|
238
|
+
},
|
|
230
239
|
resourceId: resourceId
|
|
231
240
|
});
|
|
232
241
|
case 8:
|
|
@@ -241,7 +250,8 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
241
250
|
contentUpdatedAt: (0, _utils.convertContentUpdatedAt)(blockContentResponse.contentUpdatedAt),
|
|
242
251
|
sourceAri: blockContentResponse.sourceAri,
|
|
243
252
|
product: blockContentResponse.product,
|
|
244
|
-
status: blockContentResponse.status
|
|
253
|
+
status: blockContentResponse.status,
|
|
254
|
+
deletionReason: blockContentResponse.deletionReason
|
|
245
255
|
},
|
|
246
256
|
resourceId: resourceId
|
|
247
257
|
});
|
|
@@ -253,12 +263,16 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
253
263
|
break;
|
|
254
264
|
}
|
|
255
265
|
return _context2.abrupt("return", {
|
|
256
|
-
error:
|
|
266
|
+
error: {
|
|
267
|
+
type: mapBlockError(_context2.t0)
|
|
268
|
+
},
|
|
257
269
|
resourceId: resourceId
|
|
258
270
|
});
|
|
259
271
|
case 16:
|
|
260
272
|
return _context2.abrupt("return", {
|
|
261
|
-
error:
|
|
273
|
+
error: {
|
|
274
|
+
type: _types.SyncBlockError.Errored
|
|
275
|
+
},
|
|
262
276
|
resourceId: resourceId
|
|
263
277
|
});
|
|
264
278
|
case 17:
|
|
@@ -381,7 +395,9 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
381
395
|
}
|
|
382
396
|
return _context4.abrupt("return", blockNodeIdentifiers.map(function (blockNodeIdentifier) {
|
|
383
397
|
return {
|
|
384
|
-
error:
|
|
398
|
+
error: {
|
|
399
|
+
type: _types.SyncBlockError.Errored
|
|
400
|
+
},
|
|
385
401
|
resourceId: blockNodeIdentifier.resourceId
|
|
386
402
|
};
|
|
387
403
|
}));
|
|
@@ -423,7 +439,10 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
423
439
|
break;
|
|
424
440
|
}
|
|
425
441
|
results.push({
|
|
426
|
-
error:
|
|
442
|
+
error: {
|
|
443
|
+
type: _types.SyncBlockError.NotFound,
|
|
444
|
+
reason: blockContentResponse.deletionReason
|
|
445
|
+
},
|
|
427
446
|
resourceId: resourceId
|
|
428
447
|
});
|
|
429
448
|
return _context4.abrupt("continue", 25);
|
|
@@ -438,13 +457,16 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
438
457
|
blockInstanceId: blockContentResponse.blockInstanceId,
|
|
439
458
|
sourceAri: blockContentResponse.sourceAri,
|
|
440
459
|
product: blockContentResponse.product,
|
|
441
|
-
status: blockContentResponse.status
|
|
460
|
+
status: blockContentResponse.status,
|
|
461
|
+
deletionReason: blockContentResponse.deletionReason
|
|
442
462
|
},
|
|
443
463
|
resourceId: resourceId
|
|
444
464
|
});
|
|
445
465
|
} catch (_unused3) {
|
|
446
466
|
results.push({
|
|
447
|
-
error:
|
|
467
|
+
error: {
|
|
468
|
+
type: _types.SyncBlockError.Errored
|
|
469
|
+
},
|
|
448
470
|
resourceId: resourceId
|
|
449
471
|
});
|
|
450
472
|
}
|
|
@@ -486,7 +508,9 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
486
508
|
case 44:
|
|
487
509
|
processedResourceIds.add(_resourceId);
|
|
488
510
|
results.push({
|
|
489
|
-
error:
|
|
511
|
+
error: {
|
|
512
|
+
type: mapErrorResponseCode(errorResponse.code)
|
|
513
|
+
},
|
|
490
514
|
resourceId: _resourceId
|
|
491
515
|
});
|
|
492
516
|
case 46:
|
|
@@ -511,7 +535,9 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
511
535
|
blockNodeIdentifier = _step3.value;
|
|
512
536
|
if (!processedResourceIds.has(blockNodeIdentifier.resourceId)) {
|
|
513
537
|
results.push({
|
|
514
|
-
error:
|
|
538
|
+
error: {
|
|
539
|
+
type: _types.SyncBlockError.NotFound
|
|
540
|
+
},
|
|
515
541
|
resourceId: blockNodeIdentifier.resourceId
|
|
516
542
|
});
|
|
517
543
|
}
|
|
@@ -527,7 +553,9 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
527
553
|
_context4.t2 = _context4["catch"](5);
|
|
528
554
|
return _context4.abrupt("return", blockNodeIdentifiers.map(function (blockNodeIdentifier) {
|
|
529
555
|
return {
|
|
530
|
-
error:
|
|
556
|
+
error: {
|
|
557
|
+
type: _context4.t2 instanceof _blockService.BlockError ? mapBlockError(_context4.t2) : _types.SyncBlockError.Errored
|
|
558
|
+
},
|
|
531
559
|
resourceId: blockNodeIdentifier.resourceId
|
|
532
560
|
};
|
|
533
561
|
}));
|
|
@@ -727,7 +755,7 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
727
755
|
}, {
|
|
728
756
|
key: "deleteData",
|
|
729
757
|
value: function () {
|
|
730
|
-
var _deleteData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(resourceId) {
|
|
758
|
+
var _deleteData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(resourceId, deleteReason) {
|
|
731
759
|
var blockAri;
|
|
732
760
|
return _regenerator.default.wrap(function _callee7$(_context7) {
|
|
733
761
|
while (1) switch (_context7.prev = _context7.next) {
|
|
@@ -751,7 +779,8 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
751
779
|
_context7.prev = 3;
|
|
752
780
|
_context7.next = 6;
|
|
753
781
|
return (0, _blockService.deleteSyncedBlock)({
|
|
754
|
-
blockAri: blockAri
|
|
782
|
+
blockAri: blockAri,
|
|
783
|
+
deleteReason: deleteReason
|
|
755
784
|
});
|
|
756
785
|
case 6:
|
|
757
786
|
return _context7.abrupt("return", {
|
|
@@ -792,7 +821,7 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
792
821
|
}
|
|
793
822
|
}, _callee7, this, [[3, 9]]);
|
|
794
823
|
}));
|
|
795
|
-
function deleteData(_x7) {
|
|
824
|
+
function deleteData(_x7, _x8) {
|
|
796
825
|
return _deleteData.apply(this, arguments);
|
|
797
826
|
}
|
|
798
827
|
return deleteData;
|
|
@@ -865,7 +894,7 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
865
894
|
}
|
|
866
895
|
}, _callee8, this, [[2, 8]]);
|
|
867
896
|
}));
|
|
868
|
-
function updateReferenceData(
|
|
897
|
+
function updateReferenceData(_x9, _x0) {
|
|
869
898
|
return _updateReferenceData.apply(this, arguments);
|
|
870
899
|
}
|
|
871
900
|
return updateReferenceData;
|
|
@@ -121,7 +121,9 @@ var SyncBlockProvider = exports.SyncBlockProvider = /*#__PURE__*/function (_Sync
|
|
|
121
121
|
return data;
|
|
122
122
|
}, function () {
|
|
123
123
|
return {
|
|
124
|
-
error:
|
|
124
|
+
error: {
|
|
125
|
+
type: _types.SyncBlockError.Errored
|
|
126
|
+
},
|
|
125
127
|
resourceId: blockIdentifier.resourceId
|
|
126
128
|
};
|
|
127
129
|
});
|
|
@@ -141,7 +143,9 @@ var SyncBlockProvider = exports.SyncBlockProvider = /*#__PURE__*/function (_Sync
|
|
|
141
143
|
return data;
|
|
142
144
|
}, function () {
|
|
143
145
|
return {
|
|
144
|
-
error:
|
|
146
|
+
error: {
|
|
147
|
+
type: _types.SyncBlockError.Errored
|
|
148
|
+
},
|
|
145
149
|
resourceId: blockIdentifier.resourceId
|
|
146
150
|
};
|
|
147
151
|
});
|
|
@@ -246,7 +250,7 @@ var SyncBlockProvider = exports.SyncBlockProvider = /*#__PURE__*/function (_Sync
|
|
|
246
250
|
}, {
|
|
247
251
|
key: "deleteNodesData",
|
|
248
252
|
value: (function () {
|
|
249
|
-
var _deleteNodesData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(resourceIds) {
|
|
253
|
+
var _deleteNodesData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(resourceIds, deletionReason) {
|
|
250
254
|
var _this4 = this;
|
|
251
255
|
var results;
|
|
252
256
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
@@ -263,7 +267,7 @@ var SyncBlockProvider = exports.SyncBlockProvider = /*#__PURE__*/function (_Sync
|
|
|
263
267
|
if (!_this4.writeProvider) {
|
|
264
268
|
return Promise.reject('Write provider not set');
|
|
265
269
|
}
|
|
266
|
-
return _this4.writeProvider.deleteData(resourceId);
|
|
270
|
+
return _this4.writeProvider.deleteData(resourceId, deletionReason);
|
|
267
271
|
}));
|
|
268
272
|
case 4:
|
|
269
273
|
results = _context3.sent;
|
|
@@ -284,7 +288,7 @@ var SyncBlockProvider = exports.SyncBlockProvider = /*#__PURE__*/function (_Sync
|
|
|
284
288
|
}
|
|
285
289
|
}, _callee3, this);
|
|
286
290
|
}));
|
|
287
|
-
function deleteNodesData(_x4) {
|
|
291
|
+
function deleteNodesData(_x4, _x5) {
|
|
288
292
|
return _deleteNodesData.apply(this, arguments);
|
|
289
293
|
}
|
|
290
294
|
return deleteNodesData;
|
|
@@ -382,7 +386,7 @@ var SyncBlockProvider = exports.SyncBlockProvider = /*#__PURE__*/function (_Sync
|
|
|
382
386
|
}
|
|
383
387
|
}, _callee4, this);
|
|
384
388
|
}));
|
|
385
|
-
function fetchSyncBlockSourceInfo(
|
|
389
|
+
function fetchSyncBlockSourceInfo(_x6, _x7, _x8, _x9) {
|
|
386
390
|
return _fetchSyncBlockSourceInfo.apply(this, arguments);
|
|
387
391
|
}
|
|
388
392
|
return fetchSyncBlockSourceInfo;
|
|
@@ -512,11 +512,12 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
512
512
|
// Don't fetch for not_found error since the source is already deleted
|
|
513
513
|
nodesToFetch = [];
|
|
514
514
|
syncBlockNodes.forEach(function (node) {
|
|
515
|
+
var _existingSyncBlock$er;
|
|
515
516
|
if (_this5.syncBlockFetchDataRequests.get(node.attrs.resourceId)) {
|
|
516
517
|
return;
|
|
517
518
|
}
|
|
518
519
|
var existingSyncBlock = _this5.getFromCache(node.attrs.resourceId);
|
|
519
|
-
if ((existingSyncBlock === null || existingSyncBlock === void 0 ? void 0 :
|
|
520
|
+
if ((existingSyncBlock === null || existingSyncBlock === void 0 || (_existingSyncBlock$er = existingSyncBlock.error) === null || _existingSyncBlock$er === void 0 ? void 0 : _existingSyncBlock$er.type) === _types.SyncBlockError.NotFound) {
|
|
520
521
|
return;
|
|
521
522
|
}
|
|
522
523
|
nodesToFetch.push(node);
|
|
@@ -551,8 +552,8 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
551
552
|
hasExpectedError = false;
|
|
552
553
|
data.forEach(function (syncBlockInstance) {
|
|
553
554
|
if (!syncBlockInstance.resourceId) {
|
|
554
|
-
var _this5$fireAnalyticsE;
|
|
555
|
-
(_this5$fireAnalyticsE = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE === void 0 || _this5$fireAnalyticsE.call(_this5, (0, _errorHandling.fetchErrorPayload)(syncBlockInstance.error || 'Returned sync block instance does not have resource id'));
|
|
555
|
+
var _this5$fireAnalyticsE, _syncBlockInstance$er;
|
|
556
|
+
(_this5$fireAnalyticsE = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE === void 0 || _this5$fireAnalyticsE.call(_this5, (0, _errorHandling.fetchErrorPayload)(((_syncBlockInstance$er = syncBlockInstance.error) === null || _syncBlockInstance$er === void 0 ? void 0 : _syncBlockInstance$er.type) || 'Returned sync block instance does not have resource id'));
|
|
556
557
|
return;
|
|
557
558
|
}
|
|
558
559
|
var existingSyncBlock = _this5.getFromCache(syncBlockInstance.resourceId);
|
|
@@ -560,8 +561,8 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
560
561
|
_this5.updateCache(resolvedSyncBlockInstance);
|
|
561
562
|
if (syncBlockInstance.error) {
|
|
562
563
|
var _this5$fireAnalyticsE2;
|
|
563
|
-
(_this5$fireAnalyticsE2 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE2 === void 0 || _this5$fireAnalyticsE2.call(_this5, (0, _errorHandling.fetchErrorPayload)(syncBlockInstance.error, syncBlockInstance.resourceId));
|
|
564
|
-
if (syncBlockInstance.error === _types.SyncBlockError.NotFound || syncBlockInstance.error === _types.SyncBlockError.Forbidden) {
|
|
564
|
+
(_this5$fireAnalyticsE2 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE2 === void 0 || _this5$fireAnalyticsE2.call(_this5, (0, _errorHandling.fetchErrorPayload)(syncBlockInstance.error.type, syncBlockInstance.resourceId));
|
|
565
|
+
if (syncBlockInstance.error.type === _types.SyncBlockError.NotFound || syncBlockInstance.error.type === _types.SyncBlockError.Forbidden) {
|
|
565
566
|
hasExpectedError = true;
|
|
566
567
|
} else if (syncBlockInstance.error) {
|
|
567
568
|
hasUnexpectedError = true;
|
|
@@ -135,10 +135,9 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
135
135
|
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
136
136
|
(_this$saveExperience = this.saveExperience) === null || _this$saveExperience === void 0 || _this$saveExperience.start({});
|
|
137
137
|
}
|
|
138
|
-
;
|
|
139
|
-
_context.next = 12;
|
|
138
|
+
_context.next = 11;
|
|
140
139
|
return this.dataProvider.writeNodesData(bodiedSyncBlockNodes, bodiedSyncBlockData);
|
|
141
|
-
case
|
|
140
|
+
case 11:
|
|
142
141
|
writeResults = _context.sent;
|
|
143
142
|
writeResults.forEach(function (result) {
|
|
144
143
|
// set isDirty to true for cases where it failed to save the sync block to the BE
|
|
@@ -152,7 +151,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
152
151
|
if (!writeResults.every(function (result) {
|
|
153
152
|
return result.resourceId && !result.error;
|
|
154
153
|
})) {
|
|
155
|
-
_context.next =
|
|
154
|
+
_context.next = 18;
|
|
156
155
|
break;
|
|
157
156
|
}
|
|
158
157
|
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
@@ -164,9 +163,8 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
164
163
|
}
|
|
165
164
|
});
|
|
166
165
|
}
|
|
167
|
-
;
|
|
168
166
|
return _context.abrupt("return", true);
|
|
169
|
-
case
|
|
167
|
+
case 18:
|
|
170
168
|
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
171
169
|
(_this$saveExperience3 = this.saveExperience) === null || _this$saveExperience3 === void 0 || _this$saveExperience3.failure();
|
|
172
170
|
}
|
|
@@ -177,22 +175,22 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
177
175
|
(_this2$fireAnalyticsE2 = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE2 === void 0 || _this2$fireAnalyticsE2.call(_this2, (0, _errorHandling.updateErrorPayload)(result.error || 'Failed to write data', result.resourceId));
|
|
178
176
|
});
|
|
179
177
|
return _context.abrupt("return", false);
|
|
180
|
-
case
|
|
181
|
-
_context.next =
|
|
178
|
+
case 21:
|
|
179
|
+
_context.next = 28;
|
|
182
180
|
break;
|
|
183
|
-
case
|
|
184
|
-
_context.prev =
|
|
181
|
+
case 23:
|
|
182
|
+
_context.prev = 23;
|
|
185
183
|
_context.t0 = _context["catch"](0);
|
|
186
184
|
(0, _monitoring.logException)(_context.t0, {
|
|
187
185
|
location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
|
|
188
186
|
});
|
|
189
187
|
(_this$fireAnalyticsEv2 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 || _this$fireAnalyticsEv2.call(this, (0, _errorHandling.updateErrorPayload)(_context.t0.message));
|
|
190
188
|
return _context.abrupt("return", false);
|
|
191
|
-
case
|
|
189
|
+
case 28:
|
|
192
190
|
case "end":
|
|
193
191
|
return _context.stop();
|
|
194
192
|
}
|
|
195
|
-
}, _callee, this, [[0,
|
|
193
|
+
}, _callee, this, [[0, 23]]);
|
|
196
194
|
}));
|
|
197
195
|
function flush() {
|
|
198
196
|
return _flush.apply(this, arguments);
|
|
@@ -345,7 +343,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
345
343
|
}, {
|
|
346
344
|
key: "delete",
|
|
347
345
|
value: function () {
|
|
348
|
-
var _delete2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(syncBlockIds, onDelete, onDeleteCompleted) {
|
|
346
|
+
var _delete2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(syncBlockIds, onDelete, onDeleteCompleted, reason) {
|
|
349
347
|
var _this5 = this;
|
|
350
348
|
var _this$deleteExperienc, results, callback, isDeleteSuccessful, _this$deleteExperienc2, _this$deleteExperienc3;
|
|
351
349
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
@@ -367,7 +365,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
367
365
|
_context2.next = 7;
|
|
368
366
|
return this.dataProvider.deleteNodesData(syncBlockIds.map(function (attrs) {
|
|
369
367
|
return attrs.resourceId;
|
|
370
|
-
}));
|
|
368
|
+
}), reason);
|
|
371
369
|
case 7:
|
|
372
370
|
results = _context2.sent;
|
|
373
371
|
isDeleteSuccessful = results.every(function (result) {
|
|
@@ -432,7 +430,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
432
430
|
}
|
|
433
431
|
}, _callee2, this, [[0, 15]]);
|
|
434
432
|
}));
|
|
435
|
-
function _delete(_x, _x2, _x3) {
|
|
433
|
+
function _delete(_x, _x2, _x3, _x4) {
|
|
436
434
|
return _delete2.apply(this, arguments);
|
|
437
435
|
}
|
|
438
436
|
return _delete;
|
|
@@ -446,7 +444,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
446
444
|
key: "retryDeletion",
|
|
447
445
|
value: function () {
|
|
448
446
|
var _retryDeletion = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
449
|
-
var _this$deletionRetryIn, syncBlockIds, onDelete, onDeleteCompleted;
|
|
447
|
+
var _this$deletionRetryIn, syncBlockIds, onDelete, onDeleteCompleted, deletionReason;
|
|
450
448
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
451
449
|
while (1) switch (_context3.prev = _context3.next) {
|
|
452
450
|
case 0:
|
|
@@ -456,13 +454,13 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
456
454
|
}
|
|
457
455
|
return _context3.abrupt("return", Promise.resolve());
|
|
458
456
|
case 2:
|
|
459
|
-
_this$deletionRetryIn = this.deletionRetryInfo, syncBlockIds = _this$deletionRetryIn.syncBlockIds, onDelete = _this$deletionRetryIn.onDelete, onDeleteCompleted = _this$deletionRetryIn.onDeleteCompleted;
|
|
457
|
+
_this$deletionRetryIn = this.deletionRetryInfo, syncBlockIds = _this$deletionRetryIn.syncBlockIds, onDelete = _this$deletionRetryIn.onDelete, onDeleteCompleted = _this$deletionRetryIn.onDeleteCompleted, deletionReason = _this$deletionRetryIn.deletionReason;
|
|
460
458
|
if (!this.confirmationCallback) {
|
|
461
459
|
_context3.next = 6;
|
|
462
460
|
break;
|
|
463
461
|
}
|
|
464
462
|
_context3.next = 6;
|
|
465
|
-
return this.delete(syncBlockIds, onDelete, onDeleteCompleted);
|
|
463
|
+
return this.delete(syncBlockIds, onDelete, onDeleteCompleted, deletionReason);
|
|
466
464
|
case 6:
|
|
467
465
|
case "end":
|
|
468
466
|
return _context3.stop();
|
|
@@ -492,7 +490,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
492
490
|
}, {
|
|
493
491
|
key: "deleteSyncBlocksWithConfirmation",
|
|
494
492
|
value: (function () {
|
|
495
|
-
var _deleteSyncBlocksWithConfirmation = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(syncBlockIds, onDelete, onDeleteCompleted, destroyCallback) {
|
|
493
|
+
var _deleteSyncBlocksWithConfirmation = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(syncBlockIds, deletionReason, onDelete, onDeleteCompleted, destroyCallback) {
|
|
496
494
|
var confirmed, isDeleteSuccessful;
|
|
497
495
|
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
498
496
|
while (1) switch (_context4.prev = _context4.next) {
|
|
@@ -502,7 +500,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
502
500
|
break;
|
|
503
501
|
}
|
|
504
502
|
_context4.next = 3;
|
|
505
|
-
return this.confirmationCallback(syncBlockIds
|
|
503
|
+
return this.confirmationCallback(syncBlockIds, deletionReason);
|
|
506
504
|
case 3:
|
|
507
505
|
confirmed = _context4.sent;
|
|
508
506
|
if (!confirmed) {
|
|
@@ -510,7 +508,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
510
508
|
break;
|
|
511
509
|
}
|
|
512
510
|
_context4.next = 7;
|
|
513
|
-
return this.delete(syncBlockIds, onDelete, onDeleteCompleted);
|
|
511
|
+
return this.delete(syncBlockIds, onDelete, onDeleteCompleted, deletionReason);
|
|
514
512
|
case 7:
|
|
515
513
|
isDeleteSuccessful = _context4.sent;
|
|
516
514
|
if (!isDeleteSuccessful) {
|
|
@@ -519,7 +517,8 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
519
517
|
syncBlockIds: syncBlockIds,
|
|
520
518
|
onDelete: onDelete,
|
|
521
519
|
onDeleteCompleted: onDeleteCompleted,
|
|
522
|
-
destroyCallback: destroyCallback
|
|
520
|
+
destroyCallback: destroyCallback,
|
|
521
|
+
deletionReason: deletionReason
|
|
523
522
|
};
|
|
524
523
|
} else {
|
|
525
524
|
destroyCallback();
|
|
@@ -534,7 +533,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
534
533
|
}
|
|
535
534
|
}, _callee4, this);
|
|
536
535
|
}));
|
|
537
|
-
function deleteSyncBlocksWithConfirmation(
|
|
536
|
+
function deleteSyncBlocksWithConfirmation(_x5, _x6, _x7, _x8, _x9) {
|
|
538
537
|
return _deleteSyncBlocksWithConfirmation.apply(this, arguments);
|
|
539
538
|
}
|
|
540
539
|
return deleteSyncBlocksWithConfirmation;
|
|
@@ -556,6 +555,25 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
556
555
|
return Promise.resolve(undefined);
|
|
557
556
|
}
|
|
558
557
|
}
|
|
558
|
+
}, {
|
|
559
|
+
key: "fetchReferences",
|
|
560
|
+
value: function fetchReferences(resourceId) {
|
|
561
|
+
try {
|
|
562
|
+
if (!this.dataProvider) {
|
|
563
|
+
throw new Error('Data provider not set');
|
|
564
|
+
}
|
|
565
|
+
return this.dataProvider.fetchReferences(resourceId, true);
|
|
566
|
+
} catch (error) {
|
|
567
|
+
var _this$fireAnalyticsEv7;
|
|
568
|
+
(0, _monitoring.logException)(error, {
|
|
569
|
+
location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
|
|
570
|
+
});
|
|
571
|
+
(_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 || _this$fireAnalyticsEv7.call(this, (0, _errorHandling.fetchReferencesErrorPayload)(error.message));
|
|
572
|
+
return Promise.resolve({
|
|
573
|
+
error: _types.SyncBlockError.Errored
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
}
|
|
559
577
|
}, {
|
|
560
578
|
key: "destroy",
|
|
561
579
|
value: function destroy() {
|
|
@@ -79,7 +79,7 @@ var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/functio
|
|
|
79
79
|
while (1) switch (_context.prev = _context.next) {
|
|
80
80
|
case 0:
|
|
81
81
|
_context.next = 2;
|
|
82
|
-
return (_this$dataProvider = _this.dataProvider) === null || _this$dataProvider === void 0 ? void 0 : _this$dataProvider.fetchSyncBlockSourceInfo(blockInstanceId, reference.documentAri, (0, _ari.getProductFromSourceAri)(reference.documentAri), _this.fireAnalyticsEvent, reference.hasAccess, 'view');
|
|
82
|
+
return (_this$dataProvider = _this.dataProvider) === null || _this$dataProvider === void 0 ? void 0 : _this$dataProvider.fetchSyncBlockSourceInfo(reference.blockInstanceId || '', reference.documentAri, (0, _ari.getProductFromSourceAri)(reference.documentAri), _this.fireAnalyticsEvent, reference.hasAccess, 'view');
|
|
83
83
|
case 2:
|
|
84
84
|
sourceInfo = _context.sent;
|
|
85
85
|
if (sourceInfo) {
|
|
@@ -26,8 +26,9 @@ var resolveSyncBlockInstance = exports.resolveSyncBlockInstance = function resol
|
|
|
26
26
|
if (!oldResult.data) {
|
|
27
27
|
return newResult;
|
|
28
28
|
} else if (!newResult.data) {
|
|
29
|
+
var _newResult$error, _newResult$error2;
|
|
29
30
|
// return the old result if there was an error, e.g. network error, but not if not found or forbidden
|
|
30
|
-
if (newResult.error === _types.SyncBlockError.NotFound || newResult.error === _types.SyncBlockError.Forbidden) {
|
|
31
|
+
if (((_newResult$error = newResult.error) === null || _newResult$error === void 0 ? void 0 : _newResult$error.type) === _types.SyncBlockError.NotFound || ((_newResult$error2 = newResult.error) === null || _newResult$error2 === void 0 ? void 0 : _newResult$error2.type) === _types.SyncBlockError.Forbidden) {
|
|
31
32
|
return newResult;
|
|
32
33
|
} else {
|
|
33
34
|
return oldResult;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
1
2
|
import { fetchWithRetry } from '../../utils/retry';
|
|
2
3
|
export const isBlockContentResponse = response => {
|
|
3
4
|
const content = response.content;
|
|
@@ -144,9 +145,11 @@ export const batchRetrieveSyncedBlocks = async ({
|
|
|
144
145
|
return await response.json();
|
|
145
146
|
};
|
|
146
147
|
export const deleteSyncedBlock = async ({
|
|
147
|
-
blockAri
|
|
148
|
+
blockAri,
|
|
149
|
+
deleteReason
|
|
148
150
|
}) => {
|
|
149
|
-
const
|
|
151
|
+
const url = deleteReason && fg('platform_synced_block_dogfooding') ? `${BLOCK_SERVICE_API_URL}/block/${encodeURIComponent(blockAri)}?deletionReason=${encodeURIComponent(deleteReason)}` : `${BLOCK_SERVICE_API_URL}/block/${encodeURIComponent(blockAri)}`;
|
|
152
|
+
const response = await fetchWithRetry(url, {
|
|
150
153
|
method: 'DELETE',
|
|
151
154
|
headers: COMMON_HEADERS
|
|
152
155
|
});
|
|
@@ -59,7 +59,9 @@ export const useFetchSyncBlockData = (manager, resourceId, localId, fireAnalytic
|
|
|
59
59
|
setFetchState({
|
|
60
60
|
syncBlockInstance: {
|
|
61
61
|
resourceId: resourceId || '',
|
|
62
|
-
error:
|
|
62
|
+
error: {
|
|
63
|
+
type: SyncBlockError.Errored
|
|
64
|
+
}
|
|
63
65
|
},
|
|
64
66
|
isLoading: false
|
|
65
67
|
});
|