@atlaskit/editor-synced-block-provider 3.14.2 → 3.14.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/cjs/clients/block-service/blockService.js +12 -9
- package/dist/cjs/providers/block-service/blockServiceAPI.js +28 -18
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +61 -23
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +27 -5
- package/dist/cjs/store-manager/syncBlockStoreManager.js +53 -22
- package/dist/cjs/utils/experienceTracking.js +18 -1
- package/dist/es2019/clients/block-service/blockService.js +5 -1
- package/dist/es2019/providers/block-service/blockServiceAPI.js +17 -7
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +68 -34
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +27 -6
- package/dist/es2019/store-manager/syncBlockStoreManager.js +36 -2
- package/dist/es2019/utils/experienceTracking.js +17 -0
- package/dist/esm/clients/block-service/blockService.js +12 -9
- package/dist/esm/providers/block-service/blockServiceAPI.js +28 -18
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +61 -23
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +28 -6
- package/dist/esm/store-manager/syncBlockStoreManager.js +53 -22
- package/dist/esm/utils/experienceTracking.js +17 -0
- package/dist/types/clients/block-service/blockService.d.ts +3 -2
- package/dist/types/providers/block-service/blockServiceAPI.d.ts +5 -2
- package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +9 -0
- package/dist/types/store-manager/sourceSyncBlockStoreManager.d.ts +1 -0
- package/dist/types/store-manager/syncBlockStoreManager.d.ts +2 -0
- package/dist/types/utils/experienceTracking.d.ts +8 -0
- package/dist/types-ts4.5/clients/block-service/blockService.d.ts +3 -2
- package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +5 -2
- package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +9 -0
- package/dist/types-ts4.5/store-manager/sourceSyncBlockStoreManager.d.ts +1 -0
- package/dist/types-ts4.5/store-manager/syncBlockStoreManager.d.ts +2 -0
- package/dist/types-ts4.5/utils/experienceTracking.d.ts +8 -0
- package/package.json +2 -2
|
@@ -3,7 +3,7 @@ import { logException } from '@atlaskit/editor-common/monitoring';
|
|
|
3
3
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
4
|
import { SyncBlockError } from '../common/types';
|
|
5
5
|
import { updateErrorPayload, createErrorPayload, deleteErrorPayload, updateCacheErrorPayload, getSourceInfoErrorPayload, updateSuccessPayload, createSuccessPayload, deleteSuccessPayload, fetchReferencesErrorPayload } from '../utils/errorHandling';
|
|
6
|
-
import { getCreateSourceExperience, getDeleteSourceExperience, getSaveSourceExperience } from '../utils/experienceTracking';
|
|
6
|
+
import { getCreateSourceExperience, getDeleteSourceExperience, getSaveSourceExperience, getFetchSourceInfoExperience } from '../utils/experienceTracking';
|
|
7
7
|
import { convertSyncBlockPMNodeToSyncBlockData } from '../utils/utils';
|
|
8
8
|
// A store manager responsible for the lifecycle and state management of source sync blocks in an editor instance.
|
|
9
9
|
// Designed to manage local in-memory state and synchronize with an external data provider.
|
|
@@ -26,6 +26,7 @@ export class SourceSyncBlockStoreManager {
|
|
|
26
26
|
this.createExperience = getCreateSourceExperience(fireAnalyticsEvent);
|
|
27
27
|
this.saveExperience = getSaveSourceExperience(fireAnalyticsEvent);
|
|
28
28
|
this.deleteExperience = getDeleteSourceExperience(fireAnalyticsEvent);
|
|
29
|
+
this.fetchSourceInfoExperience = getFetchSourceInfoExperience(fireAnalyticsEvent);
|
|
29
30
|
}
|
|
30
31
|
isSourceBlock(node) {
|
|
31
32
|
return node.type.name === 'bodiedSyncBlock';
|
|
@@ -396,7 +397,24 @@ export class SourceSyncBlockStoreManager {
|
|
|
396
397
|
if (!this.dataProvider) {
|
|
397
398
|
throw new Error('Data provider not set');
|
|
398
399
|
}
|
|
399
|
-
|
|
400
|
+
if (fg('platform_synced_block_dogfooding')) {
|
|
401
|
+
var _this$fetchSourceInfo;
|
|
402
|
+
(_this$fetchSourceInfo = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo === void 0 ? void 0 : _this$fetchSourceInfo.start();
|
|
403
|
+
}
|
|
404
|
+
return this.dataProvider.fetchSyncBlockSourceInfo(localId, undefined, undefined, this.fireAnalyticsEvent).then(sourceInfo => {
|
|
405
|
+
if (fg('platform_synced_block_dogfooding')) {
|
|
406
|
+
if (!sourceInfo) {
|
|
407
|
+
var _this$fetchSourceInfo2;
|
|
408
|
+
(_this$fetchSourceInfo2 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo2 === void 0 ? void 0 : _this$fetchSourceInfo2.failure({
|
|
409
|
+
reason: "No source info returned"
|
|
410
|
+
});
|
|
411
|
+
} else {
|
|
412
|
+
var _this$fetchSourceInfo3;
|
|
413
|
+
(_this$fetchSourceInfo3 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo3 === void 0 ? void 0 : _this$fetchSourceInfo3.success();
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
return sourceInfo;
|
|
417
|
+
});
|
|
400
418
|
} catch (error) {
|
|
401
419
|
var _this$fireAnalyticsEv13;
|
|
402
420
|
logException(error, {
|
|
@@ -424,20 +442,23 @@ export class SourceSyncBlockStoreManager {
|
|
|
424
442
|
}
|
|
425
443
|
}
|
|
426
444
|
destroy() {
|
|
427
|
-
var _this$saveExperience4, _this$createExperienc5, _this$deleteExperienc4;
|
|
445
|
+
var _this$saveExperience4, _this$createExperienc5, _this$deleteExperienc4, _this$fetchSourceInfo4;
|
|
428
446
|
this.syncBlockCache.clear();
|
|
429
447
|
this.confirmationCallback = undefined;
|
|
430
448
|
this.pendingResourceId = undefined;
|
|
431
449
|
this.creationCallback = undefined;
|
|
432
450
|
this.dataProvider = undefined;
|
|
433
451
|
(_this$saveExperience4 = this.saveExperience) === null || _this$saveExperience4 === void 0 ? void 0 : _this$saveExperience4.abort({
|
|
434
|
-
reason: '
|
|
452
|
+
reason: 'editorDestroyed'
|
|
435
453
|
});
|
|
436
454
|
(_this$createExperienc5 = this.createExperience) === null || _this$createExperienc5 === void 0 ? void 0 : _this$createExperienc5.abort({
|
|
437
|
-
reason: '
|
|
455
|
+
reason: 'editorDestroyed'
|
|
438
456
|
});
|
|
439
457
|
(_this$deleteExperienc4 = this.deleteExperience) === null || _this$deleteExperienc4 === void 0 ? void 0 : _this$deleteExperienc4.abort({
|
|
440
|
-
reason: '
|
|
458
|
+
reason: 'editorDestroyed'
|
|
459
|
+
});
|
|
460
|
+
(_this$fetchSourceInfo4 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo4 === void 0 ? void 0 : _this$fetchSourceInfo4.abort({
|
|
461
|
+
reason: 'editorDestroyed'
|
|
441
462
|
});
|
|
442
463
|
this.clearPendingDeletion();
|
|
443
464
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
4
|
import { getProductFromSourceAri } from '../clients/block-service/ari';
|
|
4
5
|
import { SyncBlockError } from '../common/types';
|
|
5
6
|
import { fetchReferencesErrorPayload } from '../utils/errorHandling';
|
|
7
|
+
import { getFetchReferencesExperience, getFetchSourceInfoExperience } from '../utils/experienceTracking';
|
|
6
8
|
import { ReferenceSyncBlockStoreManager } from './referenceSyncBlockStoreManager';
|
|
7
9
|
import { SourceSyncBlockStoreManager } from './sourceSyncBlockStoreManager';
|
|
8
10
|
|
|
@@ -21,30 +23,51 @@ export class SyncBlockStoreManager {
|
|
|
21
23
|
}
|
|
22
24
|
async fetchReferencesSourceInfo(resourceId, blockInstanceId, isSourceSyncBlock) {
|
|
23
25
|
try {
|
|
24
|
-
var _response$references;
|
|
26
|
+
var _this$fetchReferences, _response$references, _this$fetchReferences5;
|
|
25
27
|
if (!this.dataProvider) {
|
|
26
28
|
throw new Error('Data provider not set');
|
|
27
29
|
}
|
|
30
|
+
(_this$fetchReferences = this.fetchReferencesExperience) === null || _this$fetchReferences === void 0 ? void 0 : _this$fetchReferences.start();
|
|
28
31
|
const response = await this.dataProvider.fetchReferences(resourceId, isSourceSyncBlock);
|
|
29
32
|
if (response.error) {
|
|
33
|
+
var _this$fetchReferences2;
|
|
34
|
+
(_this$fetchReferences2 = this.fetchReferencesExperience) === null || _this$fetchReferences2 === void 0 ? void 0 : _this$fetchReferences2.failure({
|
|
35
|
+
reason: response.error
|
|
36
|
+
});
|
|
30
37
|
return {
|
|
31
38
|
error: response.error
|
|
32
39
|
};
|
|
33
40
|
}
|
|
34
41
|
if (!response.references || ((_response$references = response.references) === null || _response$references === void 0 ? void 0 : _response$references.length) === 0) {
|
|
35
42
|
// No reference found
|
|
43
|
+
if (isSourceSyncBlock) {
|
|
44
|
+
var _this$fetchReferences3;
|
|
45
|
+
(_this$fetchReferences3 = this.fetchReferencesExperience) === null || _this$fetchReferences3 === void 0 ? void 0 : _this$fetchReferences3.success();
|
|
46
|
+
} else {
|
|
47
|
+
var _this$fetchReferences4;
|
|
48
|
+
(_this$fetchReferences4 = this.fetchReferencesExperience) === null || _this$fetchReferences4 === void 0 ? void 0 : _this$fetchReferences4.failure({
|
|
49
|
+
reason: 'No references found for reference synced block'
|
|
50
|
+
});
|
|
51
|
+
}
|
|
36
52
|
return isSourceSyncBlock ? {
|
|
37
53
|
references: []
|
|
38
54
|
} : {
|
|
39
55
|
error: SyncBlockError.Errored
|
|
40
56
|
};
|
|
41
57
|
}
|
|
58
|
+
(_this$fetchReferences5 = this.fetchReferencesExperience) === null || _this$fetchReferences5 === void 0 ? void 0 : _this$fetchReferences5.success();
|
|
42
59
|
const sourceInfoPromises = response.references.map(async reference => {
|
|
43
|
-
var _this$dataProvider;
|
|
60
|
+
var _this$fetchSourceInfo, _this$dataProvider, _this$fetchSourceInfo3;
|
|
61
|
+
(_this$fetchSourceInfo = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo === void 0 ? void 0 : _this$fetchSourceInfo.start();
|
|
44
62
|
const sourceInfo = await ((_this$dataProvider = this.dataProvider) === null || _this$dataProvider === void 0 ? void 0 : _this$dataProvider.fetchSyncBlockSourceInfo(reference.blockInstanceId || '', reference.documentAri, getProductFromSourceAri(reference.documentAri), this.fireAnalyticsEvent, reference.hasAccess, 'view'));
|
|
45
63
|
if (!sourceInfo) {
|
|
64
|
+
var _this$fetchSourceInfo2;
|
|
65
|
+
(_this$fetchSourceInfo2 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo2 === void 0 ? void 0 : _this$fetchSourceInfo2.failure({
|
|
66
|
+
reason: `no source info returned for ari: ${reference.documentAri}`
|
|
67
|
+
});
|
|
46
68
|
return undefined;
|
|
47
69
|
}
|
|
70
|
+
(_this$fetchSourceInfo3 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo3 === void 0 ? void 0 : _this$fetchSourceInfo3.success();
|
|
48
71
|
return {
|
|
49
72
|
...sourceInfo,
|
|
50
73
|
onSameDocument: reference.onSameDocument,
|
|
@@ -81,6 +104,10 @@ export class SyncBlockStoreManager {
|
|
|
81
104
|
this.fireAnalyticsEvent = fireAnalyticsEvent;
|
|
82
105
|
this.referenceSyncBlockStoreManager.setFireAnalyticsEvent(fireAnalyticsEvent);
|
|
83
106
|
this.sourceSyncBlockStoreManager.setFireAnalyticsEvent(fireAnalyticsEvent);
|
|
107
|
+
if (fg('platform_synced_block_dogfooding')) {
|
|
108
|
+
this.fetchReferencesExperience = getFetchReferencesExperience(fireAnalyticsEvent);
|
|
109
|
+
this.fetchSourceInfoExperience = getFetchSourceInfoExperience(fireAnalyticsEvent);
|
|
110
|
+
}
|
|
84
111
|
}
|
|
85
112
|
get referenceManager() {
|
|
86
113
|
return this.referenceSyncBlockStoreManager;
|
|
@@ -89,8 +116,15 @@ export class SyncBlockStoreManager {
|
|
|
89
116
|
return this.sourceSyncBlockStoreManager;
|
|
90
117
|
}
|
|
91
118
|
destroy() {
|
|
119
|
+
var _this$fetchReferences6, _this$fetchSourceInfo4;
|
|
92
120
|
this.referenceSyncBlockStoreManager.destroy();
|
|
93
121
|
this.sourceSyncBlockStoreManager.destroy();
|
|
122
|
+
(_this$fetchReferences6 = this.fetchReferencesExperience) === null || _this$fetchReferences6 === void 0 ? void 0 : _this$fetchReferences6.abort({
|
|
123
|
+
reason: 'editorDestroyed'
|
|
124
|
+
});
|
|
125
|
+
(_this$fetchSourceInfo4 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo4 === void 0 ? void 0 : _this$fetchSourceInfo4.abort({
|
|
126
|
+
reason: 'editorDestroyed'
|
|
127
|
+
});
|
|
94
128
|
}
|
|
95
129
|
}
|
|
96
130
|
const createSyncBlockStoreManager = dataProvider => {
|
|
@@ -110,4 +110,21 @@ export const getCreateSourceExperience = fireAnalyticsEvent => {
|
|
|
110
110
|
durationMs: TIMEOUT_DURATION
|
|
111
111
|
})]
|
|
112
112
|
});
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* This experience tracks when a source sync block is created and registered to the BE.
|
|
117
|
+
*
|
|
118
|
+
* Start: When the fetchSourceInfo function is called.
|
|
119
|
+
* Success: When the fetching the data is successful within the timeout duration of start.
|
|
120
|
+
* Failure: When the timeout duration passes without the data being successfully fetched, or the fetch fails
|
|
121
|
+
*/
|
|
122
|
+
export const getFetchReferencesExperience = fireAnalyticsEvent => {
|
|
123
|
+
return new Experience(EXPERIENCE_ID.ASYNC_OPERATION, {
|
|
124
|
+
action: ACTION.SYNCED_BLOCK_FETCH_REFERENCES,
|
|
125
|
+
dispatchAnalyticsEvent: createExperienceDispatcher(fireAnalyticsEvent),
|
|
126
|
+
checks: [new ExperienceCheckTimeout({
|
|
127
|
+
durationMs: TIMEOUT_DURATION
|
|
128
|
+
})]
|
|
129
|
+
});
|
|
113
130
|
};
|
|
@@ -285,11 +285,11 @@ export var updateSyncedBlock = /*#__PURE__*/function () {
|
|
|
285
285
|
}();
|
|
286
286
|
export var createSyncedBlock = /*#__PURE__*/function () {
|
|
287
287
|
var _ref1 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref0) {
|
|
288
|
-
var blockAri, blockInstanceId, sourceAri, product, content, stepVersion, requestBody, response;
|
|
288
|
+
var blockAri, blockInstanceId, sourceAri, product, content, stepVersion, status, requestBody, response;
|
|
289
289
|
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
290
290
|
while (1) switch (_context6.prev = _context6.next) {
|
|
291
291
|
case 0:
|
|
292
|
-
blockAri = _ref0.blockAri, blockInstanceId = _ref0.blockInstanceId, sourceAri = _ref0.sourceAri, product = _ref0.product, content = _ref0.content, stepVersion = _ref0.stepVersion;
|
|
292
|
+
blockAri = _ref0.blockAri, blockInstanceId = _ref0.blockInstanceId, sourceAri = _ref0.sourceAri, product = _ref0.product, content = _ref0.content, stepVersion = _ref0.stepVersion, status = _ref0.status;
|
|
293
293
|
requestBody = {
|
|
294
294
|
blockAri: blockAri,
|
|
295
295
|
blockInstanceId: blockInstanceId,
|
|
@@ -300,25 +300,28 @@ export var createSyncedBlock = /*#__PURE__*/function () {
|
|
|
300
300
|
if (stepVersion !== undefined) {
|
|
301
301
|
requestBody.stepVersion = stepVersion;
|
|
302
302
|
}
|
|
303
|
-
|
|
303
|
+
if (status !== undefined && fg('platform_synced_block_dogfooding')) {
|
|
304
|
+
requestBody.status = status;
|
|
305
|
+
}
|
|
306
|
+
_context6.next = 6;
|
|
304
307
|
return fetchWithRetry("".concat(BLOCK_SERVICE_API_URL, "/block"), {
|
|
305
308
|
method: 'POST',
|
|
306
309
|
headers: COMMON_HEADERS,
|
|
307
310
|
body: JSON.stringify(requestBody)
|
|
308
311
|
});
|
|
309
|
-
case
|
|
312
|
+
case 6:
|
|
310
313
|
response = _context6.sent;
|
|
311
314
|
if (response.ok) {
|
|
312
|
-
_context6.next =
|
|
315
|
+
_context6.next = 9;
|
|
313
316
|
break;
|
|
314
317
|
}
|
|
315
318
|
throw new BlockError(response.status);
|
|
316
|
-
case
|
|
317
|
-
_context6.next =
|
|
319
|
+
case 9:
|
|
320
|
+
_context6.next = 11;
|
|
318
321
|
return response.json();
|
|
319
|
-
case 10:
|
|
320
|
-
return _context6.abrupt("return", _context6.sent);
|
|
321
322
|
case 11:
|
|
323
|
+
return _context6.abrupt("return", _context6.sent);
|
|
324
|
+
case 12:
|
|
322
325
|
case "end":
|
|
323
326
|
return _context6.stop();
|
|
324
327
|
}
|
|
@@ -11,6 +11,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
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';
|
|
14
15
|
import { generateBlockAri, generateBlockAriFromReference } from '../../clients/block-service/ari';
|
|
15
16
|
import { batchRetrieveSyncedBlocks, BlockError, createSyncedBlock, deleteSyncedBlock, getReferenceSyncedBlocks, getReferenceSyncedBlocksByBlockAri, getSyncedBlockContent, updateReferenceSyncedBlockOnDocument, updateSyncedBlock } from '../../clients/block-service/blockService';
|
|
16
17
|
import { subscribeToBlockUpdates as subscribeToBlockUpdatesWS } from '../../clients/block-service/blockSubscription';
|
|
@@ -609,13 +610,15 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
609
610
|
parentAri = _ref4.parentAri,
|
|
610
611
|
parentId = _ref4.parentId,
|
|
611
612
|
product = _ref4.product,
|
|
612
|
-
getVersion = _ref4.getVersion
|
|
613
|
+
getVersion = _ref4.getVersion,
|
|
614
|
+
isParentUnpublished = _ref4.isParentUnpublished;
|
|
613
615
|
_classCallCheck(this, BlockServiceADFWriteProvider);
|
|
614
616
|
this.cloudId = cloudId;
|
|
615
617
|
this.parentAri = parentAri;
|
|
616
618
|
this.parentId = parentId;
|
|
617
619
|
this.product = product;
|
|
618
620
|
this.getVersion = getVersion;
|
|
621
|
+
this.isParentUnpublished = isParentUnpublished;
|
|
619
622
|
}
|
|
620
623
|
|
|
621
624
|
// it will first try to update and if it can't (404) then it will try to create
|
|
@@ -685,7 +688,8 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
685
688
|
key: "createData",
|
|
686
689
|
value: function () {
|
|
687
690
|
var _createData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(data) {
|
|
688
|
-
var
|
|
691
|
+
var _this$isParentUnpubli;
|
|
692
|
+
var resourceId, blockAri, stepVersion, status;
|
|
689
693
|
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
690
694
|
while (1) switch (_context6.prev = _context6.next) {
|
|
691
695
|
case 0:
|
|
@@ -705,41 +709,43 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
705
709
|
resourceId: resourceId
|
|
706
710
|
});
|
|
707
711
|
stepVersion = this.getVersion ? this.getVersion() : undefined;
|
|
708
|
-
|
|
709
|
-
_context6.
|
|
712
|
+
status = fg('platform_synced_block_dogfooding') ? (_this$isParentUnpubli = this.isParentUnpublished) !== null && _this$isParentUnpubli !== void 0 && _this$isParentUnpubli.call(this) ? 'unpublished' : data.status || 'active' : undefined;
|
|
713
|
+
_context6.prev = 6;
|
|
714
|
+
_context6.next = 9;
|
|
710
715
|
return createSyncedBlock({
|
|
711
716
|
blockAri: blockAri,
|
|
712
717
|
blockInstanceId: data.blockInstanceId,
|
|
713
718
|
sourceAri: this.parentAri,
|
|
714
719
|
product: this.product,
|
|
715
720
|
content: JSON.stringify(data.content),
|
|
716
|
-
stepVersion: stepVersion
|
|
721
|
+
stepVersion: stepVersion,
|
|
722
|
+
status: status
|
|
717
723
|
});
|
|
718
|
-
case
|
|
724
|
+
case 9:
|
|
719
725
|
return _context6.abrupt("return", {
|
|
720
726
|
resourceId: resourceId
|
|
721
727
|
});
|
|
722
|
-
case
|
|
723
|
-
_context6.prev =
|
|
724
|
-
_context6.t0 = _context6["catch"](
|
|
728
|
+
case 12:
|
|
729
|
+
_context6.prev = 12;
|
|
730
|
+
_context6.t0 = _context6["catch"](6);
|
|
725
731
|
if (!(_context6.t0 instanceof BlockError)) {
|
|
726
|
-
_context6.next =
|
|
732
|
+
_context6.next = 16;
|
|
727
733
|
break;
|
|
728
734
|
}
|
|
729
735
|
return _context6.abrupt("return", {
|
|
730
736
|
error: mapBlockError(_context6.t0),
|
|
731
737
|
resourceId: resourceId
|
|
732
738
|
});
|
|
733
|
-
case
|
|
739
|
+
case 16:
|
|
734
740
|
return _context6.abrupt("return", {
|
|
735
741
|
error: stringifyError(_context6.t0),
|
|
736
742
|
resourceId: resourceId
|
|
737
743
|
});
|
|
738
|
-
case
|
|
744
|
+
case 17:
|
|
739
745
|
case "end":
|
|
740
746
|
return _context6.stop();
|
|
741
747
|
}
|
|
742
|
-
}, _callee6, this, [[
|
|
748
|
+
}, _callee6, this, [[6, 12]]);
|
|
743
749
|
}));
|
|
744
750
|
function createData(_x6) {
|
|
745
751
|
return _createData.apply(this, arguments);
|
|
@@ -900,7 +906,8 @@ var createBlockServiceAPIProviders = function createBlockServiceAPIProviders(_re
|
|
|
900
906
|
parentAri = _ref5.parentAri,
|
|
901
907
|
parentId = _ref5.parentId,
|
|
902
908
|
product = _ref5.product,
|
|
903
|
-
getVersion = _ref5.getVersion
|
|
909
|
+
getVersion = _ref5.getVersion,
|
|
910
|
+
isParentUnpublished = _ref5.isParentUnpublished;
|
|
904
911
|
return {
|
|
905
912
|
fetchProvider: new BlockServiceADFFetchProvider({
|
|
906
913
|
cloudId: cloudId,
|
|
@@ -911,7 +918,8 @@ var createBlockServiceAPIProviders = function createBlockServiceAPIProviders(_re
|
|
|
911
918
|
parentAri: parentAri,
|
|
912
919
|
parentId: parentId,
|
|
913
920
|
product: product,
|
|
914
|
-
getVersion: getVersion
|
|
921
|
+
getVersion: getVersion,
|
|
922
|
+
isParentUnpublished: isParentUnpublished
|
|
915
923
|
})
|
|
916
924
|
};
|
|
917
925
|
};
|
|
@@ -920,16 +928,18 @@ export var useMemoizedBlockServiceAPIProviders = function useMemoizedBlockServic
|
|
|
920
928
|
parentAri = _ref6.parentAri,
|
|
921
929
|
parentId = _ref6.parentId,
|
|
922
930
|
product = _ref6.product,
|
|
923
|
-
getVersion = _ref6.getVersion
|
|
931
|
+
getVersion = _ref6.getVersion,
|
|
932
|
+
isParentUnpublished = _ref6.isParentUnpublished;
|
|
924
933
|
return useMemo(function () {
|
|
925
934
|
return createBlockServiceAPIProviders({
|
|
926
935
|
cloudId: cloudId,
|
|
927
936
|
parentAri: parentAri,
|
|
928
937
|
parentId: parentId,
|
|
929
938
|
product: product,
|
|
930
|
-
getVersion: getVersion
|
|
939
|
+
getVersion: getVersion,
|
|
940
|
+
isParentUnpublished: isParentUnpublished
|
|
931
941
|
});
|
|
932
|
-
}, [cloudId, parentAri, parentId, product, getVersion]);
|
|
942
|
+
}, [cloudId, parentAri, parentId, product, getVersion, isParentUnpublished]);
|
|
933
943
|
};
|
|
934
944
|
var createBlockServiceFetchOnlyAPIProvider = function createBlockServiceFetchOnlyAPIProvider(_ref7) {
|
|
935
945
|
var cloudId = _ref7.cloudId,
|
|
@@ -27,6 +27,10 @@ import { createSyncBlockNode } from '../utils/utils';
|
|
|
27
27
|
export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
28
28
|
// Listeners for subscription changes (used by React components to know when to update)
|
|
29
29
|
|
|
30
|
+
// Track newly added sync blocks (resourceIds that were just subscribed to without cached data)
|
|
31
|
+
|
|
32
|
+
// Callback to notify when an unpublished sync block is detected
|
|
33
|
+
|
|
30
34
|
function ReferenceSyncBlockStoreManager(dataProvider) {
|
|
31
35
|
_classCallCheck(this, ReferenceSyncBlockStoreManager);
|
|
32
36
|
// Keeps track of addition and deletion of reference synced blocks on the document
|
|
@@ -47,6 +51,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
47
51
|
this.pendingCacheDeletions = new Map();
|
|
48
52
|
this.graphqlSubscriptions = new Map();
|
|
49
53
|
this.subscriptionChangeListeners = new Set();
|
|
54
|
+
this.newlyAddedSyncBlocks = new Set();
|
|
50
55
|
}
|
|
51
56
|
|
|
52
57
|
/**
|
|
@@ -151,6 +156,22 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
151
156
|
this.fetchSourceInfoExperience = getFetchSourceInfoExperience(fireAnalyticsEvent);
|
|
152
157
|
this.saveExperience = getSaveReferenceExperience(fireAnalyticsEvent);
|
|
153
158
|
}
|
|
159
|
+
}, {
|
|
160
|
+
key: "setOnUnpublishedSyncBlockDetected",
|
|
161
|
+
value: function setOnUnpublishedSyncBlockDetected(callback) {
|
|
162
|
+
this.onUnpublishedSyncBlockDetected = callback;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Mark a sync block as newly added to the document.
|
|
167
|
+
* This should be called when a sync block node is added via a transaction.
|
|
168
|
+
* @param resourceId - The resource ID of the newly added sync block
|
|
169
|
+
*/
|
|
170
|
+
}, {
|
|
171
|
+
key: "markAsNewlyAdded",
|
|
172
|
+
value: function markAsNewlyAdded(resourceId) {
|
|
173
|
+
this.newlyAddedSyncBlocks.add(resourceId);
|
|
174
|
+
}
|
|
154
175
|
}, {
|
|
155
176
|
key: "generateResourceIdForReference",
|
|
156
177
|
value: function generateResourceIdForReference(sourceId) {
|
|
@@ -306,13 +327,18 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
306
327
|
key: "handleGraphQLSubscriptionUpdate",
|
|
307
328
|
value: function handleGraphQLSubscriptionUpdate(syncBlockInstance) {
|
|
308
329
|
if (!syncBlockInstance.resourceId) {
|
|
309
|
-
|
|
330
|
+
throw new Error('Sync block instance provided to graphql subscription update missing resource id');
|
|
310
331
|
}
|
|
311
332
|
var existingSyncBlock = this.getFromCache(syncBlockInstance.resourceId);
|
|
312
333
|
var resolvedSyncBlockInstance = existingSyncBlock ? resolveSyncBlockInstance(existingSyncBlock, syncBlockInstance) : syncBlockInstance;
|
|
313
334
|
this.updateCache(resolvedSyncBlockInstance);
|
|
314
335
|
if (!syncBlockInstance.error) {
|
|
336
|
+
var _this$fireAnalyticsEv2, _syncBlockInstance$da, _syncBlockInstance$da2;
|
|
337
|
+
(_this$fireAnalyticsEv2 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 || _this$fireAnalyticsEv2.call(this, fetchSuccessPayload(syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.resourceId, syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.blockInstanceId, syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.product));
|
|
315
338
|
this.fetchSyncBlockSourceInfo(resolvedSyncBlockInstance.resourceId);
|
|
339
|
+
} else {
|
|
340
|
+
var _this$fireAnalyticsEv3, _syncBlockInstance$er;
|
|
341
|
+
(_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(this, fetchErrorPayload((_syncBlockInstance$er = syncBlockInstance.error) === null || _syncBlockInstance$er === void 0 ? void 0 : _syncBlockInstance$er.type, syncBlockInstance.resourceId));
|
|
316
342
|
}
|
|
317
343
|
}
|
|
318
344
|
|
|
@@ -414,8 +440,8 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
414
440
|
}
|
|
415
441
|
}
|
|
416
442
|
if (!sourceAri || !product || !blockInstanceId) {
|
|
417
|
-
var _this$
|
|
418
|
-
(_this$
|
|
443
|
+
var _this$fireAnalyticsEv4;
|
|
444
|
+
(_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(this, getSourceInfoErrorPayload('SourceAri, product or blockInstanceId missing', resourceId));
|
|
419
445
|
return Promise.resolve(undefined);
|
|
420
446
|
}
|
|
421
447
|
if (fg('platform_synced_block_dogfooding')) {
|
|
@@ -474,11 +500,11 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
474
500
|
this.syncBlockSourceInfoRequestsOld.set(resourceId, true);
|
|
475
501
|
}
|
|
476
502
|
} catch (error) {
|
|
477
|
-
var _this$
|
|
503
|
+
var _this$fireAnalyticsEv5;
|
|
478
504
|
logException(error, {
|
|
479
505
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
480
506
|
});
|
|
481
|
-
(_this$
|
|
507
|
+
(_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 || _this$fireAnalyticsEv5.call(this, getSourceInfoErrorPayload(error.message, resourceId));
|
|
482
508
|
}
|
|
483
509
|
return Promise.resolve(undefined);
|
|
484
510
|
}
|
|
@@ -545,14 +571,26 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
545
571
|
hasUnexpectedError = false;
|
|
546
572
|
hasExpectedError = false;
|
|
547
573
|
data.forEach(function (syncBlockInstance) {
|
|
574
|
+
var _resolvedSyncBlockIns;
|
|
548
575
|
if (!syncBlockInstance.resourceId) {
|
|
549
|
-
var _this5$fireAnalyticsE, _syncBlockInstance$
|
|
550
|
-
(_this5$fireAnalyticsE = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE === void 0 || _this5$fireAnalyticsE.call(_this5, fetchErrorPayload(((_syncBlockInstance$
|
|
576
|
+
var _this5$fireAnalyticsE, _syncBlockInstance$er2;
|
|
577
|
+
(_this5$fireAnalyticsE = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE === void 0 || _this5$fireAnalyticsE.call(_this5, fetchErrorPayload(((_syncBlockInstance$er2 = syncBlockInstance.error) === null || _syncBlockInstance$er2 === void 0 ? void 0 : _syncBlockInstance$er2.type) || 'Returned sync block instance does not have resource id'));
|
|
551
578
|
return;
|
|
552
579
|
}
|
|
553
580
|
var existingSyncBlock = _this5.getFromCache(syncBlockInstance.resourceId);
|
|
554
581
|
var resolvedSyncBlockInstance = existingSyncBlock ? resolveSyncBlockInstance(existingSyncBlock, syncBlockInstance) : syncBlockInstance;
|
|
555
582
|
_this5.updateCache(resolvedSyncBlockInstance);
|
|
583
|
+
|
|
584
|
+
// Check if this is a newly added unpublished sync block and notify
|
|
585
|
+
// Only trigger for sync blocks that were just added (not refreshed or loaded on page init)
|
|
586
|
+
if (!syncBlockInstance.error && ((_resolvedSyncBlockIns = resolvedSyncBlockInstance.data) === null || _resolvedSyncBlockIns === void 0 ? void 0 : _resolvedSyncBlockIns.status) === 'unpublished' && _this5.newlyAddedSyncBlocks.has(syncBlockInstance.resourceId) && _this5.onUnpublishedSyncBlockDetected && fg('platform_synced_block_dogfooding')) {
|
|
587
|
+
// Remove from newly added set after checking to prevent duplicate flags
|
|
588
|
+
_this5.newlyAddedSyncBlocks.delete(syncBlockInstance.resourceId);
|
|
589
|
+
_this5.onUnpublishedSyncBlockDetected(resolvedSyncBlockInstance.resourceId);
|
|
590
|
+
} else if (_this5.newlyAddedSyncBlocks.has(syncBlockInstance.resourceId)) {
|
|
591
|
+
// Remove from newly added set even if not unpublished (to clean up)
|
|
592
|
+
_this5.newlyAddedSyncBlocks.delete(syncBlockInstance.resourceId);
|
|
593
|
+
}
|
|
556
594
|
if (syncBlockInstance.error) {
|
|
557
595
|
var _this5$fireAnalyticsE2;
|
|
558
596
|
(_this5$fireAnalyticsE2 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE2 === void 0 || _this5$fireAnalyticsE2.call(_this5, fetchErrorPayload(syncBlockInstance.error.type, syncBlockInstance.resourceId));
|
|
@@ -563,8 +601,8 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
563
601
|
}
|
|
564
602
|
return;
|
|
565
603
|
} else if (fg('platform_synced_block_dogfooding')) {
|
|
566
|
-
var _this5$fireAnalyticsE3, _syncBlockInstance$
|
|
567
|
-
(_this5$fireAnalyticsE3 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE3 === void 0 || _this5$fireAnalyticsE3.call(_this5, fetchSuccessPayload(syncBlockInstance.resourceId, (_syncBlockInstance$
|
|
604
|
+
var _this5$fireAnalyticsE3, _syncBlockInstance$da3, _syncBlockInstance$da4;
|
|
605
|
+
(_this5$fireAnalyticsE3 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE3 === void 0 || _this5$fireAnalyticsE3.call(_this5, fetchSuccessPayload(syncBlockInstance.resourceId, (_syncBlockInstance$da3 = syncBlockInstance.data) === null || _syncBlockInstance$da3 === void 0 ? void 0 : _syncBlockInstance$da3.blockInstanceId, (_syncBlockInstance$da4 = syncBlockInstance.data) === null || _syncBlockInstance$da4 === void 0 ? void 0 : _syncBlockInstance$da4.product));
|
|
568
606
|
}
|
|
569
607
|
_this5.fetchSyncBlockSourceInfo(resolvedSyncBlockInstance.resourceId);
|
|
570
608
|
});
|
|
@@ -775,11 +813,11 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
775
813
|
}
|
|
776
814
|
return this.subscribeToSyncBlock(resourceId, localId, callback);
|
|
777
815
|
} catch (error) {
|
|
778
|
-
var _this$
|
|
816
|
+
var _this$fireAnalyticsEv6;
|
|
779
817
|
logException(error, {
|
|
780
818
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
781
819
|
});
|
|
782
|
-
(_this$
|
|
820
|
+
(_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 || _this$fireAnalyticsEv6.call(this, fetchErrorPayload(error.message));
|
|
783
821
|
return function () {};
|
|
784
822
|
}
|
|
785
823
|
}
|
|
@@ -803,12 +841,12 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
803
841
|
key: "getProviderFactory",
|
|
804
842
|
value: function getProviderFactory(resourceId) {
|
|
805
843
|
if (!this.dataProvider) {
|
|
806
|
-
var _this$
|
|
844
|
+
var _this$fireAnalyticsEv7;
|
|
807
845
|
var error = new Error('Data provider not set');
|
|
808
846
|
logException(error, {
|
|
809
847
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
810
848
|
});
|
|
811
|
-
(_this$
|
|
849
|
+
(_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 || _this$fireAnalyticsEv7.call(this, fetchErrorPayload(error.message));
|
|
812
850
|
return undefined;
|
|
813
851
|
}
|
|
814
852
|
var _this$dataProvider$ge = this.dataProvider.getSyncedBlockRendererProviderOptions(),
|
|
@@ -837,11 +875,11 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
837
875
|
try {
|
|
838
876
|
this.retrieveDynamicProviders(resourceId, providerFactory, providerCreator);
|
|
839
877
|
} catch (error) {
|
|
840
|
-
var _this$
|
|
878
|
+
var _this$fireAnalyticsEv8;
|
|
841
879
|
logException(error, {
|
|
842
880
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
843
881
|
});
|
|
844
|
-
(_this$
|
|
882
|
+
(_this$fireAnalyticsEv8 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv8 === void 0 || _this$fireAnalyticsEv8.call(this, fetchErrorPayload(error.message, resourceId));
|
|
845
883
|
}
|
|
846
884
|
}
|
|
847
885
|
return providerFactory;
|
|
@@ -901,8 +939,8 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
901
939
|
return;
|
|
902
940
|
}
|
|
903
941
|
if (!syncBlock.data.sourceAri || !syncBlock.data.product) {
|
|
904
|
-
var _this$
|
|
905
|
-
(_this$
|
|
942
|
+
var _this$fireAnalyticsEv9;
|
|
943
|
+
(_this$fireAnalyticsEv9 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv9 === void 0 || _this$fireAnalyticsEv9.call(this, fetchErrorPayload('Sync block source ari or product not found'));
|
|
906
944
|
return;
|
|
907
945
|
}
|
|
908
946
|
var parentInfo = this.dataProvider.retrieveSyncBlockParentInfo((_syncBlock$data2 = syncBlock.data) === null || _syncBlock$data2 === void 0 ? void 0 : _syncBlock$data2.sourceAri, (_syncBlock$data3 = syncBlock.data) === null || _syncBlock$data3 === void 0 ? void 0 : _syncBlock$data3.product);
|
|
@@ -952,7 +990,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
952
990
|
key: "flush",
|
|
953
991
|
value: (function () {
|
|
954
992
|
var _flush = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
955
|
-
var success, blocks, _this$saveExperience, updateResult, _this$
|
|
993
|
+
var success, blocks, _this$saveExperience, updateResult, _this$fireAnalyticsEv0, _this$saveExperience2, _this$fireAnalyticsEv1, _this$saveExperience3, _this$saveExperience4;
|
|
956
994
|
return _regeneratorRuntime.wrap(function _callee3$(_context4) {
|
|
957
995
|
while (1) switch (_context4.prev = _context4.next) {
|
|
958
996
|
case 0:
|
|
@@ -1013,7 +1051,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
1013
1051
|
reason: updateResult.error || 'Failed to update reference synced blocks on the document'
|
|
1014
1052
|
});
|
|
1015
1053
|
}
|
|
1016
|
-
(_this$
|
|
1054
|
+
(_this$fireAnalyticsEv0 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv0 === void 0 || _this$fireAnalyticsEv0.call(this, updateReferenceErrorPayload(updateResult.error || 'Failed to update reference synced blocks on the document'));
|
|
1017
1055
|
}
|
|
1018
1056
|
_context4.next = 26;
|
|
1019
1057
|
break;
|
|
@@ -1029,7 +1067,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
1029
1067
|
reason: _context4.t0.message
|
|
1030
1068
|
});
|
|
1031
1069
|
}
|
|
1032
|
-
(_this$
|
|
1070
|
+
(_this$fireAnalyticsEv1 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv1 === void 0 || _this$fireAnalyticsEv1.call(this, updateReferenceErrorPayload(_context4.t0.message));
|
|
1033
1071
|
case 26:
|
|
1034
1072
|
_context4.prev = 26;
|
|
1035
1073
|
if (!success) {
|
|
@@ -1074,13 +1112,13 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
1074
1112
|
});
|
|
1075
1113
|
this.providerFactories.clear();
|
|
1076
1114
|
(_this$saveExperience5 = this.saveExperience) === null || _this$saveExperience5 === void 0 || _this$saveExperience5.abort({
|
|
1077
|
-
reason: '
|
|
1115
|
+
reason: 'editorDestroyed'
|
|
1078
1116
|
});
|
|
1079
1117
|
(_this$fetchExperience5 = this.fetchExperience) === null || _this$fetchExperience5 === void 0 || _this$fetchExperience5.abort({
|
|
1080
|
-
reason: '
|
|
1118
|
+
reason: 'editorDestroyed'
|
|
1081
1119
|
});
|
|
1082
1120
|
(_this$fetchSourceInfo2 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo2 === void 0 || _this$fetchSourceInfo2.abort({
|
|
1083
|
-
reason: '
|
|
1121
|
+
reason: 'editorDestroyed'
|
|
1084
1122
|
});
|
|
1085
1123
|
this.fireAnalyticsEvent = undefined;
|
|
1086
1124
|
}
|