@atlaskit/editor-synced-block-provider 3.31.2 → 3.31.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 +7 -0
- package/dist/cjs/clients/block-service/blockService.js +20 -21
- package/dist/cjs/clients/confluence/fetchMediaToken.js +1 -2
- package/dist/cjs/clients/confluence/sourceInfo.js +27 -176
- package/dist/cjs/hooks/useFetchSyncBlockData.js +2 -9
- package/dist/cjs/hooks/useFetchSyncBlockTitle.js +8 -40
- package/dist/cjs/providers/block-service/blockServiceAPI.js +11 -27
- package/dist/cjs/providers/syncBlockProvider.js +22 -51
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +14 -29
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +1 -1
- package/dist/cjs/store-manager/syncBlockStoreManager.js +3 -15
- package/dist/cjs/store-manager/syncBlockSubscriptionManager.js +2 -2
- package/dist/cjs/utils/errorHandling.js +1 -10
- package/dist/cjs/utils/resolveSyncBlockInstance.js +11 -12
- package/dist/cjs/utils/retry.js +2 -23
- package/dist/es2019/clients/block-service/blockService.js +20 -21
- package/dist/es2019/clients/confluence/fetchMediaToken.js +1 -2
- package/dist/es2019/clients/confluence/sourceInfo.js +8 -126
- package/dist/es2019/hooks/useFetchSyncBlockData.js +1 -9
- package/dist/es2019/hooks/useFetchSyncBlockTitle.js +4 -33
- package/dist/es2019/providers/block-service/blockServiceAPI.js +11 -27
- package/dist/es2019/providers/syncBlockProvider.js +7 -29
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +27 -41
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +1 -1
- package/dist/es2019/store-manager/syncBlockStoreManager.js +3 -13
- package/dist/es2019/store-manager/syncBlockSubscriptionManager.js +2 -2
- package/dist/es2019/utils/errorHandling.js +1 -10
- package/dist/es2019/utils/resolveSyncBlockInstance.js +11 -12
- package/dist/es2019/utils/retry.js +2 -21
- package/dist/esm/clients/block-service/blockService.js +20 -21
- package/dist/esm/clients/confluence/fetchMediaToken.js +1 -2
- package/dist/esm/clients/confluence/sourceInfo.js +25 -176
- package/dist/esm/hooks/useFetchSyncBlockData.js +2 -9
- package/dist/esm/hooks/useFetchSyncBlockTitle.js +8 -40
- package/dist/esm/providers/block-service/blockServiceAPI.js +11 -27
- package/dist/esm/providers/syncBlockProvider.js +22 -51
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +14 -29
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +1 -1
- package/dist/esm/store-manager/syncBlockStoreManager.js +3 -15
- package/dist/esm/store-manager/syncBlockSubscriptionManager.js +2 -2
- package/dist/esm/utils/errorHandling.js +1 -10
- package/dist/esm/utils/resolveSyncBlockInstance.js +11 -12
- package/dist/esm/utils/retry.js +2 -23
- package/dist/types/clients/confluence/sourceInfo.d.ts +1 -3
- package/dist/types/providers/syncBlockProvider.d.ts +2 -3
- package/dist/types/providers/types.d.ts +1 -2
- package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +1 -1
- package/dist/types/store-manager/syncBlockStoreManager.d.ts +1 -1
- package/dist/types-ts4.5/clients/confluence/sourceInfo.d.ts +1 -3
- package/dist/types-ts4.5/providers/syncBlockProvider.d.ts +2 -3
- package/dist/types-ts4.5/providers/types.d.ts +1 -2
- package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +1 -1
- package/dist/types-ts4.5/store-manager/syncBlockStoreManager.d.ts +1 -1
- package/package.json +3 -10
|
@@ -458,10 +458,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
458
458
|
value: function handleGraphQLSubscriptionUpdate(syncBlockInstance) {
|
|
459
459
|
var _this5 = this;
|
|
460
460
|
if (!syncBlockInstance.resourceId) {
|
|
461
|
-
|
|
462
|
-
return;
|
|
463
|
-
}
|
|
464
|
-
throw new Error('Sync block instance provided to graphql subscription update missing resource id');
|
|
461
|
+
return;
|
|
465
462
|
}
|
|
466
463
|
var existingSyncBlock = this.getFromCache(syncBlockInstance.resourceId);
|
|
467
464
|
var resolvedSyncBlockInstance = existingSyncBlock ? resolveSyncBlockInstance(existingSyncBlock, syncBlockInstance) : syncBlockInstance;
|
|
@@ -475,8 +472,8 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
475
472
|
});
|
|
476
473
|
this.fetchSyncBlockSourceInfo(resolvedSyncBlockInstance.resourceId);
|
|
477
474
|
} else {
|
|
478
|
-
var _syncBlockInstance$er, _syncBlockInstance$er2,
|
|
479
|
-
var errorMessage =
|
|
475
|
+
var _syncBlockInstance$er, _syncBlockInstance$er2, _this$fireAnalyticsEv3;
|
|
476
|
+
var errorMessage = ((_syncBlockInstance$er = syncBlockInstance.error) === null || _syncBlockInstance$er === void 0 ? void 0 : _syncBlockInstance$er.reason) || ((_syncBlockInstance$er2 = syncBlockInstance.error) === null || _syncBlockInstance$er2 === void 0 ? void 0 : _syncBlockInstance$er2.type);
|
|
480
477
|
(_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(this, fetchErrorPayload(errorMessage, syncBlockInstance.resourceId));
|
|
481
478
|
}
|
|
482
479
|
}
|
|
@@ -551,12 +548,11 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
551
548
|
key: "fetchSyncBlockSourceInfoBySourceAri",
|
|
552
549
|
value: function fetchSyncBlockSourceInfoBySourceAri(sourceAri) {
|
|
553
550
|
var hasAccess = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
554
|
-
var urlType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'view';
|
|
555
551
|
try {
|
|
556
552
|
if (!this.dataProvider) {
|
|
557
553
|
throw new Error('Data provider not set');
|
|
558
554
|
}
|
|
559
|
-
var sourceInfo = this.dataProvider.fetchSyncBlockSourceInfo(undefined, sourceAri, undefined,
|
|
555
|
+
var sourceInfo = this.dataProvider.fetchSyncBlockSourceInfo(undefined, sourceAri, undefined, hasAccess);
|
|
560
556
|
return sourceInfo;
|
|
561
557
|
} catch (error) {
|
|
562
558
|
var _this$fireAnalyticsEv4;
|
|
@@ -572,7 +568,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
572
568
|
value: function fetchSyncBlockSourceInfo(resourceId) {
|
|
573
569
|
var _this6 = this;
|
|
574
570
|
try {
|
|
575
|
-
var _this$fetchSourceInfo
|
|
571
|
+
var _this$fetchSourceInfo;
|
|
576
572
|
if (!resourceId || !this.dataProvider) {
|
|
577
573
|
throw new Error('Data provider or resourceId not set');
|
|
578
574
|
}
|
|
@@ -609,12 +605,8 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
609
605
|
return Promise.resolve(undefined);
|
|
610
606
|
}
|
|
611
607
|
(_this$fetchSourceInfo = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo === void 0 || _this$fetchSourceInfo.start({});
|
|
612
|
-
var
|
|
613
|
-
|
|
614
|
-
// hasAccess
|
|
615
|
-
'edit',
|
|
616
|
-
// urlType
|
|
617
|
-
isUnpublished).then(function (sourceInfo) {
|
|
608
|
+
var sourceInfoPromise = this.dataProvider.fetchSyncBlockSourceInfo(blockInstanceId, sourceAri, product, true // hasAccess
|
|
609
|
+
).then(function (sourceInfo) {
|
|
618
610
|
if (!sourceInfo) {
|
|
619
611
|
var _this6$fetchSourceInf, _this6$fireAnalyticsE;
|
|
620
612
|
(_this6$fetchSourceInf = _this6.fetchSourceInfoExperience) === null || _this6$fetchSourceInf === void 0 || _this6$fetchSourceInf.failure({
|
|
@@ -828,8 +820,8 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
828
820
|
data.forEach(function (syncBlockInstance) {
|
|
829
821
|
var _resolvedSyncBlockIns;
|
|
830
822
|
if (!syncBlockInstance.resourceId) {
|
|
831
|
-
var _syncBlockInstance$
|
|
832
|
-
var payload =
|
|
823
|
+
var _syncBlockInstance$er3, _syncBlockInstance$er4, _this9$fireAnalyticsE;
|
|
824
|
+
var payload = ((_syncBlockInstance$er3 = syncBlockInstance.error) === null || _syncBlockInstance$er3 === void 0 ? void 0 : _syncBlockInstance$er3.reason) || ((_syncBlockInstance$er4 = syncBlockInstance.error) === null || _syncBlockInstance$er4 === void 0 ? void 0 : _syncBlockInstance$er4.type) || 'Returned sync block instance does not have resource id';
|
|
833
825
|
(_this9$fireAnalyticsE = _this9.fireAnalyticsEvent) === null || _this9$fireAnalyticsE === void 0 || _this9$fireAnalyticsE.call(_this9, fetchErrorPayload(payload));
|
|
834
826
|
return;
|
|
835
827
|
}
|
|
@@ -848,13 +840,8 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
848
840
|
_this9.newlyAddedSyncBlocks.delete(syncBlockInstance.resourceId);
|
|
849
841
|
}
|
|
850
842
|
if (syncBlockInstance.error) {
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
(_this9$fireAnalyticsE2 = _this9.fireAnalyticsEvent) === null || _this9$fireAnalyticsE2 === void 0 || _this9$fireAnalyticsE2.call(_this9, fetchErrorPayload(syncBlockInstance.error.reason || syncBlockInstance.error.type, syncBlockInstance.resourceId));
|
|
854
|
-
} else {
|
|
855
|
-
var _this9$fireAnalyticsE3;
|
|
856
|
-
(_this9$fireAnalyticsE3 = _this9.fireAnalyticsEvent) === null || _this9$fireAnalyticsE3 === void 0 || _this9$fireAnalyticsE3.call(_this9, fetchErrorPayload(syncBlockInstance.error.type, syncBlockInstance.resourceId));
|
|
857
|
-
}
|
|
843
|
+
var _this9$fireAnalyticsE2;
|
|
844
|
+
(_this9$fireAnalyticsE2 = _this9.fireAnalyticsEvent) === null || _this9$fireAnalyticsE2 === void 0 || _this9$fireAnalyticsE2.call(_this9, fetchErrorPayload(syncBlockInstance.error.reason || syncBlockInstance.error.type, syncBlockInstance.resourceId));
|
|
858
845
|
if (syncBlockInstance.error.type === SyncBlockError.NotFound || syncBlockInstance.error.type === SyncBlockError.Forbidden) {
|
|
859
846
|
hasExpectedError = true;
|
|
860
847
|
} else if (syncBlockInstance.error) {
|
|
@@ -865,8 +852,8 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
865
852
|
var callbacks = _this9.subscriptions.get(syncBlockInstance.resourceId);
|
|
866
853
|
var localIds = callbacks ? Object.keys(callbacks) : [];
|
|
867
854
|
localIds.forEach(function (localId) {
|
|
868
|
-
var _this9$
|
|
869
|
-
(_this9$
|
|
855
|
+
var _this9$fireAnalyticsE3, _syncBlockInstance$da2;
|
|
856
|
+
(_this9$fireAnalyticsE3 = _this9.fireAnalyticsEvent) === null || _this9$fireAnalyticsE3 === void 0 || _this9$fireAnalyticsE3.call(_this9, fetchSuccessPayload(syncBlockInstance.resourceId, localId, (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.product));
|
|
870
857
|
});
|
|
871
858
|
_this9.fetchSyncBlockSourceInfo(resolvedSyncBlockInstance.resourceId);
|
|
872
859
|
});
|
|
@@ -906,9 +893,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
906
893
|
callback(syncBlock);
|
|
907
894
|
});
|
|
908
895
|
}
|
|
909
|
-
|
|
910
|
-
this.updateSessionCache(resourceId);
|
|
911
|
-
}
|
|
896
|
+
this.updateSessionCache(resourceId);
|
|
912
897
|
}
|
|
913
898
|
}
|
|
914
899
|
}, {
|
|
@@ -522,7 +522,7 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
522
522
|
throw new Error('Data provider not set');
|
|
523
523
|
}
|
|
524
524
|
(_this$fetchSourceInfo = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo === void 0 || _this$fetchSourceInfo.start();
|
|
525
|
-
return this.dataProvider.fetchSyncBlockSourceInfo(localId, undefined, undefined
|
|
525
|
+
return this.dataProvider.fetchSyncBlockSourceInfo(localId, undefined, undefined).then(function (sourceInfo) {
|
|
526
526
|
if (!sourceInfo) {
|
|
527
527
|
var _this6$fetchSourceInf;
|
|
528
528
|
(_this6$fetchSourceInf = _this6.fetchSourceInfoExperience) === null || _this6$fetchSourceInf === void 0 || _this6$fetchSourceInf.failure({
|
|
@@ -7,8 +7,6 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
7
7
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
8
|
import { useMemo, useRef } from 'react';
|
|
9
9
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
10
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
|
-
import { conditionalHooksFactory } from '@atlaskit/platform-feature-flags-react';
|
|
12
10
|
import { getProductFromSourceAri } from '../clients/block-service/ari';
|
|
13
11
|
import { SyncBlockError } from '../common/types';
|
|
14
12
|
import { fetchReferencesErrorPayload } from '../utils/errorHandling';
|
|
@@ -91,7 +89,7 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
91
89
|
case 0:
|
|
92
90
|
(_this$fetchSourceInfo = _this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo === void 0 || _this$fetchSourceInfo.start();
|
|
93
91
|
_context.next = 3;
|
|
94
|
-
return (_this$dataProvider = _this.dataProvider) === null || _this$dataProvider === void 0 ? void 0 : _this$dataProvider.fetchSyncBlockSourceInfo(reference.blockInstanceId || '', reference.documentAri, getProductFromSourceAri(reference.documentAri),
|
|
92
|
+
return (_this$dataProvider = _this.dataProvider) === null || _this$dataProvider === void 0 ? void 0 : _this$dataProvider.fetchSyncBlockSourceInfo(reference.blockInstanceId || '', reference.documentAri, getProductFromSourceAri(reference.documentAri), reference.hasAccess);
|
|
95
93
|
case 3:
|
|
96
94
|
sourceInfo = _context.sent;
|
|
97
95
|
if (sourceInfo) {
|
|
@@ -196,14 +194,7 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
196
194
|
var createSyncBlockStoreManager = function createSyncBlockStoreManager(dataProvider) {
|
|
197
195
|
return new SyncBlockStoreManager(dataProvider);
|
|
198
196
|
};
|
|
199
|
-
var
|
|
200
|
-
var syncBlockStoreManager = useMemo(function () {
|
|
201
|
-
return createSyncBlockStoreManager(dataProvider);
|
|
202
|
-
}, [dataProvider]);
|
|
203
|
-
syncBlockStoreManager.setFireAnalyticsEvent(fireAnalyticsEvent);
|
|
204
|
-
return syncBlockStoreManager;
|
|
205
|
-
};
|
|
206
|
-
var useMemoizedSyncBlockStoreManagerPatched = function useMemoizedSyncBlockStoreManagerPatched(dataProvider, fireAnalyticsEvent) {
|
|
197
|
+
export var useMemoizedSyncBlockStoreManager = function useMemoizedSyncBlockStoreManager(dataProvider, fireAnalyticsEvent) {
|
|
207
198
|
var syncBlockStoreManager = useMemo(function () {
|
|
208
199
|
return createSyncBlockStoreManager(dataProvider);
|
|
209
200
|
}, [dataProvider]);
|
|
@@ -213,7 +204,4 @@ var useMemoizedSyncBlockStoreManagerPatched = function useMemoizedSyncBlockStore
|
|
|
213
204
|
syncBlockStoreManager.setFireAnalyticsEvent(fireAnalyticsEvent);
|
|
214
205
|
}
|
|
215
206
|
return syncBlockStoreManager;
|
|
216
|
-
};
|
|
217
|
-
export var useMemoizedSyncBlockStoreManager = conditionalHooksFactory(function () {
|
|
218
|
-
return fg('platform_synced_block_patch_4');
|
|
219
|
-
}, useMemoizedSyncBlockStoreManagerPatched, useMemoizedSyncBlockStoreManagerBase);
|
|
207
|
+
};
|
|
@@ -182,8 +182,8 @@ export var SyncBlockSubscriptionManager = /*#__PURE__*/function () {
|
|
|
182
182
|
});
|
|
183
183
|
this.deps.fetchSyncBlockSourceInfo(resolved.resourceId);
|
|
184
184
|
} else {
|
|
185
|
-
var _syncBlockInstance$er, _syncBlockInstance$er2,
|
|
186
|
-
var errorMessage =
|
|
185
|
+
var _syncBlockInstance$er, _syncBlockInstance$er2, _this$deps$getFireAna;
|
|
186
|
+
var errorMessage = ((_syncBlockInstance$er = syncBlockInstance.error) === null || _syncBlockInstance$er === void 0 ? void 0 : _syncBlockInstance$er.reason) || ((_syncBlockInstance$er2 = syncBlockInstance.error) === null || _syncBlockInstance$er2 === void 0 ? void 0 : _syncBlockInstance$er2.type);
|
|
187
187
|
(_this$deps$getFireAna = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna === void 0 || _this$deps$getFireAna(fetchErrorPayload(errorMessage, syncBlockInstance.resourceId));
|
|
188
188
|
}
|
|
189
189
|
}
|
|
@@ -2,7 +2,6 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
5
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
5
|
export var stringifyError = function stringifyError(error) {
|
|
7
6
|
try {
|
|
8
7
|
return JSON.stringify(error);
|
|
@@ -64,7 +63,7 @@ export var fetchSuccessPayload = function fetchSuccessPayload(resourceId, blockI
|
|
|
64
63
|
};
|
|
65
64
|
};
|
|
66
65
|
export var createSuccessPayload = function createSuccessPayload(resourceId) {
|
|
67
|
-
return
|
|
66
|
+
return {
|
|
68
67
|
action: ACTION.INSERTED,
|
|
69
68
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
70
69
|
actionSubjectId: ACTION_SUBJECT_ID.BODIED_SYNCED_BLOCK,
|
|
@@ -72,14 +71,6 @@ export var createSuccessPayload = function createSuccessPayload(resourceId) {
|
|
|
72
71
|
attributes: {
|
|
73
72
|
resourceId: resourceId
|
|
74
73
|
}
|
|
75
|
-
} : {
|
|
76
|
-
action: ACTION.INSERTED,
|
|
77
|
-
actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
78
|
-
actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK_CREATE,
|
|
79
|
-
eventType: EVENT_TYPE.OPERATIONAL,
|
|
80
|
-
attributes: {
|
|
81
|
-
resourceId: resourceId
|
|
82
|
-
}
|
|
83
74
|
};
|
|
84
75
|
};
|
|
85
76
|
export var createSuccessPayloadNew = function createSuccessPayloadNew(resourceId) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
4
|
import { getPageIdAndTypeFromConfluencePageAri } from '../clients/confluence/ari';
|
|
6
5
|
import { SyncBlockError } from '../common/types';
|
|
7
6
|
/**
|
|
@@ -16,7 +15,7 @@ import { SyncBlockError } from '../common/types';
|
|
|
16
15
|
* @returns A merged SyncBlockInstance object.
|
|
17
16
|
*/
|
|
18
17
|
export var resolveSyncBlockInstance = function resolveSyncBlockInstance(oldResult, newResult) {
|
|
19
|
-
var _newResult$data, _oldResult$data, _newResult$data2, _oldResult$data2, _newResult$data3, _oldResult$data3
|
|
18
|
+
var _newResult$data, _oldResult$data, _newResult$data2, _oldResult$data2, _newResult$data3, _oldResult$data3;
|
|
20
19
|
// if the old result has no data, we simply return the new result
|
|
21
20
|
if (!oldResult.data) {
|
|
22
21
|
return newResult;
|
|
@@ -35,30 +34,30 @@ export var resolveSyncBlockInstance = function resolveSyncBlockInstance(oldResul
|
|
|
35
34
|
data: _objectSpread(_objectSpread({}, newResult.data), {}, {
|
|
36
35
|
sourceURL: ((_newResult$data = newResult.data) === null || _newResult$data === void 0 ? void 0 : _newResult$data.sourceURL) || ((_oldResult$data = oldResult.data) === null || _oldResult$data === void 0 ? void 0 : _oldResult$data.sourceURL) || undefined,
|
|
37
36
|
sourceTitle: ((_newResult$data2 = newResult.data) === null || _newResult$data2 === void 0 ? void 0 : _newResult$data2.sourceTitle) || ((_oldResult$data2 = oldResult.data) === null || _oldResult$data2 === void 0 ? void 0 : _oldResult$data2.sourceTitle) || undefined,
|
|
38
|
-
sourceSubType:
|
|
39
|
-
onSameDocument: ((_newResult$
|
|
37
|
+
sourceSubType: mergeSubType(oldResult, newResult),
|
|
38
|
+
onSameDocument: ((_newResult$data3 = newResult.data) === null || _newResult$data3 === void 0 ? void 0 : _newResult$data3.onSameDocument) || ((_oldResult$data3 = oldResult.data) === null || _oldResult$data3 === void 0 ? void 0 : _oldResult$data3.onSameDocument) || undefined
|
|
40
39
|
})
|
|
41
40
|
});
|
|
42
41
|
};
|
|
43
42
|
var mergeSubType = function mergeSubType(oldResult, newResult) {
|
|
44
|
-
var _newResult$
|
|
43
|
+
var _newResult$data4, _newResult$data5, _oldResult$data4;
|
|
45
44
|
// for classic pages, subType is 'null'
|
|
46
|
-
if (((_newResult$
|
|
45
|
+
if (((_newResult$data4 = newResult.data) === null || _newResult$data4 === void 0 ? void 0 : _newResult$data4.sourceSubType) !== undefined) {
|
|
47
46
|
return newResult.data.sourceSubType;
|
|
48
47
|
}
|
|
49
|
-
if ((_newResult$
|
|
48
|
+
if ((_newResult$data5 = newResult.data) !== null && _newResult$data5 !== void 0 && _newResult$data5.sourceAri) {
|
|
50
49
|
// for blogposts, subType is always undefined
|
|
51
50
|
try {
|
|
52
|
-
var _newResult$
|
|
51
|
+
var _newResult$data6;
|
|
53
52
|
var _getPageIdAndTypeFrom = getPageIdAndTypeFromConfluencePageAri({
|
|
54
|
-
ari: (_newResult$
|
|
53
|
+
ari: (_newResult$data6 = newResult.data) === null || _newResult$data6 === void 0 ? void 0 : _newResult$data6.sourceAri
|
|
55
54
|
}),
|
|
56
55
|
pageType = _getPageIdAndTypeFrom.type;
|
|
57
56
|
if (pageType === 'blogpost') {
|
|
58
|
-
var _newResult$
|
|
59
|
-
return (_newResult$
|
|
57
|
+
var _newResult$data7;
|
|
58
|
+
return (_newResult$data7 = newResult.data) === null || _newResult$data7 === void 0 ? void 0 : _newResult$data7.sourceSubType;
|
|
60
59
|
}
|
|
61
60
|
} catch (_unused) {}
|
|
62
61
|
}
|
|
63
|
-
return (_oldResult$
|
|
62
|
+
return (_oldResult$data4 = oldResult.data) === null || _oldResult$data4 === void 0 ? void 0 : _oldResult$data4.sourceSubType;
|
|
64
63
|
};
|
package/dist/esm/utils/retry.js
CHANGED
|
@@ -1,25 +1,7 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
|
-
import { functionWithCondition } from '@atlaskit/platform-feature-flags-react';
|
|
5
3
|
var MAX_RETRY_DELAY = 30000;
|
|
6
|
-
var
|
|
7
|
-
var newDelay;
|
|
8
|
-
|
|
9
|
-
// retryAfter can either be in seconds or HTTP date
|
|
10
|
-
var parsedRetryAfter = parseInt(retryAfter);
|
|
11
|
-
if (!isNaN(parsedRetryAfter)) {
|
|
12
|
-
newDelay = parsedRetryAfter * 1000;
|
|
13
|
-
} else {
|
|
14
|
-
var retryDate = new Date(retryAfter);
|
|
15
|
-
var delayFromDate = retryDate.getTime() - Date.now();
|
|
16
|
-
if (delayFromDate > 0) {
|
|
17
|
-
newDelay = delayFromDate;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return newDelay;
|
|
21
|
-
};
|
|
22
|
-
var parseRetryAfterPatched = function parseRetryAfterPatched(retryAfter) {
|
|
4
|
+
var parseRetryAfter = function parseRetryAfter(retryAfter) {
|
|
23
5
|
// retryAfter can either be in seconds or HTTP date
|
|
24
6
|
var parsedRetryAfter = parseInt(retryAfter, 10);
|
|
25
7
|
if (!isNaN(parsedRetryAfter) && parsedRetryAfter > 0) {
|
|
@@ -35,9 +17,6 @@ var parseRetryAfterPatched = function parseRetryAfterPatched(retryAfter) {
|
|
|
35
17
|
}
|
|
36
18
|
return undefined;
|
|
37
19
|
};
|
|
38
|
-
var parseRetryAfter = functionWithCondition(function () {
|
|
39
|
-
return fg('platform_synced_block_patch_4');
|
|
40
|
-
}, parseRetryAfterPatched, parseRetryAfterBase);
|
|
41
20
|
var _fetchWithRetry = /*#__PURE__*/function () {
|
|
42
21
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(url, options) {
|
|
43
22
|
var _ref2;
|
|
@@ -67,7 +46,7 @@ var _fetchWithRetry = /*#__PURE__*/function () {
|
|
|
67
46
|
case 8:
|
|
68
47
|
retryAfter = response.headers.get('Retry-After');
|
|
69
48
|
parsedDelay = (_ref2 = retryAfter ? parseRetryAfter(retryAfter) : undefined) !== null && _ref2 !== void 0 ? _ref2 : delay;
|
|
70
|
-
retryDelay =
|
|
49
|
+
retryDelay = Math.min(parsedDelay, MAX_RETRY_DELAY);
|
|
71
50
|
_context.next = 13;
|
|
72
51
|
return new Promise(function (resolve) {
|
|
73
52
|
return setTimeout(resolve, retryDelay);
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import { type RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
1
|
import type { SyncBlockSourceInfo } from '../../providers/types';
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const fetchConfluencePageInfo: (pageAri: string, hasAccess: boolean, urlType: "view" | "edit", localId?: string, isUnpublished?: boolean) => Promise<SyncBlockSourceInfo | undefined>;
|
|
2
|
+
export declare const fetchConfluencePageInfo: (pageAri: string, hasAccess: boolean, localId?: string) => Promise<SyncBlockSourceInfo | undefined>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
1
|
import type { JSONNode } from '@atlaskit/editor-json-transformer/types';
|
|
3
2
|
import { type BlockInstanceId, type DeletionReason, type ReferenceSyncBlockData, type ResourceId, type SyncBlockAttrs, type SyncBlockData, type SyncBlockNode, type SyncBlockProduct } from '../common/types';
|
|
4
3
|
import { SyncBlockDataProviderInterface, type ADFFetchProvider, type ADFWriteProvider, type BlockSubscriptionErrorCallback, type BlockUpdateCallback, type DeleteSyncBlockResult, type SyncBlockInstance, type SyncBlockParentInfo, type SyncBlockSourceInfo, type SyncedBlockRendererProviderOptions, type Unsubscribe, type UpdateReferenceSyncBlockResult, type WriteSyncBlockResult } from './types';
|
|
@@ -68,7 +67,7 @@ export declare class SyncedBlockProvider extends SyncBlockDataProviderInterface
|
|
|
68
67
|
*
|
|
69
68
|
* @returns The source info
|
|
70
69
|
*/
|
|
71
|
-
fetchSyncBlockSourceInfo(localId?: BlockInstanceId, sourceAri?: string, sourceProduct?: SyncBlockProduct,
|
|
70
|
+
fetchSyncBlockSourceInfo(localId?: BlockInstanceId, sourceAri?: string, sourceProduct?: SyncBlockProduct, hasAccess?: boolean): Promise<SyncBlockSourceInfo | undefined>;
|
|
72
71
|
generateResourceId(): {
|
|
73
72
|
localId: BlockInstanceId;
|
|
74
73
|
resourceId: ResourceId;
|
|
@@ -106,5 +105,5 @@ type UseMemoizedSyncedBlockProviderProps = {
|
|
|
106
105
|
providerOptions: SyncedBlockRendererProviderOptions;
|
|
107
106
|
writeProvider: ADFWriteProvider | undefined;
|
|
108
107
|
};
|
|
109
|
-
export declare const useMemoizedSyncedBlockProvider: (
|
|
108
|
+
export declare const useMemoizedSyncedBlockProvider: ({ fetchProvider, writeProvider, providerOptions, getSSRData, }: UseMemoizedSyncedBlockProviderProps) => SyncedBlockProvider;
|
|
110
109
|
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
1
|
import type { CardProvider, MediaProvider, ProfilecardProvider } from '@atlaskit/editor-common/provider-factory';
|
|
3
2
|
import type { EmojiProvider } from '@atlaskit/emoji';
|
|
4
3
|
import type { MentionProvider } from '@atlaskit/mention/types';
|
|
@@ -118,7 +117,7 @@ export declare abstract class SyncBlockDataProviderInterface extends NodeDataPro
|
|
|
118
117
|
abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<WriteSyncBlockResult>>;
|
|
119
118
|
abstract createNodeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
120
119
|
abstract deleteNodesData(resourceIds: string[], deleteReason: DeletionReason): Promise<Array<DeleteSyncBlockResult>>;
|
|
121
|
-
abstract fetchSyncBlockSourceInfo(localId?: BlockInstanceId, sourceAri?: string, sourceProduct?: SyncBlockProduct,
|
|
120
|
+
abstract fetchSyncBlockSourceInfo(localId?: BlockInstanceId, sourceAri?: string, sourceProduct?: SyncBlockProduct, hasAccess?: boolean): Promise<SyncBlockSourceInfo | undefined>;
|
|
122
121
|
abstract setProviderOptions(providerOptions: SyncedBlockRendererProviderOptions): void;
|
|
123
122
|
abstract getSyncedBlockRendererProviderOptions(): SyncedBlockRendererProviderOptions;
|
|
124
123
|
abstract retrieveSyncBlockParentInfo(sourceAri: string, sourceProduct: SyncBlockProduct): SyncBlockParentInfo | undefined;
|
|
@@ -107,7 +107,7 @@ export declare class ReferenceSyncBlockStoreManager {
|
|
|
107
107
|
* Cleans up all GraphQL subscriptions.
|
|
108
108
|
*/
|
|
109
109
|
private cleanupAllGraphQLSubscriptions;
|
|
110
|
-
fetchSyncBlockSourceInfoBySourceAri(sourceAri: string, hasAccess?: boolean
|
|
110
|
+
fetchSyncBlockSourceInfoBySourceAri(sourceAri: string, hasAccess?: boolean): Promise<SyncBlockSourceInfo | undefined>;
|
|
111
111
|
fetchSyncBlockSourceInfo(resourceId: ResourceId): Promise<SyncBlockSourceInfo | undefined>;
|
|
112
112
|
/**
|
|
113
113
|
* Processes prefetched data and updates the cache.
|
|
@@ -17,4 +17,4 @@ export declare class SyncBlockStoreManager {
|
|
|
17
17
|
get sourceManager(): SourceSyncBlockStoreManager;
|
|
18
18
|
destroy(): void;
|
|
19
19
|
}
|
|
20
|
-
export declare const useMemoizedSyncBlockStoreManager: (dataProvider?: SyncBlockDataProviderInterface
|
|
20
|
+
export declare const useMemoizedSyncBlockStoreManager: (dataProvider?: SyncBlockDataProviderInterface, fireAnalyticsEvent?: (payload: SyncBlockEventPayload) => void) => SyncBlockStoreManager;
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import { type RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
1
|
import type { SyncBlockSourceInfo } from '../../providers/types';
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const fetchConfluencePageInfo: (pageAri: string, hasAccess: boolean, urlType: "view" | "edit", localId?: string, isUnpublished?: boolean) => Promise<SyncBlockSourceInfo | undefined>;
|
|
2
|
+
export declare const fetchConfluencePageInfo: (pageAri: string, hasAccess: boolean, localId?: string) => Promise<SyncBlockSourceInfo | undefined>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
1
|
import type { JSONNode } from '@atlaskit/editor-json-transformer/types';
|
|
3
2
|
import { type BlockInstanceId, type DeletionReason, type ReferenceSyncBlockData, type ResourceId, type SyncBlockAttrs, type SyncBlockData, type SyncBlockNode, type SyncBlockProduct } from '../common/types';
|
|
4
3
|
import { SyncBlockDataProviderInterface, type ADFFetchProvider, type ADFWriteProvider, type BlockSubscriptionErrorCallback, type BlockUpdateCallback, type DeleteSyncBlockResult, type SyncBlockInstance, type SyncBlockParentInfo, type SyncBlockSourceInfo, type SyncedBlockRendererProviderOptions, type Unsubscribe, type UpdateReferenceSyncBlockResult, type WriteSyncBlockResult } from './types';
|
|
@@ -68,7 +67,7 @@ export declare class SyncedBlockProvider extends SyncBlockDataProviderInterface
|
|
|
68
67
|
*
|
|
69
68
|
* @returns The source info
|
|
70
69
|
*/
|
|
71
|
-
fetchSyncBlockSourceInfo(localId?: BlockInstanceId, sourceAri?: string, sourceProduct?: SyncBlockProduct,
|
|
70
|
+
fetchSyncBlockSourceInfo(localId?: BlockInstanceId, sourceAri?: string, sourceProduct?: SyncBlockProduct, hasAccess?: boolean): Promise<SyncBlockSourceInfo | undefined>;
|
|
72
71
|
generateResourceId(): {
|
|
73
72
|
localId: BlockInstanceId;
|
|
74
73
|
resourceId: ResourceId;
|
|
@@ -106,5 +105,5 @@ type UseMemoizedSyncedBlockProviderProps = {
|
|
|
106
105
|
providerOptions: SyncedBlockRendererProviderOptions;
|
|
107
106
|
writeProvider: ADFWriteProvider | undefined;
|
|
108
107
|
};
|
|
109
|
-
export declare const useMemoizedSyncedBlockProvider: (
|
|
108
|
+
export declare const useMemoizedSyncedBlockProvider: ({ fetchProvider, writeProvider, providerOptions, getSSRData, }: UseMemoizedSyncedBlockProviderProps) => SyncedBlockProvider;
|
|
110
109
|
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
1
|
import type { CardProvider, MediaProvider, ProfilecardProvider } from '@atlaskit/editor-common/provider-factory';
|
|
3
2
|
import type { EmojiProvider } from '@atlaskit/emoji';
|
|
4
3
|
import type { MentionProvider } from '@atlaskit/mention/types';
|
|
@@ -118,7 +117,7 @@ export declare abstract class SyncBlockDataProviderInterface extends NodeDataPro
|
|
|
118
117
|
abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<WriteSyncBlockResult>>;
|
|
119
118
|
abstract createNodeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
120
119
|
abstract deleteNodesData(resourceIds: string[], deleteReason: DeletionReason): Promise<Array<DeleteSyncBlockResult>>;
|
|
121
|
-
abstract fetchSyncBlockSourceInfo(localId?: BlockInstanceId, sourceAri?: string, sourceProduct?: SyncBlockProduct,
|
|
120
|
+
abstract fetchSyncBlockSourceInfo(localId?: BlockInstanceId, sourceAri?: string, sourceProduct?: SyncBlockProduct, hasAccess?: boolean): Promise<SyncBlockSourceInfo | undefined>;
|
|
122
121
|
abstract setProviderOptions(providerOptions: SyncedBlockRendererProviderOptions): void;
|
|
123
122
|
abstract getSyncedBlockRendererProviderOptions(): SyncedBlockRendererProviderOptions;
|
|
124
123
|
abstract retrieveSyncBlockParentInfo(sourceAri: string, sourceProduct: SyncBlockProduct): SyncBlockParentInfo | undefined;
|
|
@@ -107,7 +107,7 @@ export declare class ReferenceSyncBlockStoreManager {
|
|
|
107
107
|
* Cleans up all GraphQL subscriptions.
|
|
108
108
|
*/
|
|
109
109
|
private cleanupAllGraphQLSubscriptions;
|
|
110
|
-
fetchSyncBlockSourceInfoBySourceAri(sourceAri: string, hasAccess?: boolean
|
|
110
|
+
fetchSyncBlockSourceInfoBySourceAri(sourceAri: string, hasAccess?: boolean): Promise<SyncBlockSourceInfo | undefined>;
|
|
111
111
|
fetchSyncBlockSourceInfo(resourceId: ResourceId): Promise<SyncBlockSourceInfo | undefined>;
|
|
112
112
|
/**
|
|
113
113
|
* Processes prefetched data and updates the cache.
|
|
@@ -17,4 +17,4 @@ export declare class SyncBlockStoreManager {
|
|
|
17
17
|
get sourceManager(): SourceSyncBlockStoreManager;
|
|
18
18
|
destroy(): void;
|
|
19
19
|
}
|
|
20
|
-
export declare const useMemoizedSyncBlockStoreManager: (dataProvider?: SyncBlockDataProviderInterface
|
|
20
|
+
export declare const useMemoizedSyncBlockStoreManager: (dataProvider?: SyncBlockDataProviderInterface, fireAnalyticsEvent?: (payload: SyncBlockEventPayload) => void) => SyncBlockStoreManager;
|
package/package.json
CHANGED
|
@@ -29,16 +29,15 @@
|
|
|
29
29
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
30
30
|
"@atlaskit/node-data-provider": "^8.3.0",
|
|
31
31
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
32
|
-
"@atlaskit/platform-feature-flags-react": "^0.4.0",
|
|
33
32
|
"@babel/runtime": "^7.0.0",
|
|
34
|
-
"@compiled/react": "^0.
|
|
33
|
+
"@compiled/react": "^0.20.0",
|
|
35
34
|
"graphql-ws": "^5.14.2",
|
|
36
35
|
"lodash": "^4.17.21",
|
|
37
36
|
"raf-schd": "^4.0.3",
|
|
38
37
|
"uuid": "^3.1.0"
|
|
39
38
|
},
|
|
40
39
|
"peerDependencies": {
|
|
41
|
-
"@atlaskit/editor-common": "^111.
|
|
40
|
+
"@atlaskit/editor-common": "^111.28.0",
|
|
42
41
|
"react": "^18.2.0"
|
|
43
42
|
},
|
|
44
43
|
"devDependencies": {
|
|
@@ -81,7 +80,7 @@
|
|
|
81
80
|
}
|
|
82
81
|
},
|
|
83
82
|
"name": "@atlaskit/editor-synced-block-provider",
|
|
84
|
-
"version": "3.31.
|
|
83
|
+
"version": "3.31.3",
|
|
85
84
|
"description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
|
|
86
85
|
"author": "Atlassian Pty Ltd",
|
|
87
86
|
"license": "Apache-2.0",
|
|
@@ -89,12 +88,6 @@
|
|
|
89
88
|
"registry": "https://registry.npmjs.org/"
|
|
90
89
|
},
|
|
91
90
|
"platform-feature-flags": {
|
|
92
|
-
"platform_synced_block_patch_3": {
|
|
93
|
-
"type": "boolean"
|
|
94
|
-
},
|
|
95
|
-
"platform_synced_block_patch_4": {
|
|
96
|
-
"type": "boolean"
|
|
97
|
-
},
|
|
98
91
|
"platform_synced_block_patch_5": {
|
|
99
92
|
"type": "boolean"
|
|
100
93
|
}
|