@atlaskit/editor-synced-block-provider 6.6.9 → 6.6.11
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 +15 -0
- package/dist/cjs/clients/block-service/blockService.js +107 -107
- package/dist/cjs/clients/confluence/fetchMediaToken.js +21 -21
- package/dist/cjs/clients/confluence/sourceInfo.js +24 -24
- package/dist/cjs/clients/jira/fetchMediaToken.js +21 -21
- package/dist/cjs/clients/jira/sourceInfo.js +24 -24
- package/dist/cjs/hooks/useFetchSyncBlockData.js +18 -18
- package/dist/cjs/providers/block-service/blockServiceAPI.js +322 -321
- package/dist/cjs/providers/syncBlockProvider.js +49 -48
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +75 -75
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +77 -78
- package/dist/cjs/store-manager/syncBlockStoreManager.js +41 -41
- package/dist/cjs/store-manager/syncBlockSubscriptionManager.js +7 -18
- package/dist/cjs/utils/resourceId.js +2 -1
- package/dist/cjs/utils/retry.js +8 -8
- package/dist/cjs/utils/utils.js +4 -3
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +1 -1
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +1 -2
- package/dist/es2019/store-manager/syncBlockSubscriptionManager.js +7 -18
- package/dist/es2019/utils/utils.js +1 -2
- package/dist/esm/clients/block-service/blockService.js +107 -107
- package/dist/esm/clients/confluence/fetchMediaToken.js +21 -21
- package/dist/esm/clients/confluence/sourceInfo.js +24 -24
- package/dist/esm/clients/jira/fetchMediaToken.js +21 -21
- package/dist/esm/clients/jira/sourceInfo.js +24 -24
- package/dist/esm/hooks/useFetchSyncBlockData.js +18 -18
- package/dist/esm/providers/block-service/blockServiceAPI.js +321 -320
- package/dist/esm/providers/syncBlockProvider.js +49 -48
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +75 -75
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +77 -78
- package/dist/esm/store-manager/syncBlockStoreManager.js +41 -41
- package/dist/esm/store-manager/syncBlockSubscriptionManager.js +7 -18
- package/dist/esm/utils/resourceId.js +2 -1
- package/dist/esm/utils/retry.js +8 -8
- package/dist/esm/utils/utils.js +1 -2
- package/package.json +5 -8
|
@@ -57,7 +57,7 @@ export var isBlockContentResponse = function isBlockContentResponse(response) {
|
|
|
57
57
|
export var getReferenceSyncedBlocks = /*#__PURE__*/function () {
|
|
58
58
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(documentAri) {
|
|
59
59
|
var bodyData, url, response, result;
|
|
60
|
-
return _regeneratorRuntime.wrap(function
|
|
60
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
61
61
|
while (1) switch (_context.prev = _context.next) {
|
|
62
62
|
case 0:
|
|
63
63
|
bodyData = {
|
|
@@ -65,40 +65,40 @@ export var getReferenceSyncedBlocks = /*#__PURE__*/function () {
|
|
|
65
65
|
operationName: GET_DOCUMENT_REFERENCE_BLOCKS_OPERATION_NAME
|
|
66
66
|
};
|
|
67
67
|
url = "".concat(GRAPHQL_ENDPOINT, "?operation=editorSyncedBlockGetDocumentReferenceBlocks");
|
|
68
|
-
_context.next =
|
|
68
|
+
_context.next = 1;
|
|
69
69
|
return fetchWithRetry(url, {
|
|
70
70
|
method: 'POST',
|
|
71
71
|
headers: COMMON_HEADERS,
|
|
72
72
|
body: JSON.stringify(bodyData)
|
|
73
73
|
});
|
|
74
|
-
case
|
|
74
|
+
case 1:
|
|
75
75
|
response = _context.sent;
|
|
76
76
|
if (response.ok) {
|
|
77
|
-
_context.next =
|
|
77
|
+
_context.next = 2;
|
|
78
78
|
break;
|
|
79
79
|
}
|
|
80
80
|
throw new BlockError(response.status);
|
|
81
|
-
case
|
|
82
|
-
_context.next =
|
|
81
|
+
case 2:
|
|
82
|
+
_context.next = 3;
|
|
83
83
|
return response.json();
|
|
84
|
-
case
|
|
84
|
+
case 3:
|
|
85
85
|
result = _context.sent;
|
|
86
86
|
if (!(result.errors && result.errors.length > 0)) {
|
|
87
|
-
_context.next =
|
|
87
|
+
_context.next = 4;
|
|
88
88
|
break;
|
|
89
89
|
}
|
|
90
90
|
throw new Error(result.errors.map(function (e) {
|
|
91
91
|
return e.message;
|
|
92
92
|
}).join(', '));
|
|
93
|
-
case
|
|
93
|
+
case 4:
|
|
94
94
|
if (result.data) {
|
|
95
|
-
_context.next =
|
|
95
|
+
_context.next = 5;
|
|
96
96
|
break;
|
|
97
97
|
}
|
|
98
98
|
throw new Error('No data returned from GraphQL query');
|
|
99
|
-
case
|
|
99
|
+
case 5:
|
|
100
100
|
return _context.abrupt("return", result.data.blockService_getDocumentReferenceBlocks);
|
|
101
|
-
case
|
|
101
|
+
case 6:
|
|
102
102
|
case "end":
|
|
103
103
|
return _context.stop();
|
|
104
104
|
}
|
|
@@ -250,7 +250,7 @@ export var getSyncedBlockContent = /*#__PURE__*/function () {
|
|
|
250
250
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref2) {
|
|
251
251
|
var _result$data;
|
|
252
252
|
var blockAri, bodyData, url, response, result;
|
|
253
|
-
return _regeneratorRuntime.wrap(function
|
|
253
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
254
254
|
while (1) switch (_context2.prev = _context2.next) {
|
|
255
255
|
case 0:
|
|
256
256
|
blockAri = _ref2.blockAri;
|
|
@@ -259,40 +259,40 @@ export var getSyncedBlockContent = /*#__PURE__*/function () {
|
|
|
259
259
|
operationName: GET_BLOCK_OPERATION_NAME
|
|
260
260
|
};
|
|
261
261
|
url = "".concat(GRAPHQL_ENDPOINT, "?operation=editorSyncedBlockGetBlock");
|
|
262
|
-
_context2.next =
|
|
262
|
+
_context2.next = 1;
|
|
263
263
|
return fetchWithRetry(url, {
|
|
264
264
|
method: 'POST',
|
|
265
265
|
headers: COMMON_HEADERS,
|
|
266
266
|
body: JSON.stringify(bodyData)
|
|
267
267
|
});
|
|
268
|
-
case
|
|
268
|
+
case 1:
|
|
269
269
|
response = _context2.sent;
|
|
270
270
|
if (response.ok) {
|
|
271
|
-
_context2.next =
|
|
271
|
+
_context2.next = 2;
|
|
272
272
|
break;
|
|
273
273
|
}
|
|
274
274
|
throw new BlockError(response.status);
|
|
275
|
-
case
|
|
276
|
-
_context2.next =
|
|
275
|
+
case 2:
|
|
276
|
+
_context2.next = 3;
|
|
277
277
|
return response.json();
|
|
278
|
-
case
|
|
278
|
+
case 3:
|
|
279
279
|
result = _context2.sent;
|
|
280
280
|
if (!(result.errors && result.errors.length > 0)) {
|
|
281
|
-
_context2.next =
|
|
281
|
+
_context2.next = 4;
|
|
282
282
|
break;
|
|
283
283
|
}
|
|
284
284
|
throw new Error(result.errors.map(function (e) {
|
|
285
285
|
return e.message;
|
|
286
286
|
}).join(', '));
|
|
287
|
-
case
|
|
287
|
+
case 4:
|
|
288
288
|
if ((_result$data = result.data) !== null && _result$data !== void 0 && _result$data.blockService_getBlock) {
|
|
289
|
-
_context2.next =
|
|
289
|
+
_context2.next = 5;
|
|
290
290
|
break;
|
|
291
291
|
}
|
|
292
292
|
throw new Error('No data returned from GraphQL query');
|
|
293
|
-
case
|
|
293
|
+
case 5:
|
|
294
294
|
return _context2.abrupt("return", result.data.blockService_getBlock);
|
|
295
|
-
case
|
|
295
|
+
case 6:
|
|
296
296
|
case "end":
|
|
297
297
|
return _context2.stop();
|
|
298
298
|
}
|
|
@@ -316,7 +316,7 @@ export var batchRetrieveSyncedBlocks = /*#__PURE__*/function () {
|
|
|
316
316
|
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref4) {
|
|
317
317
|
var _config$timeoutMs, _result$data2;
|
|
318
318
|
var blockIdentifiers, config, blockAris, bodyData, url, fetchPromise, timeoutMs, response, result, graphqlResponse;
|
|
319
|
-
return _regeneratorRuntime.wrap(function
|
|
319
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
320
320
|
while (1) switch (_context3.prev = _context3.next) {
|
|
321
321
|
case 0:
|
|
322
322
|
blockIdentifiers = _ref4.blockIdentifiers, config = _ref4.config;
|
|
@@ -335,44 +335,44 @@ export var batchRetrieveSyncedBlocks = /*#__PURE__*/function () {
|
|
|
335
335
|
body: JSON.stringify(bodyData)
|
|
336
336
|
});
|
|
337
337
|
timeoutMs = (_config$timeoutMs = config === null || config === void 0 ? void 0 : config.timeoutMs) !== null && _config$timeoutMs !== void 0 ? _config$timeoutMs : 0;
|
|
338
|
-
_context3.next =
|
|
338
|
+
_context3.next = 1;
|
|
339
339
|
return timeoutMs > 0 ? Promise.race([fetchPromise, new Promise(function (_, reject) {
|
|
340
340
|
return setTimeout(function () {
|
|
341
341
|
return reject(new BlockTimeoutError());
|
|
342
342
|
}, timeoutMs);
|
|
343
343
|
})]) : fetchPromise;
|
|
344
|
-
case
|
|
344
|
+
case 1:
|
|
345
345
|
response = _context3.sent;
|
|
346
346
|
if (response.ok) {
|
|
347
|
-
_context3.next =
|
|
347
|
+
_context3.next = 2;
|
|
348
348
|
break;
|
|
349
349
|
}
|
|
350
350
|
throw new BlockError(response.status);
|
|
351
|
-
case
|
|
352
|
-
_context3.next =
|
|
351
|
+
case 2:
|
|
352
|
+
_context3.next = 3;
|
|
353
353
|
return response.json();
|
|
354
|
-
case
|
|
354
|
+
case 3:
|
|
355
355
|
result = _context3.sent;
|
|
356
356
|
if (!(result.errors && result.errors.length > 0)) {
|
|
357
|
-
_context3.next =
|
|
357
|
+
_context3.next = 4;
|
|
358
358
|
break;
|
|
359
359
|
}
|
|
360
360
|
throw new Error(result.errors.map(function (e) {
|
|
361
361
|
return e.message;
|
|
362
362
|
}).join(', '));
|
|
363
|
-
case
|
|
363
|
+
case 4:
|
|
364
364
|
if ((_result$data2 = result.data) !== null && _result$data2 !== void 0 && _result$data2.blockService_batchRetrieveBlocks) {
|
|
365
|
-
_context3.next =
|
|
365
|
+
_context3.next = 5;
|
|
366
366
|
break;
|
|
367
367
|
}
|
|
368
368
|
throw new Error('No data returned from GraphQL query');
|
|
369
|
-
case
|
|
369
|
+
case 5:
|
|
370
370
|
graphqlResponse = result.data.blockService_batchRetrieveBlocks;
|
|
371
371
|
return _context3.abrupt("return", {
|
|
372
372
|
success: graphqlResponse.success,
|
|
373
373
|
error: graphqlResponse.error
|
|
374
374
|
});
|
|
375
|
-
case
|
|
375
|
+
case 6:
|
|
376
376
|
case "end":
|
|
377
377
|
return _context3.stop();
|
|
378
378
|
}
|
|
@@ -386,7 +386,7 @@ export var deleteSyncedBlock = /*#__PURE__*/function () {
|
|
|
386
386
|
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref6) {
|
|
387
387
|
var _result$data3;
|
|
388
388
|
var blockAri, deleteReason, bodyData, url, response, result, allNotFound, isDeleted;
|
|
389
|
-
return _regeneratorRuntime.wrap(function
|
|
389
|
+
return _regeneratorRuntime.wrap(function (_context4) {
|
|
390
390
|
while (1) switch (_context4.prev = _context4.next) {
|
|
391
391
|
case 0:
|
|
392
392
|
blockAri = _ref6.blockAri, deleteReason = _ref6.deleteReason;
|
|
@@ -395,26 +395,26 @@ export var deleteSyncedBlock = /*#__PURE__*/function () {
|
|
|
395
395
|
operationName: DELETE_BLOCK_OPERATION_NAME
|
|
396
396
|
};
|
|
397
397
|
url = "".concat(GRAPHQL_ENDPOINT, "?operation=editorSyncedBlockDeleteBlock");
|
|
398
|
-
_context4.next =
|
|
398
|
+
_context4.next = 1;
|
|
399
399
|
return fetchWithRetry(url, {
|
|
400
400
|
method: 'POST',
|
|
401
401
|
headers: COMMON_HEADERS,
|
|
402
402
|
body: JSON.stringify(bodyData)
|
|
403
403
|
});
|
|
404
|
-
case
|
|
404
|
+
case 1:
|
|
405
405
|
response = _context4.sent;
|
|
406
406
|
if (response.ok) {
|
|
407
|
-
_context4.next =
|
|
407
|
+
_context4.next = 2;
|
|
408
408
|
break;
|
|
409
409
|
}
|
|
410
410
|
throw new BlockError(response.status);
|
|
411
|
-
case
|
|
412
|
-
_context4.next =
|
|
411
|
+
case 2:
|
|
412
|
+
_context4.next = 3;
|
|
413
413
|
return response.json();
|
|
414
|
-
case
|
|
414
|
+
case 3:
|
|
415
415
|
result = _context4.sent;
|
|
416
416
|
if (!(result.errors && result.errors.length > 0)) {
|
|
417
|
-
_context4.next =
|
|
417
|
+
_context4.next = 5;
|
|
418
418
|
break;
|
|
419
419
|
}
|
|
420
420
|
allNotFound = result.errors.every(function (e) {
|
|
@@ -422,22 +422,22 @@ export var deleteSyncedBlock = /*#__PURE__*/function () {
|
|
|
422
422
|
return ((_e$extensions = e.extensions) === null || _e$extensions === void 0 ? void 0 : _e$extensions.errorType) === 'RESOURCE_NOT_FOUND';
|
|
423
423
|
});
|
|
424
424
|
if (!allNotFound) {
|
|
425
|
-
_context4.next =
|
|
425
|
+
_context4.next = 4;
|
|
426
426
|
break;
|
|
427
427
|
}
|
|
428
428
|
throw new BlockNotFoundError();
|
|
429
|
-
case
|
|
429
|
+
case 4:
|
|
430
430
|
throw new Error(result.errors.map(function (e) {
|
|
431
431
|
return e.message;
|
|
432
432
|
}).join(', '));
|
|
433
|
-
case
|
|
433
|
+
case 5:
|
|
434
434
|
isDeleted = (_result$data3 = result.data) === null || _result$data3 === void 0 || (_result$data3 = _result$data3.blockService_deleteBlock) === null || _result$data3 === void 0 ? void 0 : _result$data3.deleted;
|
|
435
435
|
if (isDeleted) {
|
|
436
|
-
_context4.next =
|
|
436
|
+
_context4.next = 6;
|
|
437
437
|
break;
|
|
438
438
|
}
|
|
439
439
|
throw new Error('Block deletion failed; deleted flag is false');
|
|
440
|
-
case
|
|
440
|
+
case 6:
|
|
441
441
|
case "end":
|
|
442
442
|
return _context4.stop();
|
|
443
443
|
}
|
|
@@ -450,7 +450,7 @@ export var deleteSyncedBlock = /*#__PURE__*/function () {
|
|
|
450
450
|
export var updateSyncedBlock = /*#__PURE__*/function () {
|
|
451
451
|
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref8) {
|
|
452
452
|
var blockAri, content, stepVersion, status, bodyData, url, response, result;
|
|
453
|
-
return _regeneratorRuntime.wrap(function
|
|
453
|
+
return _regeneratorRuntime.wrap(function (_context5) {
|
|
454
454
|
while (1) switch (_context5.prev = _context5.next) {
|
|
455
455
|
case 0:
|
|
456
456
|
blockAri = _ref8.blockAri, content = _ref8.content, stepVersion = _ref8.stepVersion, status = _ref8.status;
|
|
@@ -459,32 +459,32 @@ export var updateSyncedBlock = /*#__PURE__*/function () {
|
|
|
459
459
|
operationName: UPDATE_BLOCK_OPERATION_NAME
|
|
460
460
|
};
|
|
461
461
|
url = "".concat(GRAPHQL_ENDPOINT, "?operation=editorSyncedBlockUpdateBlock");
|
|
462
|
-
_context5.next =
|
|
462
|
+
_context5.next = 1;
|
|
463
463
|
return fetchWithRetry(url, {
|
|
464
464
|
method: 'POST',
|
|
465
465
|
headers: COMMON_HEADERS,
|
|
466
466
|
body: JSON.stringify(bodyData)
|
|
467
467
|
});
|
|
468
|
-
case
|
|
468
|
+
case 1:
|
|
469
469
|
response = _context5.sent;
|
|
470
470
|
if (response.ok) {
|
|
471
|
-
_context5.next =
|
|
471
|
+
_context5.next = 2;
|
|
472
472
|
break;
|
|
473
473
|
}
|
|
474
474
|
throw new BlockError(response.status);
|
|
475
|
-
case
|
|
476
|
-
_context5.next =
|
|
475
|
+
case 2:
|
|
476
|
+
_context5.next = 3;
|
|
477
477
|
return response.json();
|
|
478
|
-
case
|
|
478
|
+
case 3:
|
|
479
479
|
result = _context5.sent;
|
|
480
480
|
if (!(result.errors && result.errors.length > 0)) {
|
|
481
|
-
_context5.next =
|
|
481
|
+
_context5.next = 4;
|
|
482
482
|
break;
|
|
483
483
|
}
|
|
484
484
|
throw new Error(result.errors.map(function (e) {
|
|
485
485
|
return e.message;
|
|
486
486
|
}).join(', '));
|
|
487
|
-
case
|
|
487
|
+
case 4:
|
|
488
488
|
case "end":
|
|
489
489
|
return _context5.stop();
|
|
490
490
|
}
|
|
@@ -498,7 +498,7 @@ export var createSyncedBlock = /*#__PURE__*/function () {
|
|
|
498
498
|
var _ref1 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref0) {
|
|
499
499
|
var _result$data4;
|
|
500
500
|
var blockAri, blockInstanceId, sourceAri, product, content, stepVersion, status, bodyData, url, response, result;
|
|
501
|
-
return _regeneratorRuntime.wrap(function
|
|
501
|
+
return _regeneratorRuntime.wrap(function (_context6) {
|
|
502
502
|
while (1) switch (_context6.prev = _context6.next) {
|
|
503
503
|
case 0:
|
|
504
504
|
blockAri = _ref0.blockAri, blockInstanceId = _ref0.blockInstanceId, sourceAri = _ref0.sourceAri, product = _ref0.product, content = _ref0.content, stepVersion = _ref0.stepVersion, status = _ref0.status;
|
|
@@ -507,40 +507,40 @@ export var createSyncedBlock = /*#__PURE__*/function () {
|
|
|
507
507
|
operationName: CREATE_BLOCK_OPERATION_NAME
|
|
508
508
|
};
|
|
509
509
|
url = "".concat(GRAPHQL_ENDPOINT, "?operation=editorSyncedBlockCreateBlock");
|
|
510
|
-
_context6.next =
|
|
510
|
+
_context6.next = 1;
|
|
511
511
|
return fetchWithRetry(url, {
|
|
512
512
|
method: 'POST',
|
|
513
513
|
headers: COMMON_HEADERS,
|
|
514
514
|
body: JSON.stringify(bodyData)
|
|
515
515
|
});
|
|
516
|
-
case
|
|
516
|
+
case 1:
|
|
517
517
|
response = _context6.sent;
|
|
518
518
|
if (response.ok) {
|
|
519
|
-
_context6.next =
|
|
519
|
+
_context6.next = 2;
|
|
520
520
|
break;
|
|
521
521
|
}
|
|
522
522
|
throw new BlockError(response.status);
|
|
523
|
-
case
|
|
524
|
-
_context6.next =
|
|
523
|
+
case 2:
|
|
524
|
+
_context6.next = 3;
|
|
525
525
|
return response.json();
|
|
526
|
-
case
|
|
526
|
+
case 3:
|
|
527
527
|
result = _context6.sent;
|
|
528
528
|
if (!(result.errors && result.errors.length > 0)) {
|
|
529
|
-
_context6.next =
|
|
529
|
+
_context6.next = 4;
|
|
530
530
|
break;
|
|
531
531
|
}
|
|
532
532
|
throw new Error(result.errors.map(function (e) {
|
|
533
533
|
return e.message;
|
|
534
534
|
}).join(', '));
|
|
535
|
-
case
|
|
535
|
+
case 4:
|
|
536
536
|
if ((_result$data4 = result.data) !== null && _result$data4 !== void 0 && _result$data4.blockService_createBlock) {
|
|
537
|
-
_context6.next =
|
|
537
|
+
_context6.next = 5;
|
|
538
538
|
break;
|
|
539
539
|
}
|
|
540
540
|
throw new Error('No data returned from GraphQL mutation');
|
|
541
|
-
case
|
|
541
|
+
case 5:
|
|
542
542
|
return _context6.abrupt("return", result.data.blockService_createBlock);
|
|
543
|
-
case
|
|
543
|
+
case 6:
|
|
544
544
|
case "end":
|
|
545
545
|
return _context6.stop();
|
|
546
546
|
}
|
|
@@ -553,7 +553,7 @@ export var createSyncedBlock = /*#__PURE__*/function () {
|
|
|
553
553
|
export var updateReferenceSyncedBlockOnDocument = /*#__PURE__*/function () {
|
|
554
554
|
var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref10) {
|
|
555
555
|
var documentAri, blocks, _ref10$noContent, noContent, bodyData, url, response, result, _result$data5;
|
|
556
|
-
return _regeneratorRuntime.wrap(function
|
|
556
|
+
return _regeneratorRuntime.wrap(function (_context7) {
|
|
557
557
|
while (1) switch (_context7.prev = _context7.next) {
|
|
558
558
|
case 0:
|
|
559
559
|
documentAri = _ref10.documentAri, blocks = _ref10.blocks, _ref10$noContent = _ref10.noContent, noContent = _ref10$noContent === void 0 ? true : _ref10$noContent;
|
|
@@ -562,45 +562,45 @@ export var updateReferenceSyncedBlockOnDocument = /*#__PURE__*/function () {
|
|
|
562
562
|
operationName: UPDATE_DOCUMENT_REFERENCES_OPERATION_NAME
|
|
563
563
|
};
|
|
564
564
|
url = "".concat(GRAPHQL_ENDPOINT, "?operation=editorSyncedBlockUpdateDocumentReferences");
|
|
565
|
-
_context7.next =
|
|
565
|
+
_context7.next = 1;
|
|
566
566
|
return fetchWithRetry(url, {
|
|
567
567
|
method: 'POST',
|
|
568
568
|
headers: COMMON_HEADERS,
|
|
569
569
|
body: JSON.stringify(bodyData),
|
|
570
570
|
keepalive: true
|
|
571
571
|
});
|
|
572
|
-
case
|
|
572
|
+
case 1:
|
|
573
573
|
response = _context7.sent;
|
|
574
574
|
if (response.ok) {
|
|
575
|
-
_context7.next =
|
|
575
|
+
_context7.next = 2;
|
|
576
576
|
break;
|
|
577
577
|
}
|
|
578
578
|
throw new BlockError(response.status);
|
|
579
|
-
case
|
|
580
|
-
_context7.next =
|
|
579
|
+
case 2:
|
|
580
|
+
_context7.next = 3;
|
|
581
581
|
return response.json();
|
|
582
|
-
case
|
|
582
|
+
case 3:
|
|
583
583
|
result = _context7.sent;
|
|
584
584
|
if (!(result.errors && result.errors.length > 0)) {
|
|
585
|
-
_context7.next =
|
|
585
|
+
_context7.next = 4;
|
|
586
586
|
break;
|
|
587
587
|
}
|
|
588
588
|
throw new Error(result.errors.map(function (e) {
|
|
589
589
|
return e.message;
|
|
590
590
|
}).join(', '));
|
|
591
|
-
case
|
|
591
|
+
case 4:
|
|
592
592
|
if (noContent) {
|
|
593
|
-
_context7.next =
|
|
593
|
+
_context7.next = 6;
|
|
594
594
|
break;
|
|
595
595
|
}
|
|
596
596
|
if ((_result$data5 = result.data) !== null && _result$data5 !== void 0 && _result$data5.blockService_updateDocumentReferences) {
|
|
597
|
-
_context7.next =
|
|
597
|
+
_context7.next = 5;
|
|
598
598
|
break;
|
|
599
599
|
}
|
|
600
600
|
throw new Error('No data returned from GraphQL mutation');
|
|
601
|
-
case
|
|
601
|
+
case 5:
|
|
602
602
|
return _context7.abrupt("return", result.data.blockService_updateDocumentReferences);
|
|
603
|
-
case
|
|
603
|
+
case 6:
|
|
604
604
|
case "end":
|
|
605
605
|
return _context7.stop();
|
|
606
606
|
}
|
|
@@ -614,7 +614,7 @@ export var getReferenceSyncedBlocksByBlockAri = /*#__PURE__*/function () {
|
|
|
614
614
|
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref12) {
|
|
615
615
|
var _result$data6;
|
|
616
616
|
var blockAri, bodyData, url, response, result, graphqlResponse;
|
|
617
|
-
return _regeneratorRuntime.wrap(function
|
|
617
|
+
return _regeneratorRuntime.wrap(function (_context8) {
|
|
618
618
|
while (1) switch (_context8.prev = _context8.next) {
|
|
619
619
|
case 0:
|
|
620
620
|
blockAri = _ref12.blockAri;
|
|
@@ -623,45 +623,45 @@ export var getReferenceSyncedBlocksByBlockAri = /*#__PURE__*/function () {
|
|
|
623
623
|
operationName: GET_BLOCK_REFERENCES_OPERATION_NAME
|
|
624
624
|
};
|
|
625
625
|
url = "".concat(GRAPHQL_ENDPOINT, "?operation=editorSyncedBlockGetReferences");
|
|
626
|
-
_context8.next =
|
|
626
|
+
_context8.next = 1;
|
|
627
627
|
return fetchWithRetry(url, {
|
|
628
628
|
method: 'POST',
|
|
629
629
|
headers: COMMON_HEADERS,
|
|
630
630
|
body: JSON.stringify(bodyData)
|
|
631
631
|
});
|
|
632
|
-
case
|
|
632
|
+
case 1:
|
|
633
633
|
response = _context8.sent;
|
|
634
634
|
if (response.ok) {
|
|
635
|
-
_context8.next =
|
|
635
|
+
_context8.next = 2;
|
|
636
636
|
break;
|
|
637
637
|
}
|
|
638
638
|
throw new BlockError(response.status);
|
|
639
|
-
case
|
|
640
|
-
_context8.next =
|
|
639
|
+
case 2:
|
|
640
|
+
_context8.next = 3;
|
|
641
641
|
return response.json();
|
|
642
|
-
case
|
|
642
|
+
case 3:
|
|
643
643
|
result = _context8.sent;
|
|
644
644
|
if (!(result.errors && result.errors.length > 0)) {
|
|
645
|
-
_context8.next =
|
|
645
|
+
_context8.next = 4;
|
|
646
646
|
break;
|
|
647
647
|
}
|
|
648
648
|
throw new Error(result.errors.map(function (e) {
|
|
649
649
|
return e.message;
|
|
650
650
|
}).join(', '));
|
|
651
|
-
case
|
|
651
|
+
case 4:
|
|
652
652
|
if ((_result$data6 = result.data) !== null && _result$data6 !== void 0 && _result$data6.blockService_getReferences) {
|
|
653
|
-
_context8.next =
|
|
653
|
+
_context8.next = 5;
|
|
654
654
|
break;
|
|
655
655
|
}
|
|
656
656
|
throw new Error('No data returned from GraphQL query');
|
|
657
|
-
case
|
|
657
|
+
case 5:
|
|
658
658
|
graphqlResponse = result.data.blockService_getReferences;
|
|
659
659
|
return _context8.abrupt("return", {
|
|
660
660
|
blockAri: blockAri,
|
|
661
661
|
references: graphqlResponse.references || [],
|
|
662
662
|
errors: graphqlResponse.errors || []
|
|
663
663
|
});
|
|
664
|
-
case
|
|
664
|
+
case 6:
|
|
665
665
|
case "end":
|
|
666
666
|
return _context8.stop();
|
|
667
667
|
}
|
|
@@ -698,7 +698,7 @@ export var updateSyncedBlocks = /*#__PURE__*/function () {
|
|
|
698
698
|
var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref14) {
|
|
699
699
|
var _result$data7;
|
|
700
700
|
var blocks, bodyData, url, response, result, graphqlResponse;
|
|
701
|
-
return _regeneratorRuntime.wrap(function
|
|
701
|
+
return _regeneratorRuntime.wrap(function (_context9) {
|
|
702
702
|
while (1) switch (_context9.prev = _context9.next) {
|
|
703
703
|
case 0:
|
|
704
704
|
blocks = _ref14.blocks;
|
|
@@ -707,44 +707,44 @@ export var updateSyncedBlocks = /*#__PURE__*/function () {
|
|
|
707
707
|
operationName: BATCH_UPDATE_BLOCKS_OPERATION_NAME
|
|
708
708
|
};
|
|
709
709
|
url = "".concat(GRAPHQL_ENDPOINT, "?operation=editorSyncedBlockBatchUpdateBlocks");
|
|
710
|
-
_context9.next =
|
|
710
|
+
_context9.next = 1;
|
|
711
711
|
return fetchWithRetry(url, {
|
|
712
712
|
method: 'POST',
|
|
713
713
|
headers: COMMON_HEADERS,
|
|
714
714
|
body: JSON.stringify(bodyData)
|
|
715
715
|
});
|
|
716
|
-
case
|
|
716
|
+
case 1:
|
|
717
717
|
response = _context9.sent;
|
|
718
718
|
if (response.ok) {
|
|
719
|
-
_context9.next =
|
|
719
|
+
_context9.next = 2;
|
|
720
720
|
break;
|
|
721
721
|
}
|
|
722
722
|
throw new BlockError(response.status);
|
|
723
|
-
case
|
|
724
|
-
_context9.next =
|
|
723
|
+
case 2:
|
|
724
|
+
_context9.next = 3;
|
|
725
725
|
return response.json();
|
|
726
|
-
case
|
|
726
|
+
case 3:
|
|
727
727
|
result = _context9.sent;
|
|
728
728
|
if (!(result.errors && result.errors.length > 0)) {
|
|
729
|
-
_context9.next =
|
|
729
|
+
_context9.next = 4;
|
|
730
730
|
break;
|
|
731
731
|
}
|
|
732
732
|
throw new Error(result.errors.map(function (e) {
|
|
733
733
|
return e.message;
|
|
734
734
|
}).join(', '));
|
|
735
|
-
case
|
|
735
|
+
case 4:
|
|
736
736
|
if ((_result$data7 = result.data) !== null && _result$data7 !== void 0 && _result$data7.blockService_batchUpdateBlocks) {
|
|
737
|
-
_context9.next =
|
|
737
|
+
_context9.next = 5;
|
|
738
738
|
break;
|
|
739
739
|
}
|
|
740
740
|
throw new Error('No data returned from GraphQL mutation');
|
|
741
|
-
case
|
|
741
|
+
case 5:
|
|
742
742
|
graphqlResponse = result.data.blockService_batchUpdateBlocks;
|
|
743
743
|
return _context9.abrupt("return", {
|
|
744
744
|
success: graphqlResponse.success,
|
|
745
745
|
error: graphqlResponse.error
|
|
746
746
|
});
|
|
747
|
-
case
|
|
747
|
+
case 6:
|
|
748
748
|
case "end":
|
|
749
749
|
return _context9.stop();
|
|
750
750
|
}
|
|
@@ -18,7 +18,7 @@ var GET_CONTENT_MEDIA_SESSION_QUERY = "query ".concat(GET_CONTENT_MEDIA_SESSION_
|
|
|
18
18
|
var getContentMediaSession = /*#__PURE__*/function () {
|
|
19
19
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(contentId) {
|
|
20
20
|
var bodyData, response, result;
|
|
21
|
-
return _regeneratorRuntime.wrap(function
|
|
21
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
22
22
|
while (1) switch (_context.prev = _context.next) {
|
|
23
23
|
case 0:
|
|
24
24
|
bodyData = {
|
|
@@ -28,26 +28,26 @@ var getContentMediaSession = /*#__PURE__*/function () {
|
|
|
28
28
|
contentId: contentId
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
|
-
_context.next =
|
|
31
|
+
_context.next = 1;
|
|
32
32
|
return fetchWithRetry(GRAPHQL_ENDPOINT, {
|
|
33
33
|
method: 'POST',
|
|
34
34
|
headers: _objectSpread(_objectSpread({}, COMMON_HEADERS), AGG_HEADERS),
|
|
35
35
|
body: JSON.stringify(bodyData)
|
|
36
36
|
});
|
|
37
|
-
case
|
|
37
|
+
case 1:
|
|
38
38
|
response = _context.sent;
|
|
39
39
|
if (response.ok) {
|
|
40
|
-
_context.next =
|
|
40
|
+
_context.next = 2;
|
|
41
41
|
break;
|
|
42
42
|
}
|
|
43
43
|
throw new Error("Failed to get content media session: ".concat(response.statusText));
|
|
44
|
-
case
|
|
45
|
-
_context.next =
|
|
44
|
+
case 2:
|
|
45
|
+
_context.next = 3;
|
|
46
46
|
return response.json();
|
|
47
|
-
case
|
|
47
|
+
case 3:
|
|
48
48
|
result = _context.sent;
|
|
49
49
|
return _context.abrupt("return", result);
|
|
50
|
-
case
|
|
50
|
+
case 4:
|
|
51
51
|
case "end":
|
|
52
52
|
return _context.stop();
|
|
53
53
|
}
|
|
@@ -59,43 +59,43 @@ var getContentMediaSession = /*#__PURE__*/function () {
|
|
|
59
59
|
}();
|
|
60
60
|
export var fetchMediaToken = /*#__PURE__*/function () {
|
|
61
61
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(contentId) {
|
|
62
|
-
var _response$data, _contentData$token, response, contentData, token, configuration, collection, errorMsg;
|
|
63
|
-
return _regeneratorRuntime.wrap(function
|
|
62
|
+
var _response$data, _contentData$token, response, contentData, token, configuration, collection, errorMsg, _t;
|
|
63
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
64
64
|
while (1) switch (_context2.prev = _context2.next) {
|
|
65
65
|
case 0:
|
|
66
66
|
_context2.prev = 0;
|
|
67
|
-
_context2.next =
|
|
67
|
+
_context2.next = 1;
|
|
68
68
|
return getContentMediaSession(contentId);
|
|
69
|
-
case
|
|
69
|
+
case 1:
|
|
70
70
|
response = _context2.sent;
|
|
71
71
|
contentData = (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.contentMediaSession;
|
|
72
72
|
token = contentData === null || contentData === void 0 || (_contentData$token = contentData.token) === null || _contentData$token === void 0 ? void 0 : _contentData$token.value;
|
|
73
73
|
configuration = contentData === null || contentData === void 0 ? void 0 : contentData.configuration;
|
|
74
74
|
collection = contentData === null || contentData === void 0 ? void 0 : contentData.collection;
|
|
75
75
|
if (!(!token || !configuration || !collection)) {
|
|
76
|
-
_context2.next =
|
|
76
|
+
_context2.next = 2;
|
|
77
77
|
break;
|
|
78
78
|
}
|
|
79
79
|
throw new Error('Failed to get content media session data');
|
|
80
|
-
case
|
|
80
|
+
case 2:
|
|
81
81
|
return _context2.abrupt("return", {
|
|
82
82
|
config: configuration,
|
|
83
83
|
token: token,
|
|
84
84
|
collectionId: collection
|
|
85
85
|
});
|
|
86
|
-
case
|
|
87
|
-
_context2.prev =
|
|
88
|
-
|
|
89
|
-
logException(
|
|
86
|
+
case 3:
|
|
87
|
+
_context2.prev = 3;
|
|
88
|
+
_t = _context2["catch"](0);
|
|
89
|
+
logException(_t, {
|
|
90
90
|
location: 'editor-synced-block-provider/fetchMediaToken'
|
|
91
91
|
});
|
|
92
|
-
errorMsg =
|
|
92
|
+
errorMsg = _t instanceof Error ? _t.message : String(_t);
|
|
93
93
|
throw new Error("Failed to get content media session: ".concat(errorMsg));
|
|
94
|
-
case
|
|
94
|
+
case 4:
|
|
95
95
|
case "end":
|
|
96
96
|
return _context2.stop();
|
|
97
97
|
}
|
|
98
|
-
}, _callee2, null, [[0,
|
|
98
|
+
}, _callee2, null, [[0, 3]]);
|
|
99
99
|
}));
|
|
100
100
|
return function fetchMediaToken(_x2) {
|
|
101
101
|
return _ref2.apply(this, arguments);
|