@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
|
@@ -3,7 +3,7 @@ import { useMemo } from 'react';
|
|
|
3
3
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
4
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
5
|
import { generateBlockAri, generateBlockAriFromReference } from '../../clients/block-service/ari';
|
|
6
|
-
import { batchRetrieveSyncedBlocks, BlockError, BlockTimeoutError, createSyncedBlock, deleteSyncedBlock, getReferenceSyncedBlocks, getReferenceSyncedBlocksByBlockAri, getSyncedBlockContent, updateReferenceSyncedBlockOnDocument, updateSyncedBlock, updateSyncedBlocks } from '../../clients/block-service/blockService';
|
|
6
|
+
import { batchRetrieveSyncedBlocks, BlockError, BlockNotFoundError, BlockTimeoutError, createSyncedBlock, deleteSyncedBlock, getReferenceSyncedBlocks, getReferenceSyncedBlocksByBlockAri, getSyncedBlockContent, updateReferenceSyncedBlockOnDocument, updateSyncedBlock, updateSyncedBlocks } from '../../clients/block-service/blockService';
|
|
7
7
|
import { subscribeToBlockUpdates as subscribeToBlockUpdatesWS } from '../../clients/block-service/blockSubscription';
|
|
8
8
|
import { SyncBlockError } from '../../common/types';
|
|
9
9
|
import { stringifyError } from '../../utils/errorHandling';
|
|
@@ -686,6 +686,14 @@ class BlockServiceADFWriteProvider {
|
|
|
686
686
|
error: undefined
|
|
687
687
|
};
|
|
688
688
|
} catch (error) {
|
|
689
|
+
if (error instanceof BlockNotFoundError && this.parentAri && fg('platform_synced_block_patch_8')) {
|
|
690
|
+
return this.deleteOrphanBlock({
|
|
691
|
+
blockAri,
|
|
692
|
+
resourceId,
|
|
693
|
+
parentAri: this.parentAri,
|
|
694
|
+
deleteReason
|
|
695
|
+
});
|
|
696
|
+
}
|
|
689
697
|
if (error instanceof BlockError) {
|
|
690
698
|
if (error.status === 404) {
|
|
691
699
|
// User should not be blocked by not_found error when deleting,
|
|
@@ -709,6 +717,71 @@ class BlockServiceADFWriteProvider {
|
|
|
709
717
|
}
|
|
710
718
|
}
|
|
711
719
|
|
|
720
|
+
// The block is an orphan (e.g. from a copied page) — it doesn't exist in Block Service.
|
|
721
|
+
// Block Service uses soft-deletes, so we must first create the block then delete it,
|
|
722
|
+
// ensuring a deletion-reason record is stored (used to display errors in reference blocks).
|
|
723
|
+
async deleteOrphanBlock({
|
|
724
|
+
blockAri,
|
|
725
|
+
resourceId,
|
|
726
|
+
parentAri,
|
|
727
|
+
deleteReason
|
|
728
|
+
}) {
|
|
729
|
+
try {
|
|
730
|
+
const stepVersion = this.getVersion ? await this.getVersion() : undefined;
|
|
731
|
+
try {
|
|
732
|
+
await createSyncedBlock({
|
|
733
|
+
blockAri,
|
|
734
|
+
blockInstanceId: resourceId,
|
|
735
|
+
sourceAri: parentAri,
|
|
736
|
+
product: this.product,
|
|
737
|
+
content: '[]',
|
|
738
|
+
stepVersion
|
|
739
|
+
});
|
|
740
|
+
} catch (createError) {
|
|
741
|
+
// "Conditional check failed" means the block already exists in Block Service.
|
|
742
|
+
// This can happen when an orphan block is copied and pasted — a reference block repair
|
|
743
|
+
// in the backend may have already created it. We can proceed directly to delete it.
|
|
744
|
+
if (createError instanceof Error && createError.message.includes('Conditional check failed')) {
|
|
745
|
+
// block already exists, proceed to delete
|
|
746
|
+
} else if (createError instanceof BlockError) {
|
|
747
|
+
return {
|
|
748
|
+
resourceId,
|
|
749
|
+
success: false,
|
|
750
|
+
error: mapBlockError(createError)
|
|
751
|
+
};
|
|
752
|
+
} else {
|
|
753
|
+
return {
|
|
754
|
+
resourceId,
|
|
755
|
+
success: false,
|
|
756
|
+
error: stringifyError(createError)
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
await deleteSyncedBlock({
|
|
761
|
+
blockAri,
|
|
762
|
+
deleteReason
|
|
763
|
+
});
|
|
764
|
+
return {
|
|
765
|
+
resourceId,
|
|
766
|
+
success: true,
|
|
767
|
+
error: undefined
|
|
768
|
+
};
|
|
769
|
+
} catch (error) {
|
|
770
|
+
if (error instanceof BlockError) {
|
|
771
|
+
return {
|
|
772
|
+
resourceId,
|
|
773
|
+
success: false,
|
|
774
|
+
error: mapBlockError(error)
|
|
775
|
+
};
|
|
776
|
+
}
|
|
777
|
+
return {
|
|
778
|
+
resourceId,
|
|
779
|
+
success: false,
|
|
780
|
+
error: stringifyError(error)
|
|
781
|
+
};
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
|
|
712
785
|
// the sourceId is the resourceId of the source synced block.
|
|
713
786
|
generateResourceIdForReference(sourceId) {
|
|
714
787
|
return createResourceIdForReference(this.product, this.parentId || '', sourceId);
|
|
@@ -61,15 +61,33 @@ export class SourceSyncBlockStoreManager {
|
|
|
61
61
|
if (!localId || !resourceId) {
|
|
62
62
|
throw new Error('Local ID or resource ID is not set');
|
|
63
63
|
}
|
|
64
|
-
const syncBlockData = convertSyncBlockPMNodeToSyncBlockData(syncBlockNode);
|
|
65
64
|
const cachedBlock = this.syncBlockCache.get(resourceId);
|
|
66
|
-
if (
|
|
67
|
-
|
|
65
|
+
if (fg('platform_synced_block_update_refactor')) {
|
|
66
|
+
var _cachedBlock$contentF;
|
|
67
|
+
// Fast path: if the PM content fragment hasn't changed, skip serialization entirely
|
|
68
|
+
// Fragment.eq() leverages ProseMirror's structural sharing for O(1) comparison
|
|
69
|
+
if (cachedBlock !== null && cachedBlock !== void 0 && (_cachedBlock$contentF = cachedBlock.contentFragment) !== null && _cachedBlock$contentF !== void 0 && _cachedBlock$contentF.eq(syncBlockNode.content)) {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
const syncBlockData = convertSyncBlockPMNodeToSyncBlockData(syncBlockNode);
|
|
73
|
+
if (cachedBlock) {
|
|
74
|
+
this.hasReceivedContentChange = true;
|
|
75
|
+
}
|
|
76
|
+
this.syncBlockCache.set(resourceId, {
|
|
77
|
+
...syncBlockData,
|
|
78
|
+
isDirty: true,
|
|
79
|
+
contentFragment: syncBlockNode.content
|
|
80
|
+
});
|
|
81
|
+
} else {
|
|
82
|
+
const syncBlockData = convertSyncBlockPMNodeToSyncBlockData(syncBlockNode);
|
|
83
|
+
if (cachedBlock && !isEqual(syncBlockData.content, cachedBlock.content)) {
|
|
84
|
+
this.hasReceivedContentChange = true;
|
|
85
|
+
}
|
|
86
|
+
this.syncBlockCache.set(resourceId, {
|
|
87
|
+
...syncBlockData,
|
|
88
|
+
isDirty: true
|
|
89
|
+
});
|
|
68
90
|
}
|
|
69
|
-
this.syncBlockCache.set(resourceId, {
|
|
70
|
-
...syncBlockData,
|
|
71
|
-
isDirty: true
|
|
72
|
-
});
|
|
73
91
|
return true;
|
|
74
92
|
} catch (error) {
|
|
75
93
|
var _this$fireAnalyticsEv;
|
|
@@ -219,15 +219,32 @@ export var BlockError = /*#__PURE__*/function (_Error) {
|
|
|
219
219
|
_inherits(BlockError, _Error);
|
|
220
220
|
return _createClass(BlockError);
|
|
221
221
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
222
|
-
|
|
223
|
-
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Thrown when Block Service returns RESOURCE_NOT_FOUND for a block.
|
|
225
|
+
* This typically happens when an orphan block (e.g. from a copied page) is deleted.
|
|
226
|
+
* The caller should create the block first, then delete it to ensure a proper soft-delete record.
|
|
227
|
+
*/
|
|
228
|
+
export var BlockNotFoundError = /*#__PURE__*/function (_Error2) {
|
|
229
|
+
function BlockNotFoundError() {
|
|
224
230
|
var _this2;
|
|
225
|
-
_classCallCheck(this,
|
|
226
|
-
_this2 = _callSuper(this,
|
|
227
|
-
_this2.name = '
|
|
231
|
+
_classCallCheck(this, BlockNotFoundError);
|
|
232
|
+
_this2 = _callSuper(this, BlockNotFoundError, ['Block not found in Block Service']);
|
|
233
|
+
_this2.name = 'BlockNotFoundError';
|
|
228
234
|
return _this2;
|
|
229
235
|
}
|
|
230
|
-
_inherits(
|
|
236
|
+
_inherits(BlockNotFoundError, _Error2);
|
|
237
|
+
return _createClass(BlockNotFoundError);
|
|
238
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
239
|
+
export var BlockTimeoutError = /*#__PURE__*/function (_Error3) {
|
|
240
|
+
function BlockTimeoutError() {
|
|
241
|
+
var _this3;
|
|
242
|
+
_classCallCheck(this, BlockTimeoutError);
|
|
243
|
+
_this3 = _callSuper(this, BlockTimeoutError, ['Block request timed out']);
|
|
244
|
+
_this3.name = 'BlockTimeoutError';
|
|
245
|
+
return _this3;
|
|
246
|
+
}
|
|
247
|
+
_inherits(BlockTimeoutError, _Error3);
|
|
231
248
|
return _createClass(BlockTimeoutError);
|
|
232
249
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
233
250
|
export var getSyncedBlockContent = /*#__PURE__*/function () {
|
|
@@ -413,7 +430,7 @@ export var deleteSyncedBlock = /*#__PURE__*/function () {
|
|
|
413
430
|
_context4.next = 16;
|
|
414
431
|
break;
|
|
415
432
|
}
|
|
416
|
-
|
|
433
|
+
throw new BlockNotFoundError();
|
|
417
434
|
case 16:
|
|
418
435
|
throw new Error(result.errors.map(function (e) {
|
|
419
436
|
return e.message;
|
|
@@ -14,7 +14,7 @@ import { useMemo } from 'react';
|
|
|
14
14
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
15
15
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
16
16
|
import { generateBlockAri as _generateBlockAri, generateBlockAriFromReference } from '../../clients/block-service/ari';
|
|
17
|
-
import { batchRetrieveSyncedBlocks, BlockError, BlockTimeoutError, createSyncedBlock, deleteSyncedBlock, getReferenceSyncedBlocks, getReferenceSyncedBlocksByBlockAri, getSyncedBlockContent, updateReferenceSyncedBlockOnDocument, updateSyncedBlock, updateSyncedBlocks } from '../../clients/block-service/blockService';
|
|
17
|
+
import { batchRetrieveSyncedBlocks, BlockError, BlockNotFoundError, BlockTimeoutError, createSyncedBlock, deleteSyncedBlock, getReferenceSyncedBlocks, getReferenceSyncedBlocksByBlockAri, getSyncedBlockContent, updateReferenceSyncedBlockOnDocument, updateSyncedBlock, updateSyncedBlocks } from '../../clients/block-service/blockService';
|
|
18
18
|
import { subscribeToBlockUpdates as subscribeToBlockUpdatesWS } from '../../clients/block-service/blockSubscription';
|
|
19
19
|
import { SyncBlockError } from '../../common/types';
|
|
20
20
|
import { stringifyError } from '../../utils/errorHandling';
|
|
@@ -1026,31 +1026,42 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
1026
1026
|
case 9:
|
|
1027
1027
|
_context0.prev = 9;
|
|
1028
1028
|
_context0.t0 = _context0["catch"](3);
|
|
1029
|
+
if (!(_context0.t0 instanceof BlockNotFoundError && this.parentAri && fg('platform_synced_block_patch_8'))) {
|
|
1030
|
+
_context0.next = 13;
|
|
1031
|
+
break;
|
|
1032
|
+
}
|
|
1033
|
+
return _context0.abrupt("return", this.deleteOrphanBlock({
|
|
1034
|
+
blockAri: blockAri,
|
|
1035
|
+
resourceId: resourceId,
|
|
1036
|
+
parentAri: this.parentAri,
|
|
1037
|
+
deleteReason: deleteReason
|
|
1038
|
+
}));
|
|
1039
|
+
case 13:
|
|
1029
1040
|
if (!(_context0.t0 instanceof BlockError)) {
|
|
1030
|
-
_context0.next =
|
|
1041
|
+
_context0.next = 17;
|
|
1031
1042
|
break;
|
|
1032
1043
|
}
|
|
1033
1044
|
if (!(_context0.t0.status === 404)) {
|
|
1034
|
-
_context0.next =
|
|
1045
|
+
_context0.next = 16;
|
|
1035
1046
|
break;
|
|
1036
1047
|
}
|
|
1037
1048
|
return _context0.abrupt("return", {
|
|
1038
1049
|
resourceId: resourceId,
|
|
1039
1050
|
success: true
|
|
1040
1051
|
});
|
|
1041
|
-
case
|
|
1052
|
+
case 16:
|
|
1042
1053
|
return _context0.abrupt("return", {
|
|
1043
1054
|
resourceId: resourceId,
|
|
1044
1055
|
success: false,
|
|
1045
1056
|
error: mapBlockError(_context0.t0)
|
|
1046
1057
|
});
|
|
1047
|
-
case
|
|
1058
|
+
case 17:
|
|
1048
1059
|
return _context0.abrupt("return", {
|
|
1049
1060
|
resourceId: resourceId,
|
|
1050
1061
|
success: false,
|
|
1051
1062
|
error: stringifyError(_context0.t0)
|
|
1052
1063
|
});
|
|
1053
|
-
case
|
|
1064
|
+
case 18:
|
|
1054
1065
|
case "end":
|
|
1055
1066
|
return _context0.stop();
|
|
1056
1067
|
}
|
|
@@ -1060,6 +1071,111 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
1060
1071
|
return _deleteData.apply(this, arguments);
|
|
1061
1072
|
}
|
|
1062
1073
|
return deleteData;
|
|
1074
|
+
}() // The block is an orphan (e.g. from a copied page) — it doesn't exist in Block Service.
|
|
1075
|
+
// Block Service uses soft-deletes, so we must first create the block then delete it,
|
|
1076
|
+
// ensuring a deletion-reason record is stored (used to display errors in reference blocks).
|
|
1077
|
+
}, {
|
|
1078
|
+
key: "deleteOrphanBlock",
|
|
1079
|
+
value: function () {
|
|
1080
|
+
var _deleteOrphanBlock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee0(_ref7) {
|
|
1081
|
+
var blockAri, resourceId, parentAri, deleteReason, stepVersion;
|
|
1082
|
+
return _regeneratorRuntime.wrap(function _callee0$(_context1) {
|
|
1083
|
+
while (1) switch (_context1.prev = _context1.next) {
|
|
1084
|
+
case 0:
|
|
1085
|
+
blockAri = _ref7.blockAri, resourceId = _ref7.resourceId, parentAri = _ref7.parentAri, deleteReason = _ref7.deleteReason;
|
|
1086
|
+
_context1.prev = 1;
|
|
1087
|
+
if (!this.getVersion) {
|
|
1088
|
+
_context1.next = 8;
|
|
1089
|
+
break;
|
|
1090
|
+
}
|
|
1091
|
+
_context1.next = 5;
|
|
1092
|
+
return this.getVersion();
|
|
1093
|
+
case 5:
|
|
1094
|
+
_context1.t0 = _context1.sent;
|
|
1095
|
+
_context1.next = 9;
|
|
1096
|
+
break;
|
|
1097
|
+
case 8:
|
|
1098
|
+
_context1.t0 = undefined;
|
|
1099
|
+
case 9:
|
|
1100
|
+
stepVersion = _context1.t0;
|
|
1101
|
+
_context1.prev = 10;
|
|
1102
|
+
_context1.next = 13;
|
|
1103
|
+
return createSyncedBlock({
|
|
1104
|
+
blockAri: blockAri,
|
|
1105
|
+
blockInstanceId: resourceId,
|
|
1106
|
+
sourceAri: parentAri,
|
|
1107
|
+
product: this.product,
|
|
1108
|
+
content: '[]',
|
|
1109
|
+
stepVersion: stepVersion
|
|
1110
|
+
});
|
|
1111
|
+
case 13:
|
|
1112
|
+
_context1.next = 25;
|
|
1113
|
+
break;
|
|
1114
|
+
case 15:
|
|
1115
|
+
_context1.prev = 15;
|
|
1116
|
+
_context1.t1 = _context1["catch"](10);
|
|
1117
|
+
if (!(_context1.t1 instanceof Error && _context1.t1.message.includes('Conditional check failed'))) {
|
|
1118
|
+
_context1.next = 20;
|
|
1119
|
+
break;
|
|
1120
|
+
}
|
|
1121
|
+
_context1.next = 25;
|
|
1122
|
+
break;
|
|
1123
|
+
case 20:
|
|
1124
|
+
if (!(_context1.t1 instanceof BlockError)) {
|
|
1125
|
+
_context1.next = 24;
|
|
1126
|
+
break;
|
|
1127
|
+
}
|
|
1128
|
+
return _context1.abrupt("return", {
|
|
1129
|
+
resourceId: resourceId,
|
|
1130
|
+
success: false,
|
|
1131
|
+
error: mapBlockError(_context1.t1)
|
|
1132
|
+
});
|
|
1133
|
+
case 24:
|
|
1134
|
+
return _context1.abrupt("return", {
|
|
1135
|
+
resourceId: resourceId,
|
|
1136
|
+
success: false,
|
|
1137
|
+
error: stringifyError(_context1.t1)
|
|
1138
|
+
});
|
|
1139
|
+
case 25:
|
|
1140
|
+
_context1.next = 27;
|
|
1141
|
+
return deleteSyncedBlock({
|
|
1142
|
+
blockAri: blockAri,
|
|
1143
|
+
deleteReason: deleteReason
|
|
1144
|
+
});
|
|
1145
|
+
case 27:
|
|
1146
|
+
return _context1.abrupt("return", {
|
|
1147
|
+
resourceId: resourceId,
|
|
1148
|
+
success: true,
|
|
1149
|
+
error: undefined
|
|
1150
|
+
});
|
|
1151
|
+
case 30:
|
|
1152
|
+
_context1.prev = 30;
|
|
1153
|
+
_context1.t2 = _context1["catch"](1);
|
|
1154
|
+
if (!(_context1.t2 instanceof BlockError)) {
|
|
1155
|
+
_context1.next = 34;
|
|
1156
|
+
break;
|
|
1157
|
+
}
|
|
1158
|
+
return _context1.abrupt("return", {
|
|
1159
|
+
resourceId: resourceId,
|
|
1160
|
+
success: false,
|
|
1161
|
+
error: mapBlockError(_context1.t2)
|
|
1162
|
+
});
|
|
1163
|
+
case 34:
|
|
1164
|
+
return _context1.abrupt("return", {
|
|
1165
|
+
resourceId: resourceId,
|
|
1166
|
+
success: false,
|
|
1167
|
+
error: stringifyError(_context1.t2)
|
|
1168
|
+
});
|
|
1169
|
+
case 35:
|
|
1170
|
+
case "end":
|
|
1171
|
+
return _context1.stop();
|
|
1172
|
+
}
|
|
1173
|
+
}, _callee0, this, [[1, 30], [10, 15]]);
|
|
1174
|
+
}));
|
|
1175
|
+
function deleteOrphanBlock(_x18) {
|
|
1176
|
+
return _deleteOrphanBlock.apply(this, arguments);
|
|
1177
|
+
}
|
|
1178
|
+
return deleteOrphanBlock;
|
|
1063
1179
|
}() // the sourceId is the resourceId of the source synced block.
|
|
1064
1180
|
}, {
|
|
1065
1181
|
key: "generateResourceIdForReference",
|
|
@@ -1084,22 +1200,22 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
1084
1200
|
}, {
|
|
1085
1201
|
key: "updateReferenceData",
|
|
1086
1202
|
value: function () {
|
|
1087
|
-
var _updateReferenceData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1203
|
+
var _updateReferenceData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee1(blocks, noContent) {
|
|
1088
1204
|
var _this2 = this;
|
|
1089
|
-
return _regeneratorRuntime.wrap(function
|
|
1090
|
-
while (1) switch (
|
|
1205
|
+
return _regeneratorRuntime.wrap(function _callee1$(_context10) {
|
|
1206
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
1091
1207
|
case 0:
|
|
1092
1208
|
if (this.parentAri) {
|
|
1093
|
-
|
|
1209
|
+
_context10.next = 2;
|
|
1094
1210
|
break;
|
|
1095
1211
|
}
|
|
1096
|
-
return
|
|
1212
|
+
return _context10.abrupt("return", {
|
|
1097
1213
|
success: false,
|
|
1098
1214
|
error: SyncBlockError.Errored
|
|
1099
1215
|
});
|
|
1100
1216
|
case 2:
|
|
1101
|
-
|
|
1102
|
-
|
|
1217
|
+
_context10.prev = 2;
|
|
1218
|
+
_context10.next = 5;
|
|
1103
1219
|
return updateReferenceSyncedBlockOnDocument({
|
|
1104
1220
|
documentAri: this.parentAri,
|
|
1105
1221
|
blocks: blocks.map(function (block) {
|
|
@@ -1114,32 +1230,32 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
1114
1230
|
noContent: noContent
|
|
1115
1231
|
});
|
|
1116
1232
|
case 5:
|
|
1117
|
-
return
|
|
1233
|
+
return _context10.abrupt("return", {
|
|
1118
1234
|
success: true
|
|
1119
1235
|
});
|
|
1120
1236
|
case 8:
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
if (!(
|
|
1124
|
-
|
|
1237
|
+
_context10.prev = 8;
|
|
1238
|
+
_context10.t0 = _context10["catch"](2);
|
|
1239
|
+
if (!(_context10.t0 instanceof BlockError)) {
|
|
1240
|
+
_context10.next = 12;
|
|
1125
1241
|
break;
|
|
1126
1242
|
}
|
|
1127
|
-
return
|
|
1243
|
+
return _context10.abrupt("return", {
|
|
1128
1244
|
success: false,
|
|
1129
|
-
error: mapBlockError(
|
|
1245
|
+
error: mapBlockError(_context10.t0)
|
|
1130
1246
|
});
|
|
1131
1247
|
case 12:
|
|
1132
|
-
return
|
|
1248
|
+
return _context10.abrupt("return", {
|
|
1133
1249
|
success: false,
|
|
1134
|
-
error: stringifyError(
|
|
1250
|
+
error: stringifyError(_context10.t0)
|
|
1135
1251
|
});
|
|
1136
1252
|
case 13:
|
|
1137
1253
|
case "end":
|
|
1138
|
-
return
|
|
1254
|
+
return _context10.stop();
|
|
1139
1255
|
}
|
|
1140
|
-
},
|
|
1256
|
+
}, _callee1, this, [[2, 8]]);
|
|
1141
1257
|
}));
|
|
1142
|
-
function updateReferenceData(
|
|
1258
|
+
function updateReferenceData(_x19, _x20) {
|
|
1143
1259
|
return _updateReferenceData.apply(this, arguments);
|
|
1144
1260
|
}
|
|
1145
1261
|
return updateReferenceData;
|
|
@@ -1147,17 +1263,17 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
1147
1263
|
}, {
|
|
1148
1264
|
key: "writeDataBatch",
|
|
1149
1265
|
value: function () {
|
|
1150
|
-
var _writeDataBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1266
|
+
var _writeDataBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(data) {
|
|
1151
1267
|
var _this3 = this;
|
|
1152
1268
|
var stepVersion, blockAriToResourceIdMap, blocks, response, results, successResourceIds, _iterator6, _step6, block, errorResourceIds, _iterator7, _step7, _loop2;
|
|
1153
|
-
return _regeneratorRuntime.wrap(function
|
|
1154
|
-
while (1) switch (
|
|
1269
|
+
return _regeneratorRuntime.wrap(function _callee10$(_context12) {
|
|
1270
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1155
1271
|
case 0:
|
|
1156
1272
|
if (!(!this.parentAri || !this.parentId)) {
|
|
1157
|
-
|
|
1273
|
+
_context12.next = 2;
|
|
1158
1274
|
break;
|
|
1159
1275
|
}
|
|
1160
|
-
return
|
|
1276
|
+
return _context12.abrupt("return", data.map(function (block) {
|
|
1161
1277
|
return {
|
|
1162
1278
|
error: SyncBlockError.Errored,
|
|
1163
1279
|
resourceId: block.resourceId
|
|
@@ -1165,20 +1281,20 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
1165
1281
|
}));
|
|
1166
1282
|
case 2:
|
|
1167
1283
|
if (!this.getVersion) {
|
|
1168
|
-
|
|
1284
|
+
_context12.next = 8;
|
|
1169
1285
|
break;
|
|
1170
1286
|
}
|
|
1171
|
-
|
|
1287
|
+
_context12.next = 5;
|
|
1172
1288
|
return this.getVersion();
|
|
1173
1289
|
case 5:
|
|
1174
|
-
|
|
1175
|
-
|
|
1290
|
+
_context12.t0 = _context12.sent;
|
|
1291
|
+
_context12.next = 9;
|
|
1176
1292
|
break;
|
|
1177
1293
|
case 8:
|
|
1178
|
-
|
|
1294
|
+
_context12.t0 = undefined;
|
|
1179
1295
|
case 9:
|
|
1180
|
-
stepVersion =
|
|
1181
|
-
|
|
1296
|
+
stepVersion = _context12.t0;
|
|
1297
|
+
_context12.prev = 10;
|
|
1182
1298
|
// Create a map from blockAri to original resourceId for matching responses
|
|
1183
1299
|
blockAriToResourceIdMap = new Map();
|
|
1184
1300
|
blocks = data.map(function (block) {
|
|
@@ -1191,12 +1307,12 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
1191
1307
|
stepVersion: stepVersion
|
|
1192
1308
|
};
|
|
1193
1309
|
});
|
|
1194
|
-
|
|
1310
|
+
_context12.next = 15;
|
|
1195
1311
|
return updateSyncedBlocks({
|
|
1196
1312
|
blocks: blocks
|
|
1197
1313
|
});
|
|
1198
1314
|
case 15:
|
|
1199
|
-
response =
|
|
1315
|
+
response = _context12.sent;
|
|
1200
1316
|
results = []; // Process successful updates
|
|
1201
1317
|
if (response.success) {
|
|
1202
1318
|
successResourceIds = new Set(response.success.map(function (block) {
|
|
@@ -1219,7 +1335,7 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
1219
1335
|
}
|
|
1220
1336
|
}
|
|
1221
1337
|
if (!response.error) {
|
|
1222
|
-
|
|
1338
|
+
_context12.next = 36;
|
|
1223
1339
|
break;
|
|
1224
1340
|
}
|
|
1225
1341
|
errorResourceIds = new Map(response.error.map(function (err) {
|
|
@@ -1228,11 +1344,11 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
1228
1344
|
blockAriToResourceIdMap.get(err.blockAri) || '', mapErrorResponseCode(err.code)];
|
|
1229
1345
|
}));
|
|
1230
1346
|
_iterator7 = _createForOfIteratorHelper(data);
|
|
1231
|
-
|
|
1347
|
+
_context12.prev = 21;
|
|
1232
1348
|
_loop2 = /*#__PURE__*/_regeneratorRuntime.mark(function _loop2() {
|
|
1233
1349
|
var block, error;
|
|
1234
|
-
return _regeneratorRuntime.wrap(function _loop2$(
|
|
1235
|
-
while (1) switch (
|
|
1350
|
+
return _regeneratorRuntime.wrap(function _loop2$(_context11) {
|
|
1351
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1236
1352
|
case 0:
|
|
1237
1353
|
block = _step7.value;
|
|
1238
1354
|
error = errorResourceIds.get(block.resourceId);
|
|
@@ -1261,72 +1377,72 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
1261
1377
|
}
|
|
1262
1378
|
case 3:
|
|
1263
1379
|
case "end":
|
|
1264
|
-
return
|
|
1380
|
+
return _context11.stop();
|
|
1265
1381
|
}
|
|
1266
1382
|
}, _loop2);
|
|
1267
1383
|
});
|
|
1268
1384
|
_iterator7.s();
|
|
1269
1385
|
case 24:
|
|
1270
1386
|
if ((_step7 = _iterator7.n()).done) {
|
|
1271
|
-
|
|
1387
|
+
_context12.next = 28;
|
|
1272
1388
|
break;
|
|
1273
1389
|
}
|
|
1274
|
-
return
|
|
1390
|
+
return _context12.delegateYield(_loop2(), "t1", 26);
|
|
1275
1391
|
case 26:
|
|
1276
|
-
|
|
1392
|
+
_context12.next = 24;
|
|
1277
1393
|
break;
|
|
1278
1394
|
case 28:
|
|
1279
|
-
|
|
1395
|
+
_context12.next = 33;
|
|
1280
1396
|
break;
|
|
1281
1397
|
case 30:
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
_iterator7.e(
|
|
1398
|
+
_context12.prev = 30;
|
|
1399
|
+
_context12.t2 = _context12["catch"](21);
|
|
1400
|
+
_iterator7.e(_context12.t2);
|
|
1285
1401
|
case 33:
|
|
1286
|
-
|
|
1402
|
+
_context12.prev = 33;
|
|
1287
1403
|
_iterator7.f();
|
|
1288
|
-
return
|
|
1404
|
+
return _context12.finish(33);
|
|
1289
1405
|
case 36:
|
|
1290
|
-
return
|
|
1406
|
+
return _context12.abrupt("return", results);
|
|
1291
1407
|
case 39:
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
if (!(
|
|
1295
|
-
|
|
1408
|
+
_context12.prev = 39;
|
|
1409
|
+
_context12.t3 = _context12["catch"](10);
|
|
1410
|
+
if (!(_context12.t3 instanceof BlockError)) {
|
|
1411
|
+
_context12.next = 43;
|
|
1296
1412
|
break;
|
|
1297
1413
|
}
|
|
1298
|
-
return
|
|
1414
|
+
return _context12.abrupt("return", data.map(function (block) {
|
|
1299
1415
|
return {
|
|
1300
|
-
error: mapBlockError(
|
|
1416
|
+
error: mapBlockError(_context12.t3),
|
|
1301
1417
|
resourceId: block.resourceId
|
|
1302
1418
|
};
|
|
1303
1419
|
}));
|
|
1304
1420
|
case 43:
|
|
1305
|
-
return
|
|
1421
|
+
return _context12.abrupt("return", data.map(function (block) {
|
|
1306
1422
|
return {
|
|
1307
|
-
error: stringifyError(
|
|
1423
|
+
error: stringifyError(_context12.t3),
|
|
1308
1424
|
resourceId: block.resourceId
|
|
1309
1425
|
};
|
|
1310
1426
|
}));
|
|
1311
1427
|
case 44:
|
|
1312
1428
|
case "end":
|
|
1313
|
-
return
|
|
1429
|
+
return _context12.stop();
|
|
1314
1430
|
}
|
|
1315
|
-
},
|
|
1431
|
+
}, _callee10, this, [[10, 39], [21, 30, 33, 36]]);
|
|
1316
1432
|
}));
|
|
1317
|
-
function writeDataBatch(
|
|
1433
|
+
function writeDataBatch(_x21) {
|
|
1318
1434
|
return _writeDataBatch.apply(this, arguments);
|
|
1319
1435
|
}
|
|
1320
1436
|
return writeDataBatch;
|
|
1321
1437
|
}()
|
|
1322
1438
|
}]);
|
|
1323
1439
|
}();
|
|
1324
|
-
var createBlockServiceAPIProviders = function createBlockServiceAPIProviders(
|
|
1325
|
-
var cloudId =
|
|
1326
|
-
parentAri =
|
|
1327
|
-
parentId =
|
|
1328
|
-
product =
|
|
1329
|
-
getVersion =
|
|
1440
|
+
var createBlockServiceAPIProviders = function createBlockServiceAPIProviders(_ref8) {
|
|
1441
|
+
var cloudId = _ref8.cloudId,
|
|
1442
|
+
parentAri = _ref8.parentAri,
|
|
1443
|
+
parentId = _ref8.parentId,
|
|
1444
|
+
product = _ref8.product,
|
|
1445
|
+
getVersion = _ref8.getVersion;
|
|
1330
1446
|
return {
|
|
1331
1447
|
fetchProvider: new BlockServiceADFFetchProvider({
|
|
1332
1448
|
cloudId: cloudId,
|
|
@@ -1341,12 +1457,12 @@ var createBlockServiceAPIProviders = function createBlockServiceAPIProviders(_re
|
|
|
1341
1457
|
})
|
|
1342
1458
|
};
|
|
1343
1459
|
};
|
|
1344
|
-
export var useMemoizedBlockServiceAPIProviders = function useMemoizedBlockServiceAPIProviders(
|
|
1345
|
-
var cloudId =
|
|
1346
|
-
parentAri =
|
|
1347
|
-
parentId =
|
|
1348
|
-
product =
|
|
1349
|
-
getVersion =
|
|
1460
|
+
export var useMemoizedBlockServiceAPIProviders = function useMemoizedBlockServiceAPIProviders(_ref9) {
|
|
1461
|
+
var cloudId = _ref9.cloudId,
|
|
1462
|
+
parentAri = _ref9.parentAri,
|
|
1463
|
+
parentId = _ref9.parentId,
|
|
1464
|
+
product = _ref9.product,
|
|
1465
|
+
getVersion = _ref9.getVersion;
|
|
1350
1466
|
return useMemo(function () {
|
|
1351
1467
|
return createBlockServiceAPIProviders({
|
|
1352
1468
|
cloudId: cloudId,
|
|
@@ -1357,9 +1473,9 @@ export var useMemoizedBlockServiceAPIProviders = function useMemoizedBlockServic
|
|
|
1357
1473
|
});
|
|
1358
1474
|
}, [cloudId, parentAri, parentId, product, getVersion]);
|
|
1359
1475
|
};
|
|
1360
|
-
var createBlockServiceFetchOnlyAPIProvider = function createBlockServiceFetchOnlyAPIProvider(
|
|
1361
|
-
var cloudId =
|
|
1362
|
-
parentAri =
|
|
1476
|
+
var createBlockServiceFetchOnlyAPIProvider = function createBlockServiceFetchOnlyAPIProvider(_ref0) {
|
|
1477
|
+
var cloudId = _ref0.cloudId,
|
|
1478
|
+
parentAri = _ref0.parentAri;
|
|
1363
1479
|
return {
|
|
1364
1480
|
fetchProvider: new BlockServiceADFFetchProvider({
|
|
1365
1481
|
cloudId: cloudId,
|
|
@@ -1372,9 +1488,9 @@ var createBlockServiceFetchOnlyAPIProvider = function createBlockServiceFetchOnl
|
|
|
1372
1488
|
/**
|
|
1373
1489
|
* If the parentAri is not a valid ARI, pass in an empty string.
|
|
1374
1490
|
*/
|
|
1375
|
-
export var useMemoizedBlockServiceFetchOnlyAPIProvider = function useMemoizedBlockServiceFetchOnlyAPIProvider(
|
|
1376
|
-
var cloudId =
|
|
1377
|
-
parentAri =
|
|
1491
|
+
export var useMemoizedBlockServiceFetchOnlyAPIProvider = function useMemoizedBlockServiceFetchOnlyAPIProvider(_ref1) {
|
|
1492
|
+
var cloudId = _ref1.cloudId,
|
|
1493
|
+
parentAri = _ref1.parentAri;
|
|
1378
1494
|
return useMemo(function () {
|
|
1379
1495
|
return createBlockServiceFetchOnlyAPIProvider({
|
|
1380
1496
|
cloudId: cloudId,
|