@atlaskit/editor-synced-block-provider 3.23.0 → 3.25.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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atlaskit/editor-synced-block-provider
2
2
 
3
+ ## 3.25.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`1ded312f31a41`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1ded312f31a41) -
8
+ Fetch references by blockAri uses GraphQL endpoint
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies
13
+
14
+ ## 3.24.0
15
+
16
+ ### Minor Changes
17
+
18
+ - [`79754ae4abb79`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/79754ae4abb79) -
19
+ Use GraphQL query for batch retrieve blocks
20
+
3
21
  ## 3.23.0
4
22
 
5
23
  ### Minor Changes
@@ -129,6 +129,8 @@ var UPDATE_BLOCK_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_UPDATE_BLOCK';
129
129
  var DELETE_BLOCK_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_DELETE_BLOCK';
130
130
  var CREATE_BLOCK_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_CREATE_BLOCK';
131
131
  var UPDATE_DOCUMENT_REFERENCES_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_UPDATE_DOCUMENT_REFERENCES';
132
+ var BATCH_RETRIEVE_BLOCKS_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_BATCH_RETRIEVE_BLOCKS';
133
+ var GET_BLOCK_REFERENCES_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_GET_REFERENCES';
132
134
  var buildGetDocumentReferenceBlocksQuery = function buildGetDocumentReferenceBlocksQuery(documentAri) {
133
135
  return "query ".concat(GET_DOCUMENT_REFERENCE_BLOCKS_OPERATION_NAME, " {\n\tblockService_getDocumentReferenceBlocks(documentAri: \"").concat(documentAri, "\") {\n\t\tblocks {\n\t\t\tblockAri\n\t\t\tblockInstanceId\n\t\t\tcontent\n\t\t\tcontentUpdatedAt\n\t\t\tcreatedAt\n\t\t\tcreatedBy\n\t\t\tproduct\n\t\t\tsourceAri\n\t\t\tstatus\n\t\t\tversion\n\t\t}\n\t\terrors {\n\t\t\tblockAri\n\t\t\tcode\n\t\t\treason\n\t\t}\n\t}\n}");
134
136
  };
@@ -179,6 +181,16 @@ var buildUpdateDocumentReferencesMutation = function buildUpdateDocumentReferenc
179
181
  var inputArgs = "documentAri: ".concat(JSON.stringify(documentAri), ", blocks: [").concat(blocksArray, "], noContent: ").concat(noContent);
180
182
  return "mutation ".concat(UPDATE_DOCUMENT_REFERENCES_OPERATION_NAME, " {\n\tblockService_updateDocumentReferences(input: { ").concat(inputArgs, " }) {\n\t\tblocks {\n\t\t\tblockAri\n\t\t\tblockInstanceId\n\t\t\tcontent\n\t\t\tcontentUpdatedAt\n\t\t\tcreatedAt\n\t\t\tcreatedBy\n\t\t\tproduct\n\t\t\tsourceAri\n\t\t\tstatus\n\t\t\tversion\n\t\t}\n\t\terrors {\n\t\t\tblockAri\n\t\t\tcode\n\t\t\treason\n\t\t}\n\t}\n}");
181
183
  };
