@atlaskit/editor-synced-block-provider 3.29.2 → 3.29.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @atlaskit/editor-synced-block-provider
2
2
 
3
+ ## 3.29.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`e4b932a41725c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e4b932a41725c) -
8
+ [ux] EDITOR-5459 fix merging logic for subtype in resolve sync block instance
9
+ - [`aef1e97f7c9f4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/aef1e97f7c9f4) -
10
+ [EDITOR-5278] Append operation name to graphql call url for better observability
11
+ - Updated dependencies
12
+
3
13
  ## 3.29.2
4
14
 
5
15
  ### Patch Changes
@@ -13,6 +13,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
13
13
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
14
14
  var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));
15
15
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
16
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
17
  var _retry = require("../../utils/retry");
17
18
  function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
18
19
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
@@ -63,7 +64,7 @@ var isBlockContentResponse = exports.isBlockContentResponse = function isBlockCo
63
64
  */
64
65
  var getReferenceSyncedBlocks = exports.getReferenceSyncedBlocks = /*#__PURE__*/function () {
65
66
  var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(documentAri) {
66
- var bodyData, response, result;
67
+ var bodyData, url, response, result;
67
68
  return _regenerator.default.wrap(function _callee$(_context) {
68
69
  while (1) switch (_context.prev = _context.next) {
69
70
  case 0:
@@ -71,40 +72,41 @@ var getReferenceSyncedBlocks = exports.getReferenceSyncedBlocks = /*#__PURE__*/f
71
72
  query: buildGetDocumentReferenceBlocksQuery(documentAri),
72
73
  operationName: GET_DOCUMENT_REFERENCE_BLOCKS_OPERATION_NAME
73
74
  };
74
- _context.next = 3;
75
- return (0, _retry.fetchWithRetry)(GRAPHQL_ENDPOINT, {
75
+ url = (0, _platformFeatureFlags.fg)('platform_synced_block_patch_3') ? "".concat(GRAPHQL_ENDPOINT, "?operation=editorSyncedBlockGetDocumentReferenceBlocks") : GRAPHQL_ENDPOINT;
76
+ _context.next = 4;
77
+ return (0, _retry.fetchWithRetry)(url, {
76
78
  method: 'POST',
77
79
  headers: COMMON_HEADERS,
78
80
  body: JSON.stringify(bodyData)
79
81
  });
80
- case 3:
82
+ case 4:
81
83
  response = _context.sent;
82
84
  if (response.ok) {
83
- _context.next = 6;
85
+ _context.next = 7;
84
86
  break;
85
87
  }
86
88
  throw new BlockError(response.status);
87
- case 6:
88
- _context.next = 8;
89
+ case 7:
90
+ _context.next = 9;
89
91
  return response.json();
90
- case 8:
92
+ case 9:
91
93
  result = _context.sent;
92
94
  if (!(result.errors && result.errors.length > 0)) {
93
- _context.next = 11;
95
+ _context.next = 12;
94
96
  break;
95
97
  }
96
98
  throw new Error(result.errors.map(function (e) {
97
99
  return e.message;
98
100
  }).join(', '));
99
- case 11:
101
+ case 12:
100
102
  if (result.data) {
101
- _context.next = 13;
103
+ _context.next = 14;
102
104
  break;
103
105
  }
104
106
  throw new Error('No data returned from GraphQL query');
105
- case 13:
106
- return _context.abrupt("return", result.data.blockService_getDocumentReferenceBlocks);
107
107
  case 14:
108
+ return _context.abrupt("return", result.data.blockService_getDocumentReferenceBlocks);
109
+ case 15:
108
110
  case "end":
109
111
  return _context.stop();
110
112
  }
@@ -207,7 +209,7 @@ var BlockError = exports.BlockError = /*#__PURE__*/function (_Error) {
207
209
  var getSyncedBlockContent = exports.getSyncedBlockContent = /*#__PURE__*/function () {
208
210
  var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(_ref2) {
209
211
  var _result$data;
210
- var blockAri, bodyData, response, result;
212
+ var blockAri, bodyData, url, response, result;
211
213
  return _regenerator.default.wrap(function _callee2$(_context2) {
212
214
  while (1) switch (_context2.prev = _context2.next) {
213
215
  case 0:
@@ -216,40 +218,41 @@ var getSyncedBlockContent = exports.getSyncedBlockContent = /*#__PURE__*/functio
216
218
  query: buildGetBlockQuery(blockAri),
217
219
  operationName: GET_BLOCK_OPERATION_NAME
218
220
  };
219
- _context2.next = 4;
220
- return (0, _retry.fetchWithRetry)(GRAPHQL_ENDPOINT, {
221
+ url = (0, _platformFeatureFlags.fg)('platform_synced_block_patch_3') ? "".concat(GRAPHQL_ENDPOINT, "?operation=editorSyncedBlockGetBlock") : GRAPHQL_ENDPOINT;
222
+ _context2.next = 5;
223
+ return (0, _retry.fetchWithRetry)(url, {
221
224
  method: 'POST',
222
225
  headers: COMMON_HEADERS,
223
226
  body: JSON.stringify(bodyData)
224
227
  });
225
- case 4:
228
+ case 5:
226
229
  response = _context2.sent;
227
230
  if (response.ok) {
228
- _context2.next = 7;
231
+ _context2.next = 8;
229
232
  break;
230
233
  }
231
234
  throw new BlockError(response.status);
232
- case 7:
233
- _context2.next = 9;
235
+ case 8:
236
+ _context2.next = 10;
234
237
  return response.json();
235
- case 9:
238
+ case 10:
236
239
  result = _context2.sent;
237
240
  if (!(result.errors && result.errors.length > 0)) {
238
- _context2.next = 12;
241
+ _context2.next = 13;
239
242
  break;
240
243
  }
241
244
  throw new Error(result.errors.map(function (e) {
242
245
  return e.message;
243
246
  }).join(', '));
244
- case 12:
247
+ case 13:
245
248
  if ((_result$data = result.data) !== null && _result$data !== void 0 && _result$data.blockService_getBlock) {
246
- _context2.next = 14;
249
+ _context2.next = 15;
247
250
  break;
248
251
  }
249
252
  throw new Error('No data returned from GraphQL query');
250
- case 14:
251
- return _context2.abrupt("return", result.data.blockService_getBlock);
252
253
  case 15:
254
+ return _context2.abrupt("return", result.data.blockService_getBlock);
255
+ case 16:
253
256
  case "end":
254
257
  return _context2.stop();
255
258
  }
@@ -271,7 +274,7 @@ var getSyncedBlockContent = exports.getSyncedBlockContent = /*#__PURE__*/functio
271
274
  var batchRetrieveSyncedBlocks = exports.batchRetrieveSyncedBlocks = /*#__PURE__*/function () {
272
275
  var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(_ref4) {
273
276
  var _result$data2;
274
- var blockIdentifiers, blockAris, bodyData, response, result, graphqlResponse;
277
+ var blockIdentifiers, blockAris, bodyData, url, response, result, graphqlResponse;
275
278
  return _regenerator.default.wrap(function _callee3$(_context3) {
276
279
  while (1) switch (_context3.prev = _context3.next) {
277
280
  case 0:
@@ -283,44 +286,45 @@ var batchRetrieveSyncedBlocks = exports.batchRetrieveSyncedBlocks = /*#__PURE__*
283
286
  query: buildBatchRetrieveBlocksQuery(blockAris),
284
287
  operationName: BATCH_RETRIEVE_BLOCKS_OPERATION_NAME
285
288
  };
286
- _context3.next = 5;
287
- return (0, _retry.fetchWithRetry)(GRAPHQL_ENDPOINT, {
289
+ url = (0, _platformFeatureFlags.fg)('platform_synced_block_patch_3') ? "".concat(GRAPHQL_ENDPOINT, "?operation=editorSyncedBlockBatchRetrieveBlocks") : GRAPHQL_ENDPOINT;
290
+ _context3.next = 6;
291
+ return (0, _retry.fetchWithRetry)(url, {
288
292
  method: 'POST',
289
293
  headers: COMMON_HEADERS,
290
294
  body: JSON.stringify(bodyData)
291
295
  });
292
- case 5:
296
+ case 6:
293
297
  response = _context3.sent;
294
298
  if (response.ok) {
295
- _context3.next = 8;
299
+ _context3.next = 9;
296
300
  break;
297
301
  }
298
302
  throw new BlockError(response.status);
299
- case 8:
300
- _context3.next = 10;
303
+ case 9:
304
+ _context3.next = 11;
301
305
  return response.json();
302
- case 10:
306
+ case 11:
303
307
  result = _context3.sent;
304
308
  if (!(result.errors && result.errors.length > 0)) {
305
- _context3.next = 13;
309
+ _context3.next = 14;
306
310
  break;
307
311
  }
308
312
  throw new Error(result.errors.map(function (e) {
309
313
  return e.message;
310
314
  }).join(', '));
311
- case 13:
315
+ case 14:
312
316
  if ((_result$data2 = result.data) !== null && _result$data2 !== void 0 && _result$data2.blockService_batchRetrieveBlocks) {
313
- _context3.next = 15;
317
+ _context3.next = 16;
314
318
  break;
315
319
  }
316
320
  throw new Error('No data returned from GraphQL query');
317
- case 15:
321
+ case 16:
318
322
  graphqlResponse = result.data.blockService_batchRetrieveBlocks;
319
323
  return _context3.abrupt("return", {
320
324
  success: graphqlResponse.success,
321
325
  error: graphqlResponse.error
322
326
  });
323
- case 17:
327
+ case 18:
324
328
  case "end":
325
329
  return _context3.stop();
326
330
  }
@@ -333,7 +337,7 @@ var batchRetrieveSyncedBlocks = exports.batchRetrieveSyncedBlocks = /*#__PURE__*
333
337
  var deleteSyncedBlock = exports.deleteSyncedBlock = /*#__PURE__*/function () {
334
338
  var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(_ref6) {
335
339
  var _result$data3;
336
- var blockAri, deleteReason, bodyData, response, result;
340
+ var blockAri, deleteReason, bodyData, url, response, result;
337
341
  return _regenerator.default.wrap(function _callee4$(_context4) {
338
342
  while (1) switch (_context4.prev = _context4.next) {
339
343
  case 0:
@@ -342,38 +346,39 @@ var deleteSyncedBlock = exports.deleteSyncedBlock = /*#__PURE__*/function () {
342
346
  query: buildDeleteBlockMutation(blockAri, deleteReason),
343
347
  operationName: DELETE_BLOCK_OPERATION_NAME
344
348
  };
345
- _context4.next = 4;
346
- return (0, _retry.fetchWithRetry)(GRAPHQL_ENDPOINT, {
349
+ url = (0, _platformFeatureFlags.fg)('platform_synced_block_patch_3') ? "".concat(GRAPHQL_ENDPOINT, "?operation=editorSyncedBlockDeleteBlock") : GRAPHQL_ENDPOINT;
350
+ _context4.next = 5;
351
+ return (0, _retry.fetchWithRetry)(url, {
347
352
  method: 'POST',
348
353
  headers: COMMON_HEADERS,
349
354
  body: JSON.stringify(bodyData)
350
355
  });
351
- case 4:
356
+ case 5:
352
357
  response = _context4.sent;
353
358
  if (response.ok) {
354
- _context4.next = 7;
359
+ _context4.next = 8;
355
360
  break;
356
361
  }
357
362
  throw new BlockError(response.status);
358
- case 7:
359
- _context4.next = 9;
363
+ case 8:
364
+ _context4.next = 10;
360
365
  return response.json();
361
- case 9:
366
+ case 10:
362
367
  result = _context4.sent;
363
368
  if (!(result.errors && result.errors.length > 0)) {
364
- _context4.next = 12;
369
+ _context4.next = 13;
365
370
  break;
366
371
  }
367
372
  throw new Error(result.errors.map(function (e) {
368
373
  return e.message;
369
374
  }).join(', '));
370
- case 12:
375
+ case 13:
371
376
  if ((_result$data3 = result.data) !== null && _result$data3 !== void 0 && _result$data3.blockService_deleteBlock.deleted) {
372
- _context4.next = 14;
377
+ _context4.next = 15;
373
378
  break;
374
379
  }
375
380
  throw new Error('Block deletion failed; deleted flag is false');
376
- case 14:
381
+ case 15:
377
382
  case "end":
378
383
  return _context4.stop();
379
384
  }
@@ -385,7 +390,7 @@ var deleteSyncedBlock = exports.deleteSyncedBlock = /*#__PURE__*/function () {
385
390
  }();
386
391
  var updateSyncedBlock = exports.updateSyncedBlock = /*#__PURE__*/function () {
387
392
  var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(_ref8) {
388
- var blockAri, content, stepVersion, status, bodyData, response, result;
393
+ var blockAri, content, stepVersion, status, bodyData, url, response, result;
389
394
  return _regenerator.default.wrap(function _callee5$(_context5) {
390
395
  while (1) switch (_context5.prev = _context5.next) {
391
396
  case 0:
@@ -394,32 +399,33 @@ var updateSyncedBlock = exports.updateSyncedBlock = /*#__PURE__*/function () {
394
399
  query: buildUpdateBlockMutation(blockAri, content, stepVersion, status),
395
400
  operationName: UPDATE_BLOCK_OPERATION_NAME
396
401
  };
397
- _context5.next = 4;
398
- return (0, _retry.fetchWithRetry)(GRAPHQL_ENDPOINT, {
402
+ url = (0, _platformFeatureFlags.fg)('platform_synced_block_patch_3') ? "".concat(GRAPHQL_ENDPOINT, "?operation=editorSyncedBlockUpdateBlock") : GRAPHQL_ENDPOINT;
403
+ _context5.next = 5;
404
+ return (0, _retry.fetchWithRetry)(url, {
399
405
  method: 'POST',
400
406
  headers: COMMON_HEADERS,
401
407
  body: JSON.stringify(bodyData)
402
408
  });
403
- case 4:
409
+ case 5:
404
410
  response = _context5.sent;
405
411
  if (response.ok) {
406
- _context5.next = 7;
412
+ _context5.next = 8;
407
413
  break;
408
414
  }
409
415
  throw new BlockError(response.status);
410
- case 7:
411
- _context5.next = 9;
416
+ case 8:
417
+ _context5.next = 10;
412
418
  return response.json();
413
- case 9:
419
+ case 10:
414
420
  result = _context5.sent;
415
421
  if (!(result.errors && result.errors.length > 0)) {
416
- _context5.next = 12;
422
+ _context5.next = 13;
417
423
  break;
418
424
  }
419
425
  throw new Error(result.errors.map(function (e) {
420
426
  return e.message;
421
427
  }).join(', '));
422
- case 12:
428
+ case 13:
423
429
  case "end":
424
430
  return _context5.stop();
425
431
  }
@@ -432,7 +438,7 @@ var updateSyncedBlock = exports.updateSyncedBlock = /*#__PURE__*/function () {
432
438
  var createSyncedBlock = exports.createSyncedBlock = /*#__PURE__*/function () {
433
439
  var _ref1 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(_ref0) {
434
440
  var _result$data4;
435
- var blockAri, blockInstanceId, sourceAri, product, content, stepVersion, status, bodyData, response, result;
441
+ var blockAri, blockInstanceId, sourceAri, product, content, stepVersion, status, bodyData, url, response, result;
436
442
  return _regenerator.default.wrap(function _callee6$(_context6) {
437
443
  while (1) switch (_context6.prev = _context6.next) {
438
444
  case 0:
@@ -441,40 +447,41 @@ var createSyncedBlock = exports.createSyncedBlock = /*#__PURE__*/function () {
441
447
  query: buildCreateBlockMutation(blockAri, blockInstanceId, content, product, sourceAri, stepVersion, status),
442
448
  operationName: CREATE_BLOCK_OPERATION_NAME
443
449
  };
444
- _context6.next = 4;
445
- return (0, _retry.fetchWithRetry)(GRAPHQL_ENDPOINT, {
450
+ url = (0, _platformFeatureFlags.fg)('platform_synced_block_patch_3') ? "".concat(GRAPHQL_ENDPOINT, "?operation=editorSyncedBlockCreateBlock") : GRAPHQL_ENDPOINT;
451
+ _context6.next = 5;
452
+ return (0, _retry.fetchWithRetry)(url, {
446
453
  method: 'POST',
447
454
  headers: COMMON_HEADERS,
448
455
  body: JSON.stringify(bodyData)
449
456
  });
450
- case 4:
457
+ case 5:
451
458
  response = _context6.sent;
452
459
  if (response.ok) {
453
- _context6.next = 7;
460
+ _context6.next = 8;
454
461
  break;
455
462
  }
456
463
  throw new BlockError(response.status);
457
- case 7:
458
- _context6.next = 9;
464
+ case 8:
465
+ _context6.next = 10;
459
466
  return response.json();
460
- case 9:
467
+ case 10:
461
468
  result = _context6.sent;
462
469
  if (!(result.errors && result.errors.length > 0)) {
463
- _context6.next = 12;
470
+ _context6.next = 13;
464
471
  break;
465
472
  }
466
473
  throw new Error(result.errors.map(function (e) {
467
474
  return e.message;
468
475
  }).join(', '));
469
- case 12:
476
+ case 13:
470
477
  if ((_result$data4 = result.data) !== null && _result$data4 !== void 0 && _result$data4.blockService_createBlock) {
471
- _context6.next = 14;
478
+ _context6.next = 15;
472
479
  break;
473
480
  }
474
481
  throw new Error('No data returned from GraphQL mutation');
475
- case 14:
476
- return _context6.abrupt("return", result.data.blockService_createBlock);
477
482
  case 15:
483
+ return _context6.abrupt("return", result.data.blockService_createBlock);
484
+ case 16:
478
485
  case "end":
479
486
  return _context6.stop();
480
487
  }
@@ -486,7 +493,7 @@ var createSyncedBlock = exports.createSyncedBlock = /*#__PURE__*/function () {
486
493
  }();
487
494
  var updateReferenceSyncedBlockOnDocument = exports.updateReferenceSyncedBlockOnDocument = /*#__PURE__*/function () {
488
495
  var _ref11 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(_ref10) {
489
- var documentAri, blocks, _ref10$noContent, noContent, bodyData, response, result, _result$data5;
496
+ var documentAri, blocks, _ref10$noContent, noContent, bodyData, url, response, result, _result$data5;
490
497
  return _regenerator.default.wrap(function _callee7$(_context7) {
491
498
  while (1) switch (_context7.prev = _context7.next) {
492
499
  case 0:
@@ -495,45 +502,46 @@ var updateReferenceSyncedBlockOnDocument = exports.updateReferenceSyncedBlockOnD
495
502
  query: buildUpdateDocumentReferencesMutation(documentAri, blocks, noContent),
496
503
  operationName: UPDATE_DOCUMENT_REFERENCES_OPERATION_NAME
497
504
  };
498
- _context7.next = 4;
499
- return (0, _retry.fetchWithRetry)(GRAPHQL_ENDPOINT, {
505
+ url = (0, _platformFeatureFlags.fg)('platform_synced_block_patch_3') ? "".concat(GRAPHQL_ENDPOINT, "?operation=editorSyncedBlockUpdateDocumentReferences") : GRAPHQL_ENDPOINT;
506
+ _context7.next = 5;
507
+ return (0, _retry.fetchWithRetry)(url, {
500
508
  method: 'POST',
501
509
  headers: COMMON_HEADERS,
502
510
  body: JSON.stringify(bodyData),
503
511
  keepalive: true
504
512
  });
505
- case 4:
513
+ case 5:
506
514
  response = _context7.sent;
507
515
  if (response.ok) {
508
- _context7.next = 7;
516
+ _context7.next = 8;
509
517
  break;
510
518
  }
511
519
  throw new BlockError(response.status);
512
- case 7:
513
- _context7.next = 9;
520
+ case 8:
521
+ _context7.next = 10;
514
522
  return response.json();
515
- case 9:
523
+ case 10:
516
524
  result = _context7.sent;
517
525
  if (!(result.errors && result.errors.length > 0)) {
518
- _context7.next = 12;
526
+ _context7.next = 13;
519
527
  break;
520
528
  }
521
529
  throw new Error(result.errors.map(function (e) {
522
530
  return e.message;
523
531
  }).join(', '));
524
- case 12:
532
+ case 13:
525
533
  if (noContent) {
526
- _context7.next = 16;
534
+ _context7.next = 17;
527
535
  break;
528
536
  }
529
537
  if ((_result$data5 = result.data) !== null && _result$data5 !== void 0 && _result$data5.blockService_updateDocumentReferences) {
530
- _context7.next = 15;
538
+ _context7.next = 16;
531
539
  break;
532
540
  }
533
541
  throw new Error('No data returned from GraphQL mutation');
534
- case 15:
535
- return _context7.abrupt("return", result.data.blockService_updateDocumentReferences);
536
542
  case 16:
543
+ return _context7.abrupt("return", result.data.blockService_updateDocumentReferences);
544
+ case 17:
537
545
  case "end":
538
546
  return _context7.stop();
539
547
  }
@@ -546,7 +554,7 @@ var updateReferenceSyncedBlockOnDocument = exports.updateReferenceSyncedBlockOnD
546
554
  var getReferenceSyncedBlocksByBlockAri = exports.getReferenceSyncedBlocksByBlockAri = /*#__PURE__*/function () {
547
555
  var _ref13 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(_ref12) {
548
556
  var _result$data6;
549
- var blockAri, bodyData, response, result, graphqlResponse;
557
+ var blockAri, bodyData, url, response, result, graphqlResponse;
550
558
  return _regenerator.default.wrap(function _callee8$(_context8) {
551
559
  while (1) switch (_context8.prev = _context8.next) {
552
560
  case 0:
@@ -555,45 +563,46 @@ var getReferenceSyncedBlocksByBlockAri = exports.getReferenceSyncedBlocksByBlock
555
563
  query: buildGetBlockReferencesQuery(blockAri),
556
564
  operationName: GET_BLOCK_REFERENCES_OPERATION_NAME
557
565
  };
558
- _context8.next = 4;
559
- return (0, _retry.fetchWithRetry)(GRAPHQL_ENDPOINT, {
566
+ url = (0, _platformFeatureFlags.fg)('platform_synced_block_patch_3') ? "".concat(GRAPHQL_ENDPOINT, "?operation=editorSyncedBlockGetReferences") : GRAPHQL_ENDPOINT;
567
+ _context8.next = 5;
568
+ return (0, _retry.fetchWithRetry)(url, {
560
569
  method: 'POST',
561
570
  headers: COMMON_HEADERS,
562
571
  body: JSON.stringify(bodyData)
563
572
  });
564
- case 4:
573
+ case 5:
565
574
  response = _context8.sent;
566
575
  if (response.ok) {
567
- _context8.next = 7;
576
+ _context8.next = 8;
568
577
  break;
569
578
  }
570
579
  throw new BlockError(response.status);
571
- case 7:
572
- _context8.next = 9;
580
+ case 8:
581
+ _context8.next = 10;
573
582
  return response.json();
574
- case 9:
583
+ case 10:
575
584
  result = _context8.sent;
576
585
  if (!(result.errors && result.errors.length > 0)) {
577
- _context8.next = 12;
586
+ _context8.next = 13;
578
587
  break;
579
588
  }
580
589
  throw new Error(result.errors.map(function (e) {
581
590
  return e.message;
582
591
  }).join(', '));
583
- case 12:
592
+ case 13:
584
593
  if ((_result$data6 = result.data) !== null && _result$data6 !== void 0 && _result$data6.blockService_getReferences) {
585
- _context8.next = 14;
594
+ _context8.next = 15;
586
595
  break;
587
596
  }
588
597
  throw new Error('No data returned from GraphQL query');
589
- case 14:
598
+ case 15:
590
599
  graphqlResponse = result.data.blockService_getReferences;
591
600
  return _context8.abrupt("return", {
592
601
  blockAri: blockAri,
593
602
  references: graphqlResponse.references || [],
594
603
  errors: graphqlResponse.errors || []
595
604
  });
596
- case 16:
605
+ case 17:
597
606
  case "end":
598
607
  return _context8.stop();
599
608
  }
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.resolveSyncBlockInstance = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
+ var _ari = require("../clients/confluence/ari");
9
11
  var _types = require("../common/types");
10
12
  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; }
11
13
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -40,8 +42,30 @@ var resolveSyncBlockInstance = exports.resolveSyncBlockInstance = function resol
40
42
  data: _objectSpread(_objectSpread({}, newResult.data), {}, {
41
43
  sourceURL: ((_newResult$data = newResult.data) === null || _newResult$data === void 0 ? void 0 : _newResult$data.sourceURL) || ((_oldResult$data = oldResult.data) === null || _oldResult$data === void 0 ? void 0 : _oldResult$data.sourceURL) || undefined,
42
44
  sourceTitle: ((_newResult$data2 = newResult.data) === null || _newResult$data2 === void 0 ? void 0 : _newResult$data2.sourceTitle) || ((_oldResult$data2 = oldResult.data) === null || _oldResult$data2 === void 0 ? void 0 : _oldResult$data2.sourceTitle) || undefined,
43
- sourceSubType: ((_newResult$data3 = newResult.data) === null || _newResult$data3 === void 0 ? void 0 : _newResult$data3.sourceSubType) || ((_oldResult$data3 = oldResult.data) === null || _oldResult$data3 === void 0 ? void 0 : _oldResult$data3.sourceSubType) || undefined,
45
+ sourceSubType: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_3') ? mergeSubType(oldResult, newResult) : ((_newResult$data3 = newResult.data) === null || _newResult$data3 === void 0 ? void 0 : _newResult$data3.sourceSubType) || ((_oldResult$data3 = oldResult.data) === null || _oldResult$data3 === void 0 ? void 0 : _oldResult$data3.sourceSubType) || undefined,
44
46
  onSameDocument: ((_newResult$data4 = newResult.data) === null || _newResult$data4 === void 0 ? void 0 : _newResult$data4.onSameDocument) || ((_oldResult$data4 = oldResult.data) === null || _oldResult$data4 === void 0 ? void 0 : _oldResult$data4.onSameDocument) || undefined
45
47
  })
46
48
  });
49
+ };
50
+ var mergeSubType = function mergeSubType(oldResult, newResult) {
51
+ var _newResult$data5, _newResult$data6, _oldResult$data5;
52
+ // for classic pages, subType is 'null'
53
+ if (((_newResult$data5 = newResult.data) === null || _newResult$data5 === void 0 ? void 0 : _newResult$data5.sourceSubType) !== undefined) {
54
+ return newResult.data.sourceSubType;
55
+ }
56
+ if ((_newResult$data6 = newResult.data) !== null && _newResult$data6 !== void 0 && _newResult$data6.sourceAri) {
57
+ // for blogposts, subType is always undefined
58
+ try {
59
+ var _newResult$data7;
60
+ var _getPageIdAndTypeFrom = (0, _ari.getPageIdAndTypeFromConfluencePageAri)({
61
+ ari: (_newResult$data7 = newResult.data) === null || _newResult$data7 === void 0 ? void 0 : _newResult$data7.sourceAri
62
+ }),
63
+ pageType = _getPageIdAndTypeFrom.type;
64
+ if (pageType === 'blogpost') {
65
+ var _newResult$data8;
66
+ return (_newResult$data8 = newResult.data) === null || _newResult$data8 === void 0 ? void 0 : _newResult$data8.sourceSubType;
67
+ }
68
+ } catch (_unused) {}
69
+ }
70
+ return (_oldResult$data5 = oldResult.data) === null || _oldResult$data5 === void 0 ? void 0 : _oldResult$data5.sourceSubType;
47
71
  };
@@ -1,3 +1,4 @@
1
+ import { fg } from '@atlaskit/platform-feature-flags';
1
2
  import { fetchWithRetry } from '../../utils/retry';
2
3
  export const isBlockContentResponse = response => {
3
4
  const content = response.content;
@@ -49,7 +50,8 @@ export const getReferenceSyncedBlocks = async documentAri => {
49
50
  query: buildGetDocumentReferenceBlocksQuery(documentAri),
50
51
  operationName: GET_DOCUMENT_REFERENCE_BLOCKS_OPERATION_NAME
51
52
  };
52
- const response = await fetchWithRetry(GRAPHQL_ENDPOINT, {
53
+ const url = fg('platform_synced_block_patch_3') ? `${GRAPHQL_ENDPOINT}?operation=editorSyncedBlockGetDocumentReferenceBlocks` : GRAPHQL_ENDPOINT;
54
+ const response = await fetchWithRetry(url, {
53
55
  method: 'POST',
54
56
  headers: COMMON_HEADERS,
55
57
  body: JSON.stringify(bodyData)
@@ -263,7 +265,8 @@ export const getSyncedBlockContent = async ({
263
265
  query: buildGetBlockQuery(blockAri),
264
266
  operationName: GET_BLOCK_OPERATION_NAME
265
267
  };
266
- const response = await fetchWithRetry(GRAPHQL_ENDPOINT, {
268
+ const url = fg('platform_synced_block_patch_3') ? `${GRAPHQL_ENDPOINT}?operation=editorSyncedBlockGetBlock` : GRAPHQL_ENDPOINT;
269
+ const response = await fetchWithRetry(url, {
267
270
  method: 'POST',
268
271
  headers: COMMON_HEADERS,
269
272
  body: JSON.stringify(bodyData)
@@ -298,7 +301,8 @@ export const batchRetrieveSyncedBlocks = async ({
298
301
  query: buildBatchRetrieveBlocksQuery(blockAris),
299
302
  operationName: BATCH_RETRIEVE_BLOCKS_OPERATION_NAME
300
303
  };
301
- const response = await fetchWithRetry(GRAPHQL_ENDPOINT, {
304
+ const url = fg('platform_synced_block_patch_3') ? `${GRAPHQL_ENDPOINT}?operation=editorSyncedBlockBatchRetrieveBlocks` : GRAPHQL_ENDPOINT;
305
+ const response = await fetchWithRetry(url, {
302
306
  method: 'POST',
303
307
  headers: COMMON_HEADERS,
304
308
  body: JSON.stringify(bodyData)
@@ -328,7 +332,8 @@ export const deleteSyncedBlock = async ({
328
332
  query: buildDeleteBlockMutation(blockAri, deleteReason),
329
333
  operationName: DELETE_BLOCK_OPERATION_NAME
330
334
  };
331
- const response = await fetchWithRetry(GRAPHQL_ENDPOINT, {
335
+ const url = fg('platform_synced_block_patch_3') ? `${GRAPHQL_ENDPOINT}?operation=editorSyncedBlockDeleteBlock` : GRAPHQL_ENDPOINT;
336
+ const response = await fetchWithRetry(url, {
332
337
  method: 'POST',
333
338
  headers: COMMON_HEADERS,
334
339
  body: JSON.stringify(bodyData)
@@ -354,7 +359,8 @@ export const updateSyncedBlock = async ({
354
359
  query: buildUpdateBlockMutation(blockAri, content, stepVersion, status),
355
360
  operationName: UPDATE_BLOCK_OPERATION_NAME
356
361
  };
357
- const response = await fetchWithRetry(GRAPHQL_ENDPOINT, {
362
+ const url = fg('platform_synced_block_patch_3') ? `${GRAPHQL_ENDPOINT}?operation=editorSyncedBlockUpdateBlock` : GRAPHQL_ENDPOINT;
363
+ const response = await fetchWithRetry(url, {
358
364
  method: 'POST',
359
365
  headers: COMMON_HEADERS,
360
366
  body: JSON.stringify(bodyData)
@@ -381,7 +387,8 @@ export const createSyncedBlock = async ({
381
387
  query: buildCreateBlockMutation(blockAri, blockInstanceId, content, product, sourceAri, stepVersion, status),
382
388
  operationName: CREATE_BLOCK_OPERATION_NAME
383
389
  };
384
- const response = await fetchWithRetry(GRAPHQL_ENDPOINT, {
390
+ const url = fg('platform_synced_block_patch_3') ? `${GRAPHQL_ENDPOINT}?operation=editorSyncedBlockCreateBlock` : GRAPHQL_ENDPOINT;
391
+ const response = await fetchWithRetry(url, {
385
392
  method: 'POST',
386
393
  headers: COMMON_HEADERS,
387
394
  body: JSON.stringify(bodyData)
@@ -407,7 +414,8 @@ export const updateReferenceSyncedBlockOnDocument = async ({
407
414
  query: buildUpdateDocumentReferencesMutation(documentAri, blocks, noContent),
408
415
  operationName: UPDATE_DOCUMENT_REFERENCES_OPERATION_NAME
409
416
  };
410
- const response = await fetchWithRetry(GRAPHQL_ENDPOINT, {
417
+ const url = fg('platform_synced_block_patch_3') ? `${GRAPHQL_ENDPOINT}?operation=editorSyncedBlockUpdateDocumentReferences` : GRAPHQL_ENDPOINT;
418
+ const response = await fetchWithRetry(url, {
411
419
  method: 'POST',
412
420
  headers: COMMON_HEADERS,
413
421
  body: JSON.stringify(bodyData),
@@ -436,7 +444,8 @@ export const getReferenceSyncedBlocksByBlockAri = async ({
436
444
  query: buildGetBlockReferencesQuery(blockAri),
437
445
  operationName: GET_BLOCK_REFERENCES_OPERATION_NAME
438
446
  };
439
- const response = await fetchWithRetry(GRAPHQL_ENDPOINT, {
447
+ const url = fg('platform_synced_block_patch_3') ? `${GRAPHQL_ENDPOINT}?operation=editorSyncedBlockGetReferences` : GRAPHQL_ENDPOINT;
448
+ const response = await fetchWithRetry(url, {
440
449
  method: 'POST',
441
450
  headers: COMMON_HEADERS,
442
451
  body: JSON.stringify(bodyData)
@@ -1,3 +1,5 @@
1
+ import { fg } from '@atlaskit/platform-feature-flags';
2
+ import { getPageIdAndTypeFromConfluencePageAri } from '../clients/confluence/ari';
1
3
  import { SyncBlockError } from '../common/types';
2
4
  /**
3
5
  * Merges two SyncBlockInstance objects,
@@ -32,8 +34,31 @@ export const resolveSyncBlockInstance = (oldResult, newResult) => {
32
34
  ...newResult.data,
33
35
  sourceURL: ((_newResult$data = newResult.data) === null || _newResult$data === void 0 ? void 0 : _newResult$data.sourceURL) || ((_oldResult$data = oldResult.data) === null || _oldResult$data === void 0 ? void 0 : _oldResult$data.sourceURL) || undefined,
34
36
  sourceTitle: ((_newResult$data2 = newResult.data) === null || _newResult$data2 === void 0 ? void 0 : _newResult$data2.sourceTitle) || ((_oldResult$data2 = oldResult.data) === null || _oldResult$data2 === void 0 ? void 0 : _oldResult$data2.sourceTitle) || undefined,
35
- sourceSubType: ((_newResult$data3 = newResult.data) === null || _newResult$data3 === void 0 ? void 0 : _newResult$data3.sourceSubType) || ((_oldResult$data3 = oldResult.data) === null || _oldResult$data3 === void 0 ? void 0 : _oldResult$data3.sourceSubType) || undefined,
37
+ sourceSubType: fg('platform_synced_block_patch_3') ? mergeSubType(oldResult, newResult) : ((_newResult$data3 = newResult.data) === null || _newResult$data3 === void 0 ? void 0 : _newResult$data3.sourceSubType) || ((_oldResult$data3 = oldResult.data) === null || _oldResult$data3 === void 0 ? void 0 : _oldResult$data3.sourceSubType) || undefined,
36
38
  onSameDocument: ((_newResult$data4 = newResult.data) === null || _newResult$data4 === void 0 ? void 0 : _newResult$data4.onSameDocument) || ((_oldResult$data4 = oldResult.data) === null || _oldResult$data4 === void 0 ? void 0 : _oldResult$data4.onSameDocument) || undefined
37
39
  }
38
40
  };
41
+ };
42
+ const mergeSubType = (oldResult, newResult) => {
43
+ var _newResult$data5, _newResult$data6, _oldResult$data5;
44
+ // for classic pages, subType is 'null'
45
+ if (((_newResult$data5 = newResult.data) === null || _newResult$data5 === void 0 ? void 0 : _newResult$data5.sourceSubType) !== undefined) {
46
+ return newResult.data.sourceSubType;
47
+ }
48
+ if ((_newResult$data6 = newResult.data) !== null && _newResult$data6 !== void 0 && _newResult$data6.sourceAri) {
49
+ // for blogposts, subType is always undefined
50
+ try {
51
+ var _newResult$data7;
52
+ const {
53
+ type: pageType
54
+ } = getPageIdAndTypeFromConfluencePageAri({
55
+ ari: (_newResult$data7 = newResult.data) === null || _newResult$data7 === void 0 ? void 0 : _newResult$data7.sourceAri
56
+ });
57
+ if (pageType === 'blogpost') {
58
+ var _newResult$data8;
59
+ return (_newResult$data8 = newResult.data) === null || _newResult$data8 === void 0 ? void 0 : _newResult$data8.sourceSubType;
60
+ }
61
+ } catch {}
62
+ }
63
+ return (_oldResult$data5 = oldResult.data) === null || _oldResult$data5 === void 0 ? void 0 : _oldResult$data5.sourceSubType;
39
64
  };
@@ -8,6 +8,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
8
8
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
9
9
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
10
10
  import _regeneratorRuntime from "@babel/runtime/regenerator";
11
+ import { fg } from '@atlaskit/platform-feature-flags';
11
12
  import { fetchWithRetry } from '../../utils/retry';
12
13
  export var isBlockContentResponse = function isBlockContentResponse(response) {
13
14
  var content = response.content;
@@ -56,7 +57,7 @@ export var isBlockContentResponse = function isBlockContentResponse(response) {
56
57
  */
57
58
  export var getReferenceSyncedBlocks = /*#__PURE__*/function () {
58
59
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(documentAri) {
59
- var bodyData, response, result;
60
+ var bodyData, url, response, result;
60
61
  return _regeneratorRuntime.wrap(function _callee$(_context) {
61
62
  while (1) switch (_context.prev = _context.next) {
62
63
  case 0:
@@ -64,40 +65,41 @@ export var getReferenceSyncedBlocks = /*#__PURE__*/function () {
64
65
  query: buildGetDocumentReferenceBlocksQuery(documentAri),
65
66
  operationName: GET_DOCUMENT_REFERENCE_BLOCKS_OPERATION_NAME
66
67
  };
67
- _context.next = 3;
68
- return fetchWithRetry(GRAPHQL_ENDPOINT, {
68
+ url = fg('platform_synced_block_patch_3') ? "".concat(GRAPHQL_ENDPOINT, "?operation=editorSyncedBlockGetDocumentReferenceBlocks") : GRAPHQL_ENDPOINT;
69
+ _context.next = 4;
70
+ return fetchWithRetry(url, {
69
71
  method: 'POST',
70
72
  headers: COMMON_HEADERS,
71
73
  body: JSON.stringify(bodyData)
72
74
  });
73
- case 3:
75
+ case 4:
74
76
  response = _context.sent;
75
77
  if (response.ok) {
76
- _context.next = 6;
78
+ _context.next = 7;
77
79
  break;
78
80
  }
79
81
  throw new BlockError(response.status);
80
- case 6:
81
- _context.next = 8;
82
+ case 7:
83
+ _context.next = 9;
82
84
  return response.json();
83
- case 8:
85
+ case 9:
84
86
  result = _context.sent;
85
87
  if (!(result.errors && result.errors.length > 0)) {
86
- _context.next = 11;
88
+ _context.next = 12;
87
89
  break;
88
90
  }
89
91
  throw new Error(result.errors.map(function (e) {
90
92
  return e.message;
91
93
  }).join(', '));
92
- case 11:
94
+ case 12:
93
95
  if (result.data) {
94
- _context.next = 13;
96
+ _context.next = 14;
95
97
  break;
96
98
  }
97
99
  throw new Error('No data returned from GraphQL query');
98
- case 13:
99
- return _context.abrupt("return", result.data.blockService_getDocumentReferenceBlocks);
100
100
  case 14:
101
+ return _context.abrupt("return", result.data.blockService_getDocumentReferenceBlocks);
102
+ case 15:
101
103
  case "end":
102
104
  return _context.stop();
103
105
  }
@@ -200,7 +202,7 @@ export var BlockError = /*#__PURE__*/function (_Error) {
200
202
  export var getSyncedBlockContent = /*#__PURE__*/function () {
201
203
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref2) {
202
204
  var _result$data;
203
- var blockAri, bodyData, response, result;
205
+ var blockAri, bodyData, url, response, result;
204
206
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
205
207
  while (1) switch (_context2.prev = _context2.next) {
206
208
  case 0:
@@ -209,40 +211,41 @@ export var getSyncedBlockContent = /*#__PURE__*/function () {
209
211
  query: buildGetBlockQuery(blockAri),
210
212
  operationName: GET_BLOCK_OPERATION_NAME
211
213
  };
212
- _context2.next = 4;
213
- return fetchWithRetry(GRAPHQL_ENDPOINT, {
214
+ url = fg('platform_synced_block_patch_3') ? "".concat(GRAPHQL_ENDPOINT, "?operation=editorSyncedBlockGetBlock") : GRAPHQL_ENDPOINT;
215
+ _context2.next = 5;
216
+ return fetchWithRetry(url, {
214
217
  method: 'POST',
215
218
  headers: COMMON_HEADERS,
216
219
  body: JSON.stringify(bodyData)
217
220
  });
218
- case 4:
221
+ case 5:
219
222
  response = _context2.sent;
220
223
  if (response.ok) {
221
- _context2.next = 7;
224
+ _context2.next = 8;
222
225
  break;
223
226
  }
224
227
  throw new BlockError(response.status);
225
- case 7:
226
- _context2.next = 9;
228
+ case 8:
229
+ _context2.next = 10;
227
230
  return response.json();
228
- case 9:
231
+ case 10:
229
232
  result = _context2.sent;
230
233
  if (!(result.errors && result.errors.length > 0)) {
231
- _context2.next = 12;
234
+ _context2.next = 13;
232
235
  break;
233
236
  }
234
237
  throw new Error(result.errors.map(function (e) {
235
238
  return e.message;
236
239
  }).join(', '));
237
- case 12:
240
+ case 13:
238
241
  if ((_result$data = result.data) !== null && _result$data !== void 0 && _result$data.blockService_getBlock) {
239
- _context2.next = 14;
242
+ _context2.next = 15;
240
243
  break;
241
244
  }
242
245
  throw new Error('No data returned from GraphQL query');
243
- case 14:
244
- return _context2.abrupt("return", result.data.blockService_getBlock);
245
246
  case 15:
247
+ return _context2.abrupt("return", result.data.blockService_getBlock);
248
+ case 16:
246
249
  case "end":
247
250
  return _context2.stop();
248
251
  }
@@ -264,7 +267,7 @@ export var getSyncedBlockContent = /*#__PURE__*/function () {
264
267
  export var batchRetrieveSyncedBlocks = /*#__PURE__*/function () {
265
268
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref4) {
266
269
  var _result$data2;
267
- var blockIdentifiers, blockAris, bodyData, response, result, graphqlResponse;
270
+ var blockIdentifiers, blockAris, bodyData, url, response, result, graphqlResponse;
268
271
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
269
272
  while (1) switch (_context3.prev = _context3.next) {
270
273
  case 0:
@@ -276,44 +279,45 @@ export var batchRetrieveSyncedBlocks = /*#__PURE__*/function () {
276
279
  query: buildBatchRetrieveBlocksQuery(blockAris),
277
280
  operationName: BATCH_RETRIEVE_BLOCKS_OPERATION_NAME
278
281
  };
279
- _context3.next = 5;
280
- return fetchWithRetry(GRAPHQL_ENDPOINT, {
282
+ url = fg('platform_synced_block_patch_3') ? "".concat(GRAPHQL_ENDPOINT, "?operation=editorSyncedBlockBatchRetrieveBlocks") : GRAPHQL_ENDPOINT;
283
+ _context3.next = 6;
284
+ return fetchWithRetry(url, {
281
285
  method: 'POST',
282
286
  headers: COMMON_HEADERS,
283
287
  body: JSON.stringify(bodyData)
284
288
  });
285
- case 5:
289
+ case 6:
286
290
  response = _context3.sent;
287
291
  if (response.ok) {
288
- _context3.next = 8;
292
+ _context3.next = 9;
289
293
  break;
290
294
  }
291
295
  throw new BlockError(response.status);
292
- case 8:
293
- _context3.next = 10;
296
+ case 9:
297
+ _context3.next = 11;
294
298
  return response.json();
295
- case 10:
299
+ case 11:
296
300
  result = _context3.sent;
297
301
  if (!(result.errors && result.errors.length > 0)) {
298
- _context3.next = 13;
302
+ _context3.next = 14;
299
303
  break;
300
304
  }
301
305
  throw new Error(result.errors.map(function (e) {
302
306
  return e.message;
303
307
  }).join(', '));
304
- case 13:
308
+ case 14:
305
309
  if ((_result$data2 = result.data) !== null && _result$data2 !== void 0 && _result$data2.blockService_batchRetrieveBlocks) {
306
- _context3.next = 15;
310
+ _context3.next = 16;
307
311
  break;
308
312
  }
309
313
  throw new Error('No data returned from GraphQL query');
310
- case 15:
314
+ case 16:
311
315
  graphqlResponse = result.data.blockService_batchRetrieveBlocks;
312
316
  return _context3.abrupt("return", {
313
317
  success: graphqlResponse.success,
314
318
  error: graphqlResponse.error
315
319
  });
316
- case 17:
320
+ case 18:
317
321
  case "end":
318
322
  return _context3.stop();
319
323
  }
@@ -326,7 +330,7 @@ export var batchRetrieveSyncedBlocks = /*#__PURE__*/function () {
326
330
  export var deleteSyncedBlock = /*#__PURE__*/function () {
327
331
  var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref6) {
328
332
  var _result$data3;
329
- var blockAri, deleteReason, bodyData, response, result;
333
+ var blockAri, deleteReason, bodyData, url, response, result;
330
334
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
331
335
  while (1) switch (_context4.prev = _context4.next) {
332
336
  case 0:
@@ -335,38 +339,39 @@ export var deleteSyncedBlock = /*#__PURE__*/function () {
335
339
  query: buildDeleteBlockMutation(blockAri, deleteReason),
336
340
  operationName: DELETE_BLOCK_OPERATION_NAME
337
341
  };
338
- _context4.next = 4;
339
- return fetchWithRetry(GRAPHQL_ENDPOINT, {
342
+ url = fg('platform_synced_block_patch_3') ? "".concat(GRAPHQL_ENDPOINT, "?operation=editorSyncedBlockDeleteBlock") : GRAPHQL_ENDPOINT;
343
+ _context4.next = 5;
344
+ return fetchWithRetry(url, {
340
345
  method: 'POST',
341
346
  headers: COMMON_HEADERS,
342
347
  body: JSON.stringify(bodyData)
343
348
  });
344
- case 4:
349
+ case 5:
345
350
  response = _context4.sent;
346
351
  if (response.ok) {
347
- _context4.next = 7;
352
+ _context4.next = 8;
348
353
  break;
349
354
  }
350
355
  throw new BlockError(response.status);
351
- case 7:
352
- _context4.next = 9;
356
+ case 8:
357
+ _context4.next = 10;
353
358
  return response.json();
354
- case 9:
359
+ case 10:
355
360
  result = _context4.sent;
356
361
  if (!(result.errors && result.errors.length > 0)) {
357
- _context4.next = 12;
362
+ _context4.next = 13;
358
363
  break;
359
364
  }
360
365
  throw new Error(result.errors.map(function (e) {
361
366
  return e.message;
362
367
  }).join(', '));
363
- case 12:
368
+ case 13:
364
369
  if ((_result$data3 = result.data) !== null && _result$data3 !== void 0 && _result$data3.blockService_deleteBlock.deleted) {
365
- _context4.next = 14;
370
+ _context4.next = 15;
366
371
  break;
367
372
  }
368
373
  throw new Error('Block deletion failed; deleted flag is false');
369
- case 14:
374
+ case 15:
370
375
  case "end":
371
376
  return _context4.stop();
372
377
  }
@@ -378,7 +383,7 @@ export var deleteSyncedBlock = /*#__PURE__*/function () {
378
383
  }();
379
384
  export var updateSyncedBlock = /*#__PURE__*/function () {
380
385
  var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref8) {
381
- var blockAri, content, stepVersion, status, bodyData, response, result;
386
+ var blockAri, content, stepVersion, status, bodyData, url, response, result;
382
387
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
383
388
  while (1) switch (_context5.prev = _context5.next) {
384
389
  case 0:
@@ -387,32 +392,33 @@ export var updateSyncedBlock = /*#__PURE__*/function () {
387
392
  query: buildUpdateBlockMutation(blockAri, content, stepVersion, status),
388
393
  operationName: UPDATE_BLOCK_OPERATION_NAME
389
394
  };
390
- _context5.next = 4;
391
- return fetchWithRetry(GRAPHQL_ENDPOINT, {
395
+ url = fg('platform_synced_block_patch_3') ? "".concat(GRAPHQL_ENDPOINT, "?operation=editorSyncedBlockUpdateBlock") : GRAPHQL_ENDPOINT;
396
+ _context5.next = 5;
397
+ return fetchWithRetry(url, {
392
398
  method: 'POST',
393
399
  headers: COMMON_HEADERS,
394
400
  body: JSON.stringify(bodyData)
395
401
  });
396
- case 4:
402
+ case 5:
397
403
  response = _context5.sent;
398
404
  if (response.ok) {
399
- _context5.next = 7;
405
+ _context5.next = 8;
400
406
  break;
401
407
  }
402
408
  throw new BlockError(response.status);
403
- case 7:
404
- _context5.next = 9;
409
+ case 8:
410
+ _context5.next = 10;
405
411
  return response.json();
406
- case 9:
412
+ case 10:
407
413
  result = _context5.sent;
408
414
  if (!(result.errors && result.errors.length > 0)) {
409
- _context5.next = 12;
415
+ _context5.next = 13;
410
416
  break;
411
417
  }
412
418
  throw new Error(result.errors.map(function (e) {
413
419
  return e.message;
414
420
  }).join(', '));
415
- case 12:
421
+ case 13:
416
422
  case "end":
417
423
  return _context5.stop();
418
424
  }
@@ -425,7 +431,7 @@ export var updateSyncedBlock = /*#__PURE__*/function () {
425
431
  export var createSyncedBlock = /*#__PURE__*/function () {
426
432
  var _ref1 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref0) {
427
433
  var _result$data4;
428
- var blockAri, blockInstanceId, sourceAri, product, content, stepVersion, status, bodyData, response, result;
434
+ var blockAri, blockInstanceId, sourceAri, product, content, stepVersion, status, bodyData, url, response, result;
429
435
  return _regeneratorRuntime.wrap(function _callee6$(_context6) {
430
436
  while (1) switch (_context6.prev = _context6.next) {
431
437
  case 0:
@@ -434,40 +440,41 @@ export var createSyncedBlock = /*#__PURE__*/function () {
434
440
  query: buildCreateBlockMutation(blockAri, blockInstanceId, content, product, sourceAri, stepVersion, status),
435
441
  operationName: CREATE_BLOCK_OPERATION_NAME
436
442
  };
437
- _context6.next = 4;
438
- return fetchWithRetry(GRAPHQL_ENDPOINT, {
443
+ url = fg('platform_synced_block_patch_3') ? "".concat(GRAPHQL_ENDPOINT, "?operation=editorSyncedBlockCreateBlock") : GRAPHQL_ENDPOINT;
444
+ _context6.next = 5;
445
+ return fetchWithRetry(url, {
439
446
  method: 'POST',
440
447
  headers: COMMON_HEADERS,
441
448
  body: JSON.stringify(bodyData)
442
449
  });
443
- case 4:
450
+ case 5:
444
451
  response = _context6.sent;
445
452
  if (response.ok) {
446
- _context6.next = 7;
453
+ _context6.next = 8;
447
454
  break;
448
455
  }
449
456
  throw new BlockError(response.status);
450
- case 7:
451
- _context6.next = 9;
457
+ case 8:
458
+ _context6.next = 10;
452
459
  return response.json();
453
- case 9:
460
+ case 10:
454
461
  result = _context6.sent;
455
462
  if (!(result.errors && result.errors.length > 0)) {
456
- _context6.next = 12;
463
+ _context6.next = 13;
457
464
  break;
458
465
  }
459
466
  throw new Error(result.errors.map(function (e) {
460
467
  return e.message;
461
468
  }).join(', '));
462
- case 12:
469
+ case 13:
463
470
  if ((_result$data4 = result.data) !== null && _result$data4 !== void 0 && _result$data4.blockService_createBlock) {
464
- _context6.next = 14;
471
+ _context6.next = 15;
465
472
  break;
466
473
  }
467
474
  throw new Error('No data returned from GraphQL mutation');
468
- case 14:
469
- return _context6.abrupt("return", result.data.blockService_createBlock);
470
475
  case 15:
476
+ return _context6.abrupt("return", result.data.blockService_createBlock);
477
+ case 16:
471
478
  case "end":
472
479
  return _context6.stop();
473
480
  }
@@ -479,7 +486,7 @@ export var createSyncedBlock = /*#__PURE__*/function () {
479
486
  }();
480
487
  export var updateReferenceSyncedBlockOnDocument = /*#__PURE__*/function () {
481
488
  var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref10) {
482
- var documentAri, blocks, _ref10$noContent, noContent, bodyData, response, result, _result$data5;
489
+ var documentAri, blocks, _ref10$noContent, noContent, bodyData, url, response, result, _result$data5;
483
490
  return _regeneratorRuntime.wrap(function _callee7$(_context7) {
484
491
  while (1) switch (_context7.prev = _context7.next) {
485
492
  case 0:
@@ -488,45 +495,46 @@ export var updateReferenceSyncedBlockOnDocument = /*#__PURE__*/function () {
488
495
  query: buildUpdateDocumentReferencesMutation(documentAri, blocks, noContent),
489
496
  operationName: UPDATE_DOCUMENT_REFERENCES_OPERATION_NAME
490
497
  };
491
- _context7.next = 4;
492
- return fetchWithRetry(GRAPHQL_ENDPOINT, {
498
+ url = fg('platform_synced_block_patch_3') ? "".concat(GRAPHQL_ENDPOINT, "?operation=editorSyncedBlockUpdateDocumentReferences") : GRAPHQL_ENDPOINT;
499
+ _context7.next = 5;
500
+ return fetchWithRetry(url, {
493
501
  method: 'POST',
494
502
  headers: COMMON_HEADERS,
495
503
  body: JSON.stringify(bodyData),
496
504
  keepalive: true
497
505
  });
498
- case 4:
506
+ case 5:
499
507
  response = _context7.sent;
500
508
  if (response.ok) {
501
- _context7.next = 7;
509
+ _context7.next = 8;
502
510
  break;
503
511
  }
504
512
  throw new BlockError(response.status);
505
- case 7:
506
- _context7.next = 9;
513
+ case 8:
514
+ _context7.next = 10;
507
515
  return response.json();
508
- case 9:
516
+ case 10:
509
517
  result = _context7.sent;
510
518
  if (!(result.errors && result.errors.length > 0)) {
511
- _context7.next = 12;
519
+ _context7.next = 13;
512
520
  break;
513
521
  }
514
522
  throw new Error(result.errors.map(function (e) {
515
523
  return e.message;
516
524
  }).join(', '));
517
- case 12:
525
+ case 13:
518
526
  if (noContent) {
519
- _context7.next = 16;
527
+ _context7.next = 17;
520
528
  break;
521
529
  }
522
530
  if ((_result$data5 = result.data) !== null && _result$data5 !== void 0 && _result$data5.blockService_updateDocumentReferences) {
523
- _context7.next = 15;
531
+ _context7.next = 16;
524
532
  break;
525
533
  }
526
534
  throw new Error('No data returned from GraphQL mutation');
527
- case 15:
528
- return _context7.abrupt("return", result.data.blockService_updateDocumentReferences);
529
535
  case 16:
536
+ return _context7.abrupt("return", result.data.blockService_updateDocumentReferences);
537
+ case 17:
530
538
  case "end":
531
539
  return _context7.stop();
532
540
  }
@@ -539,7 +547,7 @@ export var updateReferenceSyncedBlockOnDocument = /*#__PURE__*/function () {
539
547
  export var getReferenceSyncedBlocksByBlockAri = /*#__PURE__*/function () {
540
548
  var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref12) {
541
549
  var _result$data6;
542
- var blockAri, bodyData, response, result, graphqlResponse;
550
+ var blockAri, bodyData, url, response, result, graphqlResponse;
543
551
  return _regeneratorRuntime.wrap(function _callee8$(_context8) {
544
552
  while (1) switch (_context8.prev = _context8.next) {
545
553
  case 0:
@@ -548,45 +556,46 @@ export var getReferenceSyncedBlocksByBlockAri = /*#__PURE__*/function () {
548
556
  query: buildGetBlockReferencesQuery(blockAri),
549
557
  operationName: GET_BLOCK_REFERENCES_OPERATION_NAME
550
558
  };
551
- _context8.next = 4;
552
- return fetchWithRetry(GRAPHQL_ENDPOINT, {
559
+ url = fg('platform_synced_block_patch_3') ? "".concat(GRAPHQL_ENDPOINT, "?operation=editorSyncedBlockGetReferences") : GRAPHQL_ENDPOINT;
560
+ _context8.next = 5;
561
+ return fetchWithRetry(url, {
553
562
  method: 'POST',
554
563
  headers: COMMON_HEADERS,
555
564
  body: JSON.stringify(bodyData)
556
565
  });
557
- case 4:
566
+ case 5:
558
567
  response = _context8.sent;
559
568
  if (response.ok) {
560
- _context8.next = 7;
569
+ _context8.next = 8;
561
570
  break;
562
571
  }
563
572
  throw new BlockError(response.status);
564
- case 7:
565
- _context8.next = 9;
573
+ case 8:
574
+ _context8.next = 10;
566
575
  return response.json();
567
- case 9:
576
+ case 10:
568
577
  result = _context8.sent;
569
578
  if (!(result.errors && result.errors.length > 0)) {
570
- _context8.next = 12;
579
+ _context8.next = 13;
571
580
  break;
572
581
  }
573
582
  throw new Error(result.errors.map(function (e) {
574
583
  return e.message;
575
584
  }).join(', '));
576
- case 12:
585
+ case 13:
577
586
  if ((_result$data6 = result.data) !== null && _result$data6 !== void 0 && _result$data6.blockService_getReferences) {
578
- _context8.next = 14;
587
+ _context8.next = 15;
579
588
  break;
580
589
  }
581
590
  throw new Error('No data returned from GraphQL query');
582
- case 14:
591
+ case 15:
583
592
  graphqlResponse = result.data.blockService_getReferences;
584
593
  return _context8.abrupt("return", {
585
594
  blockAri: blockAri,
586
595
  references: graphqlResponse.references || [],
587
596
  errors: graphqlResponse.errors || []
588
597
  });
589
- case 16:
598
+ case 17:
590
599
  case "end":
591
600
  return _context8.stop();
592
601
  }
@@ -1,6 +1,8 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ import { fg } from '@atlaskit/platform-feature-flags';
5
+ import { getPageIdAndTypeFromConfluencePageAri } from '../clients/confluence/ari';
4
6
  import { SyncBlockError } from '../common/types';
5
7
  /**
6
8
  * Merges two SyncBlockInstance objects,
@@ -33,8 +35,30 @@ export var resolveSyncBlockInstance = function resolveSyncBlockInstance(oldResul
33
35
  data: _objectSpread(_objectSpread({}, newResult.data), {}, {
34
36
  sourceURL: ((_newResult$data = newResult.data) === null || _newResult$data === void 0 ? void 0 : _newResult$data.sourceURL) || ((_oldResult$data = oldResult.data) === null || _oldResult$data === void 0 ? void 0 : _oldResult$data.sourceURL) || undefined,
35
37
  sourceTitle: ((_newResult$data2 = newResult.data) === null || _newResult$data2 === void 0 ? void 0 : _newResult$data2.sourceTitle) || ((_oldResult$data2 = oldResult.data) === null || _oldResult$data2 === void 0 ? void 0 : _oldResult$data2.sourceTitle) || undefined,
36
- sourceSubType: ((_newResult$data3 = newResult.data) === null || _newResult$data3 === void 0 ? void 0 : _newResult$data3.sourceSubType) || ((_oldResult$data3 = oldResult.data) === null || _oldResult$data3 === void 0 ? void 0 : _oldResult$data3.sourceSubType) || undefined,
38
+ sourceSubType: fg('platform_synced_block_patch_3') ? mergeSubType(oldResult, newResult) : ((_newResult$data3 = newResult.data) === null || _newResult$data3 === void 0 ? void 0 : _newResult$data3.sourceSubType) || ((_oldResult$data3 = oldResult.data) === null || _oldResult$data3 === void 0 ? void 0 : _oldResult$data3.sourceSubType) || undefined,
37
39
  onSameDocument: ((_newResult$data4 = newResult.data) === null || _newResult$data4 === void 0 ? void 0 : _newResult$data4.onSameDocument) || ((_oldResult$data4 = oldResult.data) === null || _oldResult$data4 === void 0 ? void 0 : _oldResult$data4.onSameDocument) || undefined
38
40
  })
39
41
  });
42
+ };
43
+ var mergeSubType = function mergeSubType(oldResult, newResult) {
44
+ var _newResult$data5, _newResult$data6, _oldResult$data5;
45
+ // for classic pages, subType is 'null'
46
+ if (((_newResult$data5 = newResult.data) === null || _newResult$data5 === void 0 ? void 0 : _newResult$data5.sourceSubType) !== undefined) {
47
+ return newResult.data.sourceSubType;
48
+ }
49
+ if ((_newResult$data6 = newResult.data) !== null && _newResult$data6 !== void 0 && _newResult$data6.sourceAri) {
50
+ // for blogposts, subType is always undefined
51
+ try {
52
+ var _newResult$data7;
53
+ var _getPageIdAndTypeFrom = getPageIdAndTypeFromConfluencePageAri({
54
+ ari: (_newResult$data7 = newResult.data) === null || _newResult$data7 === void 0 ? void 0 : _newResult$data7.sourceAri
55
+ }),
56
+ pageType = _getPageIdAndTypeFrom.type;
57
+ if (pageType === 'blogpost') {
58
+ var _newResult$data8;
59
+ return (_newResult$data8 = newResult.data) === null || _newResult$data8 === void 0 ? void 0 : _newResult$data8.sourceSubType;
60
+ }
61
+ } catch (_unused) {}
62
+ }
63
+ return (_oldResult$data5 = oldResult.data) === null || _oldResult$data5 === void 0 ? void 0 : _oldResult$data5.sourceSubType;
40
64
  };
package/package.json CHANGED
@@ -37,7 +37,7 @@
37
37
  "uuid": "^3.1.0"
38
38
  },
39
39
  "peerDependencies": {
40
- "@atlaskit/editor-common": "^111.14.0",
40
+ "@atlaskit/editor-common": "^111.15.0",
41
41
  "react": "^18.2.0"
42
42
  },
43
43
  "devDependencies": {
@@ -80,7 +80,7 @@
80
80
  }
81
81
  },
82
82
  "name": "@atlaskit/editor-synced-block-provider",
83
- "version": "3.29.2",
83
+ "version": "3.29.3",
84
84
  "description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
85
85
  "author": "Atlassian Pty Ltd",
86
86
  "license": "Apache-2.0",