@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
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import isEqual from 'lodash/isEqual';
|
|
3
2
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
4
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
6
3
|
import { SyncBlockError } from '../common/types';
|
|
7
4
|
import { updateErrorPayload, createErrorPayload, deleteErrorPayload, updateCacheErrorPayload, getSourceInfoErrorPayload, updateSuccessPayload, createSuccessPayload, deleteSuccessPayload, fetchReferencesErrorPayload } from '../utils/errorHandling';
|
|
8
5
|
import { getCreateSourceExperience, getDeleteSourceExperience, getSaveSourceExperience, getFetchSourceInfoExperience } from '../utils/experienceTracking';
|
|
@@ -16,7 +13,7 @@ export class SourceSyncBlockStoreManager {
|
|
|
16
13
|
constructor(dataProvider, viewMode, isLivePage) {
|
|
17
14
|
_defineProperty(this, "hasReceivedContentChange", false);
|
|
18
15
|
_defineProperty(this, "setPendingDeletion", (Ids, value) => {
|
|
19
|
-
if (this.viewMode === 'view'
|
|
16
|
+
if (this.viewMode === 'view') {
|
|
20
17
|
return;
|
|
21
18
|
}
|
|
22
19
|
const syncBlock = this.syncBlockCache.get(Ids.resourceId);
|
|
@@ -56,7 +53,8 @@ export class SourceSyncBlockStoreManager {
|
|
|
56
53
|
*/
|
|
57
54
|
updateSyncBlockData(syncBlockNode, isRemote) {
|
|
58
55
|
try {
|
|
59
|
-
|
|
56
|
+
var _cachedBlock$contentF;
|
|
57
|
+
if (this.viewMode === 'view') {
|
|
60
58
|
return false;
|
|
61
59
|
}
|
|
62
60
|
if (!this.isSourceBlock(syncBlockNode)) {
|
|
@@ -70,40 +68,24 @@ export class SourceSyncBlockStoreManager {
|
|
|
70
68
|
throw new Error('Local ID or resource ID is not set');
|
|
71
69
|
}
|
|
72
70
|
const cachedBlock = this.syncBlockCache.get(resourceId);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
const syncBlockData = convertSyncBlockPMNodeToSyncBlockData(syncBlockNode);
|
|
81
|
-
if (cachedBlock && !isRemote) {
|
|
82
|
-
this.hasReceivedContentChange = true;
|
|
83
|
-
}
|
|
84
|
-
const isDirty = !isRemote || !cachedBlock; // if the change is not remote, or the block is not in the cache yet, it's dirty
|
|
85
|
-
this.syncBlockCache.set(resourceId, {
|
|
86
|
-
...syncBlockData,
|
|
87
|
-
isDirty: isDirty,
|
|
88
|
-
// if the change is from remote, it's not dirty
|
|
89
|
-
contentFragment: syncBlockNode.content,
|
|
90
|
-
...(fg('platform_synced_block_patch_10') && {
|
|
91
|
-
status: cachedBlock === null || cachedBlock === void 0 ? void 0 : cachedBlock.status
|
|
92
|
-
})
|
|
93
|
-
});
|
|
94
|
-
} else {
|
|
95
|
-
const syncBlockData = convertSyncBlockPMNodeToSyncBlockData(syncBlockNode);
|
|
96
|
-
if (cachedBlock && !isEqual(syncBlockData.content, cachedBlock.content)) {
|
|
97
|
-
this.hasReceivedContentChange = true;
|
|
98
|
-
}
|
|
99
|
-
this.syncBlockCache.set(resourceId, {
|
|
100
|
-
...syncBlockData,
|
|
101
|
-
isDirty: true,
|
|
102
|
-
...(fg('platform_synced_block_patch_10') && {
|
|
103
|
-
status: cachedBlock === null || cachedBlock === void 0 ? void 0 : cachedBlock.status
|
|
104
|
-
})
|
|
105
|
-
});
|
|
71
|
+
|
|
72
|
+
// Fast path: if the PM content fragment hasn't changed, skip serialization entirely
|
|
73
|
+
// Fragment.eq() leverages ProseMirror's structural sharing for O(1) comparison
|
|
74
|
+
if (cachedBlock !== null && cachedBlock !== void 0 && (_cachedBlock$contentF = cachedBlock.contentFragment) !== null && _cachedBlock$contentF !== void 0 && _cachedBlock$contentF.eq(syncBlockNode.content)) {
|
|
75
|
+
return true;
|
|
106
76
|
}
|
|
77
|
+
const syncBlockData = convertSyncBlockPMNodeToSyncBlockData(syncBlockNode);
|
|
78
|
+
if (cachedBlock && !isRemote) {
|
|
79
|
+
this.hasReceivedContentChange = true;
|
|
80
|
+
}
|
|
81
|
+
const isDirty = !isRemote || !cachedBlock; // if the change is not remote, or the block is not in the cache yet, it's dirty
|
|
82
|
+
this.syncBlockCache.set(resourceId, {
|
|
83
|
+
...syncBlockData,
|
|
84
|
+
isDirty: isDirty,
|
|
85
|
+
// if the change is from remote, it's not dirty
|
|
86
|
+
contentFragment: syncBlockNode.content,
|
|
87
|
+
status: cachedBlock === null || cachedBlock === void 0 ? void 0 : cachedBlock.status
|
|
88
|
+
});
|
|
107
89
|
return true;
|
|
108
90
|
} catch (error) {
|
|
109
91
|
var _this$fireAnalyticsEv, _syncBlockNode$attrs, _syncBlockNode$attrs2;
|
|
@@ -125,7 +107,7 @@ export class SourceSyncBlockStoreManager {
|
|
|
125
107
|
async flush() {
|
|
126
108
|
try {
|
|
127
109
|
var _this$saveExperience;
|
|
128
|
-
if (this.viewMode === 'view'
|
|
110
|
+
if (this.viewMode === 'view') {
|
|
129
111
|
return true;
|
|
130
112
|
}
|
|
131
113
|
const bodiedSyncBlockNodes = [];
|
|
@@ -181,11 +163,9 @@ export class SourceSyncBlockStoreManager {
|
|
|
181
163
|
if (result.resourceId && !result.error) {
|
|
182
164
|
var _this$fireAnalyticsEv2;
|
|
183
165
|
// Update cache with the status returned from the backend
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
cachedData.status = result.status;
|
|
188
|
-
}
|
|
166
|
+
const cachedData = this.syncBlockCache.get(result.resourceId);
|
|
167
|
+
if (cachedData && result.status) {
|
|
168
|
+
cachedData.status = result.status;
|
|
189
169
|
}
|
|
190
170
|
(_this$fireAnalyticsEv2 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 ? void 0 : _this$fireAnalyticsEv2.call(this, updateSuccessPayload(result.resourceId, false, productAttrIfGateOn(result.resourceId)));
|
|
191
171
|
}
|
|
@@ -214,7 +194,7 @@ export class SourceSyncBlockStoreManager {
|
|
|
214
194
|
}
|
|
215
195
|
}
|
|
216
196
|
hasUnsavedChanges() {
|
|
217
|
-
if (this.viewMode === 'view'
|
|
197
|
+
if (this.viewMode === 'view') {
|
|
218
198
|
return false;
|
|
219
199
|
}
|
|
220
200
|
|
|
@@ -245,16 +225,14 @@ export class SourceSyncBlockStoreManager {
|
|
|
245
225
|
* @param success
|
|
246
226
|
*/
|
|
247
227
|
commitPendingCreation(success, resourceId) {
|
|
248
|
-
if (this.viewMode === 'view'
|
|
228
|
+
if (this.viewMode === 'view') {
|
|
249
229
|
return;
|
|
250
230
|
}
|
|
251
231
|
const onCompletion = this.creationCompletionCallbacks.get(resourceId);
|
|
252
232
|
if (onCompletion) {
|
|
253
233
|
this.creationCompletionCallbacks.delete(resourceId);
|
|
254
234
|
onCompletion(success);
|
|
255
|
-
if (success
|
|
256
|
-
exposure: true
|
|
257
|
-
})) {
|
|
235
|
+
if (success) {
|
|
258
236
|
// If creation is successful, set hasReceivedContentChange to true
|
|
259
237
|
// to indicate that there are unsaved changes in the cache
|
|
260
238
|
this.hasReceivedContentChange = true;
|
|
@@ -307,7 +285,7 @@ export class SourceSyncBlockStoreManager {
|
|
|
307
285
|
* @param onCompletion callback invoked when creation completes
|
|
308
286
|
*/
|
|
309
287
|
createBodiedSyncBlockNode(attrs, node, onCompletion) {
|
|
310
|
-
if (this.viewMode === 'view'
|
|
288
|
+
if (this.viewMode === 'view') {
|
|
311
289
|
return;
|
|
312
290
|
}
|
|
313
291
|
const {
|
|
@@ -319,17 +297,14 @@ export class SourceSyncBlockStoreManager {
|
|
|
319
297
|
if (!this.dataProvider) {
|
|
320
298
|
throw new Error('Data provider not set');
|
|
321
299
|
}
|
|
322
|
-
if (fg('platform_synced_block_update_refactor')) {
|
|
323
|
-
// add the node to the cache
|
|
324
|
-
this.updateSyncBlockData(node, false);
|
|
325
300
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
301
|
+
// add the node to the cache
|
|
302
|
+
this.updateSyncBlockData(node, false);
|
|
303
|
+
|
|
304
|
+
// Mark the block as unpublished in the cache so it can be cleaned up on cancel
|
|
305
|
+
const cached = this.syncBlockCache.get(resourceId);
|
|
306
|
+
if (cached) {
|
|
307
|
+
cached.status = 'unpublished';
|
|
333
308
|
}
|
|
334
309
|
this.creationCompletionCallbacks.set(resourceId, onCompletion);
|
|
335
310
|
(_this$createExperienc = this.createExperience) === null || _this$createExperienc === void 0 ? void 0 : _this$createExperienc.start({});
|
|
@@ -376,7 +351,7 @@ export class SourceSyncBlockStoreManager {
|
|
|
376
351
|
async delete(syncBlockIds, onDelete, onDeleteCompleted, reason) {
|
|
377
352
|
try {
|
|
378
353
|
var _this$deleteExperienc;
|
|
379
|
-
if (this.viewMode === 'view'
|
|
354
|
+
if (this.viewMode === 'view') {
|
|
380
355
|
return false;
|
|
381
356
|
}
|
|
382
357
|
if (!this.dataProvider) {
|
|
@@ -435,7 +410,7 @@ export class SourceSyncBlockStoreManager {
|
|
|
435
410
|
return !!this.deletionRetryInfo;
|
|
436
411
|
}
|
|
437
412
|
async retryDeletion() {
|
|
438
|
-
if (this.viewMode === 'view'
|
|
413
|
+
if (this.viewMode === 'view') {
|
|
439
414
|
return Promise.resolve();
|
|
440
415
|
}
|
|
441
416
|
if (!this.deletionRetryInfo) {
|
|
@@ -463,7 +438,7 @@ export class SourceSyncBlockStoreManager {
|
|
|
463
438
|
* This is called on editor init so we know which blocks are 'unpublished' vs 'active'.
|
|
464
439
|
*/
|
|
465
440
|
async fetchAndCacheStatuses() {
|
|
466
|
-
if (!
|
|
441
|
+
if (!this.dataProvider || this.syncBlockCache.size === 0) {
|
|
467
442
|
return;
|
|
468
443
|
}
|
|
469
444
|
|
|
@@ -511,9 +486,6 @@ export class SourceSyncBlockStoreManager {
|
|
|
511
486
|
* @returns true if all deletions succeeded, false otherwise
|
|
512
487
|
*/
|
|
513
488
|
discardUnpublishedBlocks() {
|
|
514
|
-
if (!fg('platform_synced_block_patch_10')) {
|
|
515
|
-
return Promise.resolve(true);
|
|
516
|
-
}
|
|
517
489
|
const unpublishedBlockIds = Array.from(this.syncBlockCache.entries()).filter(([_, data]) => data.status === 'unpublished' && !data.pendingDeletion).map(([resourceId, data]) => ({
|
|
518
490
|
resourceId,
|
|
519
491
|
localId: data.blockInstanceId
|
|
@@ -537,7 +509,7 @@ export class SourceSyncBlockStoreManager {
|
|
|
537
509
|
* @param destroyCallback - The callback to clear any reference stored for deletion (regardless if deletion is completed or abort)
|
|
538
510
|
*/
|
|
539
511
|
async deleteSyncBlocksWithConfirmation(syncBlockIds, deletionReason, onDelete, onDeleteCompleted, destroyCallback) {
|
|
540
|
-
if (this.viewMode === 'view'
|
|
512
|
+
if (this.viewMode === 'view') {
|
|
541
513
|
return Promise.resolve();
|
|
542
514
|
}
|
|
543
515
|
if (this.confirmationCallback) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useMemo, useRef } from 'react';
|
|
2
2
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
3
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
3
|
import { getProductFromSourceAri } from '../clients/block-service/ari';
|
|
5
4
|
import { SyncBlockError } from '../common/types';
|
|
6
5
|
import { fetchReferencesErrorPayload } from '../utils/errorHandling';
|
|
@@ -28,7 +27,7 @@ export class SyncBlockStoreManager {
|
|
|
28
27
|
}
|
|
29
28
|
async fetchReferencesSourceInfo(resourceId, blockInstanceId, isSourceSyncBlock) {
|
|
30
29
|
try {
|
|
31
|
-
var _this$fetchReferences, _response$references, _this$
|
|
30
|
+
var _this$fetchReferences, _response$references, _this$fetchReferences3, _response$references2;
|
|
32
31
|
if (!this.dataProvider) {
|
|
33
32
|
throw new Error('Data provider not set');
|
|
34
33
|
}
|
|
@@ -44,27 +43,9 @@ export class SyncBlockStoreManager {
|
|
|
44
43
|
};
|
|
45
44
|
}
|
|
46
45
|
if (!response.references || ((_response$references = response.references) === null || _response$references === void 0 ? void 0 : _response$references.length) === 0) {
|
|
47
|
-
|
|
48
|
-
return this.getUnregisteredReferences(resourceId, blockInstanceId, isSourceSyncBlock);
|
|
49
|
-
} else {
|
|
50
|
-
// No reference found
|
|
51
|
-
if (isSourceSyncBlock) {
|
|
52
|
-
var _this$fetchReferences3;
|
|
53
|
-
(_this$fetchReferences3 = this.fetchReferencesExperience) === null || _this$fetchReferences3 === void 0 ? void 0 : _this$fetchReferences3.success();
|
|
54
|
-
} else {
|
|
55
|
-
var _this$fetchReferences4;
|
|
56
|
-
(_this$fetchReferences4 = this.fetchReferencesExperience) === null || _this$fetchReferences4 === void 0 ? void 0 : _this$fetchReferences4.failure({
|
|
57
|
-
reason: 'No references found for reference synced block'
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
return isSourceSyncBlock ? {
|
|
61
|
-
references: []
|
|
62
|
-
} : {
|
|
63
|
-
error: SyncBlockError.Errored
|
|
64
|
-
};
|
|
65
|
-
}
|
|
46
|
+
return this.getUnregisteredReferences(resourceId, blockInstanceId, isSourceSyncBlock);
|
|
66
47
|
}
|
|
67
|
-
(_this$
|
|
48
|
+
(_this$fetchReferences3 = this.fetchReferencesExperience) === null || _this$fetchReferences3 === void 0 ? void 0 : _this$fetchReferences3.success();
|
|
68
49
|
const sourceInfoPromises = ((_response$references2 = response.references) !== null && _response$references2 !== void 0 ? _response$references2 : []).map(async reference => {
|
|
69
50
|
var _this$fetchSourceInfo, _this$dataProvider, _this$fetchSourceInfo3;
|
|
70
51
|
(_this$fetchSourceInfo = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo === void 0 ? void 0 : _this$fetchSourceInfo.start();
|
|
@@ -123,10 +104,10 @@ export class SyncBlockStoreManager {
|
|
|
123
104
|
return this.sourceSyncBlockStoreManager;
|
|
124
105
|
}
|
|
125
106
|
destroy() {
|
|
126
|
-
var _this$
|
|
107
|
+
var _this$fetchReferences4, _this$fetchSourceInfo4;
|
|
127
108
|
this.referenceSyncBlockStoreManager.destroy();
|
|
128
109
|
this.sourceSyncBlockStoreManager.destroy();
|
|
129
|
-
(_this$
|
|
110
|
+
(_this$fetchReferences4 = this.fetchReferencesExperience) === null || _this$fetchReferences4 === void 0 ? void 0 : _this$fetchReferences4.abort({
|
|
130
111
|
reason: 'editorDestroyed'
|
|
131
112
|
});
|
|
132
113
|
(_this$fetchSourceInfo4 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo4 === void 0 ? void 0 : _this$fetchSourceInfo4.abort({
|
|
@@ -134,17 +115,17 @@ export class SyncBlockStoreManager {
|
|
|
134
115
|
});
|
|
135
116
|
}
|
|
136
117
|
async getUnregisteredReferences(resourceId, blockInstanceId, isSourceSyncBlock) {
|
|
137
|
-
var _this$
|
|
118
|
+
var _this$fetchReferences8;
|
|
138
119
|
// No reference found
|
|
139
120
|
if (isSourceSyncBlock) {
|
|
140
|
-
var _this$
|
|
121
|
+
var _this$fetchReferences6;
|
|
141
122
|
// Verify that a reference sync block for this specific source actually
|
|
142
123
|
// exists on the current page by checking if the reference manager has
|
|
143
124
|
// an active subscription for the derived reference resourceId.
|
|
144
125
|
const referenceResourceId = this.referenceSyncBlockStoreManager.generateResourceIdForReference(resourceId);
|
|
145
126
|
const hasUnregisteredReferenceOnPage = this.referenceSyncBlockStoreManager.getSubscribedResourceIds().includes(referenceResourceId);
|
|
146
127
|
if (hasUnregisteredReferenceOnPage) {
|
|
147
|
-
var _this$
|
|
128
|
+
var _this$fetchReferences5;
|
|
148
129
|
// This is current page data. It is the same for data for source and reference
|
|
149
130
|
const sourceSyncBlockData = await this.sourceSyncBlockStoreManager.getSyncBlockSourceInfo(blockInstanceId);
|
|
150
131
|
const references = [];
|
|
@@ -163,14 +144,14 @@ export class SyncBlockStoreManager {
|
|
|
163
144
|
};
|
|
164
145
|
references.push(sourceSyncBlockReference, referenceSyncBlockReference);
|
|
165
146
|
}
|
|
166
|
-
(_this$
|
|
147
|
+
(_this$fetchReferences5 = this.fetchReferencesExperience) === null || _this$fetchReferences5 === void 0 ? void 0 : _this$fetchReferences5.success();
|
|
167
148
|
return {
|
|
168
149
|
references
|
|
169
150
|
};
|
|
170
151
|
}
|
|
171
152
|
|
|
172
153
|
// No remote or local reference exists — show info text with link to doco on how to use Synced Blocks
|
|
173
|
-
(_this$
|
|
154
|
+
(_this$fetchReferences6 = this.fetchReferencesExperience) === null || _this$fetchReferences6 === void 0 ? void 0 : _this$fetchReferences6.success();
|
|
174
155
|
return {
|
|
175
156
|
references: []
|
|
176
157
|
};
|
|
@@ -199,15 +180,15 @@ export class SyncBlockStoreManager {
|
|
|
199
180
|
});
|
|
200
181
|
}
|
|
201
182
|
if (references.length === 0) {
|
|
202
|
-
var _this$
|
|
203
|
-
(_this$
|
|
183
|
+
var _this$fetchReferences7;
|
|
184
|
+
(_this$fetchReferences7 = this.fetchReferencesExperience) === null || _this$fetchReferences7 === void 0 ? void 0 : _this$fetchReferences7.failure({
|
|
204
185
|
reason: 'No references found for reference synced block'
|
|
205
186
|
});
|
|
206
187
|
return {
|
|
207
188
|
error: SyncBlockError.Errored
|
|
208
189
|
};
|
|
209
190
|
}
|
|
210
|
-
(_this$
|
|
191
|
+
(_this$fetchReferences8 = this.fetchReferencesExperience) === null || _this$fetchReferences8 === void 0 ? void 0 : _this$fetchReferences8.success();
|
|
211
192
|
return {
|
|
212
193
|
references
|
|
213
194
|
};
|
|
@@ -8,7 +8,6 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
|
8
8
|
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
9
9
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
10
10
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
11
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
11
|
import { fetchWithRetry } from '../../utils/retry';
|
|
13
12
|
export var isBlockContentResponse = function isBlockContentResponse(response) {
|
|
14
13
|
var content = response.content;
|
|
@@ -415,10 +414,6 @@ export var deleteSyncedBlock = /*#__PURE__*/function () {
|
|
|
415
414
|
case 10:
|
|
416
415
|
result = _context4.sent;
|
|
417
416
|
if (!(result.errors && result.errors.length > 0)) {
|
|
418
|
-
_context4.next = 17;
|
|
419
|
-
break;
|
|
420
|
-
}
|
|
421
|
-
if (!fg('platform_synced_block_patch_8')) {
|
|
422
417
|
_context4.next = 16;
|
|
423
418
|
break;
|
|
424
419
|
}
|
|
@@ -427,22 +422,22 @@ export var deleteSyncedBlock = /*#__PURE__*/function () {
|
|
|
427
422
|
return ((_e$extensions = e.extensions) === null || _e$extensions === void 0 ? void 0 : _e$extensions.errorType) === 'RESOURCE_NOT_FOUND';
|
|
428
423
|
});
|
|
429
424
|
if (!allNotFound) {
|
|
430
|
-
_context4.next =
|
|
425
|
+
_context4.next = 15;
|
|
431
426
|
break;
|
|
432
427
|
}
|
|
433
428
|
throw new BlockNotFoundError();
|
|
434
|
-
case
|
|
429
|
+
case 15:
|
|
435
430
|
throw new Error(result.errors.map(function (e) {
|
|
436
431
|
return e.message;
|
|
437
432
|
}).join(', '));
|
|
438
|
-
case
|
|
433
|
+
case 16:
|
|
439
434
|
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;
|
|
440
435
|
if (isDeleted) {
|
|
441
|
-
_context4.next =
|
|
436
|
+
_context4.next = 19;
|
|
442
437
|
break;
|
|
443
438
|
}
|
|
444
439
|
throw new Error('Block deletion failed; deleted flag is false');
|
|
445
|
-
case
|
|
440
|
+
case 19:
|
|
446
441
|
case "end":
|
|
447
442
|
return _context4.stop();
|
|
448
443
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
2
|
import { createClient } from 'graphql-ws';
|
|
3
3
|
import { isSSR } from '@atlaskit/editor-common/core-utils';
|
|
4
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
4
|
import { convertContentUpdatedAt } from '../../utils/utils';
|
|
6
5
|
var GRAPHQL_WS_ENDPOINT = '/gateway/api/graphql/subscriptions';
|
|
7
6
|
var blockServiceClient = null;
|
|
@@ -60,7 +59,7 @@ var getBlockServiceClient = function getBlockServiceClient() {
|
|
|
60
59
|
url: wsUrl,
|
|
61
60
|
lazy: true,
|
|
62
61
|
retryAttempts: 3,
|
|
63
|
-
on:
|
|
62
|
+
on: {
|
|
64
63
|
connecting: function connecting(isRetry) {
|
|
65
64
|
connectionDiagnostics.wasRetry = isRetry;
|
|
66
65
|
connectionDiagnostics.state = 'connecting';
|
|
@@ -83,7 +82,7 @@ var getBlockServiceClient = function getBlockServiceClient() {
|
|
|
83
82
|
connectionDiagnostics.state = 'error';
|
|
84
83
|
connectionDiagnostics.consecutiveFailures += 1;
|
|
85
84
|
}
|
|
86
|
-
}
|
|
85
|
+
}
|
|
87
86
|
});
|
|
88
87
|
}
|
|
89
88
|
return blockServiceClient;
|
|
@@ -201,12 +200,7 @@ export var subscribeToBlockUpdates = function subscribeToBlockUpdates(blockAri,
|
|
|
201
200
|
};
|
|
202
201
|
return error;
|
|
203
202
|
}(function (error) {
|
|
204
|
-
|
|
205
|
-
onError === null || onError === void 0 || onError(new Error(extractGraphQLWSErrorMessage(error)));
|
|
206
|
-
} else {
|
|
207
|
-
var errorMessage = error instanceof Error ? error.message : 'GraphQL subscription error';
|
|
208
|
-
onError === null || onError === void 0 || onError(new Error(errorMessage));
|
|
209
|
-
}
|
|
203
|
+
onError === null || onError === void 0 || onError(new Error(extractGraphQLWSErrorMessage(error)));
|
|
210
204
|
}),
|
|
211
205
|
complete: function complete() {
|
|
212
206
|
// Subscription completed
|
|
@@ -11,7 +11,6 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
11
11
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
12
12
|
/* eslint-disable require-unicode-regexp */
|
|
13
13
|
import { useMemo } from 'react';
|
|
14
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
15
14
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
16
15
|
import { generateBlockAri as _generateBlockAri, generateBlockAriFromReference } from '../../clients/block-service/ari';
|
|
17
16
|
import { batchRetrieveSyncedBlocks, BlockError, BlockNotFoundError, BlockTimeoutError, createSyncedBlock, deleteSyncedBlock, getReferenceSyncedBlocks, getReferenceSyncedBlocksByBlockAri, getSyncedBlockContent, updateReferenceSyncedBlockOnDocument, updateSyncedBlock, updateSyncedBlocks } from '../../clients/block-service/blockService';
|
|
@@ -47,7 +46,7 @@ var mapErrorResponseCode = function mapErrorResponseCode(errorCode) {
|
|
|
47
46
|
case 'NOT_FOUND':
|
|
48
47
|
return SyncBlockError.NotFound;
|
|
49
48
|
case 'EntityNotFound':
|
|
50
|
-
return
|
|
49
|
+
return SyncBlockError.EntityNotFound;
|
|
51
50
|
case 'INVALID_REQUEST':
|
|
52
51
|
return SyncBlockError.InvalidRequest;
|
|
53
52
|
case 'CONFLICT':
|
|
@@ -1051,7 +1050,7 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
1051
1050
|
case 9:
|
|
1052
1051
|
_context0.prev = 9;
|
|
1053
1052
|
_context0.t0 = _context0["catch"](3);
|
|
1054
|
-
if (!(_context0.t0 instanceof BlockNotFoundError && this.parentAri
|
|
1053
|
+
if (!(_context0.t0 instanceof BlockNotFoundError && this.parentAri)) {
|
|
1055
1054
|
_context0.next = 13;
|
|
1056
1055
|
break;
|
|
1057
1056
|
}
|
|
@@ -1349,11 +1348,10 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
1349
1348
|
block = _step6.value;
|
|
1350
1349
|
successBlock = successBlocks.get(block.resourceId);
|
|
1351
1350
|
if (successBlock) {
|
|
1352
|
-
results.push(
|
|
1353
|
-
resourceId: block.resourceId
|
|
1354
|
-
}, fg('platform_synced_block_patch_10') && {
|
|
1351
|
+
results.push({
|
|
1352
|
+
resourceId: block.resourceId,
|
|
1355
1353
|
status: successBlock.status
|
|
1356
|
-
})
|
|
1354
|
+
});
|
|
1357
1355
|
}
|
|
1358
1356
|
}
|
|
1359
1357
|
} catch (err) {
|
|
@@ -713,7 +713,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
713
713
|
return _regeneratorRuntime.wrap(function _callee3$(_context4) {
|
|
714
714
|
while (1) switch (_context4.prev = _context4.next) {
|
|
715
715
|
case 0:
|
|
716
|
-
if (!(this.viewMode === 'view'
|
|
716
|
+
if (!(this.viewMode === 'view')) {
|
|
717
717
|
_context4.next = 2;
|
|
718
718
|
break;
|
|
719
719
|
}
|