184
+ var buildBatchRetrieveBlocksQuery = function buildBatchRetrieveBlocksQuery(blockAris) {
185
+ var blockArisArray = blockAris.map(function (ari) {
186
+ return JSON.stringify(ari);
187
+ }).join(', ');
188
+ var inputArgs = "blockAris: [".concat(blockArisArray, "]");
189
+ return "query ".concat(BATCH_RETRIEVE_BLOCKS_OPERATION_NAME, " {\n\tblockService_batchRetrieveBlocks(input: { ").concat(inputArgs, " }) {\n\t\tsuccess {\n\t\t\tblockAri\n\t\t\tblockInstanceId\n\t\t\tcontent\n\t\t\tcontentUpdatedAt\n\t\t\tcreatedAt\n\t\t\tcreatedBy\n\t\t\tdeletionReason\n\t\t\tproduct\n\t\t\tsourceAri\n\t\t\tstatus\n\t\t\tversion\n\t\t}\n\t\terror {\n\t\t\tblockAri\n\t\t\tcode\n\t\t\treason\n\t\t}\n\t}\n}");
190
+ };
191
+ var buildGetBlockReferencesQuery = function buildGetBlockReferencesQuery(blockAri) {
192
+ return "query ".concat(GET_BLOCK_REFERENCES_OPERATION_NAME, " {\n\tblockService_getReferences(blockAri: ").concat(JSON.stringify(blockAri), ") {\n\t\treferences {\n\t\t\tblockAri\n\t\t\tblockInstanceId\n\t\t\tcreatedAt\n\t\t\tcreatedBy\n\t\t\tdocumentAri\n\t\t}\n\t\terrors {\n\t\t\tblockAri\n\t\t\tcode\n\t\t\treason\n\t\t}\n\t}\n}");
193
+ };
182
194
  var BlockError = exports.BlockError = /*#__PURE__*/function (_Error) {
183
195
  function BlockError(status) {
184
196
  var _this;
@@ -233,18 +245,68 @@ var getSyncedBlockContent = exports.getSyncedBlockContent = /*#__PURE__*/functio
233
245
  * Batch retrieves multiple synced blocks by their ARIs.
234
246
  *
235
247
  * Calls the Block Service API endpoint: `POST /v1/block/batch-retrieve`
248
+ * or GraphQL query `blockService_batchRetrieveBlocks` when feature flag is enabled
236
249
  *
237
250
  * @param blockAris - Array of block ARIs to retrieve
238
251
  * @returns A promise containing arrays of successfully fetched blocks and any errors encountered
239
252
  */
240
253
  var batchRetrieveSyncedBlocks = exports.batchRetrieveSyncedBlocks = /*#__PURE__*/function () {
241
254
  var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(_ref4) {
242
- var blockIdentifiers, documentAri, response;
255
+ var blockIdentifiers, documentAri, _result$data, blockAris, bodyData, _response, result, graphqlResponse, response;
243
256
  return _regenerator.default.wrap(function _callee3$(_context3) {
244
257
  while (1) switch (_context3.prev = _context3.next) {
245
258
  case 0:
246
259
  blockIdentifiers = _ref4.blockIdentifiers, documentAri = _ref4.documentAri;
247
- _context3.next = 3;
260
+ if (!(0, _platformFeatureFlags.fg)('platform_synced_block_patch_1')) {
261
+ _context3.next = 18;
262
+ break;
263
+ }
264
+ blockAris = blockIdentifiers.map(function (blockIdentifier) {
265
+ return blockIdentifier.blockAri;
266
+ });
267
+ bodyData = {
268
+ query: buildBatchRetrieveBlocksQuery(blockAris),
269
+ operationName: BATCH_RETRIEVE_BLOCKS_OPERATION_NAME
270
+ };
271
+ _context3.next = 6;
272
+ return (0, _retry.fetchWithRetry)(GRAPHQL_ENDPOINT, {
273
+ method: 'POST',
274
+ headers: COMMON_HEADERS,
275
+ body: JSON.stringify(bodyData)
276
+ });
277
+ case 6:
278
+ _response = _context3.sent;
279
+ if (_response.ok) {
280
+ _context3.next = 9;
281
+ break;
282
+ }
283
+ throw new BlockError(_response.status);
284
+ case 9:
285
+ _context3.next = 11;
286
+ return _response.json();
287
+ case 11:
288
+ result = _context3.sent;
289
+ if (!(result.errors && result.errors.length > 0)) {
290
+ _context3.next = 14;
291
+ break;
292
+ }
293
+ throw new Error(result.errors.map(function (e) {
294
+ return e.message;
295
+ }).join(', '));
296
+ case 14:
297
+ if ((_result$data = result.data) !== null && _result$data !== void 0 && _result$data.blockService_batchRetrieveBlocks) {
298
+ _context3.next = 16;
299
+ break;
300
+ }
301
+ throw new Error('No data returned from GraphQL query');
302
+ case 16:
303
+ graphqlResponse = result.data.blockService_batchRetrieveBlocks;
304
+ return _context3.abrupt("return", {
305
+ success: graphqlResponse.success,
306
+ error: graphqlResponse.error
307
+ });
308
+ case 18:
309
+ _context3.next = 20;
248
310
  return (0, _retry.fetchWithRetry)("".concat(BLOCK_SERVICE_API_URL, "/block/batch-retrieve"), {
249
311
  method: 'POST',
250
312
  headers: COMMON_HEADERS,
@@ -256,19 +318,19 @@ var batchRetrieveSyncedBlocks = exports.batchRetrieveSyncedBlocks = /*#__PURE__*
256
318
  })
257
319
  })
258
320
  });
259
- case 3:
321
+ case 20:
260
322
  response = _context3.sent;
261
323
  if (response.ok) {
262
- _context3.next = 6;
324
+ _context3.next = 23;
263
325
  break;
264
326
  }
265
327
  throw new BlockError(response.status);
266
- case 6:
267
- _context3.next = 8;
328
+ case 23:
329
+ _context3.next = 25;
268
330
  return response.json();
269
- case 8:
331
+ case 25:
270
332
  return _context3.abrupt("return", _context3.sent);
271
- case 9:
333
+ case 26:
272
334
  case "end":
273
335
  return _context3.stop();
274
336
  }
@@ -280,7 +342,7 @@ var batchRetrieveSyncedBlocks = exports.batchRetrieveSyncedBlocks = /*#__PURE__*
280
342
  }();
281
343
  var deleteSyncedBlock = exports.deleteSyncedBlock = /*#__PURE__*/function () {
282
344
  var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(_ref6) {
283
- var blockAri, deleteReason, _result$data, bodyData, _response, result, url, response;
345
+ var blockAri, deleteReason, _result$data2, bodyData, _response2, result, url, response;
284
346
  return _regenerator.default.wrap(function _callee4$(_context4) {
285
347
  while (1) switch (_context4.prev = _context4.next) {
286
348
  case 0:
@@ -300,15 +362,15 @@ var deleteSyncedBlock = exports.deleteSyncedBlock = /*#__PURE__*/function () {
300
362
  body: JSON.stringify(bodyData)
301
363
  });
302
364
  case 5:
303
- _response = _context4.sent;
304
- if (_response.ok) {
365
+ _response2 = _context4.sent;
366
+ if (_response2.ok) {
305
367
  _context4.next = 8;
306
368
  break;
307
369
  }
308
- throw new BlockError(_response.status);
370
+ throw new BlockError(_response2.status);
309
371
  case 8:
310
372
  _context4.next = 10;
311
- return _response.json();
373
+ return _response2.json();
312
374
  case 10:
313
375
  result = _context4.sent;
314
376
  if (!(result.errors && result.errors.length > 0)) {
@@ -319,7 +381,7 @@ var deleteSyncedBlock = exports.deleteSyncedBlock = /*#__PURE__*/function () {
319
381
  return e.message;
320
382
  }).join(', '));
321
383
  case 13:
322
- if ((_result$data = result.data) !== null && _result$data !== void 0 && _result$data.blockService_deleteBlock.deleted) {
384
+ if ((_result$data2 = result.data) !== null && _result$data2 !== void 0 && _result$data2.blockService_deleteBlock.deleted) {
323
385
  _context4.next = 15;
324
386
  break;
325
387
  }
@@ -352,7 +414,7 @@ var deleteSyncedBlock = exports.deleteSyncedBlock = /*#__PURE__*/function () {
352
414
  }();
353
415
  var updateSyncedBlock = exports.updateSyncedBlock = /*#__PURE__*/function () {
354
416
  var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(_ref8) {
355
- var blockAri, content, stepVersion, bodyData, _response2, result, requestBody, response;
417
+ var blockAri, content, stepVersion, bodyData, _response3, result, requestBody, response;
356
418
  return _regenerator.default.wrap(function _callee5$(_context5) {
357
419
  while (1) switch (_context5.prev = _context5.next) {
358
420
  case 0:
@@ -372,15 +434,15 @@ var updateSyncedBlock = exports.updateSyncedBlock = /*#__PURE__*/function () {
372
434
  body: JSON.stringify(bodyData)
373
435
  });
374
436
  case 5:
375
- _response2 = _context5.sent;
376
- if (_response2.ok) {
437
+ _response3 = _context5.sent;
438
+ if (_response3.ok) {
377
439
  _context5.next = 8;
378
440
  break;
379
441
  }
380
- throw new BlockError(_response2.status);
442
+ throw new BlockError(_response3.status);
381
443
  case 8:
382
444
  _context5.next = 10;
383
- return _response2.json();
445
+ return _response3.json();
384
446
  case 10:
385
447
  result = _context5.sent;
386
448
  if (!(result.errors && result.errors.length > 0)) {
@@ -424,7 +486,7 @@ var updateSyncedBlock = exports.updateSyncedBlock = /*#__PURE__*/function () {
424
486
  }();
425
487
  var createSyncedBlock = exports.createSyncedBlock = /*#__PURE__*/function () {
426
488
  var _ref1 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(_ref0) {
427
- var blockAri, blockInstanceId, sourceAri, product, content, stepVersion, status, _result$data2, bodyData, _response3, result, requestBody, response;
489
+ var blockAri, blockInstanceId, sourceAri, product, content, stepVersion, status, _result$data3, bodyData, _response4, result, requestBody, response;
428
490
  return _regenerator.default.wrap(function _callee6$(_context6) {
429
491
  while (1) switch (_context6.prev = _context6.next) {
430
492
  case 0:
@@ -444,15 +506,15 @@ var createSyncedBlock = exports.createSyncedBlock = /*#__PURE__*/function () {
444
506
  body: JSON.stringify(bodyData)
445
507
  });
446
508
  case 5:
447
- _response3 = _context6.sent;
448
- if (_response3.ok) {
509
+ _response4 = _context6.sent;
510
+ if (_response4.ok) {
449
511
  _context6.next = 8;
450
512
  break;
451
513
  }
452
- throw new BlockError(_response3.status);
514
+ throw new BlockError(_response4.status);
453
515
  case 8:
454
516
  _context6.next = 10;
455
- return _response3.json();
517
+ return _response4.json();
456
518
  case 10:
457
519
  result = _context6.sent;
458
520
  if (!(result.errors && result.errors.length > 0)) {
@@ -463,7 +525,7 @@ var createSyncedBlock = exports.createSyncedBlock = /*#__PURE__*/function () {
463
525
  return e.message;
464
526
  }).join(', '));
465
527
  case 13:
466
- if ((_result$data2 = result.data) !== null && _result$data2 !== void 0 && _result$data2.blockService_createBlock) {
528
+ if ((_result$data3 = result.data) !== null && _result$data3 !== void 0 && _result$data3.blockService_createBlock) {
467
529
  _context6.next = 15;
468
530
  break;
469
531
  }
@@ -514,7 +576,7 @@ var createSyncedBlock = exports.createSyncedBlock = /*#__PURE__*/function () {
514
576
  }();
515
577
  var updateReferenceSyncedBlockOnDocument = exports.updateReferenceSyncedBlockOnDocument = /*#__PURE__*/function () {
516
578
  var _ref11 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(_ref10) {
517
- var documentAri, blocks, _ref10$noContent, noContent, bodyData, _response4, result, _result$data3, response;
579
+ var documentAri, blocks, _ref10$noContent, noContent, bodyData, _response5, result, _result$data4, response;
518
580
  return _regenerator.default.wrap(function _callee7$(_context7) {
519
581
  while (1) switch (_context7.prev = _context7.next) {
520
582
  case 0:
@@ -536,15 +598,15 @@ var updateReferenceSyncedBlockOnDocument = exports.updateReferenceSyncedBlockOnD
536
598
  keepalive: true
537
599
  } : {}));
538
600
  case 5:
539
- _response4 = _context7.sent;
540
- if (_response4.ok) {
601
+ _response5 = _context7.sent;
602
+ if (_response5.ok) {
541
603
  _context7.next = 8;
542
604
  break;
543
605
  }
544
- throw new BlockError(_response4.status);
606
+ throw new BlockError(_response5.status);
545
607
  case 8:
546
608
  _context7.next = 10;
547
- return _response4.json();
609
+ return _response5.json();
548
610
  case 10:
549
611
  result = _context7.sent;
550
612
  if (!(result.errors && result.errors.length > 0)) {
@@ -559,7 +621,7 @@ var updateReferenceSyncedBlockOnDocument = exports.updateReferenceSyncedBlockOnD
559
621
  _context7.next = 17;
560
622
  break;
561
623
  }
562
- if ((_result$data3 = result.data) !== null && _result$data3 !== void 0 && _result$data3.blockService_updateDocumentReferences) {
624
+ if ((_result$data4 = result.data) !== null && _result$data4 !== void 0 && _result$data4.blockService_updateDocumentReferences) {
563
625
  _context7.next = 16;
564
626
  break;
565
627
  }
@@ -607,29 +669,76 @@ var updateReferenceSyncedBlockOnDocument = exports.updateReferenceSyncedBlockOnD
607
669
  }();
608
670
  var getReferenceSyncedBlocksByBlockAri = exports.getReferenceSyncedBlocksByBlockAri = /*#__PURE__*/function () {
609
671
  var _ref13 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(_ref12) {
610
- var blockAri, response;
672
+ var blockAri, _result$data5, bodyData, _response6, result, graphqlResponse, response;
611
673
  return _regenerator.default.wrap(function _callee8$(_context8) {
612
674
  while (1) switch (_context8.prev = _context8.next) {
613
675
  case 0:
614
676
  blockAri = _ref12.blockAri;
615
- _context8.next = 3;
677
+ if (!(0, _platformFeatureFlags.fg)('platform_synced_block_patch_1')) {
678
+ _context8.next = 17;
679
+ break;
680
+ }
681
+ bodyData = {
682
+ query: buildGetBlockReferencesQuery(blockAri),
683
+ operationName: GET_BLOCK_REFERENCES_OPERATION_NAME
684
+ };
685
+ _context8.next = 5;
686
+ return (0, _retry.fetchWithRetry)(GRAPHQL_ENDPOINT, {
687
+ method: 'POST',
688
+ headers: COMMON_HEADERS,
689
+ body: JSON.stringify(bodyData)
690
+ });
691
+ case 5:
692
+ _response6 = _context8.sent;
693
+ if (_response6.ok) {
694
+ _context8.next = 8;
695
+ break;
696
+ }
697
+ throw new BlockError(_response6.status);
698
+ case 8:
699
+ _context8.next = 10;
700
+ return _response6.json();
701
+ case 10:
702
+ result = _context8.sent;
703
+ if (!(result.errors && result.errors.length > 0)) {
704
+ _context8.next = 13;
705
+ break;
706
+ }
707
+ throw new Error(result.errors.map(function (e) {
708
+ return e.message;
709
+ }).join(', '));
710
+ case 13:
711
+ if ((_result$data5 = result.data) !== null && _result$data5 !== void 0 && _result$data5.blockService_getReferences) {
712
+ _context8.next = 15;
713
+ break;
714
+ }
715
+ throw new Error('No data returned from GraphQL query');
716
+ case 15:
717
+ graphqlResponse = result.data.blockService_getReferences;
718
+ return _context8.abrupt("return", {
719
+ blockAri: blockAri,
720
+ references: graphqlResponse.references || [],
721
+ errors: graphqlResponse.errors || []
722
+ });
723
+ case 17:
724
+ _context8.next = 19;
616
725
  return (0, _retry.fetchWithRetry)("".concat(BLOCK_SERVICE_API_URL, "/reference/batch-retrieve/").concat(encodeURIComponent(blockAri)), {
617
726
  method: 'GET',
618
727
  headers: COMMON_HEADERS
619
728
  });
620
- case 3:
729
+ case 19:
621
730
  response = _context8.sent;
622
731
  if (response.ok) {
623
- _context8.next = 6;
732
+ _context8.next = 22;
624
733
  break;
625
734
  }
626
735
  throw new BlockError(response.status);
627
- case 6:
628
- _context8.next = 8;
736
+ case 22:
737
+ _context8.next = 24;
629
738
  return response.json();
630
- case 8:
739
+ case 24:
631
740
  return _context8.abrupt("return", _context8.sent);
632
- case 9:
741
+ case 25:
633
742
  case "end":
634
743
  return _context8.stop();
635
744
  }
@@ -78,6 +78,8 @@ const UPDATE_BLOCK_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_UPDATE_BLOCK';
78
78
  const DELETE_BLOCK_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_DELETE_BLOCK';
79
79
  const CREATE_BLOCK_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_CREATE_BLOCK';
80
80
  const UPDATE_DOCUMENT_REFERENCES_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_UPDATE_DOCUMENT_REFERENCES';
81
+ const BATCH_RETRIEVE_BLOCKS_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_BATCH_RETRIEVE_BLOCKS';
82
+ const GET_BLOCK_REFERENCES_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_GET_REFERENCES';
81
83
  const buildGetDocumentReferenceBlocksQuery = documentAri => `query ${GET_DOCUMENT_REFERENCE_BLOCKS_OPERATION_NAME} {
82
84
  blockService_getDocumentReferenceBlocks(documentAri: "${documentAri}") {
83
85
  blocks {
@@ -186,6 +188,50 @@ const buildUpdateDocumentReferencesMutation = (documentAri, blocks, noContent) =
186
188
  }
187
189
  }`;
188
190
  };
191
+ const buildBatchRetrieveBlocksQuery = blockAris => {
192
+ const blockArisArray = blockAris.map(ari => JSON.stringify(ari)).join(', ');
193
+ const inputArgs = `blockAris: [${blockArisArray}]`;
194
+ return `query ${BATCH_RETRIEVE_BLOCKS_OPERATION_NAME} {
195
+ blockService_batchRetrieveBlocks(input: { ${inputArgs} }) {
196
+ success {
197
+ blockAri
198
+ blockInstanceId
199
+ content
200
+ contentUpdatedAt
201
+ createdAt
202
+ createdBy
203
+ deletionReason
204
+ product
205
+ sourceAri
206
+ status
207
+ version
208
+ }
209
+ error {
210
+ blockAri
211
+ code
212
+ reason
213
+ }
214
+ }
215
+ }`;
216
+ };
217
+ const buildGetBlockReferencesQuery = blockAri => {
218
+ return `query ${GET_BLOCK_REFERENCES_OPERATION_NAME} {
219
+ blockService_getReferences(blockAri: ${JSON.stringify(blockAri)}) {
220
+ references {
221
+ blockAri
222
+ blockInstanceId
223
+ createdAt
224
+ createdBy
225
+ documentAri
226
+ }
227
+ errors {
228
+ blockAri
229
+ code
230
+ reason
231
+ }
232
+ }
233
+ }`;
234
+ };
189
235
  export class BlockError extends Error {
190
236
  constructor(status) {
191
237
  super(`Block error`);
@@ -213,6 +259,7 @@ export const getSyncedBlockContent = async ({
213
259
  * Batch retrieves multiple synced blocks by their ARIs.
214
260
  *
215
261
  * Calls the Block Service API endpoint: `POST /v1/block/batch-retrieve`
262
+ * or GraphQL query `blockService_batchRetrieveBlocks` when feature flag is enabled
216
263
  *
217
264
  * @param blockAris - Array of block ARIs to retrieve
218
265
  * @returns A promise containing arrays of successfully fetched blocks and any errors encountered
@@ -221,6 +268,34 @@ export const batchRetrieveSyncedBlocks = async ({
221
268
  blockIdentifiers,
222
269
  documentAri
223
270
  }) => {
271
+ if (fg('platform_synced_block_patch_1')) {
272
+ var _result$data;
273
+ const blockAris = blockIdentifiers.map(blockIdentifier => blockIdentifier.blockAri);
274
+ const bodyData = {
275
+ query: buildBatchRetrieveBlocksQuery(blockAris),
276
+ operationName: BATCH_RETRIEVE_BLOCKS_OPERATION_NAME
277
+ };
278
+ const response = await fetchWithRetry(GRAPHQL_ENDPOINT, {
279
+ method: 'POST',
280
+ headers: COMMON_HEADERS,
281
+ body: JSON.stringify(bodyData)
282
+ });
283
+ if (!response.ok) {
284
+ throw new BlockError(response.status);
285
+ }
286
+ const result = await response.json();
287
+ if (result.errors && result.errors.length > 0) {
288
+ throw new Error(result.errors.map(e => e.message).join(', '));
289
+ }
290
+ if (!((_result$data = result.data) !== null && _result$data !== void 0 && _result$data.blockService_batchRetrieveBlocks)) {
291
+ throw new Error('No data returned from GraphQL query');
292
+ }
293
+ const graphqlResponse = result.data.blockService_batchRetrieveBlocks;
294
+ return {
295
+ success: graphqlResponse.success,
296
+ error: graphqlResponse.error
297
+ };
298
+ }
224
299
  const response = await fetchWithRetry(`${BLOCK_SERVICE_API_URL}/block/batch-retrieve`, {
225
300
  method: 'POST',
226
301
  headers: COMMON_HEADERS,
@@ -240,7 +315,7 @@ export const deleteSyncedBlock = async ({
240
315
  deleteReason
241
316
  }) => {
242
317
  if (fg('platform_synced_block_patch_1')) {
243
- var _result$data;
318
+ var _result$data2;
244
319
  const bodyData = {
245
320
  query: buildDeleteBlockMutation(blockAri, deleteReason),
246
321
  operationName: DELETE_BLOCK_OPERATION_NAME
@@ -257,7 +332,7 @@ export const deleteSyncedBlock = async ({
257
332
  if (result.errors && result.errors.length > 0) {
258
333
  throw new Error(result.errors.map(e => e.message).join(', '));
259
334
  }
260
- if (!((_result$data = result.data) !== null && _result$data !== void 0 && _result$data.blockService_deleteBlock.deleted)) {
335
+ if (!((_result$data2 = result.data) !== null && _result$data2 !== void 0 && _result$data2.blockService_deleteBlock.deleted)) {
261
336
  throw new Error('Block deletion failed; deleted flag is false');
262
337
  }
263
338
  return;
@@ -320,7 +395,7 @@ export const createSyncedBlock = async ({
320
395
  status
321
396
  }) => {
322
397
  if (fg('platform_synced_block_patch_1')) {
323
- var _result$data2;
398
+ var _result$data3;
324
399
  const bodyData = {
325
400
  query: buildCreateBlockMutation(blockAri, blockInstanceId, content, product, sourceAri, stepVersion, status !== undefined && fg('platform_synced_block_dogfooding') ? status : undefined),
326
401
  operationName: CREATE_BLOCK_OPERATION_NAME
@@ -337,7 +412,7 @@ export const createSyncedBlock = async ({
337
412
  if (result.errors && result.errors.length > 0) {
338
413
  throw new Error(result.errors.map(e => e.message).join(', '));
339
414
  }
340
- if (!((_result$data2 = result.data) !== null && _result$data2 !== void 0 && _result$data2.blockService_createBlock)) {
415
+ if (!((_result$data3 = result.data) !== null && _result$data3 !== void 0 && _result$data3.blockService_createBlock)) {
341
416
  throw new Error('No data returned from GraphQL mutation');
342
417
  }
343
418
  return result.data.blockService_createBlock;
@@ -391,8 +466,8 @@ export const updateReferenceSyncedBlockOnDocument = async ({
391
466
  throw new Error(result.errors.map(e => e.message).join(', '));
392
467
  }
393
468
  if (!noContent) {
394
- var _result$data3;
395
- if (!((_result$data3 = result.data) !== null && _result$data3 !== void 0 && _result$data3.blockService_updateDocumentReferences)) {
469
+ var _result$data4;
470
+ if (!((_result$data4 = result.data) !== null && _result$data4 !== void 0 && _result$data4.blockService_updateDocumentReferences)) {
396
471
  throw new Error('No data returned from GraphQL mutation');
397
472
  }
398
473
  return result.data.blockService_updateDocumentReferences;
@@ -419,6 +494,34 @@ export const updateReferenceSyncedBlockOnDocument = async ({
419
494
  export const getReferenceSyncedBlocksByBlockAri = async ({
420
495
  blockAri
421
496
  }) => {
497
+ if (fg('platform_synced_block_patch_1')) {
498
+ var _result$data5;
499
+ const bodyData = {
500
+ query: buildGetBlockReferencesQuery(blockAri),
501
+ operationName: GET_BLOCK_REFERENCES_OPERATION_NAME
502
+ };
503
+ const response = await fetchWithRetry(GRAPHQL_ENDPOINT, {
504
+ method: 'POST',
505
+ headers: COMMON_HEADERS,
506
+ body: JSON.stringify(bodyData)
507
+ });
508
+ if (!response.ok) {
509
+ throw new BlockError(response.status);
510
+ }
511
+ const result = await response.json();
512
+ if (result.errors && result.errors.length > 0) {
513
+ throw new Error(result.errors.map(e => e.message).join(', '));
514
+ }
515
+ if (!((_result$data5 = result.data) !== null && _result$data5 !== void 0 && _result$data5.blockService_getReferences)) {
516
+ throw new Error('No data returned from GraphQL query');
517
+ }
518
+ const graphqlResponse = result.data.blockService_getReferences;
519
+ return {
520
+ blockAri,
521
+ references: graphqlResponse.references || [],
522
+ errors: graphqlResponse.errors || []
523
+ };
524
+ }
422
525
  const response = await fetchWithRetry(`${BLOCK_SERVICE_API_URL}/reference/batch-retrieve/${encodeURIComponent(blockAri)}`, {
423
526
  method: 'GET',
424
527
  headers: COMMON_HEADERS
@@ -122,6 +122,8 @@ var UPDATE_BLOCK_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_UPDATE_BLOCK';
122
122
  var DELETE_BLOCK_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_DELETE_BLOCK';
123
123
  var CREATE_BLOCK_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_CREATE_BLOCK';
124
124
  var UPDATE_DOCUMENT_REFERENCES_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_UPDATE_DOCUMENT_REFERENCES';
125
+ var BATCH_RETRIEVE_BLOCKS_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_BATCH_RETRIEVE_BLOCKS';
126
+ var GET_BLOCK_REFERENCES_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_GET_REFERENCES';
125
127
  var buildGetDocumentReferenceBlocksQuery = function buildGetDocumentReferenceBlocksQuery(documentAri) {
126
128
  return "query ".concat(GET_DOCUMENT_REFERENCE_BLOCKS_OPERATION_NAME, " {\n\tblockService_getDocumentReferenceBlocks(documentAri: \"").concat(documentAri, "\") {\n\t\tblocks {\n\t\t\tblockAri\n\t\t\tblockInstanceId\n\t\t\tcontent\n\t\t\tcontentUpdatedAt\n\t\t\tcreatedAt\n\t\t\tcreatedBy\n\t\t\tproduct\n\t\t\tsourceAri\n\t\t\tstatus\n\t\t\tversion\n\t\t}\n\t\terrors {\n\t\t\tblockAri\n\t\t\tcode\n\t\t\treason\n\t\t}\n\t}\n}");
127
129
  };
@@ -172,6 +174,16 @@ var buildUpdateDocumentReferencesMutation = function buildUpdateDocumentReferenc
172
174
  var inputArgs = "documentAri: ".concat(JSON.stringify(documentAri), ", blocks: [").concat(blocksArray, "], noContent: ").concat(noContent);
173
175
  return "mutation ".concat(UPDATE_DOCUMENT_REFERENCES_OPERATION_NAME, " {\n\tblockService_updateDocumentReferences(input: { ").concat(inputArgs, " }) {\n\t\tblocks {\n\t\t\tblockAri\n\t\t\tblockInstanceId\n\t\t\tcontent\n\t\t\tcontentUpdatedAt\n\t\t\tcreatedAt\n\t\t\tcreatedBy\n\t\t\tproduct\n\t\t\tsourceAri\n\t\t\tstatus\n\t\t\tversion\n\t\t}\n\t\terrors {\n\t\t\tblockAri\n\t\t\tcode\n\t\t\treason\n\t\t}\n\t}\n}");
174
176
  };
177
+ var buildBatchRetrieveBlocksQuery = function buildBatchRetrieveBlocksQuery(blockAris) {
178
+ var blockArisArray = blockAris.map(function (ari) {
179
+ return JSON.stringify(ari);
180
+ }).join(', ');
181
+ var inputArgs = "blockAris: [".concat(blockArisArray, "]");
182
+ return "query ".concat(BATCH_RETRIEVE_BLOCKS_OPERATION_NAME, " {\n\tblockService_batchRetrieveBlocks(input: { ").concat(inputArgs, " }) {\n\t\tsuccess {\n\t\t\tblockAri\n\t\t\tblockInstanceId\n\t\t\tcontent\n\t\t\tcontentUpdatedAt\n\t\t\tcreatedAt\n\t\t\tcreatedBy\n\t\t\tdeletionReason\n\t\t\tproduct\n\t\t\tsourceAri\n\t\t\tstatus\n\t\t\tversion\n\t\t}\n\t\terror {\n\t\t\tblockAri\n\t\t\tcode\n\t\t\treason\n\t\t}\n\t}\n}");
183
+ };
184
+ var buildGetBlockReferencesQuery = function buildGetBlockReferencesQuery(blockAri) {
185
+ return "query ".concat(GET_BLOCK_REFERENCES_OPERATION_NAME, " {\n\tblockService_getReferences(blockAri: ").concat(JSON.stringify(blockAri), ") {\n\t\treferences {\n\t\t\tblockAri\n\t\t\tblockInstanceId\n\t\t\tcreatedAt\n\t\t\tcreatedBy\n\t\t\tdocumentAri\n\t\t}\n\t\terrors {\n\t\t\tblockAri\n\t\t\tcode\n\t\t\treason\n\t\t}\n\t}\n}");
186
+ };
175
187
  export var BlockError = /*#__PURE__*/function (_Error) {
176
188
  function BlockError(status) {
177
189
  var _this;
@@ -226,18 +238,68 @@ export var getSyncedBlockContent = /*#__PURE__*/function () {
226
238
  * Batch retrieves multiple synced blocks by their ARIs.
227
239
  *
228
240
  * Calls the Block Service API endpoint: `POST /v1/block/batch-retrieve`
241
+ * or GraphQL query `blockService_batchRetrieveBlocks` when feature flag is enabled
229
242
  *
230
243
  * @param blockAris - Array of block ARIs to retrieve
231
244
  * @returns A promise containing arrays of successfully fetched blocks and any errors encountered
232
245
  */
233
246
  export var batchRetrieveSyncedBlocks = /*#__PURE__*/function () {
234
247
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref4) {
235
- var blockIdentifiers, documentAri, response;
248
+ var blockIdentifiers, documentAri, _result$data, blockAris, bodyData, _response, result, graphqlResponse, response;
236
249
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
237
250
  while (1) switch (_context3.prev = _context3.next) {
238
251
  case 0:
239
252
  blockIdentifiers = _ref4.blockIdentifiers, documentAri = _ref4.documentAri;
240
- _context3.next = 3;
253
+ if (!fg('platform_synced_block_patch_1')) {
254
+ _context3.next = 18;
255
+ break;
256
+ }
257
+ blockAris = blockIdentifiers.map(function (blockIdentifier) {
258
+ return blockIdentifier.blockAri;
259
+ });
260
+ bodyData = {
261
+ query: buildBatchRetrieveBlocksQuery(blockAris),
262
+ operationName: BATCH_RETRIEVE_BLOCKS_OPERATION_NAME
263
+ };
264
+ _context3.next = 6;
265
+ return fetchWithRetry(GRAPHQL_ENDPOINT, {
266
+ method: 'POST',
267
+ headers: COMMON_HEADERS,
268
+ body: JSON.stringify(bodyData)
269
+ });
270
+ case 6:
271
+ _response = _context3.sent;
272
+ if (_response.ok) {
273
+ _context3.next = 9;
274
+ break;
275
+ }
276
+ throw new BlockError(_response.status);
277
+ case 9:
278
+ _context3.next = 11;
279
+ return _response.json();
280
+ case 11:
281
+ result = _context3.sent;
282
+ if (!(result.errors && result.errors.length > 0)) {
283
+ _context3.next = 14;
284
+ break;
285
+ }
286
+ throw new Error(result.errors.map(function (e) {
287
+ return e.message;
288
+ }).join(', '));
289
+ case 14:
290
+ if ((_result$data = result.data) !== null && _result$data !== void 0 && _result$data.blockService_batchRetrieveBlocks) {
291
+ _context3.next = 16;
292
+ break;
293
+ }
294
+ throw new Error('No data returned from GraphQL query');
295
+ case 16:
296
+ graphqlResponse = result.data.blockService_batchRetrieveBlocks;
297
+ return _context3.abrupt("return", {
298
+ success: graphqlResponse.success,
299
+ error: graphqlResponse.error
300
+ });
301
+ case 18:
302
+ _context3.next = 20;
241
303
  return fetchWithRetry("".concat(BLOCK_SERVICE_API_URL, "/block/batch-retrieve"), {
242
304
  method: 'POST',
243
305
  headers: COMMON_HEADERS,
@@ -249,19 +311,19 @@ export var batchRetrieveSyncedBlocks = /*#__PURE__*/function () {
249
311
  })
250
312
  })
251
313
  });
252
- case 3:
314
+ case 20:
253
315
  response = _context3.sent;
254
316
  if (response.ok) {
255
- _context3.next = 6;
317
+ _context3.next = 23;
256
318
  break;
257
319
  }
258
320
  throw new BlockError(response.status);
259
- case 6:
260
- _context3.next = 8;
321
+ case 23:
322
+ _context3.next = 25;
261
323
  return response.json();
262
- case 8:
324
+ case 25:
263
325
  return _context3.abrupt("return", _context3.sent);
264
- case 9:
326
+ case 26:
265
327
  case "end":
266
328
  return _context3.stop();
267
329
  }
@@ -273,7 +335,7 @@ export var batchRetrieveSyncedBlocks = /*#__PURE__*/function () {
273
335
  }();
274
336
  export var deleteSyncedBlock = /*#__PURE__*/function () {
275
337
  var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref6) {
276
- var blockAri, deleteReason, _result$data, bodyData, _response, result, url, response;
338
+ var blockAri, deleteReason, _result$data2, bodyData, _response2, result, url, response;
277
339
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
278
340
  while (1) switch (_context4.prev = _context4.next) {
279
341
  case 0:
@@ -293,15 +355,15 @@ export var deleteSyncedBlock = /*#__PURE__*/function () {
293
355
  body: JSON.stringify(bodyData)
294
356
  });
295
357
  case 5:
296
- _response = _context4.sent;
297
- if (_response.ok) {
358
+ _response2 = _context4.sent;
359
+ if (_response2.ok) {
298
360
  _context4.next = 8;
299
361
  break;
300
362
  }
301
- throw new BlockError(_response.status);
363
+ throw new BlockError(_response2.status);
302
364
  case 8:
303
365
  _context4.next = 10;
304
- return _response.json();
366
+ return _response2.json();
305
367
  case 10:
306
368
  result = _context4.sent;
307
369
  if (!(result.errors && result.errors.length > 0)) {
@@ -312,7 +374,7 @@ export var deleteSyncedBlock = /*#__PURE__*/function () {
312
374
  return e.message;
313
375
  }).join(', '));
314
376
  case 13:
315
- if ((_result$data = result.data) !== null && _result$data !== void 0 && _result$data.blockService_deleteBlock.deleted) {
377
+ if ((_result$data2 = result.data) !== null && _result$data2 !== void 0 && _result$data2.blockService_deleteBlock.deleted) {
316
378
  _context4.next = 15;
317
379
  break;
318
380
  }
@@ -345,7 +407,7 @@ export var deleteSyncedBlock = /*#__PURE__*/function () {
345
407
  }();
346
408
  export var updateSyncedBlock = /*#__PURE__*/function () {
347
409
  var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref8) {
348
- var blockAri, content, stepVersion, bodyData, _response2, result, requestBody, response;
410
+ var blockAri, content, stepVersion, bodyData, _response3, result, requestBody, response;
349
411
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
350
412
  while (1) switch (_context5.prev = _context5.next) {
351
413
  case 0:
@@ -365,15 +427,15 @@ export var updateSyncedBlock = /*#__PURE__*/function () {
365
427
  body: JSON.stringify(bodyData)
366
428
  });
367
429
  case 5:
368
- _response2 = _context5.sent;
369
- if (_response2.ok) {
430
+ _response3 = _context5.sent;
431
+ if (_response3.ok) {
370
432
  _context5.next = 8;
371
433
  break;
372
434
  }
373
- throw new BlockError(_response2.status);
435
+ throw new BlockError(_response3.status);
374
436
  case 8:
375
437
  _context5.next = 10;
376
- return _response2.json();
438
+ return _response3.json();
377
439
  case 10:
378
440
  result = _context5.sent;
379
441
  if (!(result.errors && result.errors.length > 0)) {
@@ -417,7 +479,7 @@ export var updateSyncedBlock = /*#__PURE__*/function () {
417
479
  }();
418
480
  export var createSyncedBlock = /*#__PURE__*/function () {
419
481
  var _ref1 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref0) {
420
- var blockAri, blockInstanceId, sourceAri, product, content, stepVersion, status, _result$data2, bodyData, _response3, result, requestBody, response;
482
+ var blockAri, blockInstanceId, sourceAri, product, content, stepVersion, status, _result$data3, bodyData, _response4, result, requestBody, response;
421
483
  return _regeneratorRuntime.wrap(function _callee6$(_context6) {
422
484
  while (1) switch (_context6.prev = _context6.next) {
423
485
  case 0:
@@ -437,15 +499,15 @@ export var createSyncedBlock = /*#__PURE__*/function () {
437
499
  body: JSON.stringify(bodyData)
438
500
  });
439
501
  case 5:
440
- _response3 = _context6.sent;
441
- if (_response3.ok) {
502
+ _response4 = _context6.sent;
503
+ if (_response4.ok) {
442
504
  _context6.next = 8;
443
505
  break;
444
506
  }
445
- throw new BlockError(_response3.status);
507
+ throw new BlockError(_response4.status);
446
508
  case 8:
447
509
  _context6.next = 10;
448
- return _response3.json();
510
+ return _response4.json();
449
511
  case 10:
450
512
  result = _context6.sent;
451
513
  if (!(result.errors && result.errors.length > 0)) {
@@ -456,7 +518,7 @@ export var createSyncedBlock = /*#__PURE__*/function () {
456
518
  return e.message;
457
519
  }).join(', '));
458
520
  case 13:
459
- if ((_result$data2 = result.data) !== null && _result$data2 !== void 0 && _result$data2.blockService_createBlock) {
521
+ if ((_result$data3 = result.data) !== null && _result$data3 !== void 0 && _result$data3.blockService_createBlock) {
460
522
  _context6.next = 15;
461
523
  break;
462
524
  }
@@ -507,7 +569,7 @@ export var createSyncedBlock = /*#__PURE__*/function () {
507
569
  }();
508
570
  export var updateReferenceSyncedBlockOnDocument = /*#__PURE__*/function () {
509
571
  var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref10) {
510
- var documentAri, blocks, _ref10$noContent, noContent, bodyData, _response4, result, _result$data3, response;
572
+ var documentAri, blocks, _ref10$noContent, noContent, bodyData, _response5, result, _result$data4, response;
511
573
  return _regeneratorRuntime.wrap(function _callee7$(_context7) {
512
574
  while (1) switch (_context7.prev = _context7.next) {
513
575
  case 0:
@@ -529,15 +591,15 @@ export var updateReferenceSyncedBlockOnDocument = /*#__PURE__*/function () {
529
591
  keepalive: true
530
592
  } : {}));
531
593
  case 5:
532
- _response4 = _context7.sent;
533
- if (_response4.ok) {
594
+ _response5 = _context7.sent;
595
+ if (_response5.ok) {
534
596
  _context7.next = 8;
535
597
  break;
536
598
  }
537
- throw new BlockError(_response4.status);
599
+ throw new BlockError(_response5.status);
538
600
  case 8:
539
601
  _context7.next = 10;
540
- return _response4.json();
602
+ return _response5.json();
541
603
  case 10:
542
604
  result = _context7.sent;
543
605
  if (!(result.errors && result.errors.length > 0)) {
@@ -552,7 +614,7 @@ export var updateReferenceSyncedBlockOnDocument = /*#__PURE__*/function () {
552
614
  _context7.next = 17;
553
615
  break;
554
616
  }
555
- if ((_result$data3 = result.data) !== null && _result$data3 !== void 0 && _result$data3.blockService_updateDocumentReferences) {
617
+ if ((_result$data4 = result.data) !== null && _result$data4 !== void 0 && _result$data4.blockService_updateDocumentReferences) {
556
618
  _context7.next = 16;
557
619
  break;
558
620
  }
@@ -600,29 +662,76 @@ export var updateReferenceSyncedBlockOnDocument = /*#__PURE__*/function () {
600
662
  }();
601
663
  export var getReferenceSyncedBlocksByBlockAri = /*#__PURE__*/function () {
602
664
  var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref12) {
603
- var blockAri, response;
665
+ var blockAri, _result$data5, bodyData, _response6, result, graphqlResponse, response;
604
666
  return _regeneratorRuntime.wrap(function _callee8$(_context8) {
605
667
  while (1) switch (_context8.prev = _context8.next) {
606
668
  case 0:
607
669
  blockAri = _ref12.blockAri;
608
- _context8.next = 3;
670
+ if (!fg('platform_synced_block_patch_1')) {
671
+ _context8.next = 17;
672
+ break;
673
+ }
674
+ bodyData = {
675
+ query: buildGetBlockReferencesQuery(blockAri),
676
+ operationName: GET_BLOCK_REFERENCES_OPERATION_NAME
677
+ };
678
+ _context8.next = 5;
679
+ return fetchWithRetry(GRAPHQL_ENDPOINT, {
680
+ method: 'POST',
681
+ headers: COMMON_HEADERS,
682
+ body: JSON.stringify(bodyData)
683
+ });
684
+ case 5:
685
+ _response6 = _context8.sent;
686
+ if (_response6.ok) {
687
+ _context8.next = 8;
688
+ break;
689
+ }
690
+ throw new BlockError(_response6.status);
691
+ case 8:
692
+ _context8.next = 10;
693
+ return _response6.json();
694
+ case 10:
695
+ result = _context8.sent;
696
+ if (!(result.errors && result.errors.length > 0)) {
697
+ _context8.next = 13;
698
+ break;
699
+ }
700
+ throw new Error(result.errors.map(function (e) {
701
+ return e.message;
702
+ }).join(', '));
703
+ case 13:
704
+ if ((_result$data5 = result.data) !== null && _result$data5 !== void 0 && _result$data5.blockService_getReferences) {
705
+ _context8.next = 15;
706
+ break;
707
+ }
708
+ throw new Error('No data returned from GraphQL query');
709
+ case 15:
710
+ graphqlResponse = result.data.blockService_getReferences;
711
+ return _context8.abrupt("return", {
712
+ blockAri: blockAri,
713
+ references: graphqlResponse.references || [],
714
+ errors: graphqlResponse.errors || []
715
+ });
716
+ case 17:
717
+ _context8.next = 19;
609
718
  return fetchWithRetry("".concat(BLOCK_SERVICE_API_URL, "/reference/batch-retrieve/").concat(encodeURIComponent(blockAri)), {
610
719
  method: 'GET',
611
720
  headers: COMMON_HEADERS
612
721
  });
613
- case 3:
722
+ case 19:
614
723
  response = _context8.sent;
615
724
  if (response.ok) {
616
- _context8.next = 6;
725
+ _context8.next = 22;
617
726
  break;
618
727
  }
619
728
  throw new BlockError(response.status);
620
- case 6:
621
- _context8.next = 8;
729
+ case 22:
730
+ _context8.next = 24;
622
731
  return response.json();
623
- case 8:
732
+ case 24:
624
733
  return _context8.abrupt("return", _context8.sent);
625
- case 9:
734
+ case 25:
626
735
  case "end":
627
736
  return _context8.stop();
628
737
  }
@@ -125,6 +125,7 @@ export declare const getSyncedBlockContent: ({ blockAri, }: GetSyncedBlockConten
125
125
  * Batch retrieves multiple synced blocks by their ARIs.
126
126
  *
127
127
  * Calls the Block Service API endpoint: `POST /v1/block/batch-retrieve`
128
+ * or GraphQL query `blockService_batchRetrieveBlocks` when feature flag is enabled
128
129
  *
129
130
  * @param blockAris - Array of block ARIs to retrieve
130
131
  * @returns A promise containing arrays of successfully fetched blocks and any errors encountered
@@ -125,6 +125,7 @@ export declare const getSyncedBlockContent: ({ blockAri, }: GetSyncedBlockConten
125
125
  * Batch retrieves multiple synced blocks by their ARIs.
126
126
  *
127
127
  * Calls the Block Service API endpoint: `POST /v1/block/batch-retrieve`
128
+ * or GraphQL query `blockService_batchRetrieveBlocks` when feature flag is enabled
128
129
  *
129
130
  * @param blockAris - Array of block ARIs to retrieve
130
131
  * @returns A promise containing arrays of successfully fetched blocks and any errors encountered
package/package.json CHANGED
@@ -79,7 +79,7 @@
79
79
  }
80
80
  },
81
81
  "name": "@atlaskit/editor-synced-block-provider",
82
- "version": "3.23.0",
82
+ "version": "3.25.0",
83
83
  "description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
84
84
  "author": "Atlassian Pty Ltd",
85
85
  "license": "Apache-2.0",