@atlaskit/editor-synced-block-provider 4.2.8 → 4.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/cjs/clients/block-service/blockService.js +24 -8
- package/dist/cjs/providers/block-service/blockServiceAPI.js +198 -82
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +23 -6
- package/dist/es2019/clients/block-service/blockService.js +16 -4
- package/dist/es2019/providers/block-service/blockServiceAPI.js +74 -1
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +25 -7
- package/dist/esm/clients/block-service/blockService.js +24 -7
- package/dist/esm/providers/block-service/blockServiceAPI.js +199 -83
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +23 -6
- package/dist/types/clients/block-service/blockService.d.ts +8 -0
- package/dist/types/providers/block-service/blockServiceAPI.d.ts +1 -0
- package/dist/types-ts4.5/clients/block-service/blockService.d.ts +8 -0
- package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +1 -0
- package/package.json +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @atlaskit/editor-synced-block-provider
|
|
2
2
|
|
|
3
|
+
## 4.2.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`becb755f01510`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/becb755f01510) -
|
|
8
|
+
Editor-5990: Create and delete call to block service when deleting orphan source blocks
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 4.2.9
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`827be3d512390`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/827be3d512390) -
|
|
16
|
+
Refactor source synced block cache update to use appendTransaction instead of nodeview update.
|
|
17
|
+
Behind fg('platform_synced_block_update_refactor'):
|
|
18
|
+
- Moves cache update from nodeview update() to PM plugin appendTransaction hook, filtering out
|
|
19
|
+
non-user changes (remote collab, table auto-scale, dirty transactions)
|
|
20
|
+
- Moves initial cache population from nodeview constructor to PM plugin state.init()
|
|
21
|
+
- Optimises updateSyncBlockData with Fragment.eq() for O(1) comparison instead of toJSON() +
|
|
22
|
+
lodash/isEqual
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
|
|
3
25
|
## 4.2.8
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.updateSyncedBlocks = exports.updateSyncedBlock = exports.updateReferenceSyncedBlockOnDocument = exports.isBlockContentResponse = exports.getSyncedBlockContent = exports.getReferenceSyncedBlocksByBlockAri = exports.getReferenceSyncedBlocks = exports.deleteSyncedBlock = exports.createSyncedBlock = exports.batchRetrieveSyncedBlocks = exports.BlockTimeoutError = exports.BlockError = void 0;
|
|
7
|
+
exports.updateSyncedBlocks = exports.updateSyncedBlock = exports.updateReferenceSyncedBlockOnDocument = exports.isBlockContentResponse = exports.getSyncedBlockContent = exports.getReferenceSyncedBlocksByBlockAri = exports.getReferenceSyncedBlocks = exports.deleteSyncedBlock = exports.createSyncedBlock = exports.batchRetrieveSyncedBlocks = exports.BlockTimeoutError = exports.BlockNotFoundError = exports.BlockError = void 0;
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
@@ -226,15 +226,31 @@ var BlockError = exports.BlockError = /*#__PURE__*/function (_Error) {
|
|
|
226
226
|
(0, _inherits2.default)(BlockError, _Error);
|
|
227
227
|
return (0, _createClass2.default)(BlockError);
|
|
228
228
|
}( /*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
|
|
229
|
-
|
|
230
|
-
|
|
229
|
+
/**
|
|
230
|
+
* Thrown when Block Service returns RESOURCE_NOT_FOUND for a block.
|
|
231
|
+
* This typically happens when an orphan block (e.g. from a copied page) is deleted.
|
|
232
|
+
* The caller should create the block first, then delete it to ensure a proper soft-delete record.
|
|
233
|
+
*/
|
|
234
|
+
var BlockNotFoundError = exports.BlockNotFoundError = /*#__PURE__*/function (_Error2) {
|
|
235
|
+
function BlockNotFoundError() {
|
|
231
236
|
var _this2;
|
|
232
|
-
(0, _classCallCheck2.default)(this,
|
|
233
|
-
_this2 = _callSuper(this,
|
|
234
|
-
_this2.name = '
|
|
237
|
+
(0, _classCallCheck2.default)(this, BlockNotFoundError);
|
|
238
|
+
_this2 = _callSuper(this, BlockNotFoundError, ['Block not found in Block Service']);
|
|
239
|
+
_this2.name = 'BlockNotFoundError';
|
|
235
240
|
return _this2;
|
|
236
241
|
}
|
|
237
|
-
(0, _inherits2.default)(
|
|
242
|
+
(0, _inherits2.default)(BlockNotFoundError, _Error2);
|
|
243
|
+
return (0, _createClass2.default)(BlockNotFoundError);
|
|
244
|
+
}( /*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
|
|
245
|
+
var BlockTimeoutError = exports.BlockTimeoutError = /*#__PURE__*/function (_Error3) {
|
|
246
|
+
function BlockTimeoutError() {
|
|
247
|
+
var _this3;
|
|
248
|
+
(0, _classCallCheck2.default)(this, BlockTimeoutError);
|
|
249
|
+
_this3 = _callSuper(this, BlockTimeoutError, ['Block request timed out']);
|
|
250
|
+
_this3.name = 'BlockTimeoutError';
|
|
251
|
+
return _this3;
|
|
252
|
+
}
|
|
253
|
+
(0, _inherits2.default)(BlockTimeoutError, _Error3);
|
|
238
254
|
return (0, _createClass2.default)(BlockTimeoutError);
|
|
239
255
|
}( /*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
|
|
240
256
|
var getSyncedBlockContent = exports.getSyncedBlockContent = /*#__PURE__*/function () {
|
|
@@ -420,7 +436,7 @@ var deleteSyncedBlock = exports.deleteSyncedBlock = /*#__PURE__*/function () {
|
|
|
420
436
|
_context4.next = 16;
|
|
421
437
|
break;
|
|
422
438
|
}
|
|
423
|
-
|
|
439
|
+
throw new BlockNotFoundError();
|
|
424
440
|
case 16:
|
|
425
441
|
throw new Error(result.errors.map(function (e) {
|
|
426
442
|
return e.message;
|
|
@@ -1031,31 +1031,42 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
1031
1031
|
case 9:
|
|
1032
1032
|
_context0.prev = 9;
|
|
1033
1033
|
_context0.t0 = _context0["catch"](3);
|
|
1034
|
+
if (!(_context0.t0 instanceof _blockService.BlockNotFoundError && this.parentAri && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_8'))) {
|
|
1035
|
+
_context0.next = 13;
|
|
1036
|
+
break;
|
|
1037
|
+
}
|
|
1038
|
+
return _context0.abrupt("return", this.deleteOrphanBlock({
|
|
1039
|
+
blockAri: blockAri,
|
|
1040
|
+
resourceId: resourceId,
|
|
1041
|
+
parentAri: this.parentAri,
|
|
1042
|
+
deleteReason: deleteReason
|
|
1043
|
+
}));
|
|
1044
|
+
case 13:
|
|
1034
1045
|
if (!(_context0.t0 instanceof _blockService.BlockError)) {
|
|
1035
|
-
_context0.next =
|
|
1046
|
+
_context0.next = 17;
|
|
1036
1047
|
break;
|
|
1037
1048
|
}
|
|
1038
1049
|
if (!(_context0.t0.status === 404)) {
|
|
1039
|
-
_context0.next =
|
|
1050
|
+
_context0.next = 16;
|
|
1040
1051
|
break;
|
|
1041
1052
|
}
|
|
1042
1053
|
return _context0.abrupt("return", {
|
|
1043
1054
|
resourceId: resourceId,
|
|
1044
1055
|
success: true
|
|
1045
1056
|
});
|
|
1046
|
-
case
|
|
1057
|
+
case 16:
|
|
1047
1058
|
return _context0.abrupt("return", {
|
|
1048
1059
|
resourceId: resourceId,
|
|
1049
1060
|
success: false,
|
|
1050
1061
|
error: mapBlockError(_context0.t0)
|
|
1051
1062
|
});
|
|
1052
|
-
case
|
|
1063
|
+
case 17:
|
|
1053
1064
|
return _context0.abrupt("return", {
|
|
1054
1065
|
resourceId: resourceId,
|
|
1055
1066
|
success: false,
|
|
1056
1067
|
error: (0, _errorHandling.stringifyError)(_context0.t0)
|
|
1057
1068
|
});
|
|
1058
|
-
case
|
|
1069
|
+
case 18:
|
|
1059
1070
|
case "end":
|
|
1060
1071
|
return _context0.stop();
|
|
1061
1072
|
}
|
|
@@ -1065,6 +1076,111 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
1065
1076
|
return _deleteData.apply(this, arguments);
|
|
1066
1077
|
}
|
|
1067
1078
|
return deleteData;
|
|
1079
|
+
}() // The block is an orphan (e.g. from a copied page) — it doesn't exist in Block Service.
|
|
1080
|
+
// Block Service uses soft-deletes, so we must first create the block then delete it,
|
|
1081
|
+
// ensuring a deletion-reason record is stored (used to display errors in reference blocks).
|
|
1082
|
+
}, {
|
|
1083
|
+
key: "deleteOrphanBlock",
|
|
1084
|
+
value: function () {
|
|
1085
|
+
var _deleteOrphanBlock = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee0(_ref7) {
|
|
1086
|
+
var blockAri, resourceId, parentAri, deleteReason, stepVersion;
|
|
1087
|
+
return _regenerator.default.wrap(function _callee0$(_context1) {
|
|
1088
|
+
while (1) switch (_context1.prev = _context1.next) {
|
|
1089
|
+
case 0:
|
|
1090
|
+
blockAri = _ref7.blockAri, resourceId = _ref7.resourceId, parentAri = _ref7.parentAri, deleteReason = _ref7.deleteReason;
|
|
1091
|
+
_context1.prev = 1;
|
|
1092
|
+
if (!this.getVersion) {
|
|
1093
|
+
_context1.next = 8;
|
|
1094
|
+
break;
|
|
1095
|
+
}
|
|
1096
|
+
_context1.next = 5;
|
|
1097
|
+
return this.getVersion();
|
|
1098
|
+
case 5:
|
|
1099
|
+
_context1.t0 = _context1.sent;
|
|
1100
|
+
_context1.next = 9;
|
|
1101
|
+
break;
|
|
1102
|
+
case 8:
|
|
1103
|
+
_context1.t0 = undefined;
|
|
1104
|
+
case 9:
|
|
1105
|
+
stepVersion = _context1.t0;
|
|
1106
|
+
_context1.prev = 10;
|
|
1107
|
+
_context1.next = 13;
|
|
1108
|
+
return (0, _blockService.createSyncedBlock)({
|
|
1109
|
+
blockAri: blockAri,
|
|
1110
|
+
blockInstanceId: resourceId,
|
|
1111
|
+
sourceAri: parentAri,
|
|
1112
|
+
product: this.product,
|
|
1113
|
+
content: '[]',
|
|
1114
|
+
stepVersion: stepVersion
|
|
1115
|
+
});
|
|
1116
|
+
case 13:
|
|
1117
|
+
_context1.next = 25;
|
|
1118
|
+
break;
|
|
1119
|
+
case 15:
|
|
1120
|
+
_context1.prev = 15;
|
|
1121
|
+
_context1.t1 = _context1["catch"](10);
|
|
1122
|
+
if (!(_context1.t1 instanceof Error && _context1.t1.message.includes('Conditional check failed'))) {
|
|
1123
|
+
_context1.next = 20;
|
|
1124
|
+
break;
|
|
1125
|
+
}
|
|
1126
|
+
_context1.next = 25;
|
|
1127
|
+
break;
|
|
1128
|
+
case 20:
|
|
1129
|
+
if (!(_context1.t1 instanceof _blockService.BlockError)) {
|
|
1130
|
+
_context1.next = 24;
|
|
1131
|
+
break;
|
|
1132
|
+
}
|
|
1133
|
+
return _context1.abrupt("return", {
|
|
1134
|
+
resourceId: resourceId,
|
|
1135
|
+
success: false,
|
|
1136
|
+
error: mapBlockError(_context1.t1)
|
|
1137
|
+
});
|
|
1138
|
+
case 24:
|
|
1139
|
+
return _context1.abrupt("return", {
|
|
1140
|
+
resourceId: resourceId,
|
|
1141
|
+
success: false,
|
|
1142
|
+
error: (0, _errorHandling.stringifyError)(_context1.t1)
|
|
1143
|
+
});
|
|
1144
|
+
case 25:
|
|
1145
|
+
_context1.next = 27;
|
|
1146
|
+
return (0, _blockService.deleteSyncedBlock)({
|
|
1147
|
+
blockAri: blockAri,
|
|
1148
|
+
deleteReason: deleteReason
|
|
1149
|
+
});
|
|
1150
|
+
case 27:
|
|
1151
|
+
return _context1.abrupt("return", {
|
|
1152
|
+
resourceId: resourceId,
|
|
1153
|
+
success: true,
|
|
1154
|
+
error: undefined
|
|
1155
|
+
});
|
|
1156
|
+
case 30:
|
|
1157
|
+
_context1.prev = 30;
|
|
1158
|
+
_context1.t2 = _context1["catch"](1);
|
|
1159
|
+
if (!(_context1.t2 instanceof _blockService.BlockError)) {
|
|
1160
|
+
_context1.next = 34;
|
|
1161
|
+
break;
|
|
1162
|
+
}
|
|
1163
|
+
return _context1.abrupt("return", {
|
|
1164
|
+
resourceId: resourceId,
|
|
1165
|
+
success: false,
|
|
1166
|
+
error: mapBlockError(_context1.t2)
|
|
1167
|
+
});
|
|
1168
|
+
case 34:
|
|
1169
|
+
return _context1.abrupt("return", {
|
|
1170
|
+
resourceId: resourceId,
|
|
1171
|
+
success: false,
|
|
1172
|
+
error: (0, _errorHandling.stringifyError)(_context1.t2)
|
|
1173
|
+
});
|
|
1174
|
+
case 35:
|
|
1175
|
+
case "end":
|
|
1176
|
+
return _context1.stop();
|
|
1177
|
+
}
|
|
1178
|
+
}, _callee0, this, [[1, 30], [10, 15]]);
|
|
1179
|
+
}));
|
|
1180
|
+
function deleteOrphanBlock(_x18) {
|
|
1181
|
+
return _deleteOrphanBlock.apply(this, arguments);
|
|
1182
|
+
}
|
|
1183
|
+
return deleteOrphanBlock;
|
|
1068
1184
|
}() // the sourceId is the resourceId of the source synced block.
|
|
1069
1185
|
}, {
|
|
1070
1186
|
key: "generateResourceIdForReference",
|
|
@@ -1089,22 +1205,22 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
1089
1205
|
}, {
|
|
1090
1206
|
key: "updateReferenceData",
|
|
1091
1207
|
value: function () {
|
|
1092
|
-
var _updateReferenceData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
1208
|
+
var _updateReferenceData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee1(blocks, noContent) {
|
|
1093
1209
|
var _this2 = this;
|
|
1094
|
-
return _regenerator.default.wrap(function
|
|
1095
|
-
while (1) switch (
|
|
1210
|
+
return _regenerator.default.wrap(function _callee1$(_context10) {
|
|
1211
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
1096
1212
|
case 0:
|
|
1097
1213
|
if (this.parentAri) {
|
|
1098
|
-
|
|
1214
|
+
_context10.next = 2;
|
|
1099
1215
|
break;
|
|
1100
1216
|
}
|
|
1101
|
-
return
|
|
1217
|
+
return _context10.abrupt("return", {
|
|
1102
1218
|
success: false,
|
|
1103
1219
|
error: _types.SyncBlockError.Errored
|
|
1104
1220
|
});
|
|
1105
1221
|
case 2:
|
|
1106
|
-
|
|
1107
|
-
|
|
1222
|
+
_context10.prev = 2;
|
|
1223
|
+
_context10.next = 5;
|
|
1108
1224
|
return (0, _blockService.updateReferenceSyncedBlockOnDocument)({
|
|
1109
1225
|
documentAri: this.parentAri,
|
|
1110
1226
|
blocks: blocks.map(function (block) {
|
|
@@ -1119,32 +1235,32 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
1119
1235
|
noContent: noContent
|
|
1120
1236
|
});
|
|
1121
1237
|
case 5:
|
|
1122
|
-
return
|
|
1238
|
+
return _context10.abrupt("return", {
|
|
1123
1239
|
success: true
|
|
1124
1240
|
});
|
|
1125
1241
|
case 8:
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
if (!(
|
|
1129
|
-
|
|
1242
|
+
_context10.prev = 8;
|
|
1243
|
+
_context10.t0 = _context10["catch"](2);
|
|
1244
|
+
if (!(_context10.t0 instanceof _blockService.BlockError)) {
|
|
1245
|
+
_context10.next = 12;
|
|
1130
1246
|
break;
|
|
1131
1247
|
}
|
|
1132
|
-
return
|
|
1248
|
+
return _context10.abrupt("return", {
|
|
1133
1249
|
success: false,
|
|
1134
|
-
error: mapBlockError(
|
|
1250
|
+
error: mapBlockError(_context10.t0)
|
|
1135
1251
|
});
|
|
1136
1252
|
case 12:
|
|
1137
|
-
return
|
|
1253
|
+
return _context10.abrupt("return", {
|
|
1138
1254
|
success: false,
|
|
1139
|
-
error: (0, _errorHandling.stringifyError)(
|
|
1255
|
+
error: (0, _errorHandling.stringifyError)(_context10.t0)
|
|
1140
1256
|
});
|
|
1141
1257
|
case 13:
|
|
1142
1258
|
case "end":
|
|
1143
|
-
return
|
|
1259
|
+
return _context10.stop();
|
|
1144
1260
|
}
|
|
1145
|
-
},
|
|
1261
|
+
}, _callee1, this, [[2, 8]]);
|
|
1146
1262
|
}));
|
|
1147
|
-
function updateReferenceData(
|
|
1263
|
+
function updateReferenceData(_x19, _x20) {
|
|
1148
1264
|
return _updateReferenceData.apply(this, arguments);
|
|
1149
1265
|
}
|
|
1150
1266
|
return updateReferenceData;
|
|
@@ -1152,17 +1268,17 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
1152
1268
|
}, {
|
|
1153
1269
|
key: "writeDataBatch",
|
|
1154
1270
|
value: function () {
|
|
1155
|
-
var _writeDataBatch = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
1271
|
+
var _writeDataBatch = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(data) {
|
|
1156
1272
|
var _this3 = this;
|
|
1157
1273
|
var stepVersion, blockAriToResourceIdMap, blocks, response, results, successResourceIds, _iterator6, _step6, block, errorResourceIds, _iterator7, _step7, _loop2;
|
|
1158
|
-
return _regenerator.default.wrap(function
|
|
1159
|
-
while (1) switch (
|
|
1274
|
+
return _regenerator.default.wrap(function _callee10$(_context12) {
|
|
1275
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1160
1276
|
case 0:
|
|
1161
1277
|
if (!(!this.parentAri || !this.parentId)) {
|
|
1162
|
-
|
|
1278
|
+
_context12.next = 2;
|
|
1163
1279
|
break;
|
|
1164
1280
|
}
|
|
1165
|
-
return
|
|
1281
|
+
return _context12.abrupt("return", data.map(function (block) {
|
|
1166
1282
|
return {
|
|
1167
1283
|
error: _types.SyncBlockError.Errored,
|
|
1168
1284
|
resourceId: block.resourceId
|
|
@@ -1170,20 +1286,20 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
1170
1286
|
}));
|
|
1171
1287
|
case 2:
|
|
1172
1288
|
if (!this.getVersion) {
|
|
1173
|
-
|
|
1289
|
+
_context12.next = 8;
|
|
1174
1290
|
break;
|
|
1175
1291
|
}
|
|
1176
|
-
|
|
1292
|
+
_context12.next = 5;
|
|
1177
1293
|
return this.getVersion();
|
|
1178
1294
|
case 5:
|
|
1179
|
-
|
|
1180
|
-
|
|
1295
|
+
_context12.t0 = _context12.sent;
|
|
1296
|
+
_context12.next = 9;
|
|
1181
1297
|
break;
|
|
1182
1298
|
case 8:
|
|
1183
|
-
|
|
1299
|
+
_context12.t0 = undefined;
|
|
1184
1300
|
case 9:
|
|
1185
|
-
stepVersion =
|
|
1186
|
-
|
|
1301
|
+
stepVersion = _context12.t0;
|
|
1302
|
+
_context12.prev = 10;
|
|
1187
1303
|
// Create a map from blockAri to original resourceId for matching responses
|
|
1188
1304
|
blockAriToResourceIdMap = new Map();
|
|
1189
1305
|
blocks = data.map(function (block) {
|
|
@@ -1196,12 +1312,12 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
1196
1312
|
stepVersion: stepVersion
|
|
1197
1313
|
};
|
|
1198
1314
|
});
|
|
1199
|
-
|
|
1315
|
+
_context12.next = 15;
|
|
1200
1316
|
return (0, _blockService.updateSyncedBlocks)({
|
|
1201
1317
|
blocks: blocks
|
|
1202
1318
|
});
|
|
1203
1319
|
case 15:
|
|
1204
|
-
response =
|
|
1320
|
+
response = _context12.sent;
|
|
1205
1321
|
results = []; // Process successful updates
|
|
1206
1322
|
if (response.success) {
|
|
1207
1323
|
successResourceIds = new Set(response.success.map(function (block) {
|
|
@@ -1224,7 +1340,7 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
1224
1340
|
}
|
|
1225
1341
|
}
|
|
1226
1342
|
if (!response.error) {
|
|
1227
|
-
|
|
1343
|
+
_context12.next = 36;
|
|
1228
1344
|
break;
|
|
1229
1345
|
}
|
|
1230
1346
|
errorResourceIds = new Map(response.error.map(function (err) {
|
|
@@ -1233,11 +1349,11 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
1233
1349
|
blockAriToResourceIdMap.get(err.blockAri) || '', mapErrorResponseCode(err.code)];
|
|
1234
1350
|
}));
|
|
1235
1351
|
_iterator7 = _createForOfIteratorHelper(data);
|
|
1236
|
-
|
|
1352
|
+
_context12.prev = 21;
|
|
1237
1353
|
_loop2 = /*#__PURE__*/_regenerator.default.mark(function _loop2() {
|
|
1238
1354
|
var block, error;
|
|
1239
|
-
return _regenerator.default.wrap(function _loop2$(
|
|
1240
|
-
while (1) switch (
|
|
1355
|
+
return _regenerator.default.wrap(function _loop2$(_context11) {
|
|
1356
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1241
1357
|
case 0:
|
|
1242
1358
|
block = _step7.value;
|
|
1243
1359
|
error = errorResourceIds.get(block.resourceId);
|
|
@@ -1266,72 +1382,72 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
1266
1382
|
}
|
|
1267
1383
|
case 3:
|
|
1268
1384
|
case "end":
|
|
1269
|
-
return
|
|
1385
|
+
return _context11.stop();
|
|
1270
1386
|
}
|
|
1271
1387
|
}, _loop2);
|
|
1272
1388
|
});
|
|
1273
1389
|
_iterator7.s();
|
|
1274
1390
|
case 24:
|
|
1275
1391
|
if ((_step7 = _iterator7.n()).done) {
|
|
1276
|
-
|
|
1392
|
+
_context12.next = 28;
|
|
1277
1393
|
break;
|
|
1278
1394
|
}
|
|
1279
|
-
return
|
|
1395
|
+
return _context12.delegateYield(_loop2(), "t1", 26);
|
|
1280
1396
|
case 26:
|
|
1281
|
-
|
|
1397
|
+
_context12.next = 24;
|
|
1282
1398
|
break;
|
|
1283
1399
|
case 28:
|
|
1284
|
-
|
|
1400
|
+
_context12.next = 33;
|
|
1285
1401
|
break;
|
|
1286
1402
|
case 30:
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
_iterator7.e(
|
|
1403
|
+
_context12.prev = 30;
|
|
1404
|
+
_context12.t2 = _context12["catch"](21);
|
|
1405
|
+
_iterator7.e(_context12.t2);
|
|
1290
1406
|
case 33:
|
|
1291
|
-
|
|
1407
|
+
_context12.prev = 33;
|
|
1292
1408
|
_iterator7.f();
|
|
1293
|
-
return
|
|
1409
|
+
return _context12.finish(33);
|
|
1294
1410
|
case 36:
|
|
1295
|
-
return
|
|
1411
|
+
return _context12.abrupt("return", results);
|
|
1296
1412
|
case 39:
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
if (!(
|
|
1300
|
-
|
|
1413
|
+
_context12.prev = 39;
|
|
1414
|
+
_context12.t3 = _context12["catch"](10);
|
|
1415
|
+
if (!(_context12.t3 instanceof _blockService.BlockError)) {
|
|
1416
|
+
_context12.next = 43;
|
|
1301
1417
|
break;
|
|
1302
1418
|
}
|
|
1303
|
-
return
|
|
1419
|
+
return _context12.abrupt("return", data.map(function (block) {
|
|
1304
1420
|
return {
|
|
1305
|
-
error: mapBlockError(
|
|
1421
|
+
error: mapBlockError(_context12.t3),
|
|
1306
1422
|
resourceId: block.resourceId
|
|
1307
1423
|
};
|
|
1308
1424
|
}));
|
|
1309
1425
|
case 43:
|
|
1310
|
-
return
|
|
1426
|
+
return _context12.abrupt("return", data.map(function (block) {
|
|
1311
1427
|
return {
|
|
1312
|
-
error: (0, _errorHandling.stringifyError)(
|
|
1428
|
+
error: (0, _errorHandling.stringifyError)(_context12.t3),
|
|
1313
1429
|
resourceId: block.resourceId
|
|
1314
1430
|
};
|
|
1315
1431
|
}));
|
|
1316
1432
|
case 44:
|
|
1317
1433
|
case "end":
|
|
1318
|
-
return
|
|
1434
|
+
return _context12.stop();
|
|
1319
1435
|
}
|
|
1320
|
-
},
|
|
1436
|
+
}, _callee10, this, [[10, 39], [21, 30, 33, 36]]);
|
|
1321
1437
|
}));
|
|
1322
|
-
function writeDataBatch(
|
|
1438
|
+
function writeDataBatch(_x21) {
|
|
1323
1439
|
return _writeDataBatch.apply(this, arguments);
|
|
1324
1440
|
}
|
|
1325
1441
|
return writeDataBatch;
|
|
1326
1442
|
}()
|
|
1327
1443
|
}]);
|
|
1328
1444
|
}();
|
|
1329
|
-
var createBlockServiceAPIProviders = function createBlockServiceAPIProviders(
|
|
1330
|
-
var cloudId =
|
|
1331
|
-
parentAri =
|
|
1332
|
-
parentId =
|
|
1333
|
-
product =
|
|
1334
|
-
getVersion =
|
|
1445
|
+
var createBlockServiceAPIProviders = function createBlockServiceAPIProviders(_ref8) {
|
|
1446
|
+
var cloudId = _ref8.cloudId,
|
|
1447
|
+
parentAri = _ref8.parentAri,
|
|
1448
|
+
parentId = _ref8.parentId,
|
|
1449
|
+
product = _ref8.product,
|
|
1450
|
+
getVersion = _ref8.getVersion;
|
|
1335
1451
|
return {
|
|
1336
1452
|
fetchProvider: new BlockServiceADFFetchProvider({
|
|
1337
1453
|
cloudId: cloudId,
|
|
@@ -1346,12 +1462,12 @@ var createBlockServiceAPIProviders = function createBlockServiceAPIProviders(_re
|
|
|
1346
1462
|
})
|
|
1347
1463
|
};
|
|
1348
1464
|
};
|
|
1349
|
-
var useMemoizedBlockServiceAPIProviders = exports.useMemoizedBlockServiceAPIProviders = function useMemoizedBlockServiceAPIProviders(
|
|
1350
|
-
var cloudId =
|
|
1351
|
-
parentAri =
|
|
1352
|
-
parentId =
|
|
1353
|
-
product =
|
|
1354
|
-
getVersion =
|
|
1465
|
+
var useMemoizedBlockServiceAPIProviders = exports.useMemoizedBlockServiceAPIProviders = function useMemoizedBlockServiceAPIProviders(_ref9) {
|
|
1466
|
+
var cloudId = _ref9.cloudId,
|
|
1467
|
+
parentAri = _ref9.parentAri,
|
|
1468
|
+
parentId = _ref9.parentId,
|
|
1469
|
+
product = _ref9.product,
|
|
1470
|
+
getVersion = _ref9.getVersion;
|
|
1355
1471
|
return (0, _react.useMemo)(function () {
|
|
1356
1472
|
return createBlockServiceAPIProviders({
|
|
1357
1473
|
cloudId: cloudId,
|
|
@@ -1362,9 +1478,9 @@ var useMemoizedBlockServiceAPIProviders = exports.useMemoizedBlockServiceAPIProv
|
|
|
1362
1478
|
});
|
|
1363
1479
|
}, [cloudId, parentAri, parentId, product, getVersion]);
|
|
1364
1480
|
};
|
|
1365
|
-
var createBlockServiceFetchOnlyAPIProvider = function createBlockServiceFetchOnlyAPIProvider(
|
|
1366
|
-
var cloudId =
|
|
1367
|
-
parentAri =
|
|
1481
|
+
var createBlockServiceFetchOnlyAPIProvider = function createBlockServiceFetchOnlyAPIProvider(_ref0) {
|
|
1482
|
+
var cloudId = _ref0.cloudId,
|
|
1483
|
+
parentAri = _ref0.parentAri;
|
|
1368
1484
|
return {
|
|
1369
1485
|
fetchProvider: new BlockServiceADFFetchProvider({
|
|
1370
1486
|
cloudId: cloudId,
|
|
@@ -1377,9 +1493,9 @@ var createBlockServiceFetchOnlyAPIProvider = function createBlockServiceFetchOnl
|
|
|
1377
1493
|
/**
|
|
1378
1494
|
* If the parentAri is not a valid ARI, pass in an empty string.
|
|
1379
1495
|
*/
|
|
1380
|
-
var useMemoizedBlockServiceFetchOnlyAPIProvider = exports.useMemoizedBlockServiceFetchOnlyAPIProvider = function useMemoizedBlockServiceFetchOnlyAPIProvider(
|
|
1381
|
-
var cloudId =
|
|
1382
|
-
parentAri =
|
|
1496
|
+
var useMemoizedBlockServiceFetchOnlyAPIProvider = exports.useMemoizedBlockServiceFetchOnlyAPIProvider = function useMemoizedBlockServiceFetchOnlyAPIProvider(_ref1) {
|
|
1497
|
+
var cloudId = _ref1.cloudId,
|
|
1498
|
+
parentAri = _ref1.parentAri;
|
|
1383
1499
|
return (0, _react.useMemo)(function () {
|
|
1384
1500
|
return createBlockServiceFetchOnlyAPIProvider({
|
|
1385
1501
|
cloudId: cloudId,
|
|
@@ -83,14 +83,31 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
83
83
|
if (!localId || !resourceId) {
|
|
84
84
|
throw new Error('Local ID or resource ID is not set');
|
|
85
85
|
}
|
|
86
|
-
var syncBlockData = (0, _utils.convertSyncBlockPMNodeToSyncBlockData)(syncBlockNode);
|
|
87
86
|
var cachedBlock = this.syncBlockCache.get(resourceId);
|
|
88
|
-
if (
|
|
89
|
-
|
|
87
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_update_refactor')) {
|
|
88
|
+
var _cachedBlock$contentF;
|
|
89
|
+
// Fast path: if the PM content fragment hasn't changed, skip serialization entirely
|
|
90
|
+
// Fragment.eq() leverages ProseMirror's structural sharing for O(1) comparison
|
|
91
|
+
if (cachedBlock !== null && cachedBlock !== void 0 && (_cachedBlock$contentF = cachedBlock.contentFragment) !== null && _cachedBlock$contentF !== void 0 && _cachedBlock$contentF.eq(syncBlockNode.content)) {
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
var syncBlockData = (0, _utils.convertSyncBlockPMNodeToSyncBlockData)(syncBlockNode);
|
|
95
|
+
if (cachedBlock) {
|
|
96
|
+
this.hasReceivedContentChange = true;
|
|
97
|
+
}
|
|
98
|
+
this.syncBlockCache.set(resourceId, _objectSpread(_objectSpread({}, syncBlockData), {}, {
|
|
99
|
+
isDirty: true,
|
|
100
|
+
contentFragment: syncBlockNode.content
|
|
101
|
+
}));
|
|
102
|
+
} else {
|
|
103
|
+
var _syncBlockData = (0, _utils.convertSyncBlockPMNodeToSyncBlockData)(syncBlockNode);
|
|
104
|
+
if (cachedBlock && !(0, _isEqual.default)(_syncBlockData.content, cachedBlock.content)) {
|
|
105
|
+
this.hasReceivedContentChange = true;
|
|
106
|
+
}
|
|
107
|
+
this.syncBlockCache.set(resourceId, _objectSpread(_objectSpread({}, _syncBlockData), {}, {
|
|
108
|
+
isDirty: true
|
|
109
|
+
}));
|
|
90
110
|
}
|
|
91
|
-
this.syncBlockCache.set(resourceId, _objectSpread(_objectSpread({}, syncBlockData), {}, {
|
|
92
|
-
isDirty: true
|
|
93
|
-
}));
|
|
94
111
|
return true;
|
|
95
112
|
} catch (error) {
|
|
96
113
|
var _this$fireAnalyticsEv;
|
|
@@ -298,6 +298,18 @@ export class BlockError extends Error {
|
|
|
298
298
|
this.status = status;
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Thrown when Block Service returns RESOURCE_NOT_FOUND for a block.
|
|
304
|
+
* This typically happens when an orphan block (e.g. from a copied page) is deleted.
|
|
305
|
+
* The caller should create the block first, then delete it to ensure a proper soft-delete record.
|
|
306
|
+
*/
|
|
307
|
+
export class BlockNotFoundError extends Error {
|
|
308
|
+
constructor() {
|
|
309
|
+
super('Block not found in Block Service');
|
|
310
|
+
this.name = 'BlockNotFoundError';
|
|
311
|
+
}
|
|
312
|
+
}
|
|
301
313
|
export class BlockTimeoutError extends Error {
|
|
302
314
|
constructor() {
|
|
303
315
|
super('Block request timed out');
|
|
@@ -404,10 +416,10 @@ export const deleteSyncedBlock = async ({
|
|
|
404
416
|
return ((_e$extensions = e.extensions) === null || _e$extensions === void 0 ? void 0 : _e$extensions.errorType) === 'RESOURCE_NOT_FOUND';
|
|
405
417
|
});
|
|
406
418
|
if (allNotFound) {
|
|
407
|
-
//
|
|
408
|
-
//
|
|
409
|
-
//
|
|
410
|
-
|
|
419
|
+
// Throw BlockNotFoundError so the caller can create the block first then retry the delete.
|
|
420
|
+
// Block Service uses soft-deletes: the entry must exist before deletion so a deletion-reason
|
|
421
|
+
// is stored (used to display errors in reference blocks).
|
|
422
|
+
throw new BlockNotFoundError();
|
|
411
423
|
}
|
|
412
424
|
}
|
|
413
425
|
throw new Error(result.errors.map(e => e.message).join(', '));
|