@atlaskit/editor-synced-block-provider 3.26.0 → 3.26.1
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 +8 -0
- package/dist/cjs/clients/block-service/blockService.js +9 -14
- package/dist/cjs/clients/confluence/sourceInfo.js +3 -35
- package/dist/cjs/hooks/useFetchSyncBlockData.js +5 -11
- package/dist/cjs/providers/block-service/blockServiceAPI.js +1 -1
- package/dist/cjs/providers/syncBlockProvider.js +29 -72
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +75 -124
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +59 -93
- package/dist/cjs/store-manager/syncBlockStoreManager.js +2 -4
- package/dist/cjs/utils/errorHandling.js +2 -5
- package/dist/cjs/utils/resolveSyncBlockInstance.js +1 -3
- package/dist/cjs/utils/utils.js +5 -6
- package/dist/es2019/clients/block-service/blockService.js +5 -9
- package/dist/es2019/clients/confluence/sourceInfo.js +1 -4
- package/dist/es2019/hooks/useFetchSyncBlockData.js +6 -12
- package/dist/es2019/providers/block-service/blockServiceAPI.js +1 -1
- package/dist/es2019/providers/syncBlockProvider.js +21 -53
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +65 -114
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +60 -92
- package/dist/es2019/store-manager/syncBlockStoreManager.js +2 -4
- package/dist/es2019/utils/errorHandling.js +1 -4
- package/dist/es2019/utils/resolveSyncBlockInstance.js +2 -5
- package/dist/es2019/utils/utils.js +5 -6
- package/dist/esm/clients/block-service/blockService.js +9 -14
- package/dist/esm/clients/confluence/sourceInfo.js +2 -34
- package/dist/esm/hooks/useFetchSyncBlockData.js +5 -11
- package/dist/esm/providers/block-service/blockServiceAPI.js +1 -1
- package/dist/esm/providers/syncBlockProvider.js +29 -72
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +75 -124
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +59 -93
- package/dist/esm/store-manager/syncBlockStoreManager.js +2 -4
- package/dist/esm/utils/errorHandling.js +2 -5
- package/dist/esm/utils/resolveSyncBlockInstance.js +1 -3
- package/dist/esm/utils/utils.js +5 -6
- package/dist/types/clients/confluence/sourceInfo.d.ts +1 -2
- package/dist/types/hooks/useFetchSyncBlockData.d.ts +1 -1
- package/dist/types/providers/syncBlockProvider.d.ts +1 -1
- package/dist/types/providers/types.d.ts +2 -2
- package/dist/types/store-manager/sourceSyncBlockStoreManager.d.ts +1 -1
- package/dist/types-ts4.5/clients/confluence/sourceInfo.d.ts +1 -2
- package/dist/types-ts4.5/hooks/useFetchSyncBlockData.d.ts +1 -1
- package/dist/types-ts4.5/providers/syncBlockProvider.d.ts +1 -1
- package/dist/types-ts4.5/providers/types.d.ts +2 -2
- package/dist/types-ts4.5/store-manager/sourceSyncBlockStoreManager.d.ts +1 -1
- package/package.json +2 -5
|
@@ -11,7 +11,6 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
11
11
|
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
12
12
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
13
13
|
import { useMemo } from 'react';
|
|
14
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
15
14
|
import { getProductFromSourceAri } from '../clients/block-service/ari';
|
|
16
15
|
import { getPageIdAndTypeFromConfluencePageAri } from '../clients/confluence/ari';
|
|
17
16
|
import { fetchConfluencePageInfo } from '../clients/confluence/sourceInfo';
|
|
@@ -97,40 +96,14 @@ export var SyncBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
|
|
|
97
96
|
}
|
|
98
97
|
return _context.abrupt("return", []);
|
|
99
98
|
case 3:
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
_context.prev = 4;
|
|
105
|
-
_context.next = 7;
|
|
99
|
+
_context.prev = 3;
|
|
100
|
+
_context.next = 6;
|
|
106
101
|
return this.fetchProvider.batchFetchData(blockIdentifiers);
|
|
107
|
-
case
|
|
102
|
+
case 6:
|
|
108
103
|
return _context.abrupt("return", _context.sent);
|
|
109
|
-
case
|
|
110
|
-
_context.prev =
|
|
111
|
-
_context.t0 = _context["catch"](
|
|
112
|
-
return _context.abrupt("return", Promise.allSettled(blockIdentifiers.map(function (blockIdentifier) {
|
|
113
|
-
return _this2.fetchProvider.fetchData(blockIdentifier.resourceId).then(function (data) {
|
|
114
|
-
return data;
|
|
115
|
-
}, function () {
|
|
116
|
-
return {
|
|
117
|
-
error: {
|
|
118
|
-
type: SyncBlockError.Errored
|
|
119
|
-
},
|
|
120
|
-
resourceId: blockIdentifier.resourceId
|
|
121
|
-
};
|
|
122
|
-
});
|
|
123
|
-
})).then(function (results) {
|
|
124
|
-
return results.filter(function (result) {
|
|
125
|
-
return result.status === 'fulfilled';
|
|
126
|
-
}).map(function (result) {
|
|
127
|
-
return result.value;
|
|
128
|
-
});
|
|
129
|
-
}));
|
|
130
|
-
case 13:
|
|
131
|
-
_context.next = 16;
|
|
132
|
-
break;
|
|
133
|
-
case 15:
|
|
104
|
+
case 9:
|
|
105
|
+
_context.prev = 9;
|
|
106
|
+
_context.t0 = _context["catch"](3);
|
|
134
107
|
return _context.abrupt("return", Promise.allSettled(blockIdentifiers.map(function (blockIdentifier) {
|
|
135
108
|
return _this2.fetchProvider.fetchData(blockIdentifier.resourceId).then(function (data) {
|
|
136
109
|
return data;
|
|
@@ -149,11 +122,11 @@ export var SyncBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
|
|
|
149
122
|
return result.value;
|
|
150
123
|
});
|
|
151
124
|
}));
|
|
152
|
-
case
|
|
125
|
+
case 12:
|
|
153
126
|
case "end":
|
|
154
127
|
return _context.stop();
|
|
155
128
|
}
|
|
156
|
-
}, _callee, this, [[
|
|
129
|
+
}, _callee, this, [[3, 9]]);
|
|
157
130
|
}));
|
|
158
131
|
function fetchNodesData(_x) {
|
|
159
132
|
return _fetchNodesData.apply(this, arguments);
|
|
@@ -300,16 +273,15 @@ export var SyncBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
|
|
|
300
273
|
key: "fetchSyncBlockSourceInfo",
|
|
301
274
|
value: (function () {
|
|
302
275
|
var _fetchSyncBlockSourceInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(localId, sourceAri, sourceProduct, fireAnalyticsEvent) {
|
|
276
|
+
var _this$writeProvider, _this$writeProvider3;
|
|
303
277
|
var hasAccess,
|
|
304
278
|
urlType,
|
|
305
279
|
isUnpublished,
|
|
306
280
|
ari,
|
|
307
281
|
product,
|
|
308
|
-
_this$writeProvider,
|
|
309
|
-
sourceInfo,
|
|
310
282
|
_this$writeProvider2,
|
|
311
|
-
_this$writeProvider3,
|
|
312
283
|
_sourceInfo,
|
|
284
|
+
sourceInfo,
|
|
313
285
|
_args4 = arguments;
|
|
314
286
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
315
287
|
while (1) switch (_context4.prev = _context4.next) {
|
|
@@ -317,11 +289,8 @@ export var SyncBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
|
|
|
317
289
|
hasAccess = _args4.length > 4 && _args4[4] !== undefined ? _args4[4] : true;
|
|
318
290
|
urlType = _args4.length > 5 && _args4[5] !== undefined ? _args4[5] : 'edit';
|
|
319
291
|
isUnpublished = _args4.length > 6 ? _args4[6] : undefined;
|
|
320
|
-
ari = sourceAri
|
|
321
|
-
|
|
322
|
-
ari = sourceAri !== null && sourceAri !== void 0 ? sourceAri : (_this$writeProvider = this.writeProvider) === null || _this$writeProvider === void 0 ? void 0 : _this$writeProvider.parentAri;
|
|
323
|
-
product = sourceProduct !== null && sourceProduct !== void 0 ? sourceProduct : getProductFromSourceAri(ari);
|
|
324
|
-
}
|
|
292
|
+
ari = sourceAri !== null && sourceAri !== void 0 ? sourceAri : (_this$writeProvider = this.writeProvider) === null || _this$writeProvider === void 0 ? void 0 : _this$writeProvider.parentAri;
|
|
293
|
+
product = sourceProduct !== null && sourceProduct !== void 0 ? sourceProduct : getProductFromSourceAri(ari);
|
|
325
294
|
if (!(!ari || !product)) {
|
|
326
295
|
_context4.next = 7;
|
|
327
296
|
break;
|
|
@@ -329,53 +298,41 @@ export var SyncBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
|
|
|
329
298
|
return _context4.abrupt("return", Promise.reject(new Error('Source ari or source product is undefined')));
|
|
330
299
|
case 7:
|
|
331
300
|
_context4.t0 = product;
|
|
332
|
-
_context4.next = _context4.t0 === 'confluence-page' ? 10 : _context4.t0 === 'jira-work-item' ?
|
|
301
|
+
_context4.next = _context4.t0 === 'confluence-page' ? 10 : _context4.t0 === 'jira-work-item' ? 16 : 22;
|
|
333
302
|
break;
|
|
334
303
|
case 10:
|
|
335
304
|
_context4.next = 12;
|
|
336
|
-
return fetchConfluencePageInfo(ari, hasAccess, urlType, localId,
|
|
305
|
+
return fetchConfluencePageInfo(ari, hasAccess, urlType, localId, isUnpublished);
|
|
337
306
|
case 12:
|
|
338
|
-
|
|
339
|
-
if (
|
|
340
|
-
_context4.next =
|
|
341
|
-
break;
|
|
342
|
-
}
|
|
343
|
-
if (sourceInfo) {
|
|
344
|
-
_context4.next = 16;
|
|
307
|
+
_sourceInfo = _context4.sent;
|
|
308
|
+
if (_sourceInfo) {
|
|
309
|
+
_context4.next = 15;
|
|
345
310
|
break;
|
|
346
311
|
}
|
|
347
312
|
return _context4.abrupt("return", Promise.resolve(undefined));
|
|
348
|
-
case
|
|
349
|
-
return _context4.abrupt("return", _objectSpread(_objectSpread({},
|
|
313
|
+
case 15:
|
|
314
|
+
return _context4.abrupt("return", _objectSpread(_objectSpread({}, _sourceInfo), {}, {
|
|
350
315
|
onSameDocument: ((_this$writeProvider2 = this.writeProvider) === null || _this$writeProvider2 === void 0 ? void 0 : _this$writeProvider2.parentAri) === ari,
|
|
351
316
|
productType: product
|
|
352
317
|
}));
|
|
353
|
-
case
|
|
354
|
-
|
|
355
|
-
case 20:
|
|
356
|
-
if (!fg('platform_synced_block_dogfooding')) {
|
|
357
|
-
_context4.next = 27;
|
|
358
|
-
break;
|
|
359
|
-
}
|
|
360
|
-
_context4.next = 23;
|
|
318
|
+
case 16:
|
|
319
|
+
_context4.next = 18;
|
|
361
320
|
return fetchJiraWorkItemInfo(ari, hasAccess);
|
|
362
|
-
case
|
|
363
|
-
|
|
364
|
-
if (
|
|
365
|
-
_context4.next =
|
|
321
|
+
case 18:
|
|
322
|
+
sourceInfo = _context4.sent;
|
|
323
|
+
if (sourceInfo) {
|
|
324
|
+
_context4.next = 21;
|
|
366
325
|
break;
|
|
367
326
|
}
|
|
368
327
|
return _context4.abrupt("return", Promise.resolve(undefined));
|
|
369
|
-
case
|
|
370
|
-
return _context4.abrupt("return", _objectSpread(_objectSpread({},
|
|
328
|
+
case 21:
|
|
329
|
+
return _context4.abrupt("return", _objectSpread(_objectSpread({}, sourceInfo), {}, {
|
|
371
330
|
onSameDocument: ((_this$writeProvider3 = this.writeProvider) === null || _this$writeProvider3 === void 0 ? void 0 : _this$writeProvider3.parentAri) === ari,
|
|
372
331
|
productType: product
|
|
373
332
|
}));
|
|
374
|
-
case
|
|
375
|
-
return _context4.abrupt("return", Promise.reject(new Error('Jira work item source product not supported')));
|
|
376
|
-
case 28:
|
|
333
|
+
case 22:
|
|
377
334
|
return _context4.abrupt("return", Promise.reject(new Error("".concat(product, " source product not supported"))));
|
|
378
|
-
case
|
|
335
|
+
case 23:
|
|
379
336
|
case "end":
|
|
380
337
|
return _context4.stop();
|
|
381
338
|
}
|
|
@@ -209,7 +209,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
209
209
|
value: function getInitialSyncBlockData(resourceId) {
|
|
210
210
|
var _this$dataProvider2;
|
|
211
211
|
var syncBlockNode = createSyncBlockNode('', resourceId);
|
|
212
|
-
if (isSSR()
|
|
212
|
+
if (isSSR() || fg('platform_synced_block_patch_1')) {
|
|
213
213
|
var _this$dataProvider;
|
|
214
214
|
// In SSR, prefer data from data provider cache
|
|
215
215
|
// should not take from store manager cache as it may be in incomplete state
|
|
@@ -452,17 +452,13 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
452
452
|
value: function fetchSyncBlockSourceInfo(resourceId) {
|
|
453
453
|
var _this6 = this;
|
|
454
454
|
try {
|
|
455
|
-
var _existingSyncBlock$da;
|
|
455
|
+
var _this$fetchSourceInfo, _existingSyncBlock$da;
|
|
456
456
|
if (!resourceId || !this.dataProvider) {
|
|
457
457
|
throw new Error('Data provider or resourceId not set');
|
|
458
458
|
}
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
return existingRequest;
|
|
463
|
-
}
|
|
464
|
-
} else if (this.syncBlockSourceInfoRequestsOld.get(resourceId)) {
|
|
465
|
-
return Promise.resolve(undefined);
|
|
459
|
+
var existingRequest = this.syncBlockSourceInfoRequests.get(resourceId);
|
|
460
|
+
if (existingRequest) {
|
|
461
|
+
return existingRequest;
|
|
466
462
|
}
|
|
467
463
|
var existingSyncBlock = this.getFromCache(resourceId);
|
|
468
464
|
if (!existingSyncBlock) {
|
|
@@ -478,28 +474,21 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
478
474
|
sourceSubType = _ref.sourceSubType;
|
|
479
475
|
// skip if source URL and title are already present
|
|
480
476
|
if (sourceURL && sourceTitle) {
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
});
|
|
490
|
-
} else {
|
|
491
|
-
return Promise.resolve(undefined);
|
|
492
|
-
}
|
|
477
|
+
return Promise.resolve({
|
|
478
|
+
title: sourceTitle,
|
|
479
|
+
url: sourceURL,
|
|
480
|
+
subType: sourceSubType,
|
|
481
|
+
sourceAri: sourceAri || '',
|
|
482
|
+
onSameDocument: onSameDocument,
|
|
483
|
+
productType: product
|
|
484
|
+
});
|
|
493
485
|
}
|
|
494
486
|
if (!sourceAri || !product || !blockInstanceId) {
|
|
495
487
|
var _this$fireAnalyticsEv5;
|
|
496
488
|
(_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 || _this$fireAnalyticsEv5.call(this, getSourceInfoErrorPayload('SourceAri, product or blockInstanceId missing', resourceId));
|
|
497
489
|
return Promise.resolve(undefined);
|
|
498
490
|
}
|
|
499
|
-
|
|
500
|
-
var _this$fetchSourceInfo;
|
|
501
|
-
(_this$fetchSourceInfo = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo === void 0 || _this$fetchSourceInfo.start({});
|
|
502
|
-
}
|
|
491
|
+
(_this$fetchSourceInfo = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo === void 0 || _this$fetchSourceInfo.start({});
|
|
503
492
|
|
|
504
493
|
// Only use unpublished endpoint if feature flag is enabled
|
|
505
494
|
var isUnpublished = fg('platform_synced_block_patch_1') && ((_existingSyncBlock$da = existingSyncBlock.data) === null || _existingSyncBlock$da === void 0 ? void 0 : _existingSyncBlock$da.status) === 'unpublished';
|
|
@@ -509,55 +498,40 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
509
498
|
// urlType
|
|
510
499
|
isUnpublished).then(function (sourceInfo) {
|
|
511
500
|
if (!sourceInfo) {
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
(_this6$fireAnalyticsE = _this6.fireAnalyticsEvent) === null || _this6$fireAnalyticsE === void 0 || _this6$fireAnalyticsE.call(_this6, getSourceInfoErrorPayload('No source info returned', resourceId));
|
|
518
|
-
}
|
|
501
|
+
var _this6$fetchSourceInf, _this6$fireAnalyticsE;
|
|
502
|
+
(_this6$fetchSourceInf = _this6.fetchSourceInfoExperience) === null || _this6$fetchSourceInf === void 0 || _this6$fetchSourceInf.failure({
|
|
503
|
+
reason: 'No source info returned'
|
|
504
|
+
});
|
|
505
|
+
(_this6$fireAnalyticsE = _this6.fireAnalyticsEvent) === null || _this6$fireAnalyticsE === void 0 || _this6$fireAnalyticsE.call(_this6, getSourceInfoErrorPayload('No source info returned', resourceId));
|
|
519
506
|
return undefined;
|
|
520
507
|
}
|
|
521
508
|
_this6.updateCacheWithSourceInfo(resourceId, sourceInfo);
|
|
522
509
|
if (sourceInfo.title) {
|
|
523
510
|
_this6.updateSourceTitleSubscriptions(resourceId, sourceInfo.title);
|
|
524
511
|
}
|
|
525
|
-
if (
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
reason: 'Missing title or url'
|
|
533
|
-
});
|
|
534
|
-
(_this6$fireAnalyticsE2 = _this6.fireAnalyticsEvent) === null || _this6$fireAnalyticsE2 === void 0 || _this6$fireAnalyticsE2.call(_this6, getSourceInfoErrorPayload('Missing title or url', resourceId));
|
|
535
|
-
}
|
|
536
|
-
return sourceInfo;
|
|
537
|
-
}
|
|
538
|
-
}).catch(function (error) {
|
|
539
|
-
var _this6$fireAnalyticsE3;
|
|
540
|
-
if (fg('platform_synced_block_dogfooding')) {
|
|
541
|
-
var _this6$fetchSourceInf4;
|
|
542
|
-
(_this6$fetchSourceInf4 = _this6.fetchSourceInfoExperience) === null || _this6$fetchSourceInf4 === void 0 || _this6$fetchSourceInf4.failure({
|
|
543
|
-
reason: error.message
|
|
512
|
+
if (sourceInfo.title && sourceInfo.url) {
|
|
513
|
+
var _this6$fetchSourceInf2;
|
|
514
|
+
(_this6$fetchSourceInf2 = _this6.fetchSourceInfoExperience) === null || _this6$fetchSourceInf2 === void 0 || _this6$fetchSourceInf2.success();
|
|
515
|
+
} else {
|
|
516
|
+
var _this6$fetchSourceInf3, _this6$fireAnalyticsE2;
|
|
517
|
+
(_this6$fetchSourceInf3 = _this6.fetchSourceInfoExperience) === null || _this6$fetchSourceInf3 === void 0 || _this6$fetchSourceInf3.failure({
|
|
518
|
+
reason: 'Missing title or url'
|
|
544
519
|
});
|
|
520
|
+
(_this6$fireAnalyticsE2 = _this6.fireAnalyticsEvent) === null || _this6$fireAnalyticsE2 === void 0 || _this6$fireAnalyticsE2.call(_this6, getSourceInfoErrorPayload('Missing title or url', resourceId));
|
|
545
521
|
}
|
|
522
|
+
return sourceInfo;
|
|
523
|
+
}).catch(function (error) {
|
|
524
|
+
var _this6$fetchSourceInf4, _this6$fireAnalyticsE3;
|
|
525
|
+
(_this6$fetchSourceInf4 = _this6.fetchSourceInfoExperience) === null || _this6$fetchSourceInf4 === void 0 || _this6$fetchSourceInf4.failure({
|
|
526
|
+
reason: error.message
|
|
527
|
+
});
|
|
546
528
|
(_this6$fireAnalyticsE3 = _this6.fireAnalyticsEvent) === null || _this6$fireAnalyticsE3 === void 0 || _this6$fireAnalyticsE3.call(_this6, getSourceInfoErrorPayload(error.message, resourceId));
|
|
547
529
|
return undefined;
|
|
548
530
|
}).finally(function () {
|
|
549
|
-
|
|
550
|
-
_this6.syncBlockSourceInfoRequests.delete(resourceId);
|
|
551
|
-
} else {
|
|
552
|
-
_this6.syncBlockSourceInfoRequestsOld.delete(resourceId);
|
|
553
|
-
}
|
|
531
|
+
_this6.syncBlockSourceInfoRequests.delete(resourceId);
|
|
554
532
|
});
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
return sourceInfoPromise;
|
|
558
|
-
} else {
|
|
559
|
-
this.syncBlockSourceInfoRequestsOld.set(resourceId, true);
|
|
560
|
-
}
|
|
533
|
+
this.syncBlockSourceInfoRequests.set(resourceId, sourceInfoPromise);
|
|
534
|
+
return sourceInfoPromise;
|
|
561
535
|
} catch (error) {
|
|
562
536
|
var _this$fireAnalyticsEv6;
|
|
563
537
|
logException(error, {
|
|
@@ -577,8 +551,9 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
577
551
|
key: "fetchSyncBlocksData",
|
|
578
552
|
value: (function () {
|
|
579
553
|
var _fetchSyncBlocksData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(syncBlockNodes) {
|
|
580
|
-
var _this7 = this
|
|
581
|
-
|
|
554
|
+
var _this7 = this,
|
|
555
|
+
_this$fetchExperience;
|
|
556
|
+
var nodesToFetch, data, hasUnexpectedError, hasExpectedError, _this$fetchExperience2, _this$fetchExperience3, _this$fetchExperience4;
|
|
582
557
|
return _regeneratorRuntime.wrap(function _callee2$(_context3) {
|
|
583
558
|
while (1) switch (_context3.prev = _context3.next) {
|
|
584
559
|
case 0:
|
|
@@ -616,9 +591,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
616
591
|
nodesToFetch.forEach(function (node) {
|
|
617
592
|
_this7.syncBlockFetchDataRequests.set(node.attrs.resourceId, true);
|
|
618
593
|
});
|
|
619
|
-
|
|
620
|
-
(_this$fetchExperience = this.fetchExperience) === null || _this$fetchExperience === void 0 || _this$fetchExperience.start({});
|
|
621
|
-
}
|
|
594
|
+
(_this$fetchExperience = this.fetchExperience) === null || _this$fetchExperience === void 0 || _this$fetchExperience.start({});
|
|
622
595
|
_context3.next = 12;
|
|
623
596
|
return this.dataProvider.fetchNodesData(nodesToFetch).finally(function () {
|
|
624
597
|
nodesToFetch.forEach(function (node) {
|
|
@@ -642,7 +615,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
642
615
|
|
|
643
616
|
// Check if this is a newly added unpublished sync block and notify
|
|
644
617
|
// Only trigger for sync blocks that were just added (not refreshed or loaded on page init)
|
|
645
|
-
if (!syncBlockInstance.error && ((_resolvedSyncBlockIns = resolvedSyncBlockInstance.data) === null || _resolvedSyncBlockIns === void 0 ? void 0 : _resolvedSyncBlockIns.status) === 'unpublished' && _this7.newlyAddedSyncBlocks.has(syncBlockInstance.resourceId) && _this7.onUnpublishedSyncBlockDetected
|
|
618
|
+
if (!syncBlockInstance.error && ((_resolvedSyncBlockIns = resolvedSyncBlockInstance.data) === null || _resolvedSyncBlockIns === void 0 ? void 0 : _resolvedSyncBlockIns.status) === 'unpublished' && _this7.newlyAddedSyncBlocks.has(syncBlockInstance.resourceId) && _this7.onUnpublishedSyncBlockDetected) {
|
|
646
619
|
// Remove from newly added set after checking to prevent duplicate flags
|
|
647
620
|
_this7.newlyAddedSyncBlocks.delete(syncBlockInstance.resourceId);
|
|
648
621
|
_this7.onUnpublishedSyncBlockDetected(resolvedSyncBlockInstance.resourceId);
|
|
@@ -659,7 +632,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
659
632
|
hasUnexpectedError = true;
|
|
660
633
|
}
|
|
661
634
|
return;
|
|
662
|
-
} else
|
|
635
|
+
} else {
|
|
663
636
|
var callbacks = _this7.subscriptions.get(syncBlockInstance.resourceId);
|
|
664
637
|
var localIds = callbacks ? Object.keys(callbacks) : [];
|
|
665
638
|
localIds.forEach(function (localId) {
|
|
@@ -669,18 +642,16 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
669
642
|
}
|
|
670
643
|
_this7.fetchSyncBlockSourceInfo(resolvedSyncBlockInstance.resourceId);
|
|
671
644
|
});
|
|
672
|
-
if (
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
(_this$fetchExperience4 = this.fetchExperience) === null || _this$fetchExperience4 === void 0 || _this$fetchExperience4.success();
|
|
683
|
-
}
|
|
645
|
+
if (hasUnexpectedError) {
|
|
646
|
+
(_this$fetchExperience2 = this.fetchExperience) === null || _this$fetchExperience2 === void 0 || _this$fetchExperience2.failure({
|
|
647
|
+
reason: 'Unexpected error during fetch'
|
|
648
|
+
});
|
|
649
|
+
} else if (hasExpectedError) {
|
|
650
|
+
(_this$fetchExperience3 = this.fetchExperience) === null || _this$fetchExperience3 === void 0 || _this$fetchExperience3.abort({
|
|
651
|
+
reason: 'Expected error: NotFound or PermissionDenied'
|
|
652
|
+
});
|
|
653
|
+
} else {
|
|
654
|
+
(_this$fetchExperience4 = this.fetchExperience) === null || _this$fetchExperience4 === void 0 || _this$fetchExperience4.success();
|
|
684
655
|
}
|
|
685
656
|
case 17:
|
|
686
657
|
case "end":
|
|
@@ -804,7 +775,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
804
775
|
|
|
805
776
|
// call the callback immediately if we have cached data
|
|
806
777
|
var cachedData = fg('platform_synced_block_patch_1') ? // When feature flag is enabled, use dataProvider cache only
|
|
807
|
-
(_this$dataProvider7 = this.dataProvider) === null || _this$dataProvider7 === void 0 || (_this$dataProvider7 = _this$dataProvider7.getNodeDataFromCache(syncBlockNode)) === null || _this$dataProvider7 === void 0 ? void 0 : _this$dataProvider7.data : isSSR()
|
|
778
|
+
(_this$dataProvider7 = this.dataProvider) === null || _this$dataProvider7 === void 0 || (_this$dataProvider7 = _this$dataProvider7.getNodeDataFromCache(syncBlockNode)) === null || _this$dataProvider7 === void 0 ? void 0 : _this$dataProvider7.data : isSSR() // in SSR, prefer data provider cache
|
|
808
779
|
? ((_this$dataProvider8 = this.dataProvider) === null || _this$dataProvider8 === void 0 || (_this$dataProvider8 = _this$dataProvider8.getNodeDataFromCache(syncBlockNode)) === null || _this$dataProvider8 === void 0 ? void 0 : _this$dataProvider8.data) || this.getFromCache(resourceId) : this.getFromCache(resourceId) || ((_this$dataProvider9 = this.dataProvider) === null || _this$dataProvider9 === void 0 || (_this$dataProvider9 = _this$dataProvider9.getNodeDataFromCache(syncBlockNode)) === null || _this$dataProvider9 === void 0 ? void 0 : _this$dataProvider9.data);
|
|
809
780
|
if (cachedData) {
|
|
810
781
|
callback(cachedData);
|
|
@@ -985,9 +956,6 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
985
956
|
}, {
|
|
986
957
|
key: "getSSRProviders",
|
|
987
958
|
value: function getSSRProviders(resourceId) {
|
|
988
|
-
if (!fg('platform_synced_block_dogfooding')) {
|
|
989
|
-
return null;
|
|
990
|
-
}
|
|
991
959
|
if (!this.dataProvider) {
|
|
992
960
|
return null;
|
|
993
961
|
}
|
|
@@ -1088,7 +1056,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
1088
1056
|
key: "flush",
|
|
1089
1057
|
value: (function () {
|
|
1090
1058
|
var _flush = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
1091
|
-
var success,
|
|
1059
|
+
var success, _this$saveExperience, blocks, updateResult, _this$saveExperience2, _this$fireAnalyticsEv1, _this$saveExperience3, _this$fireAnalyticsEv10, _this$saveExperience4;
|
|
1092
1060
|
return _regeneratorRuntime.wrap(function _callee3$(_context4) {
|
|
1093
1061
|
while (1) switch (_context4.prev = _context4.next) {
|
|
1094
1062
|
case 0:
|
|
@@ -1112,76 +1080,59 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
1112
1080
|
});
|
|
1113
1081
|
});
|
|
1114
1082
|
});
|
|
1115
|
-
if (fg('platform_synced_block_dogfooding')) {
|
|
1116
|
-
_context4.next = 10;
|
|
1117
|
-
break;
|
|
1118
|
-
}
|
|
1119
|
-
if (!(blocks.length === 0)) {
|
|
1120
|
-
_context4.next = 10;
|
|
1121
|
-
break;
|
|
1122
|
-
}
|
|
1123
|
-
this.isCacheDirty = false;
|
|
1124
|
-
return _context4.abrupt("return", true);
|
|
1125
|
-
case 10:
|
|
1126
1083
|
if (this.dataProvider) {
|
|
1127
|
-
_context4.next =
|
|
1084
|
+
_context4.next = 8;
|
|
1128
1085
|
break;
|
|
1129
1086
|
}
|
|
1130
1087
|
throw new Error('Data provider not set');
|
|
1131
|
-
case
|
|
1088
|
+
case 8:
|
|
1132
1089
|
// reset isCacheDirty early to prevent race condition
|
|
1133
1090
|
// There is a race condition where if a user makes changes (create/delete) to a reference sync block
|
|
1134
1091
|
// on a live page and the reference sync block is being saved while the user
|
|
1135
1092
|
// is still making changes, the new changes might not be saved if they all happen
|
|
1136
1093
|
// exactly at a time when the updateReferenceData is being executed asynchronously.
|
|
1137
1094
|
this.isCacheDirty = false;
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
}
|
|
1141
|
-
_context4.next = 16;
|
|
1095
|
+
(_this$saveExperience = this.saveExperience) === null || _this$saveExperience === void 0 || _this$saveExperience.start();
|
|
1096
|
+
_context4.next = 12;
|
|
1142
1097
|
return this.dataProvider.updateReferenceData(blocks);
|
|
1143
|
-
case
|
|
1098
|
+
case 12:
|
|
1144
1099
|
updateResult = _context4.sent;
|
|
1145
1100
|
if (!updateResult.success) {
|
|
1146
1101
|
success = false;
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
});
|
|
1151
|
-
}
|
|
1102
|
+
(_this$saveExperience2 = this.saveExperience) === null || _this$saveExperience2 === void 0 || _this$saveExperience2.failure({
|
|
1103
|
+
reason: updateResult.error || 'Failed to update reference synced blocks on the document'
|
|
1104
|
+
});
|
|
1152
1105
|
(_this$fireAnalyticsEv1 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv1 === void 0 || _this$fireAnalyticsEv1.call(this, updateReferenceErrorPayload(updateResult.error || 'Failed to update reference synced blocks on the document'));
|
|
1153
1106
|
}
|
|
1154
|
-
_context4.next =
|
|
1107
|
+
_context4.next = 22;
|
|
1155
1108
|
break;
|
|
1156
|
-
case
|
|
1157
|
-
_context4.prev =
|
|
1109
|
+
case 16:
|
|
1110
|
+
_context4.prev = 16;
|
|
1158
1111
|
_context4.t0 = _context4["catch"](3);
|
|
1159
1112
|
success = false;
|
|
1160
1113
|
logException(_context4.t0, {
|
|
1161
1114
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
1162
1115
|
});
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
});
|
|
1167
|
-
}
|
|
1116
|
+
(_this$saveExperience3 = this.saveExperience) === null || _this$saveExperience3 === void 0 || _this$saveExperience3.failure({
|
|
1117
|
+
reason: _context4.t0.message
|
|
1118
|
+
});
|
|
1168
1119
|
(_this$fireAnalyticsEv10 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv10 === void 0 || _this$fireAnalyticsEv10.call(this, updateReferenceErrorPayload(_context4.t0.message));
|
|
1169
|
-
case
|
|
1170
|
-
_context4.prev =
|
|
1120
|
+
case 22:
|
|
1121
|
+
_context4.prev = 22;
|
|
1171
1122
|
if (!success) {
|
|
1172
1123
|
// set isCacheDirty back to true for cases where it failed to update the reference synced blocks on the BE
|
|
1173
1124
|
this.isCacheDirty = true;
|
|
1174
|
-
} else
|
|
1125
|
+
} else {
|
|
1175
1126
|
(_this$saveExperience4 = this.saveExperience) === null || _this$saveExperience4 === void 0 || _this$saveExperience4.success();
|
|
1176
1127
|
}
|
|
1177
|
-
return _context4.finish(
|
|
1178
|
-
case
|
|
1128
|
+
return _context4.finish(22);
|
|
1129
|
+
case 25:
|
|
1179
1130
|
return _context4.abrupt("return", success);
|
|
1180
|
-
case
|
|
1131
|
+
case 26:
|
|
1181
1132
|
case "end":
|
|
1182
1133
|
return _context4.stop();
|
|
1183
1134
|
}
|
|
1184
|
-
}, _callee3, this, [[3,
|
|
1135
|
+
}, _callee3, this, [[3, 16, 22, 25]]);
|
|
1185
1136
|
}));
|
|
1186
1137
|
function flush() {
|
|
1187
1138
|
return _flush.apply(this, arguments);
|