@atlaskit/editor-synced-block-provider 3.30.3 → 3.30.5
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 +16 -0
- package/dist/cjs/clients/block-service/blockSubscription.js +3 -53
- package/dist/cjs/clients/block-service/sharedSubscriptionUtils.js +82 -0
- package/dist/cjs/index.js +33 -0
- package/dist/cjs/providers/block-service/blockServiceAPI.js +22 -6
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +52 -85
- package/dist/cjs/utils/__generated__/relaySubscriptionUtilsSubscription.graphql.js +94 -0
- package/dist/cjs/utils/relayResponseConverter.js +76 -0
- package/dist/cjs/utils/relaySubscriptionUtils.js +130 -0
- package/dist/es2019/clients/block-service/blockSubscription.js +2 -67
- package/dist/es2019/clients/block-service/sharedSubscriptionUtils.js +91 -0
- package/dist/es2019/index.js +4 -0
- package/dist/es2019/providers/block-service/blockServiceAPI.js +22 -6
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +41 -62
- package/dist/es2019/utils/__generated__/relaySubscriptionUtilsSubscription.graphql.js +88 -0
- package/dist/es2019/utils/relayResponseConverter.js +69 -0
- package/dist/es2019/utils/relaySubscriptionUtils.js +125 -0
- package/dist/esm/clients/block-service/blockSubscription.js +2 -52
- package/dist/esm/clients/block-service/sharedSubscriptionUtils.js +76 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/providers/block-service/blockServiceAPI.js +22 -6
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +52 -85
- package/dist/esm/utils/__generated__/relaySubscriptionUtilsSubscription.graphql.js +88 -0
- package/dist/esm/utils/relayResponseConverter.js +69 -0
- package/dist/esm/utils/relaySubscriptionUtils.js +123 -0
- package/dist/types/clients/block-service/blockSubscription.d.ts +1 -26
- package/dist/types/clients/block-service/sharedSubscriptionUtils.d.ts +61 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/providers/block-service/blockServiceAPI.d.ts +7 -2
- package/dist/types/utils/__generated__/relaySubscriptionUtilsSubscription.graphql.d.ts +31 -0
- package/dist/types/utils/relayResponseConverter.d.ts +47 -0
- package/dist/types/utils/relaySubscriptionUtils.d.ts +61 -0
- package/dist/types-ts4.5/clients/block-service/blockSubscription.d.ts +1 -26
- package/dist/types-ts4.5/clients/block-service/sharedSubscriptionUtils.d.ts +61 -0
- package/dist/types-ts4.5/index.d.ts +4 -0
- package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +7 -2
- package/dist/types-ts4.5/utils/__generated__/relaySubscriptionUtilsSubscription.graphql.d.ts +31 -0
- package/dist/types-ts4.5/utils/relayResponseConverter.d.ts +47 -0
- package/dist/types-ts4.5/utils/relaySubscriptionUtils.d.ts +61 -0
- package/package.json +3 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-synced-block-provider
|
|
2
2
|
|
|
3
|
+
## 3.30.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`85444e8a5672a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/85444e8a5672a) -
|
|
8
|
+
EDITOR-5526 clean up platform_synced_block_patch_2
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 3.30.4
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`610719fffa0ba`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/610719fffa0ba) -
|
|
16
|
+
Move subscription API to pass in environment for subscription instead
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 3.30.3
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.subscribeToBlockUpdates = void 0;
|
|
7
7
|
var _graphqlWs = require("graphql-ws");
|
|
8
8
|
var _coreUtils = require("@atlaskit/editor-common/core-utils");
|
|
9
|
-
var
|
|
9
|
+
var _sharedSubscriptionUtils = require("./sharedSubscriptionUtils");
|
|
10
10
|
var GRAPHQL_WS_ENDPOINT = '/gateway/api/graphql/subscriptions';
|
|
11
11
|
var blockServiceClient = null;
|
|
12
12
|
var getBlockServiceClient = function getBlockServiceClient() {
|
|
@@ -25,56 +25,6 @@ var getBlockServiceClient = function getBlockServiceClient() {
|
|
|
25
25
|
}
|
|
26
26
|
return blockServiceClient;
|
|
27
27
|
};
|
|
28
|
-
var SUBSCRIPTION_QUERY = "\nsubscription EDITOR_SYNCED_BLOCK_ON_BLOCK_UPDATED($resourceId: ID!) {\n\tblockService_onBlockUpdated(resourceId: $resourceId) {\n\t\tblockAri\n\t\tblockInstanceId\n\t\tcontent\n\t\tcontentUpdatedAt\n\t\tcreatedAt\n\t\tcreatedBy\n\t\tdeletionReason\n\t\tproduct\n\t\tsourceAri\n\t\tstatus\n\t}\n}\n";
|
|
29
|
-
/**
|
|
30
|
-
* Extracts the resourceId from a block ARI.
|
|
31
|
-
* Block ARI format: ari:cloud:blocks:<cloudId>:synced-block/<resourceId>
|
|
32
|
-
* @param blockAri - The block ARI string
|
|
33
|
-
* @returns The resourceId portion of the ARI
|
|
34
|
-
*/
|
|
35
|
-
var extractResourceIdFromBlockAri = function extractResourceIdFromBlockAri(blockAri) {
|
|
36
|
-
// eslint-disable-next-line require-unicode-regexp
|
|
37
|
-
var match = blockAri.match(/ari:cloud:blocks:[^:]+:synced-block\/(.+)$/);
|
|
38
|
-
return (match === null || match === void 0 ? void 0 : match[1]) || null;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Parses the subscription payload into a standardized format.
|
|
43
|
-
* @param payload - The raw subscription payload
|
|
44
|
-
* @returns Parsed block data or null if parsing fails
|
|
45
|
-
*/
|
|
46
|
-
var parseSubscriptionPayload = function parseSubscriptionPayload(payload) {
|
|
47
|
-
try {
|
|
48
|
-
var resourceId = extractResourceIdFromBlockAri(payload.blockAri);
|
|
49
|
-
if (!resourceId) {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
var createdAt;
|
|
53
|
-
if (payload.createdAt !== undefined && payload.createdAt !== null) {
|
|
54
|
-
try {
|
|
55
|
-
// BE returns microseconds, convert to milliseconds
|
|
56
|
-
createdAt = new Date(payload.createdAt / 1000).toISOString();
|
|
57
|
-
} catch (_unused) {
|
|
58
|
-
createdAt = undefined;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return {
|
|
62
|
-
blockAri: payload.blockAri,
|
|
63
|
-
blockInstanceId: payload.blockInstanceId,
|
|
64
|
-
content: JSON.parse(payload.content),
|
|
65
|
-
contentUpdatedAt: (0, _utils.convertContentUpdatedAt)(payload.contentUpdatedAt),
|
|
66
|
-
createdAt: createdAt,
|
|
67
|
-
createdBy: payload.createdBy,
|
|
68
|
-
product: payload.product,
|
|
69
|
-
resourceId: resourceId,
|
|
70
|
-
sourceAri: payload.sourceAri,
|
|
71
|
-
status: payload.status
|
|
72
|
-
};
|
|
73
|
-
} catch (_unused2) {
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
|
|
78
28
|
/**
|
|
79
29
|
* Creates a GraphQL subscription to block updates using the shared graphql-ws client.
|
|
80
30
|
*
|
|
@@ -90,7 +40,7 @@ var subscribeToBlockUpdates = exports.subscribeToBlockUpdates = function subscri
|
|
|
90
40
|
return function () {};
|
|
91
41
|
}
|
|
92
42
|
var unsubscribe = client.subscribe({
|
|
93
|
-
query:
|
|
43
|
+
query: _sharedSubscriptionUtils.BLOCK_SERVICE_SUBSCRIPTION_QUERY,
|
|
94
44
|
variables: {
|
|
95
45
|
resourceId: blockAri
|
|
96
46
|
},
|
|
@@ -99,7 +49,7 @@ var subscribeToBlockUpdates = exports.subscribeToBlockUpdates = function subscri
|
|
|
99
49
|
next: function next(value) {
|
|
100
50
|
var _value$data;
|
|
101
51
|
if ((_value$data = value.data) !== null && _value$data !== void 0 && _value$data.blockService_onBlockUpdated) {
|
|
102
|
-
var parsed = parseSubscriptionPayload(value.data.blockService_onBlockUpdated);
|
|
52
|
+
var parsed = (0, _sharedSubscriptionUtils.parseSubscriptionPayload)(value.data.blockService_onBlockUpdated);
|
|
103
53
|
if (parsed !== null) {
|
|
104
54
|
onData(parsed);
|
|
105
55
|
} else {
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.parseSubscriptionPayload = exports.extractResourceIdFromBlockAri = exports.convertTimestampToISOString = exports.BLOCK_SERVICE_SUBSCRIPTION_QUERY = void 0;
|
|
7
|
+
var _utils = require("../../utils/utils");
|
|
8
|
+
/**
|
|
9
|
+
* Shared GraphQL subscription query for block updates.
|
|
10
|
+
* This is the canonical subscription query used across all implementations.
|
|
11
|
+
*/
|
|
12
|
+
var BLOCK_SERVICE_SUBSCRIPTION_QUERY = exports.BLOCK_SERVICE_SUBSCRIPTION_QUERY = "\nsubscription EDITOR_SYNCED_BLOCK_ON_BLOCK_UPDATED($resourceId: ID!) {\n\tblockService_onBlockUpdated(resourceId: $resourceId) {\n\t\tblockAri\n\t\tblockInstanceId\n\t\tcontent\n\t\tcontentUpdatedAt\n\t\tcreatedAt\n\t\tcreatedBy\n\t\tdeletionReason\n\t\tproduct\n\t\tsourceAri\n\t\tstatus\n\t}\n}\n";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Raw subscription payload from the GraphQL subscription.
|
|
16
|
+
* This represents the exact shape returned by the blockService_onBlockUpdated subscription.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Parsed and normalized block subscription data.
|
|
21
|
+
* This is the standardized format used across different subscription implementations.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Extracts the resourceId from a block ARI.
|
|
26
|
+
* Block ARI format: ari:cloud:blocks:<cloudId>:synced-block/<resourceId>
|
|
27
|
+
* @param blockAri - The block ARI string
|
|
28
|
+
* @returns The resourceId portion of the ARI
|
|
29
|
+
*/
|
|
30
|
+
var extractResourceIdFromBlockAri = exports.extractResourceIdFromBlockAri = function extractResourceIdFromBlockAri(blockAri) {
|
|
31
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
32
|
+
var match = blockAri.match(/ari:cloud:blocks:[^:]+:synced-block\/(.+)$/);
|
|
33
|
+
return (match === null || match === void 0 ? void 0 : match[1]) || null;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Converts a timestamp to ISO string.
|
|
38
|
+
* @param timestamp - Timestamp in milliseconds
|
|
39
|
+
* @returns ISO string or undefined if conversion fails
|
|
40
|
+
*/
|
|
41
|
+
var convertTimestampToISOString = exports.convertTimestampToISOString = function convertTimestampToISOString(timestamp) {
|
|
42
|
+
if (timestamp === undefined || timestamp === null) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
return new Date(timestamp).toISOString();
|
|
47
|
+
} catch (_unused) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Parses the raw subscription payload into a standardized format.
|
|
54
|
+
* This function handles all the data transformation and error handling consistently
|
|
55
|
+
* across different subscription implementations.
|
|
56
|
+
*
|
|
57
|
+
* @param payload - The raw subscription payload
|
|
58
|
+
* @returns Parsed block data or null if parsing fails
|
|
59
|
+
*/
|
|
60
|
+
var parseSubscriptionPayload = exports.parseSubscriptionPayload = function parseSubscriptionPayload(payload) {
|
|
61
|
+
try {
|
|
62
|
+
var resourceId = extractResourceIdFromBlockAri(payload.blockAri);
|
|
63
|
+
if (!resourceId) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
var createdAt = convertTimestampToISOString(payload.createdAt);
|
|
67
|
+
return {
|
|
68
|
+
blockAri: payload.blockAri,
|
|
69
|
+
blockInstanceId: payload.blockInstanceId,
|
|
70
|
+
content: JSON.parse(payload.content),
|
|
71
|
+
contentUpdatedAt: (0, _utils.convertContentUpdatedAt)(payload.contentUpdatedAt),
|
|
72
|
+
createdAt: createdAt,
|
|
73
|
+
createdBy: payload.createdBy,
|
|
74
|
+
product: payload.product,
|
|
75
|
+
resourceId: resourceId,
|
|
76
|
+
sourceAri: payload.sourceAri,
|
|
77
|
+
status: payload.status
|
|
78
|
+
};
|
|
79
|
+
} catch (_unused2) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
};
|
package/dist/cjs/index.js
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "BLOCK_SERVICE_SUBSCRIPTION_QUERY", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _sharedSubscriptionUtils.BLOCK_SERVICE_SUBSCRIPTION_QUERY;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
6
12
|
Object.defineProperty(exports, "BlockError", {
|
|
7
13
|
enumerable: true,
|
|
8
14
|
get: function get() {
|
|
@@ -57,6 +63,12 @@ Object.defineProperty(exports, "convertPMNodesToSyncBlockNodes", {
|
|
|
57
63
|
return _utils.convertPMNodesToSyncBlockNodes;
|
|
58
64
|
}
|
|
59
65
|
});
|
|
66
|
+
Object.defineProperty(exports, "convertRelayResponseToSyncBlockInstance", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function get() {
|
|
69
|
+
return _relayResponseConverter.convertRelayResponseToSyncBlockInstance;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
60
72
|
Object.defineProperty(exports, "convertSyncBlockJSONNodeToSyncBlockNode", {
|
|
61
73
|
enumerable: true,
|
|
62
74
|
get: function get() {
|
|
@@ -75,6 +87,18 @@ Object.defineProperty(exports, "convertToSyncBlockData", {
|
|
|
75
87
|
return _blockServiceAPI.convertToSyncBlockData;
|
|
76
88
|
}
|
|
77
89
|
});
|
|
90
|
+
Object.defineProperty(exports, "createRelayBlockSubscription", {
|
|
91
|
+
enumerable: true,
|
|
92
|
+
get: function get() {
|
|
93
|
+
return _relaySubscriptionUtils.createRelayBlockSubscription;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
Object.defineProperty(exports, "createRelaySubscriptionFunction", {
|
|
97
|
+
enumerable: true,
|
|
98
|
+
get: function get() {
|
|
99
|
+
return _relaySubscriptionUtils.createRelaySubscriptionFunction;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
78
102
|
Object.defineProperty(exports, "createResourceIdForReference", {
|
|
79
103
|
enumerable: true,
|
|
80
104
|
get: function get() {
|
|
@@ -183,6 +207,12 @@ Object.defineProperty(exports, "parseResourceId", {
|
|
|
183
207
|
return _resourceId.parseResourceId;
|
|
184
208
|
}
|
|
185
209
|
});
|
|
210
|
+
Object.defineProperty(exports, "parseSubscriptionPayload", {
|
|
211
|
+
enumerable: true,
|
|
212
|
+
get: function get() {
|
|
213
|
+
return _sharedSubscriptionUtils.parseSubscriptionPayload;
|
|
214
|
+
}
|
|
215
|
+
});
|
|
186
216
|
Object.defineProperty(exports, "rebaseTransaction", {
|
|
187
217
|
enumerable: true,
|
|
188
218
|
get: function get() {
|
|
@@ -259,6 +289,9 @@ var _syncBlockProvider = require("./providers/syncBlockProvider");
|
|
|
259
289
|
var _referenceSyncBlockStoreManager = require("./store-manager/referenceSyncBlockStoreManager");
|
|
260
290
|
var _syncBlockInMemorySessionCache = require("./store-manager/syncBlockInMemorySessionCache");
|
|
261
291
|
var _syncBlockStoreManager = require("./store-manager/syncBlockStoreManager");
|
|
292
|
+
var _sharedSubscriptionUtils = require("./clients/block-service/sharedSubscriptionUtils");
|
|
293
|
+
var _relayResponseConverter = require("./utils/relayResponseConverter");
|
|
294
|
+
var _relaySubscriptionUtils = require("./utils/relaySubscriptionUtils");
|
|
262
295
|
var _resolveSyncBlockInstance = require("./utils/resolveSyncBlockInstance");
|
|
263
296
|
var _resourceId = require("./utils/resourceId");
|
|
264
297
|
var _utils = require("./utils/utils");
|
|
@@ -18,6 +18,7 @@ var _blockService = require("../../clients/block-service/blockService");
|
|
|
18
18
|
var _blockSubscription = require("../../clients/block-service/blockSubscription");
|
|
19
19
|
var _types = require("../../common/types");
|
|
20
20
|
var _errorHandling = require("../../utils/errorHandling");
|
|
21
|
+
var _relaySubscriptionUtils = require("../../utils/relaySubscriptionUtils");
|
|
21
22
|
var _resourceId2 = require("../../utils/resourceId");
|
|
22
23
|
var _utils = require("../../utils/utils");
|
|
23
24
|
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; }
|
|
@@ -427,10 +428,12 @@ var _batchFetchData = exports.batchFetchData = /*#__PURE__*/function () {
|
|
|
427
428
|
var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
428
429
|
function BlockServiceADFFetchProvider(_ref4) {
|
|
429
430
|
var cloudId = _ref4.cloudId,
|
|
430
|
-
parentAri = _ref4.parentAri
|
|
431
|
+
parentAri = _ref4.parentAri,
|
|
432
|
+
relayEnvironment = _ref4.relayEnvironment;
|
|
431
433
|
(0, _classCallCheck2.default)(this, BlockServiceADFFetchProvider);
|
|
432
434
|
this.cloudId = cloudId;
|
|
433
435
|
this.parentAri = parentAri;
|
|
436
|
+
this.relayEnvironment = relayEnvironment;
|
|
434
437
|
}
|
|
435
438
|
|
|
436
439
|
// resourceId of the reference synced block.
|
|
@@ -615,6 +618,7 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
615
618
|
}()
|
|
616
619
|
/**
|
|
617
620
|
* Subscribes to real-time updates for a specific block using GraphQL WebSocket subscriptions.
|
|
621
|
+
* If a Relay environment is provided, uses Relay subscriptions; otherwise falls back to WebSocket.
|
|
618
622
|
* @param resourceId - The resource ID of the block to subscribe to
|
|
619
623
|
* @param onUpdate - Callback function invoked when the block is updated
|
|
620
624
|
* @param onError - Optional callback function invoked on subscription errors
|
|
@@ -628,6 +632,14 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
628
632
|
cloudId: this.cloudId,
|
|
629
633
|
resourceId: resourceId
|
|
630
634
|
});
|
|
635
|
+
|
|
636
|
+
// If Relay environment is available, use Relay subscriptions
|
|
637
|
+
if (this.relayEnvironment && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_3')) {
|
|
638
|
+
var relaySubscribeToBlockUpdates = (0, _relaySubscriptionUtils.createRelaySubscriptionFunction)(this.cloudId, this.relayEnvironment);
|
|
639
|
+
return relaySubscribeToBlockUpdates(resourceId, onUpdate, onError);
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
// Fall back to WebSocket subscriptions
|
|
631
643
|
return (0, _blockSubscription.subscribeToBlockUpdates)(blockAri, function (parsedData) {
|
|
632
644
|
// Convert ParsedBlockSubscriptionData to SyncBlockInstance
|
|
633
645
|
var syncBlockInstance = {
|
|
@@ -979,11 +991,13 @@ var createBlockServiceAPIProviders = function createBlockServiceAPIProviders(_re
|
|
|
979
991
|
parentAri = _ref6.parentAri,
|
|
980
992
|
parentId = _ref6.parentId,
|
|
981
993
|
product = _ref6.product,
|
|
982
|
-
getVersion = _ref6.getVersion
|
|
994
|
+
getVersion = _ref6.getVersion,
|
|
995
|
+
relayEnvironment = _ref6.relayEnvironment;
|
|
983
996
|
return {
|
|
984
997
|
fetchProvider: new BlockServiceADFFetchProvider({
|
|
985
998
|
cloudId: cloudId,
|
|
986
|
-
parentAri: parentAri
|
|
999
|
+
parentAri: parentAri,
|
|
1000
|
+
relayEnvironment: relayEnvironment
|
|
987
1001
|
}),
|
|
988
1002
|
writeProvider: new BlockServiceADFWriteProvider({
|
|
989
1003
|
cloudId: cloudId,
|
|
@@ -999,16 +1013,18 @@ var useMemoizedBlockServiceAPIProviders = exports.useMemoizedBlockServiceAPIProv
|
|
|
999
1013
|
parentAri = _ref7.parentAri,
|
|
1000
1014
|
parentId = _ref7.parentId,
|
|
1001
1015
|
product = _ref7.product,
|
|
1002
|
-
getVersion = _ref7.getVersion
|
|
1016
|
+
getVersion = _ref7.getVersion,
|
|
1017
|
+
relayEnvironment = _ref7.relayEnvironment;
|
|
1003
1018
|
return (0, _react.useMemo)(function () {
|
|
1004
1019
|
return createBlockServiceAPIProviders({
|
|
1005
1020
|
cloudId: cloudId,
|
|
1006
1021
|
parentAri: parentAri,
|
|
1007
1022
|
parentId: parentId,
|
|
1008
1023
|
product: product,
|
|
1009
|
-
getVersion: getVersion
|
|
1024
|
+
getVersion: getVersion,
|
|
1025
|
+
relayEnvironment: relayEnvironment
|
|
1010
1026
|
});
|
|
1011
|
-
}, [cloudId, parentAri, parentId, product, getVersion]);
|
|
1027
|
+
}, [cloudId, parentAri, parentId, product, getVersion, relayEnvironment]);
|
|
1012
1028
|
};
|
|
1013
1029
|
var createBlockServiceFetchOnlyAPIProvider = function createBlockServiceFetchOnlyAPIProvider(_ref8) {
|
|
1014
1030
|
var cloudId = _ref8.cloudId,
|
|
@@ -858,17 +858,12 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
858
858
|
}, {
|
|
859
859
|
key: "debouncedBatchedFetchSyncBlocks",
|
|
860
860
|
value: function debouncedBatchedFetchSyncBlocks(resourceId) {
|
|
861
|
-
if
|
|
862
|
-
|
|
863
|
-
if (this.subscriptions.has(resourceId) && Object.keys(this.subscriptions.get(resourceId) || {}).length > 0) {
|
|
864
|
-
this.pendingFetchRequests.add(resourceId);
|
|
865
|
-
this.scheduledBatchFetch();
|
|
866
|
-
} else {
|
|
867
|
-
this.pendingFetchRequests.delete(resourceId);
|
|
868
|
-
}
|
|
869
|
-
} else {
|
|
861
|
+
// Only add to pending requests if there are active subscriptions for this resource
|
|
862
|
+
if (this.subscriptions.has(resourceId) && Object.keys(this.subscriptions.get(resourceId) || {}).length > 0) {
|
|
870
863
|
this.pendingFetchRequests.add(resourceId);
|
|
871
864
|
this.scheduledBatchFetch();
|
|
865
|
+
} else {
|
|
866
|
+
this.pendingFetchRequests.delete(resourceId);
|
|
872
867
|
}
|
|
873
868
|
}
|
|
874
869
|
}, {
|
|
@@ -1191,12 +1186,8 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1191
1186
|
}
|
|
1192
1187
|
return _context6.abrupt("return", true);
|
|
1193
1188
|
case 2:
|
|
1194
|
-
if (!(0, _platformFeatureFlags.fg)('platform_synced_block_patch_2')) {
|
|
1195
|
-
_context6.next = 9;
|
|
1196
|
-
break;
|
|
1197
|
-
}
|
|
1198
1189
|
if (!this.isFlushInProgress) {
|
|
1199
|
-
_context6.next =
|
|
1190
|
+
_context6.next = 7;
|
|
1200
1191
|
break;
|
|
1201
1192
|
}
|
|
1202
1193
|
// Mark that another flush is needed after the current one completes
|
|
@@ -1204,27 +1195,22 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1204
1195
|
|
|
1205
1196
|
// We return true here because we know the pending flush will handle the dirty cache
|
|
1206
1197
|
return _context6.abrupt("return", true);
|
|
1207
|
-
case
|
|
1198
|
+
case 7:
|
|
1208
1199
|
this.isFlushInProgress = true;
|
|
1209
|
-
case
|
|
1200
|
+
case 8:
|
|
1210
1201
|
success = true; // a copy of the subscriptions STRUCTURE (without the callbacks)
|
|
1211
1202
|
// To be saved as the last flushed structure if the flush is successful
|
|
1212
1203
|
syncedBlocksToFlush = {};
|
|
1213
|
-
_context6.prev =
|
|
1204
|
+
_context6.prev = 10;
|
|
1214
1205
|
if (this.dataProvider) {
|
|
1215
|
-
_context6.next =
|
|
1206
|
+
_context6.next = 13;
|
|
1216
1207
|
break;
|
|
1217
1208
|
}
|
|
1218
1209
|
throw new Error('Data provider not set');
|
|
1219
|
-
case
|
|
1220
|
-
blocks = [];
|
|
1221
|
-
if (!(0, _platformFeatureFlags.fg)('platform_synced_block_patch_2')) {
|
|
1222
|
-
_context6.next = 37;
|
|
1223
|
-
break;
|
|
1224
|
-
}
|
|
1225
|
-
// First, build the complete subscription structure
|
|
1210
|
+
case 13:
|
|
1211
|
+
blocks = []; // First, build the complete subscription structure
|
|
1226
1212
|
_iterator4 = _createForOfIteratorHelper(this.subscriptions.entries());
|
|
1227
|
-
_context6.prev =
|
|
1213
|
+
_context6.prev = 15;
|
|
1228
1214
|
_loop2 = /*#__PURE__*/_regenerator.default.mark(function _loop2() {
|
|
1229
1215
|
var _step4$value, resourceId, callbacks;
|
|
1230
1216
|
return _regenerator.default.wrap(function _loop2$(_context5) {
|
|
@@ -1246,50 +1232,34 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1246
1232
|
}, _loop2);
|
|
1247
1233
|
});
|
|
1248
1234
|
_iterator4.s();
|
|
1249
|
-
case
|
|
1235
|
+
case 18:
|
|
1250
1236
|
if ((_step4 = _iterator4.n()).done) {
|
|
1251
|
-
_context6.next =
|
|
1237
|
+
_context6.next = 22;
|
|
1252
1238
|
break;
|
|
1253
1239
|
}
|
|
1254
|
-
return _context6.delegateYield(_loop2(), "t0",
|
|
1240
|
+
return _context6.delegateYield(_loop2(), "t0", 20);
|
|
1241
|
+
case 20:
|
|
1242
|
+
_context6.next = 18;
|
|
1243
|
+
break;
|
|
1255
1244
|
case 22:
|
|
1256
|
-
_context6.next =
|
|
1245
|
+
_context6.next = 27;
|
|
1257
1246
|
break;
|
|
1258
1247
|
case 24:
|
|
1259
|
-
_context6.
|
|
1260
|
-
|
|
1261
|
-
case 26:
|
|
1262
|
-
_context6.prev = 26;
|
|
1263
|
-
_context6.t1 = _context6["catch"](17);
|
|
1248
|
+
_context6.prev = 24;
|
|
1249
|
+
_context6.t1 = _context6["catch"](15);
|
|
1264
1250
|
_iterator4.e(_context6.t1);
|
|
1265
|
-
case
|
|
1266
|
-
_context6.prev =
|
|
1251
|
+
case 27:
|
|
1252
|
+
_context6.prev = 27;
|
|
1267
1253
|
_iterator4.f();
|
|
1268
|
-
return _context6.finish(
|
|
1269
|
-
case
|
|
1254
|
+
return _context6.finish(27);
|
|
1255
|
+
case 30:
|
|
1270
1256
|
if (!(0, _isEqual.default)(syncedBlocksToFlush, this.lastFlushedSyncedBlocks)) {
|
|
1271
|
-
_context6.next =
|
|
1257
|
+
_context6.next = 33;
|
|
1272
1258
|
break;
|
|
1273
1259
|
}
|
|
1274
1260
|
this.isCacheDirty = false; // Reset since we're considering this a successful no-op flush
|
|
1275
1261
|
return _context6.abrupt("return", true);
|
|
1276
|
-
case
|
|
1277
|
-
_context6.next = 38;
|
|
1278
|
-
break;
|
|
1279
|
-
case 37:
|
|
1280
|
-
// Collect all reference synced blocks on the current document
|
|
1281
|
-
Array.from(this.subscriptions.entries()).forEach(function (_ref2) {
|
|
1282
|
-
var _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
|
|
1283
|
-
resourceId = _ref3[0],
|
|
1284
|
-
callbacks = _ref3[1];
|
|
1285
|
-
Object.keys(callbacks).forEach(function (localId) {
|
|
1286
|
-
blocks.push({
|
|
1287
|
-
resourceId: resourceId,
|
|
1288
|
-
localId: localId
|
|
1289
|
-
});
|
|
1290
|
-
});
|
|
1291
|
-
});
|
|
1292
|
-
case 38:
|
|
1262
|
+
case 33:
|
|
1293
1263
|
// reset isCacheDirty early to prevent race condition
|
|
1294
1264
|
// There is a race condition where if a user makes changes (create/delete) to a reference sync block
|
|
1295
1265
|
// on a live page and the reference sync block is being saved while the user
|
|
@@ -1297,9 +1267,9 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1297
1267
|
// exactly at a time when the updateReferenceData is being executed asynchronously.
|
|
1298
1268
|
this.isCacheDirty = false;
|
|
1299
1269
|
(_this$saveExperience = this.saveExperience) === null || _this$saveExperience === void 0 || _this$saveExperience.start();
|
|
1300
|
-
_context6.next =
|
|
1270
|
+
_context6.next = 37;
|
|
1301
1271
|
return this.dataProvider.updateReferenceData(blocks);
|
|
1302
|
-
case
|
|
1272
|
+
case 37:
|
|
1303
1273
|
updateResult = _context6.sent;
|
|
1304
1274
|
if (!updateResult.success) {
|
|
1305
1275
|
success = false;
|
|
@@ -1308,11 +1278,11 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1308
1278
|
});
|
|
1309
1279
|
(_this$fireAnalyticsEv1 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv1 === void 0 || _this$fireAnalyticsEv1.call(this, (0, _errorHandling.updateReferenceErrorPayload)(updateResult.error || 'Failed to update reference synced blocks on the document'));
|
|
1310
1280
|
}
|
|
1311
|
-
_context6.next =
|
|
1281
|
+
_context6.next = 47;
|
|
1312
1282
|
break;
|
|
1313
|
-
case
|
|
1314
|
-
_context6.prev =
|
|
1315
|
-
_context6.t2 = _context6["catch"](
|
|
1283
|
+
case 41:
|
|
1284
|
+
_context6.prev = 41;
|
|
1285
|
+
_context6.t2 = _context6["catch"](10);
|
|
1316
1286
|
success = false;
|
|
1317
1287
|
(0, _monitoring.logException)(_context6.t2, {
|
|
1318
1288
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
@@ -1321,40 +1291,37 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1321
1291
|
reason: _context6.t2.message
|
|
1322
1292
|
});
|
|
1323
1293
|
(_this$fireAnalyticsEv10 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv10 === void 0 || _this$fireAnalyticsEv10.call(this, (0, _errorHandling.updateReferenceErrorPayload)(_context6.t2.message));
|
|
1324
|
-
case
|
|
1325
|
-
_context6.prev =
|
|
1294
|
+
case 47:
|
|
1295
|
+
_context6.prev = 47;
|
|
1326
1296
|
if (!success) {
|
|
1327
1297
|
// set isCacheDirty back to true for cases where it failed to update the reference synced blocks on the BE
|
|
1328
1298
|
this.isCacheDirty = true;
|
|
1329
1299
|
} else {
|
|
1330
|
-
|
|
1331
|
-
this.lastFlushedSyncedBlocks = syncedBlocksToFlush;
|
|
1332
|
-
}
|
|
1300
|
+
this.lastFlushedSyncedBlocks = syncedBlocksToFlush;
|
|
1333
1301
|
(_this$saveExperience4 = this.saveExperience) === null || _this$saveExperience4 === void 0 || _this$saveExperience4.success();
|
|
1334
1302
|
}
|
|
1335
|
-
if ((0, _platformFeatureFlags.fg)('platform_synced_block_patch_2')) {
|
|
1336
|
-
// Always reset isFlushInProgress regardless of feature flag
|
|
1337
|
-
this.isFlushInProgress = false;
|
|
1338
1303
|
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1304
|
+
// Always reset isFlushInProgress
|
|
1305
|
+
this.isFlushInProgress = false;
|
|
1306
|
+
|
|
1307
|
+
// If another flush was requested while this one was in progress, execute it now
|
|
1308
|
+
if (this.flushNeededAfterCurrent) {
|
|
1309
|
+
this.flushNeededAfterCurrent = false;
|
|
1310
|
+
// Use setTimeout to avoid deep recursion and run queued flush asynchronously
|
|
1311
|
+
// Note: flush() handles all exceptions internally and never rejects
|
|
1312
|
+
this.queuedFlushTimeout = setTimeout(function () {
|
|
1313
|
+
_this11.queuedFlushTimeout = undefined;
|
|
1314
|
+
void _this11.flush();
|
|
1315
|
+
}, 0);
|
|
1349
1316
|
}
|
|
1350
|
-
return _context6.finish(
|
|
1351
|
-
case
|
|
1317
|
+
return _context6.finish(47);
|
|
1318
|
+
case 52:
|
|
1352
1319
|
return _context6.abrupt("return", success);
|
|
1353
|
-
case
|
|
1320
|
+
case 53:
|
|
1354
1321
|
case "end":
|
|
1355
1322
|
return _context6.stop();
|
|
1356
1323
|
}
|
|
1357
|
-
}, _callee4, this, [[
|
|
1324
|
+
}, _callee4, this, [[10, 41, 47, 52], [15, 24, 27, 30]]);
|
|
1358
1325
|
}));
|
|
1359
1326
|
function flush() {
|
|
1360
1327
|
return _flush.apply(this, arguments);
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* @generated SignedSource<<559b4fb25d0e5bc72be383427a939e2d>>
|
|
9
|
+
* @relayHash 38684212c43376e58fea2d6095011652
|
|
10
|
+
* @lightSyntaxTransform
|
|
11
|
+
* @nogrep
|
|
12
|
+
* @codegen-command: yarn relay
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/* tslint:disable */
|
|
16
|
+
/* eslint-disable */
|
|
17
|
+
// @ts-nocheck
|
|
18
|
+
|
|
19
|
+
// @relayRequestID c84045a1f05bd1e73ade0a9d8b18462cc3dad5dcae1ebabab76b13135411c530
|
|
20
|
+
|
|
21
|
+
var node = function () {
|
|
22
|
+
var v0 = [{
|
|
23
|
+
"defaultValue": null,
|
|
24
|
+
"kind": "LocalArgument",
|
|
25
|
+
"name": "resourceId"
|
|
26
|
+
}],
|
|
27
|
+
v1 = [{
|
|
28
|
+
"args": [{
|
|
29
|
+
"kind": "Variable",
|
|
30
|
+
"name": "resourceId",
|
|
31
|
+
"variableName": "resourceId"
|
|
32
|
+
}],
|
|
33
|
+
"concreteType": "BlockServiceBlockPayload",
|
|
34
|
+
"kind": "LinkedField",
|
|
35
|
+
"name": "blockService_onBlockUpdated",
|
|
36
|
+
"plural": false,
|
|
37
|
+
"selections": [{
|
|
38
|
+
"kind": "ScalarField",
|
|
39
|
+
"name": "blockAri"
|
|
40
|
+
}, {
|
|
41
|
+
"kind": "ScalarField",
|
|
42
|
+
"name": "blockInstanceId"
|
|
43
|
+
}, {
|
|
44
|
+
"kind": "ScalarField",
|
|
45
|
+
"name": "content"
|
|
46
|
+
}, {
|
|
47
|
+
"kind": "ScalarField",
|
|
48
|
+
"name": "contentUpdatedAt"
|
|
49
|
+
}, {
|
|
50
|
+
"kind": "ScalarField",
|
|
51
|
+
"name": "createdAt"
|
|
52
|
+
}, {
|
|
53
|
+
"kind": "ScalarField",
|
|
54
|
+
"name": "createdBy"
|
|
55
|
+
}, {
|
|
56
|
+
"kind": "ScalarField",
|
|
57
|
+
"name": "deletionReason"
|
|
58
|
+
}, {
|
|
59
|
+
"kind": "ScalarField",
|
|
60
|
+
"name": "product"
|
|
61
|
+
}, {
|
|
62
|
+
"kind": "ScalarField",
|
|
63
|
+
"name": "sourceAri"
|
|
64
|
+
}, {
|
|
65
|
+
"kind": "ScalarField",
|
|
66
|
+
"name": "status"
|
|
67
|
+
}]
|
|
68
|
+
}];
|
|
69
|
+
return {
|
|
70
|
+
"fragment": {
|
|
71
|
+
"argumentDefinitions": v0 /*: any*/,
|
|
72
|
+
"kind": "Fragment",
|
|
73
|
+
"name": "relaySubscriptionUtilsSubscription",
|
|
74
|
+
"selections": v1 /*: any*/,
|
|
75
|
+
"type": "Subscription"
|
|
76
|
+
},
|
|
77
|
+
"kind": "Request",
|
|
78
|
+
"operation": {
|
|
79
|
+
"argumentDefinitions": v0 /*: any*/,
|
|
80
|
+
"kind": "Operation",
|
|
81
|
+
"name": "relaySubscriptionUtilsSubscription",
|
|
82
|
+
"selections": v1 /*: any*/
|
|
83
|
+
},
|
|
84
|
+
"params": {
|
|
85
|
+
"id": "c84045a1f05bd1e73ade0a9d8b18462cc3dad5dcae1ebabab76b13135411c530",
|
|
86
|
+
"metadata": {},
|
|
87
|
+
"name": "relaySubscriptionUtilsSubscription",
|
|
88
|
+
"operationKind": "subscription",
|
|
89
|
+
"text": null
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}();
|
|
93
|
+
node.hash = "6f3ebc87921555436cad753ec1aead2e";
|
|
94
|
+
var _default = exports.default = node;
|