@atlaskit/editor-synced-block-provider 4.0.0 → 4.1.0
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 +19 -0
- package/dist/cjs/clients/block-service/blockService.js +35 -17
- package/dist/cjs/common/types.js +2 -0
- package/dist/cjs/providers/block-service/blockServiceAPI.js +16 -1
- package/dist/es2019/clients/block-service/blockService.js +16 -3
- package/dist/es2019/common/types.js +2 -0
- package/dist/es2019/providers/block-service/blockServiceAPI.js +12 -1
- package/dist/esm/clients/block-service/blockService.js +34 -16
- package/dist/esm/common/types.js +2 -0
- package/dist/esm/providers/block-service/blockServiceAPI.js +17 -2
- package/dist/types/clients/block-service/blockService.d.ts +4 -1
- package/dist/types/common/types.d.ts +3 -2
- package/dist/types/providers/types.d.ts +1 -1
- package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +2 -2
- package/dist/types/store-manager/syncBlockProviderFactoryManager.d.ts +2 -2
- package/dist/types-ts4.5/clients/block-service/blockService.d.ts +4 -1
- package/dist/types-ts4.5/common/types.d.ts +3 -2
- package/dist/types-ts4.5/providers/types.d.ts +1 -1
- package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +2 -2
- package/dist/types-ts4.5/store-manager/syncBlockProviderFactoryManager.d.ts +2 -2
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/editor-synced-block-provider
|
|
2
2
|
|
|
3
|
+
## 4.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`beb2f030213b1`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/beb2f030213b1) -
|
|
8
|
+
EDITOR-5735 Make SSR bulk request configurable
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
14
|
+
## 4.0.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [`b8082ae893289`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b8082ae893289) -
|
|
19
|
+
Account for new deletionReason: source-block-unpublished
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
3
22
|
## 4.0.0
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.updateSyncedBlocks = exports.updateSyncedBlock = exports.updateReferenceSyncedBlockOnDocument = exports.isBlockContentResponse = exports.getSyncedBlockContent = exports.getReferenceSyncedBlocksByBlockAri = exports.getReferenceSyncedBlocks = exports.deleteSyncedBlock = exports.createSyncedBlock = exports.batchRetrieveSyncedBlocks = exports.BlockError = void 0;
|
|
7
|
+
exports.updateSyncedBlocks = exports.updateSyncedBlock = exports.updateReferenceSyncedBlockOnDocument = exports.isBlockContentResponse = exports.getSyncedBlockContent = exports.getReferenceSyncedBlocksByBlockAri = exports.getReferenceSyncedBlocks = exports.deleteSyncedBlock = exports.createSyncedBlock = exports.batchRetrieveSyncedBlocks = exports.BlockTimeoutError = exports.BlockError = void 0;
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
@@ -225,6 +225,17 @@ var BlockError = exports.BlockError = /*#__PURE__*/function (_Error) {
|
|
|
225
225
|
(0, _inherits2.default)(BlockError, _Error);
|
|
226
226
|
return (0, _createClass2.default)(BlockError);
|
|
227
227
|
}( /*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
|
|
228
|
+
var BlockTimeoutError = exports.BlockTimeoutError = /*#__PURE__*/function (_Error2) {
|
|
229
|
+
function BlockTimeoutError() {
|
|
230
|
+
var _this2;
|
|
231
|
+
(0, _classCallCheck2.default)(this, BlockTimeoutError);
|
|
232
|
+
_this2 = _callSuper(this, BlockTimeoutError, ['Block request timed out']);
|
|
233
|
+
_this2.name = 'BlockTimeoutError';
|
|
234
|
+
return _this2;
|
|
235
|
+
}
|
|
236
|
+
(0, _inherits2.default)(BlockTimeoutError, _Error2);
|
|
237
|
+
return (0, _createClass2.default)(BlockTimeoutError);
|
|
238
|
+
}( /*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
|
|
228
239
|
var getSyncedBlockContent = exports.getSyncedBlockContent = /*#__PURE__*/function () {
|
|
229
240
|
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(_ref2) {
|
|
230
241
|
var _result$data;
|
|
@@ -293,12 +304,12 @@ var getSyncedBlockContent = exports.getSyncedBlockContent = /*#__PURE__*/functio
|
|
|
293
304
|
*/
|
|
294
305
|
var batchRetrieveSyncedBlocks = exports.batchRetrieveSyncedBlocks = /*#__PURE__*/function () {
|
|
295
306
|
var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(_ref4) {
|
|
296
|
-
var _result$data2;
|
|
297
|
-
var blockIdentifiers, blockAris, bodyData, url, response, result, graphqlResponse;
|
|
307
|
+
var _config$timeoutMs, _result$data2;
|
|
308
|
+
var blockIdentifiers, config, blockAris, bodyData, url, fetchPromise, timeoutMs, response, result, graphqlResponse;
|
|
298
309
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
299
310
|
while (1) switch (_context3.prev = _context3.next) {
|
|
300
311
|
case 0:
|
|
301
|
-
blockIdentifiers = _ref4.blockIdentifiers;
|
|
312
|
+
blockIdentifiers = _ref4.blockIdentifiers, config = _ref4.config;
|
|
302
313
|
blockAris = blockIdentifiers.map(function (blockIdentifier) {
|
|
303
314
|
return blockIdentifier.blockAri;
|
|
304
315
|
});
|
|
@@ -306,45 +317,52 @@ var batchRetrieveSyncedBlocks = exports.batchRetrieveSyncedBlocks = /*#__PURE__*
|
|
|
306
317
|
query: buildBatchRetrieveBlocksQuery(blockAris),
|
|
307
318
|
operationName: BATCH_RETRIEVE_BLOCKS_OPERATION_NAME
|
|
308
319
|
};
|
|
309
|
-
url = "".concat(GRAPHQL_ENDPOINT, "?operation=editorSyncedBlockBatchRetrieveBlocks");
|
|
310
|
-
|
|
311
|
-
|
|
320
|
+
url = "".concat(GRAPHQL_ENDPOINT, "?operation=editorSyncedBlockBatchRetrieveBlocks"); // undefined or 0 or negative means no timeout,
|
|
321
|
+
// We don't enforce a minimum timeout for simplicity
|
|
322
|
+
fetchPromise = (0, _retry.fetchWithRetry)(url, {
|
|
312
323
|
method: 'POST',
|
|
313
324
|
headers: COMMON_HEADERS,
|
|
314
325
|
body: JSON.stringify(bodyData)
|
|
315
326
|
});
|
|
316
|
-
|
|
327
|
+
timeoutMs = (_config$timeoutMs = config === null || config === void 0 ? void 0 : config.timeoutMs) !== null && _config$timeoutMs !== void 0 ? _config$timeoutMs : 0;
|
|
328
|
+
_context3.next = 8;
|
|
329
|
+
return timeoutMs > 0 ? Promise.race([fetchPromise, new Promise(function (_, reject) {
|
|
330
|
+
return setTimeout(function () {
|
|
331
|
+
return reject(new BlockTimeoutError());
|
|
332
|
+
}, timeoutMs);
|
|
333
|
+
})]) : fetchPromise;
|
|
334
|
+
case 8:
|
|
317
335
|
response = _context3.sent;
|
|
318
336
|
if (response.ok) {
|
|
319
|
-
_context3.next =
|
|
337
|
+
_context3.next = 11;
|
|
320
338
|
break;
|
|
321
339
|
}
|
|
322
340
|
throw new BlockError(response.status);
|
|
323
|
-
case 9:
|
|
324
|
-
_context3.next = 11;
|
|
325
|
-
return response.json();
|
|
326
341
|
case 11:
|
|
342
|
+
_context3.next = 13;
|
|
343
|
+
return response.json();
|
|
344
|
+
case 13:
|
|
327
345
|
result = _context3.sent;
|
|
328
346
|
if (!(result.errors && result.errors.length > 0)) {
|
|
329
|
-
_context3.next =
|
|
347
|
+
_context3.next = 16;
|
|
330
348
|
break;
|
|
331
349
|
}
|
|
332
350
|
throw new Error(result.errors.map(function (e) {
|
|
333
351
|
return e.message;
|
|
334
352
|
}).join(', '));
|
|
335
|
-
case
|
|
353
|
+
case 16:
|
|
336
354
|
if ((_result$data2 = result.data) !== null && _result$data2 !== void 0 && _result$data2.blockService_batchRetrieveBlocks) {
|
|
337
|
-
_context3.next =
|
|
355
|
+
_context3.next = 18;
|
|
338
356
|
break;
|
|
339
357
|
}
|
|
340
358
|
throw new Error('No data returned from GraphQL query');
|
|
341
|
-
case
|
|
359
|
+
case 18:
|
|
342
360
|
graphqlResponse = result.data.blockService_batchRetrieveBlocks;
|
|
343
361
|
return _context3.abrupt("return", {
|
|
344
362
|
success: graphqlResponse.success,
|
|
345
363
|
error: graphqlResponse.error
|
|
346
364
|
});
|
|
347
|
-
case
|
|
365
|
+
case 20:
|
|
348
366
|
case "end":
|
|
349
367
|
return _context3.stop();
|
|
350
368
|
}
|
package/dist/cjs/common/types.js
CHANGED
|
@@ -17,5 +17,7 @@ var SyncBlockError = exports.SyncBlockError = /*#__PURE__*/function (SyncBlockEr
|
|
|
17
17
|
// content is not a valid JSON
|
|
18
18
|
SyncBlockError["Offline"] = "offline";
|
|
19
19
|
SyncBlockError["Unpublished"] = "unpublished";
|
|
20
|
+
// request was aborted, typically due to client timeout
|
|
21
|
+
SyncBlockError["Aborted"] = "aborted";
|
|
20
22
|
return SyncBlockError;
|
|
21
23
|
}({});
|
|
@@ -12,6 +12,7 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
|
|
|
12
12
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
13
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
14
14
|
var _react = require("react");
|
|
15
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
15
16
|
var _ari = require("../../clients/block-service/ari");
|
|
16
17
|
var _blockService = require("../../clients/block-service/blockService");
|
|
17
18
|
var _blockSubscription = require("../../clients/block-service/blockSubscription");
|
|
@@ -392,6 +393,20 @@ var _batchFetchData = exports.batchFetchData = /*#__PURE__*/function () {
|
|
|
392
393
|
case 61:
|
|
393
394
|
_context2.prev = 61;
|
|
394
395
|
_context2.t2 = _context2["catch"](5);
|
|
396
|
+
if (!(_context2.t2 instanceof _blockService.BlockTimeoutError && (0, _expValEquals.expValEquals)('platform_editor_sync_block_ssr_config', 'isEnabled', true))) {
|
|
397
|
+
_context2.next = 65;
|
|
398
|
+
break;
|
|
399
|
+
}
|
|
400
|
+
return _context2.abrupt("return", blockNodeIdentifiers.map(function (blockNodeIdentifier) {
|
|
401
|
+
return {
|
|
402
|
+
error: {
|
|
403
|
+
type: _types.SyncBlockError.Aborted,
|
|
404
|
+
reason: _context2.t2.message
|
|
405
|
+
},
|
|
406
|
+
resourceId: blockNodeIdentifier.resourceId
|
|
407
|
+
};
|
|
408
|
+
}));
|
|
409
|
+
case 65:
|
|
395
410
|
return _context2.abrupt("return", blockNodeIdentifiers.map(function (blockNodeIdentifier) {
|
|
396
411
|
return {
|
|
397
412
|
error: {
|
|
@@ -401,7 +416,7 @@ var _batchFetchData = exports.batchFetchData = /*#__PURE__*/function () {
|
|
|
401
416
|
resourceId: blockNodeIdentifier.resourceId
|
|
402
417
|
};
|
|
403
418
|
}));
|
|
404
|
-
case
|
|
419
|
+
case 66:
|
|
405
420
|
case "end":
|
|
406
421
|
return _context2.stop();
|
|
407
422
|
}
|
|
@@ -297,6 +297,12 @@ export class BlockError extends Error {
|
|
|
297
297
|
this.status = status;
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
|
+
export class BlockTimeoutError extends Error {
|
|
301
|
+
constructor() {
|
|
302
|
+
super('Block request timed out');
|
|
303
|
+
this.name = 'BlockTimeoutError';
|
|
304
|
+
}
|
|
305
|
+
}
|
|
300
306
|
export const getSyncedBlockContent = async ({
|
|
301
307
|
blockAri
|
|
302
308
|
}) => {
|
|
@@ -334,20 +340,27 @@ export const getSyncedBlockContent = async ({
|
|
|
334
340
|
* @returns A promise containing arrays of successfully fetched blocks and any errors encountered
|
|
335
341
|
*/
|
|
336
342
|
export const batchRetrieveSyncedBlocks = async ({
|
|
337
|
-
blockIdentifiers
|
|
343
|
+
blockIdentifiers,
|
|
344
|
+
config
|
|
338
345
|
}) => {
|
|
339
|
-
var _result$data2;
|
|
346
|
+
var _config$timeoutMs, _result$data2;
|
|
340
347
|
const blockAris = blockIdentifiers.map(blockIdentifier => blockIdentifier.blockAri);
|
|
341
348
|
const bodyData = {
|
|
342
349
|
query: buildBatchRetrieveBlocksQuery(blockAris),
|
|
343
350
|
operationName: BATCH_RETRIEVE_BLOCKS_OPERATION_NAME
|
|
344
351
|
};
|
|
345
352
|
const url = `${GRAPHQL_ENDPOINT}?operation=editorSyncedBlockBatchRetrieveBlocks`;
|
|
346
|
-
|
|
353
|
+
|
|
354
|
+
// undefined or 0 or negative means no timeout,
|
|
355
|
+
// We don't enforce a minimum timeout for simplicity
|
|
356
|
+
|
|
357
|
+
const fetchPromise = fetchWithRetry(url, {
|
|
347
358
|
method: 'POST',
|
|
348
359
|
headers: COMMON_HEADERS,
|
|
349
360
|
body: JSON.stringify(bodyData)
|
|
350
361
|
});
|
|
362
|
+
const timeoutMs = (_config$timeoutMs = config === null || config === void 0 ? void 0 : config.timeoutMs) !== null && _config$timeoutMs !== void 0 ? _config$timeoutMs : 0;
|
|
363
|
+
const response = await (timeoutMs > 0 ? Promise.race([fetchPromise, new Promise((_, reject) => setTimeout(() => reject(new BlockTimeoutError()), timeoutMs))]) : fetchPromise);
|
|
351
364
|
if (!response.ok) {
|
|
352
365
|
throw new BlockError(response.status);
|
|
353
366
|
}
|
|
@@ -11,5 +11,7 @@ export let SyncBlockError = /*#__PURE__*/function (SyncBlockError) {
|
|
|
11
11
|
// content is not a valid JSON
|
|
12
12
|
SyncBlockError["Offline"] = "offline";
|
|
13
13
|
SyncBlockError["Unpublished"] = "unpublished";
|
|
14
|
+
// request was aborted, typically due to client timeout
|
|
15
|
+
SyncBlockError["Aborted"] = "aborted";
|
|
14
16
|
return SyncBlockError;
|
|
15
17
|
}({});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/* eslint-disable require-unicode-regexp */
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
4
|
import { generateBlockAri, generateBlockAriFromReference } from '../../clients/block-service/ari';
|
|
4
|
-
import { batchRetrieveSyncedBlocks, BlockError, createSyncedBlock, deleteSyncedBlock, getReferenceSyncedBlocks, getReferenceSyncedBlocksByBlockAri, getSyncedBlockContent, updateReferenceSyncedBlockOnDocument, updateSyncedBlock, updateSyncedBlocks } from '../../clients/block-service/blockService';
|
|
5
|
+
import { batchRetrieveSyncedBlocks, BlockError, BlockTimeoutError, createSyncedBlock, deleteSyncedBlock, getReferenceSyncedBlocks, getReferenceSyncedBlocksByBlockAri, getSyncedBlockContent, updateReferenceSyncedBlockOnDocument, updateSyncedBlock, updateSyncedBlocks } from '../../clients/block-service/blockService';
|
|
5
6
|
import { subscribeToBlockUpdates as subscribeToBlockUpdatesWS } from '../../clients/block-service/blockSubscription';
|
|
6
7
|
import { SyncBlockError } from '../../common/types';
|
|
7
8
|
import { stringifyError } from '../../utils/errorHandling';
|
|
@@ -287,6 +288,16 @@ export const batchFetchData = async (cloudId, parentAri, blockNodeIdentifiers, c
|
|
|
287
288
|
}
|
|
288
289
|
return results;
|
|
289
290
|
} catch (error) {
|
|
291
|
+
if (error instanceof BlockTimeoutError && expValEquals('platform_editor_sync_block_ssr_config', 'isEnabled', true)) {
|
|
292
|
+
return blockNodeIdentifiers.map(blockNodeIdentifier => ({
|
|
293
|
+
error: {
|
|
294
|
+
type: SyncBlockError.Aborted,
|
|
295
|
+
reason: error.message
|
|
296
|
+
},
|
|
297
|
+
resourceId: blockNodeIdentifier.resourceId
|
|
298
|
+
}));
|
|
299
|
+
}
|
|
300
|
+
|
|
290
301
|
// If batch request fails, return error for all resourceIds
|
|
291
302
|
return blockNodeIdentifiers.map(blockNodeIdentifier => ({
|
|
292
303
|
error: {
|
|
@@ -218,6 +218,17 @@ export var BlockError = /*#__PURE__*/function (_Error) {
|
|
|
218
218
|
_inherits(BlockError, _Error);
|
|
219
219
|
return _createClass(BlockError);
|
|
220
220
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
221
|
+
export var BlockTimeoutError = /*#__PURE__*/function (_Error2) {
|
|
222
|
+
function BlockTimeoutError() {
|
|
223
|
+
var _this2;
|
|
224
|
+
_classCallCheck(this, BlockTimeoutError);
|
|
225
|
+
_this2 = _callSuper(this, BlockTimeoutError, ['Block request timed out']);
|
|
226
|
+
_this2.name = 'BlockTimeoutError';
|
|
227
|
+
return _this2;
|
|
228
|
+
}
|
|
229
|
+
_inherits(BlockTimeoutError, _Error2);
|
|
230
|
+
return _createClass(BlockTimeoutError);
|
|
231
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
221
232
|
export var getSyncedBlockContent = /*#__PURE__*/function () {
|
|
222
233
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref2) {
|
|
223
234
|
var _result$data;
|
|
@@ -286,12 +297,12 @@ export var getSyncedBlockContent = /*#__PURE__*/function () {
|
|
|
286
297
|
*/
|
|
287
298
|
export var batchRetrieveSyncedBlocks = /*#__PURE__*/function () {
|
|
288
299
|
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref4) {
|
|
289
|
-
var _result$data2;
|
|
290
|
-
var blockIdentifiers, blockAris, bodyData, url, response, result, graphqlResponse;
|
|
300
|
+
var _config$timeoutMs, _result$data2;
|
|
301
|
+
var blockIdentifiers, config, blockAris, bodyData, url, fetchPromise, timeoutMs, response, result, graphqlResponse;
|
|
291
302
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
292
303
|
while (1) switch (_context3.prev = _context3.next) {
|
|
293
304
|
case 0:
|
|
294
|
-
blockIdentifiers = _ref4.blockIdentifiers;
|
|
305
|
+
blockIdentifiers = _ref4.blockIdentifiers, config = _ref4.config;
|
|
295
306
|
blockAris = blockIdentifiers.map(function (blockIdentifier) {
|
|
296
307
|
return blockIdentifier.blockAri;
|
|
297
308
|
});
|
|
@@ -299,45 +310,52 @@ export var batchRetrieveSyncedBlocks = /*#__PURE__*/function () {
|
|
|
299
310
|
query: buildBatchRetrieveBlocksQuery(blockAris),
|
|
300
311
|
operationName: BATCH_RETRIEVE_BLOCKS_OPERATION_NAME
|
|
301
312
|
};
|
|
302
|
-
url = "".concat(GRAPHQL_ENDPOINT, "?operation=editorSyncedBlockBatchRetrieveBlocks");
|
|
303
|
-
|
|
304
|
-
|
|
313
|
+
url = "".concat(GRAPHQL_ENDPOINT, "?operation=editorSyncedBlockBatchRetrieveBlocks"); // undefined or 0 or negative means no timeout,
|
|
314
|
+
// We don't enforce a minimum timeout for simplicity
|
|
315
|
+
fetchPromise = fetchWithRetry(url, {
|
|
305
316
|
method: 'POST',
|
|
306
317
|
headers: COMMON_HEADERS,
|
|
307
318
|
body: JSON.stringify(bodyData)
|
|
308
319
|
});
|
|
309
|
-
|
|
320
|
+
timeoutMs = (_config$timeoutMs = config === null || config === void 0 ? void 0 : config.timeoutMs) !== null && _config$timeoutMs !== void 0 ? _config$timeoutMs : 0;
|
|
321
|
+
_context3.next = 8;
|
|
322
|
+
return timeoutMs > 0 ? Promise.race([fetchPromise, new Promise(function (_, reject) {
|
|
323
|
+
return setTimeout(function () {
|
|
324
|
+
return reject(new BlockTimeoutError());
|
|
325
|
+
}, timeoutMs);
|
|
326
|
+
})]) : fetchPromise;
|
|
327
|
+
case 8:
|
|
310
328
|
response = _context3.sent;
|
|
311
329
|
if (response.ok) {
|
|
312
|
-
_context3.next =
|
|
330
|
+
_context3.next = 11;
|
|
313
331
|
break;
|
|
314
332
|
}
|
|
315
333
|
throw new BlockError(response.status);
|
|
316
|
-
case 9:
|
|
317
|
-
_context3.next = 11;
|
|
318
|
-
return response.json();
|
|
319
334
|
case 11:
|
|
335
|
+
_context3.next = 13;
|
|
336
|
+
return response.json();
|
|
337
|
+
case 13:
|
|
320
338
|
result = _context3.sent;
|
|
321
339
|
if (!(result.errors && result.errors.length > 0)) {
|
|
322
|
-
_context3.next =
|
|
340
|
+
_context3.next = 16;
|
|
323
341
|
break;
|
|
324
342
|
}
|
|
325
343
|
throw new Error(result.errors.map(function (e) {
|
|
326
344
|
return e.message;
|
|
327
345
|
}).join(', '));
|
|
328
|
-
case
|
|
346
|
+
case 16:
|
|
329
347
|
if ((_result$data2 = result.data) !== null && _result$data2 !== void 0 && _result$data2.blockService_batchRetrieveBlocks) {
|
|
330
|
-
_context3.next =
|
|
348
|
+
_context3.next = 18;
|
|
331
349
|
break;
|
|
332
350
|
}
|
|
333
351
|
throw new Error('No data returned from GraphQL query');
|
|
334
|
-
case
|
|
352
|
+
case 18:
|
|
335
353
|
graphqlResponse = result.data.blockService_batchRetrieveBlocks;
|
|
336
354
|
return _context3.abrupt("return", {
|
|
337
355
|
success: graphqlResponse.success,
|
|
338
356
|
error: graphqlResponse.error
|
|
339
357
|
});
|
|
340
|
-
case
|
|
358
|
+
case 20:
|
|
341
359
|
case "end":
|
|
342
360
|
return _context3.stop();
|
|
343
361
|
}
|
package/dist/esm/common/types.js
CHANGED
|
@@ -11,5 +11,7 @@ export var SyncBlockError = /*#__PURE__*/function (SyncBlockError) {
|
|
|
11
11
|
// content is not a valid JSON
|
|
12
12
|
SyncBlockError["Offline"] = "offline";
|
|
13
13
|
SyncBlockError["Unpublished"] = "unpublished";
|
|
14
|
+
// request was aborted, typically due to client timeout
|
|
15
|
+
SyncBlockError["Aborted"] = "aborted";
|
|
14
16
|
return SyncBlockError;
|
|
15
17
|
}({});
|
|
@@ -11,8 +11,9 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
11
11
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
12
12
|
/* eslint-disable require-unicode-regexp */
|
|
13
13
|
import { useMemo } from 'react';
|
|
14
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
14
15
|
import { generateBlockAri as _generateBlockAri, generateBlockAriFromReference } from '../../clients/block-service/ari';
|
|
15
|
-
import { batchRetrieveSyncedBlocks, BlockError, createSyncedBlock, deleteSyncedBlock, getReferenceSyncedBlocks, getReferenceSyncedBlocksByBlockAri, getSyncedBlockContent, updateReferenceSyncedBlockOnDocument, updateSyncedBlock, updateSyncedBlocks } from '../../clients/block-service/blockService';
|
|
16
|
+
import { batchRetrieveSyncedBlocks, BlockError, BlockTimeoutError, createSyncedBlock, deleteSyncedBlock, getReferenceSyncedBlocks, getReferenceSyncedBlocksByBlockAri, getSyncedBlockContent, updateReferenceSyncedBlockOnDocument, updateSyncedBlock, updateSyncedBlocks } from '../../clients/block-service/blockService';
|
|
16
17
|
import { subscribeToBlockUpdates as subscribeToBlockUpdatesWS } from '../../clients/block-service/blockSubscription';
|
|
17
18
|
import { SyncBlockError } from '../../common/types';
|
|
18
19
|
import { stringifyError } from '../../utils/errorHandling';
|
|
@@ -386,6 +387,20 @@ var _batchFetchData = /*#__PURE__*/function () {
|
|
|
386
387
|
case 61:
|
|
387
388
|
_context2.prev = 61;
|
|
388
389
|
_context2.t2 = _context2["catch"](5);
|
|
390
|
+
if (!(_context2.t2 instanceof BlockTimeoutError && expValEquals('platform_editor_sync_block_ssr_config', 'isEnabled', true))) {
|
|
391
|
+
_context2.next = 65;
|
|
392
|
+
break;
|
|
393
|
+
}
|
|
394
|
+
return _context2.abrupt("return", blockNodeIdentifiers.map(function (blockNodeIdentifier) {
|
|
395
|
+
return {
|
|
396
|
+
error: {
|
|
397
|
+
type: SyncBlockError.Aborted,
|
|
398
|
+
reason: _context2.t2.message
|
|
399
|
+
},
|
|
400
|
+
resourceId: blockNodeIdentifier.resourceId
|
|
401
|
+
};
|
|
402
|
+
}));
|
|
403
|
+
case 65:
|
|
389
404
|
return _context2.abrupt("return", blockNodeIdentifiers.map(function (blockNodeIdentifier) {
|
|
390
405
|
return {
|
|
391
406
|
error: {
|
|
@@ -395,7 +410,7 @@ var _batchFetchData = /*#__PURE__*/function () {
|
|
|
395
410
|
resourceId: blockNodeIdentifier.resourceId
|
|
396
411
|
};
|
|
397
412
|
}));
|
|
398
|
-
case
|
|
413
|
+
case 66:
|
|
399
414
|
case "end":
|
|
400
415
|
return _context2.stop();
|
|
401
416
|
}
|
|
@@ -134,6 +134,9 @@ export declare class BlockError extends Error {
|
|
|
134
134
|
readonly status: number;
|
|
135
135
|
constructor(status: number);
|
|
136
136
|
}
|
|
137
|
+
export declare class BlockTimeoutError extends Error {
|
|
138
|
+
constructor();
|
|
139
|
+
}
|
|
137
140
|
export declare const getSyncedBlockContent: ({ blockAri, }: GetSyncedBlockContentRequest) => Promise<BlockContentResponse>;
|
|
138
141
|
/**
|
|
139
142
|
* Batch retrieves multiple synced blocks by their ARIs.
|
|
@@ -144,7 +147,7 @@ export declare const getSyncedBlockContent: ({ blockAri, }: GetSyncedBlockConten
|
|
|
144
147
|
* @param config - Optional batch fetch configuration (e.g. timeout)
|
|
145
148
|
* @returns A promise containing arrays of successfully fetched blocks and any errors encountered
|
|
146
149
|
*/
|
|
147
|
-
export declare const batchRetrieveSyncedBlocks: ({ blockIdentifiers, }: BatchRetrieveSyncedBlocksRequest) => Promise<BatchRetrieveSyncedBlocksResponse>;
|
|
150
|
+
export declare const batchRetrieveSyncedBlocks: ({ blockIdentifiers, config, }: BatchRetrieveSyncedBlocksRequest) => Promise<BatchRetrieveSyncedBlocksResponse>;
|
|
148
151
|
export declare const deleteSyncedBlock: ({ blockAri, deleteReason, }: DeleteSyncedBlockRequest) => Promise<void>;
|
|
149
152
|
export declare const updateSyncedBlock: ({ blockAri, content, stepVersion, status, }: UpdateSyncedBlockRequest) => Promise<void>;
|
|
150
153
|
export declare const createSyncedBlock: ({ blockAri, blockInstanceId, sourceAri, product, content, stepVersion, status, }: CreateSyncedBlockRequest) => Promise<BlockContentResponse>;
|
|
@@ -25,7 +25,8 @@ export declare enum SyncBlockError {
|
|
|
25
25
|
ServerError = "server_error",
|
|
26
26
|
InvalidContent = "invalid_content",// content is not a valid JSON
|
|
27
27
|
Offline = "offline",
|
|
28
|
-
Unpublished = "unpublished"
|
|
28
|
+
Unpublished = "unpublished",
|
|
29
|
+
Aborted = "aborted"
|
|
29
30
|
}
|
|
30
31
|
export interface SyncBlockData {
|
|
31
32
|
blockInstanceId: BlockInstanceId;
|
|
@@ -71,7 +72,7 @@ export type ReferencesSourceInfo = {
|
|
|
71
72
|
error?: SyncBlockError;
|
|
72
73
|
references?: Array<SyncBlockSourceInfo | undefined>;
|
|
73
74
|
};
|
|
74
|
-
export type DeletionReason = 'source-block-deleted' | 'source-block-unsynced';
|
|
75
|
+
export type DeletionReason = 'source-block-deleted' | 'source-block-unsynced' | 'source-block-unpublished';
|
|
75
76
|
export type DeletionReasonResponse = DeletionReason | 'source-document-deleted';
|
|
76
77
|
export type SyncBlockPrefetchData = {
|
|
77
78
|
prefetchPromise: Promise<SyncBlockInstance[] | undefined>;
|
|
@@ -88,7 +88,7 @@ export interface ADFWriteProvider {
|
|
|
88
88
|
/**
|
|
89
89
|
* Delete source block.
|
|
90
90
|
* @param resourceId the resourceId of the block to be deleted
|
|
91
|
-
* @param deleteReason the reason for the deletion, e.g. 'source-block-unsynced', 'source-block-deleted'
|
|
91
|
+
* @param deleteReason the reason for the deletion, e.g. 'source-block-unsynced', 'source-block-deleted', 'source-block-unpublished'
|
|
92
92
|
* @returns Object representing the result of the deletion. {resourceId: string, success: boolean, error?: string}.
|
|
93
93
|
* User should not be blocked by not_found error when deleting, so successful result should be returned for 404 error
|
|
94
94
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import type { Experience } from '@atlaskit/editor-common/experiences';
|
|
3
|
-
import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
3
|
+
import { ProviderFactory, type MediaProvider } from '@atlaskit/editor-common/provider-factory';
|
|
4
4
|
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import { type ResourceId, type SyncBlockNode, type SyncBlockPrefetchData } from '../common/types';
|
|
6
6
|
import type { SyncBlockInstance, SubscriptionCallback, SyncBlockDataProviderInterface, TitleSubscriptionCallback, SyncBlockSourceInfo } from '../providers/types';
|
|
@@ -140,7 +140,7 @@ export declare class ReferenceSyncBlockStoreManager {
|
|
|
140
140
|
getSyncBlockURL(resourceId: ResourceId): string | undefined;
|
|
141
141
|
getProviderFactory(resourceId: ResourceId): ProviderFactory | undefined;
|
|
142
142
|
getSSRProviders(resourceId: ResourceId): {
|
|
143
|
-
media:
|
|
143
|
+
media: MediaProvider;
|
|
144
144
|
} | null;
|
|
145
145
|
private retrieveDynamicProviders;
|
|
146
146
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
2
|
+
import { ProviderFactory, type MediaProvider } from '@atlaskit/editor-common/provider-factory';
|
|
3
3
|
import type { ResourceId } from '../common/types';
|
|
4
4
|
import type { SyncBlockInstance, SyncBlockDataProviderInterface } from '../providers/types';
|
|
5
5
|
export interface SyncBlockProviderFactoryManagerDeps {
|
|
@@ -17,7 +17,7 @@ export declare class SyncBlockProviderFactoryManager {
|
|
|
17
17
|
constructor(deps: SyncBlockProviderFactoryManagerDeps);
|
|
18
18
|
getProviderFactory(resourceId: ResourceId): ProviderFactory | undefined;
|
|
19
19
|
getSSRProviders(resourceId: ResourceId): {
|
|
20
|
-
media:
|
|
20
|
+
media: MediaProvider;
|
|
21
21
|
} | null;
|
|
22
22
|
deleteFactory(resourceId: ResourceId): void;
|
|
23
23
|
destroy(): void;
|
|
@@ -134,6 +134,9 @@ export declare class BlockError extends Error {
|
|
|
134
134
|
readonly status: number;
|
|
135
135
|
constructor(status: number);
|
|
136
136
|
}
|
|
137
|
+
export declare class BlockTimeoutError extends Error {
|
|
138
|
+
constructor();
|
|
139
|
+
}
|
|
137
140
|
export declare const getSyncedBlockContent: ({ blockAri, }: GetSyncedBlockContentRequest) => Promise<BlockContentResponse>;
|
|
138
141
|
/**
|
|
139
142
|
* Batch retrieves multiple synced blocks by their ARIs.
|
|
@@ -144,7 +147,7 @@ export declare const getSyncedBlockContent: ({ blockAri, }: GetSyncedBlockConten
|
|
|
144
147
|
* @param config - Optional batch fetch configuration (e.g. timeout)
|
|
145
148
|
* @returns A promise containing arrays of successfully fetched blocks and any errors encountered
|
|
146
149
|
*/
|
|
147
|
-
export declare const batchRetrieveSyncedBlocks: ({ blockIdentifiers, }: BatchRetrieveSyncedBlocksRequest) => Promise<BatchRetrieveSyncedBlocksResponse>;
|
|
150
|
+
export declare const batchRetrieveSyncedBlocks: ({ blockIdentifiers, config, }: BatchRetrieveSyncedBlocksRequest) => Promise<BatchRetrieveSyncedBlocksResponse>;
|
|
148
151
|
export declare const deleteSyncedBlock: ({ blockAri, deleteReason, }: DeleteSyncedBlockRequest) => Promise<void>;
|
|
149
152
|
export declare const updateSyncedBlock: ({ blockAri, content, stepVersion, status, }: UpdateSyncedBlockRequest) => Promise<void>;
|
|
150
153
|
export declare const createSyncedBlock: ({ blockAri, blockInstanceId, sourceAri, product, content, stepVersion, status, }: CreateSyncedBlockRequest) => Promise<BlockContentResponse>;
|
|
@@ -25,7 +25,8 @@ export declare enum SyncBlockError {
|
|
|
25
25
|
ServerError = "server_error",
|
|
26
26
|
InvalidContent = "invalid_content",// content is not a valid JSON
|
|
27
27
|
Offline = "offline",
|
|
28
|
-
Unpublished = "unpublished"
|
|
28
|
+
Unpublished = "unpublished",
|
|
29
|
+
Aborted = "aborted"
|
|
29
30
|
}
|
|
30
31
|
export interface SyncBlockData {
|
|
31
32
|
blockInstanceId: BlockInstanceId;
|
|
@@ -71,7 +72,7 @@ export type ReferencesSourceInfo = {
|
|
|
71
72
|
error?: SyncBlockError;
|
|
72
73
|
references?: Array<SyncBlockSourceInfo | undefined>;
|
|
73
74
|
};
|
|
74
|
-
export type DeletionReason = 'source-block-deleted' | 'source-block-unsynced';
|
|
75
|
+
export type DeletionReason = 'source-block-deleted' | 'source-block-unsynced' | 'source-block-unpublished';
|
|
75
76
|
export type DeletionReasonResponse = DeletionReason | 'source-document-deleted';
|
|
76
77
|
export type SyncBlockPrefetchData = {
|
|
77
78
|
prefetchPromise: Promise<SyncBlockInstance[] | undefined>;
|
|
@@ -88,7 +88,7 @@ export interface ADFWriteProvider {
|
|
|
88
88
|
/**
|
|
89
89
|
* Delete source block.
|
|
90
90
|
* @param resourceId the resourceId of the block to be deleted
|
|
91
|
-
* @param deleteReason the reason for the deletion, e.g. 'source-block-unsynced', 'source-block-deleted'
|
|
91
|
+
* @param deleteReason the reason for the deletion, e.g. 'source-block-unsynced', 'source-block-deleted', 'source-block-unpublished'
|
|
92
92
|
* @returns Object representing the result of the deletion. {resourceId: string, success: boolean, error?: string}.
|
|
93
93
|
* User should not be blocked by not_found error when deleting, so successful result should be returned for 404 error
|
|
94
94
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import type { Experience } from '@atlaskit/editor-common/experiences';
|
|
3
|
-
import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
3
|
+
import { ProviderFactory, type MediaProvider } from '@atlaskit/editor-common/provider-factory';
|
|
4
4
|
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import { type ResourceId, type SyncBlockNode, type SyncBlockPrefetchData } from '../common/types';
|
|
6
6
|
import type { SyncBlockInstance, SubscriptionCallback, SyncBlockDataProviderInterface, TitleSubscriptionCallback, SyncBlockSourceInfo } from '../providers/types';
|
|
@@ -140,7 +140,7 @@ export declare class ReferenceSyncBlockStoreManager {
|
|
|
140
140
|
getSyncBlockURL(resourceId: ResourceId): string | undefined;
|
|
141
141
|
getProviderFactory(resourceId: ResourceId): ProviderFactory | undefined;
|
|
142
142
|
getSSRProviders(resourceId: ResourceId): {
|
|
143
|
-
media:
|
|
143
|
+
media: MediaProvider;
|
|
144
144
|
} | null;
|
|
145
145
|
private retrieveDynamicProviders;
|
|
146
146
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
2
|
+
import { ProviderFactory, type MediaProvider } from '@atlaskit/editor-common/provider-factory';
|
|
3
3
|
import type { ResourceId } from '../common/types';
|
|
4
4
|
import type { SyncBlockInstance, SyncBlockDataProviderInterface } from '../providers/types';
|
|
5
5
|
export interface SyncBlockProviderFactoryManagerDeps {
|
|
@@ -17,7 +17,7 @@ export declare class SyncBlockProviderFactoryManager {
|
|
|
17
17
|
constructor(deps: SyncBlockProviderFactoryManagerDeps);
|
|
18
18
|
getProviderFactory(resourceId: ResourceId): ProviderFactory | undefined;
|
|
19
19
|
getSSRProviders(resourceId: ResourceId): {
|
|
20
|
-
media:
|
|
20
|
+
media: MediaProvider;
|
|
21
21
|
} | null;
|
|
22
22
|
deleteFactory(resourceId: ResourceId): void;
|
|
23
23
|
destroy(): void;
|
package/package.json
CHANGED
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
30
30
|
"@atlaskit/node-data-provider": "^9.0.0",
|
|
31
31
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
32
|
+
"@atlaskit/tmp-editor-statsig": "^40.3.0",
|
|
32
33
|
"@babel/runtime": "^7.0.0",
|
|
33
34
|
"@compiled/react": "^0.20.0",
|
|
34
35
|
"graphql-ws": "^5.14.2",
|
|
@@ -37,7 +38,7 @@
|
|
|
37
38
|
"uuid": "^3.1.0"
|
|
38
39
|
},
|
|
39
40
|
"peerDependencies": {
|
|
40
|
-
"@atlaskit/editor-common": "^112.
|
|
41
|
+
"@atlaskit/editor-common": "^112.5.0",
|
|
41
42
|
"react": "^18.2.0"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
@@ -80,7 +81,7 @@
|
|
|
80
81
|
}
|
|
81
82
|
},
|
|
82
83
|
"name": "@atlaskit/editor-synced-block-provider",
|
|
83
|
-
"version": "4.
|
|
84
|
+
"version": "4.1.0",
|
|
84
85
|
"description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
|
|
85
86
|
"author": "Atlassian Pty Ltd",
|
|
86
87
|
"license": "Apache-2.0",
|