@atlaskit/editor-synced-block-provider 3.27.2 → 3.28.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/cjs/clients/block-service/blockService.js +118 -310
- package/dist/cjs/clients/confluence/sourceInfo.js +1 -1
- package/dist/cjs/providers/block-service/blockServiceAPI.js +8 -18
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +163 -100
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +29 -84
- package/dist/cjs/store-manager/syncBlockStoreManager.js +1 -2
- package/dist/es2019/clients/block-service/blockService.js +119 -235
- package/dist/es2019/clients/confluence/sourceInfo.js +1 -1
- package/dist/es2019/providers/block-service/blockServiceAPI.js +8 -18
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +113 -89
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +40 -90
- package/dist/es2019/store-manager/syncBlockStoreManager.js +1 -2
- package/dist/esm/clients/block-service/blockService.js +118 -310
- package/dist/esm/clients/confluence/sourceInfo.js +1 -1
- package/dist/esm/providers/block-service/blockServiceAPI.js +8 -18
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +163 -100
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +29 -84
- package/dist/esm/store-manager/syncBlockStoreManager.js +1 -2
- package/dist/types/clients/block-service/blockService.d.ts +3 -6
- package/dist/types/providers/block-service/blockServiceAPI.d.ts +2 -5
- package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +4 -2
- package/dist/types/store-manager/sourceSyncBlockStoreManager.d.ts +0 -14
- package/dist/types-ts4.5/clients/block-service/blockService.d.ts +3 -6
- package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +2 -5
- package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +4 -2
- package/dist/types-ts4.5/store-manager/sourceSyncBlockStoreManager.d.ts +0 -14
- package/package.json +2 -4
|
@@ -8,7 +8,6 @@ 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';
|
|
12
11
|
import { fetchWithRetry } from '../../utils/retry';
|
|
13
12
|
export var isBlockContentResponse = function isBlockContentResponse(response) {
|
|
14
13
|
var content = response.content;
|
|
@@ -112,7 +111,6 @@ var COMMON_HEADERS = {
|
|
|
112
111
|
'Content-Type': 'application/json',
|
|
113
112
|
Accept: 'application/json'
|
|
114
113
|
};
|
|
115
|
-
var BLOCK_SERVICE_API_URL = '/gateway/api/blocks/v1';
|
|
116
114
|
var GRAPHQL_ENDPOINT = '/gateway/api/graphql';
|
|
117
115
|
var GET_DOCUMENT_REFERENCE_BLOCKS_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_GET_DOCUMENT_REFERENCE_BLOCKS';
|
|
118
116
|
var UPDATE_BLOCK_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_UPDATE_BLOCK';
|
|
@@ -133,7 +131,7 @@ var buildUpdateBlockMutation = function buildUpdateBlockMutation(blockAri, conte
|
|
|
133
131
|
if (stepVersion !== undefined) {
|
|
134
132
|
inputParts.push("stepVersion: ".concat(stepVersion));
|
|
135
133
|
}
|
|
136
|
-
if (status !== undefined
|
|
134
|
+
if (status !== undefined) {
|
|
137
135
|
inputParts.push("status: ".concat(JSON.stringify(status)));
|
|
138
136
|
}
|
|
139
137
|
var inputArgs = inputParts.join(', ');
|
|
@@ -201,75 +199,50 @@ export var BlockError = /*#__PURE__*/function (_Error) {
|
|
|
201
199
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
202
200
|
export var getSyncedBlockContent = /*#__PURE__*/function () {
|
|
203
201
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref2) {
|
|
204
|
-
var
|
|
202
|
+
var _result$data;
|
|
203
|
+
var blockAri, bodyData, response, result;
|
|
205
204
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
206
205
|
while (1) switch (_context2.prev = _context2.next) {
|
|
207
206
|
case 0:
|
|
208
207
|
blockAri = _ref2.blockAri;
|
|
209
|
-
if (!fg('platform_synced_block_patch_1')) {
|
|
210
|
-
_context2.next = 16;
|
|
211
|
-
break;
|
|
212
|
-
}
|
|
213
208
|
bodyData = {
|
|
214
209
|
query: buildGetBlockQuery(blockAri),
|
|
215
210
|
operationName: GET_BLOCK_OPERATION_NAME
|
|
216
211
|
};
|
|
217
|
-
_context2.next =
|
|
212
|
+
_context2.next = 4;
|
|
218
213
|
return fetchWithRetry(GRAPHQL_ENDPOINT, {
|
|
219
214
|
method: 'POST',
|
|
220
215
|
headers: COMMON_HEADERS,
|
|
221
216
|
body: JSON.stringify(bodyData)
|
|
222
217
|
});
|
|
223
|
-
case
|
|
224
|
-
|
|
225
|
-
if (
|
|
226
|
-
_context2.next =
|
|
218
|
+
case 4:
|
|
219
|
+
response = _context2.sent;
|
|
220
|
+
if (response.ok) {
|
|
221
|
+
_context2.next = 7;
|
|
227
222
|
break;
|
|
228
223
|
}
|
|
229
|
-
throw new BlockError(
|
|
230
|
-
case
|
|
231
|
-
_context2.next =
|
|
232
|
-
return
|
|
233
|
-
case
|
|
224
|
+
throw new BlockError(response.status);
|
|
225
|
+
case 7:
|
|
226
|
+
_context2.next = 9;
|
|
227
|
+
return response.json();
|
|
228
|
+
case 9:
|
|
234
229
|
result = _context2.sent;
|
|
235
230
|
if (!(result.errors && result.errors.length > 0)) {
|
|
236
|
-
_context2.next =
|
|
231
|
+
_context2.next = 12;
|
|
237
232
|
break;
|
|
238
233
|
}
|
|
239
234
|
throw new Error(result.errors.map(function (e) {
|
|
240
235
|
return e.message;
|
|
241
236
|
}).join(', '));
|
|
242
|
-
case
|
|
237
|
+
case 12:
|
|
243
238
|
if ((_result$data = result.data) !== null && _result$data !== void 0 && _result$data.blockService_getBlock) {
|
|
244
|
-
_context2.next =
|
|
239
|
+
_context2.next = 14;
|
|
245
240
|
break;
|
|
246
241
|
}
|
|
247
242
|
throw new Error('No data returned from GraphQL query');
|
|
248
|
-
case
|
|
243
|
+
case 14:
|
|
249
244
|
return _context2.abrupt("return", result.data.blockService_getBlock);
|
|
250
|
-
case
|
|
251
|
-
// Disable sending documentAri for now. We'll add it back if we find a way to update references that follows the save & refresh principle.
|
|
252
|
-
// Slack discussion here: https://atlassian.slack.com/archives/C09DZT1TBNW/p1767836775552099?thread_ts=1767836754.024889&cid=C09DZT1TBNW
|
|
253
|
-
// const queryParams = documentAri ? `?documentAri=${encodeURIComponent(documentAri)}` : '';
|
|
254
|
-
queryParams = '';
|
|
255
|
-
_context2.next = 19;
|
|
256
|
-
return fetchWithRetry("".concat(BLOCK_SERVICE_API_URL, "/block/").concat(encodeURIComponent(blockAri)) + queryParams, {
|
|
257
|
-
method: 'GET',
|
|
258
|
-
headers: COMMON_HEADERS
|
|
259
|
-
});
|
|
260
|
-
case 19:
|
|
261
|
-
response = _context2.sent;
|
|
262
|
-
if (response.ok) {
|
|
263
|
-
_context2.next = 22;
|
|
264
|
-
break;
|
|
265
|
-
}
|
|
266
|
-
throw new BlockError(response.status);
|
|
267
|
-
case 22:
|
|
268
|
-
_context2.next = 24;
|
|
269
|
-
return response.json();
|
|
270
|
-
case 24:
|
|
271
|
-
return _context2.abrupt("return", _context2.sent);
|
|
272
|
-
case 25:
|
|
245
|
+
case 15:
|
|
273
246
|
case "end":
|
|
274
247
|
return _context2.stop();
|
|
275
248
|
}
|
|
@@ -283,23 +256,19 @@ export var getSyncedBlockContent = /*#__PURE__*/function () {
|
|
|
283
256
|
/**
|
|
284
257
|
* Batch retrieves multiple synced blocks by their ARIs.
|
|
285
258
|
*
|
|
286
|
-
* Calls the Block Service API
|
|
287
|
-
* or GraphQL query `blockService_batchRetrieveBlocks` when feature flag is enabled
|
|
259
|
+
* Calls the Block Service GraphQL API: `blockService_batchRetrieveBlocks`
|
|
288
260
|
*
|
|
289
|
-
* @param
|
|
261
|
+
* @param blockIdentifiers - Array of block identifiers to retrieve
|
|
290
262
|
* @returns A promise containing arrays of successfully fetched blocks and any errors encountered
|
|
291
263
|
*/
|
|
292
264
|
export var batchRetrieveSyncedBlocks = /*#__PURE__*/function () {
|
|
293
265
|
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref4) {
|
|
294
|
-
var
|
|
266
|
+
var _result$data2;
|
|
267
|
+
var blockIdentifiers, blockAris, bodyData, response, result, graphqlResponse;
|
|
295
268
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
296
269
|
while (1) switch (_context3.prev = _context3.next) {
|
|
297
270
|
case 0:
|
|
298
|
-
blockIdentifiers = _ref4.blockIdentifiers
|
|
299
|
-
if (!fg('platform_synced_block_patch_1')) {
|
|
300
|
-
_context3.next = 18;
|
|
301
|
-
break;
|
|
302
|
-
}
|
|
271
|
+
blockIdentifiers = _ref4.blockIdentifiers;
|
|
303
272
|
blockAris = blockIdentifiers.map(function (blockIdentifier) {
|
|
304
273
|
return blockIdentifier.blockAri;
|
|
305
274
|
});
|
|
@@ -307,69 +276,44 @@ export var batchRetrieveSyncedBlocks = /*#__PURE__*/function () {
|
|
|
307
276
|
query: buildBatchRetrieveBlocksQuery(blockAris),
|
|
308
277
|
operationName: BATCH_RETRIEVE_BLOCKS_OPERATION_NAME
|
|
309
278
|
};
|
|
310
|
-
_context3.next =
|
|
279
|
+
_context3.next = 5;
|
|
311
280
|
return fetchWithRetry(GRAPHQL_ENDPOINT, {
|
|
312
281
|
method: 'POST',
|
|
313
282
|
headers: COMMON_HEADERS,
|
|
314
283
|
body: JSON.stringify(bodyData)
|
|
315
284
|
});
|
|
316
|
-
case
|
|
317
|
-
|
|
318
|
-
if (
|
|
319
|
-
_context3.next =
|
|
285
|
+
case 5:
|
|
286
|
+
response = _context3.sent;
|
|
287
|
+
if (response.ok) {
|
|
288
|
+
_context3.next = 8;
|
|
320
289
|
break;
|
|
321
290
|
}
|
|
322
|
-
throw new BlockError(
|
|
323
|
-
case
|
|
324
|
-
_context3.next =
|
|
325
|
-
return
|
|
326
|
-
case
|
|
291
|
+
throw new BlockError(response.status);
|
|
292
|
+
case 8:
|
|
293
|
+
_context3.next = 10;
|
|
294
|
+
return response.json();
|
|
295
|
+
case 10:
|
|
327
296
|
result = _context3.sent;
|
|
328
297
|
if (!(result.errors && result.errors.length > 0)) {
|
|
329
|
-
_context3.next =
|
|
298
|
+
_context3.next = 13;
|
|
330
299
|
break;
|
|
331
300
|
}
|
|
332
301
|
throw new Error(result.errors.map(function (e) {
|
|
333
302
|
return e.message;
|
|
334
303
|
}).join(', '));
|
|
335
|
-
case
|
|
304
|
+
case 13:
|
|
336
305
|
if ((_result$data2 = result.data) !== null && _result$data2 !== void 0 && _result$data2.blockService_batchRetrieveBlocks) {
|
|
337
|
-
_context3.next =
|
|
306
|
+
_context3.next = 15;
|
|
338
307
|
break;
|
|
339
308
|
}
|
|
340
309
|
throw new Error('No data returned from GraphQL query');
|
|
341
|
-
case
|
|
310
|
+
case 15:
|
|
342
311
|
graphqlResponse = result.data.blockService_batchRetrieveBlocks;
|
|
343
312
|
return _context3.abrupt("return", {
|
|
344
313
|
success: graphqlResponse.success,
|
|
345
314
|
error: graphqlResponse.error
|
|
346
315
|
});
|
|
347
|
-
case
|
|
348
|
-
_context3.next = 20;
|
|
349
|
-
return fetchWithRetry("".concat(BLOCK_SERVICE_API_URL, "/block/batch-retrieve"), {
|
|
350
|
-
method: 'POST',
|
|
351
|
-
headers: COMMON_HEADERS,
|
|
352
|
-
body: JSON.stringify({
|
|
353
|
-
documentAri: documentAri,
|
|
354
|
-
blockIdentifiers: blockIdentifiers,
|
|
355
|
-
blockAris: blockIdentifiers.map(function (blockIdentifier) {
|
|
356
|
-
return blockIdentifier.blockAri;
|
|
357
|
-
})
|
|
358
|
-
})
|
|
359
|
-
});
|
|
360
|
-
case 20:
|
|
361
|
-
response = _context3.sent;
|
|
362
|
-
if (response.ok) {
|
|
363
|
-
_context3.next = 23;
|
|
364
|
-
break;
|
|
365
|
-
}
|
|
366
|
-
throw new BlockError(response.status);
|
|
367
|
-
case 23:
|
|
368
|
-
_context3.next = 25;
|
|
369
|
-
return response.json();
|
|
370
|
-
case 25:
|
|
371
|
-
return _context3.abrupt("return", _context3.sent);
|
|
372
|
-
case 26:
|
|
316
|
+
case 17:
|
|
373
317
|
case "end":
|
|
374
318
|
return _context3.stop();
|
|
375
319
|
}
|
|
@@ -381,67 +325,48 @@ export var batchRetrieveSyncedBlocks = /*#__PURE__*/function () {
|
|
|
381
325
|
}();
|
|
382
326
|
export var deleteSyncedBlock = /*#__PURE__*/function () {
|
|
383
327
|
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref6) {
|
|
384
|
-
var
|
|
328
|
+
var _result$data3;
|
|
329
|
+
var blockAri, deleteReason, bodyData, response, result;
|
|
385
330
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
386
331
|
while (1) switch (_context4.prev = _context4.next) {
|
|
387
332
|
case 0:
|
|
388
333
|
blockAri = _ref6.blockAri, deleteReason = _ref6.deleteReason;
|
|
389
|
-
if (!fg('platform_synced_block_patch_1')) {
|
|
390
|
-
_context4.next = 16;
|
|
391
|
-
break;
|
|
392
|
-
}
|
|
393
334
|
bodyData = {
|
|
394
335
|
query: buildDeleteBlockMutation(blockAri, deleteReason),
|
|
395
336
|
operationName: DELETE_BLOCK_OPERATION_NAME
|
|
396
337
|
};
|
|
397
|
-
_context4.next =
|
|
338
|
+
_context4.next = 4;
|
|
398
339
|
return fetchWithRetry(GRAPHQL_ENDPOINT, {
|
|
399
340
|
method: 'POST',
|
|
400
341
|
headers: COMMON_HEADERS,
|
|
401
342
|
body: JSON.stringify(bodyData)
|
|
402
343
|
});
|
|
403
|
-
case
|
|
404
|
-
|
|
405
|
-
if (
|
|
406
|
-
_context4.next =
|
|
344
|
+
case 4:
|
|
345
|
+
response = _context4.sent;
|
|
346
|
+
if (response.ok) {
|
|
347
|
+
_context4.next = 7;
|
|
407
348
|
break;
|
|
408
349
|
}
|
|
409
|
-
throw new BlockError(
|
|
410
|
-
case
|
|
411
|
-
_context4.next =
|
|
412
|
-
return
|
|
413
|
-
case
|
|
350
|
+
throw new BlockError(response.status);
|
|
351
|
+
case 7:
|
|
352
|
+
_context4.next = 9;
|
|
353
|
+
return response.json();
|
|
354
|
+
case 9:
|
|
414
355
|
result = _context4.sent;
|
|
415
356
|
if (!(result.errors && result.errors.length > 0)) {
|
|
416
|
-
_context4.next =
|
|
357
|
+
_context4.next = 12;
|
|
417
358
|
break;
|
|
418
359
|
}
|
|
419
360
|
throw new Error(result.errors.map(function (e) {
|
|
420
361
|
return e.message;
|
|
421
362
|
}).join(', '));
|
|
422
|
-
case
|
|
363
|
+
case 12:
|
|
423
364
|
if ((_result$data3 = result.data) !== null && _result$data3 !== void 0 && _result$data3.blockService_deleteBlock.deleted) {
|
|
424
|
-
_context4.next =
|
|
365
|
+
_context4.next = 14;
|
|
425
366
|
break;
|
|
426
367
|
}
|
|
427
368
|
throw new Error('Block deletion failed; deleted flag is false');
|
|
428
|
-
case
|
|
429
|
-
return _context4.abrupt("return");
|
|
430
|
-
case 16:
|
|
431
|
-
url = deleteReason ? "".concat(BLOCK_SERVICE_API_URL, "/block/").concat(encodeURIComponent(blockAri), "?deletionReason=").concat(encodeURIComponent(deleteReason)) : "".concat(BLOCK_SERVICE_API_URL, "/block/").concat(encodeURIComponent(blockAri));
|
|
432
|
-
_context4.next = 19;
|
|
433
|
-
return fetchWithRetry(url, {
|
|
434
|
-
method: 'DELETE',
|
|
435
|
-
headers: COMMON_HEADERS
|
|
436
|
-
});
|
|
437
|
-
case 19:
|
|
438
|
-
response = _context4.sent;
|
|
439
|
-
if (response.ok) {
|
|
440
|
-
_context4.next = 22;
|
|
441
|
-
break;
|
|
442
|
-
}
|
|
443
|
-
throw new BlockError(response.status);
|
|
444
|
-
case 22:
|
|
369
|
+
case 14:
|
|
445
370
|
case "end":
|
|
446
371
|
return _context4.stop();
|
|
447
372
|
}
|
|
@@ -453,70 +378,41 @@ export var deleteSyncedBlock = /*#__PURE__*/function () {
|
|
|
453
378
|
}();
|
|
454
379
|
export var updateSyncedBlock = /*#__PURE__*/function () {
|
|
455
380
|
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref8) {
|
|
456
|
-
var blockAri, content, stepVersion, status, bodyData,
|
|
381
|
+
var blockAri, content, stepVersion, status, bodyData, response, result;
|
|
457
382
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
458
383
|
while (1) switch (_context5.prev = _context5.next) {
|
|
459
384
|
case 0:
|
|
460
385
|
blockAri = _ref8.blockAri, content = _ref8.content, stepVersion = _ref8.stepVersion, status = _ref8.status;
|
|
461
|
-
if (!fg('platform_synced_block_patch_1')) {
|
|
462
|
-
_context5.next = 14;
|
|
463
|
-
break;
|
|
464
|
-
}
|
|
465
386
|
bodyData = {
|
|
466
387
|
query: buildUpdateBlockMutation(blockAri, content, stepVersion, status),
|
|
467
388
|
operationName: UPDATE_BLOCK_OPERATION_NAME
|
|
468
389
|
};
|
|
469
|
-
_context5.next =
|
|
390
|
+
_context5.next = 4;
|
|
470
391
|
return fetchWithRetry(GRAPHQL_ENDPOINT, {
|
|
471
392
|
method: 'POST',
|
|
472
393
|
headers: COMMON_HEADERS,
|
|
473
394
|
body: JSON.stringify(bodyData)
|
|
474
395
|
});
|
|
475
|
-
case
|
|
476
|
-
|
|
477
|
-
if (
|
|
478
|
-
_context5.next =
|
|
396
|
+
case 4:
|
|
397
|
+
response = _context5.sent;
|
|
398
|
+
if (response.ok) {
|
|
399
|
+
_context5.next = 7;
|
|
479
400
|
break;
|
|
480
401
|
}
|
|
481
|
-
throw new BlockError(
|
|
482
|
-
case
|
|
483
|
-
_context5.next =
|
|
484
|
-
return
|
|
485
|
-
case
|
|
402
|
+
throw new BlockError(response.status);
|
|
403
|
+
case 7:
|
|
404
|
+
_context5.next = 9;
|
|
405
|
+
return response.json();
|
|
406
|
+
case 9:
|
|
486
407
|
result = _context5.sent;
|
|
487
408
|
if (!(result.errors && result.errors.length > 0)) {
|
|
488
|
-
_context5.next =
|
|
409
|
+
_context5.next = 12;
|
|
489
410
|
break;
|
|
490
411
|
}
|
|
491
412
|
throw new Error(result.errors.map(function (e) {
|
|
492
413
|
return e.message;
|
|
493
414
|
}).join(', '));
|
|
494
|
-
case
|
|
495
|
-
return _context5.abrupt("return");
|
|
496
|
-
case 14:
|
|
497
|
-
requestBody = {
|
|
498
|
-
content: content
|
|
499
|
-
};
|
|
500
|
-
if (stepVersion !== undefined) {
|
|
501
|
-
requestBody.stepVersion = stepVersion;
|
|
502
|
-
}
|
|
503
|
-
if (status !== undefined && fg('platform_synced_block_patch_1')) {
|
|
504
|
-
requestBody.status = status;
|
|
505
|
-
}
|
|
506
|
-
_context5.next = 19;
|
|
507
|
-
return fetchWithRetry("".concat(BLOCK_SERVICE_API_URL, "/block/").concat(encodeURIComponent(blockAri)), {
|
|
508
|
-
method: 'PUT',
|
|
509
|
-
headers: COMMON_HEADERS,
|
|
510
|
-
body: JSON.stringify(requestBody)
|
|
511
|
-
});
|
|
512
|
-
case 19:
|
|
513
|
-
response = _context5.sent;
|
|
514
|
-
if (response.ok) {
|
|
515
|
-
_context5.next = 22;
|
|
516
|
-
break;
|
|
517
|
-
}
|
|
518
|
-
throw new BlockError(response.status);
|
|
519
|
-
case 22:
|
|
415
|
+
case 12:
|
|
520
416
|
case "end":
|
|
521
417
|
return _context5.stop();
|
|
522
418
|
}
|
|
@@ -528,85 +424,50 @@ export var updateSyncedBlock = /*#__PURE__*/function () {
|
|
|
528
424
|
}();
|
|
529
425
|
export var createSyncedBlock = /*#__PURE__*/function () {
|
|
530
426
|
var _ref1 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref0) {
|
|
531
|
-
var
|
|
427
|
+
var _result$data4;
|
|
428
|
+
var blockAri, blockInstanceId, sourceAri, product, content, stepVersion, status, bodyData, response, result;
|
|
532
429
|
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
533
430
|
while (1) switch (_context6.prev = _context6.next) {
|
|
534
431
|
case 0:
|
|
535
432
|
blockAri = _ref0.blockAri, blockInstanceId = _ref0.blockInstanceId, sourceAri = _ref0.sourceAri, product = _ref0.product, content = _ref0.content, stepVersion = _ref0.stepVersion, status = _ref0.status;
|
|
536
|
-
if (!fg('platform_synced_block_patch_1')) {
|
|
537
|
-
_context6.next = 16;
|
|
538
|
-
break;
|
|
539
|
-
}
|
|
540
433
|
bodyData = {
|
|
541
434
|
query: buildCreateBlockMutation(blockAri, blockInstanceId, content, product, sourceAri, stepVersion, status),
|
|
542
435
|
operationName: CREATE_BLOCK_OPERATION_NAME
|
|
543
436
|
};
|
|
544
|
-
_context6.next =
|
|
437
|
+
_context6.next = 4;
|
|
545
438
|
return fetchWithRetry(GRAPHQL_ENDPOINT, {
|
|
546
439
|
method: 'POST',
|
|
547
440
|
headers: COMMON_HEADERS,
|
|
548
441
|
body: JSON.stringify(bodyData)
|
|
549
442
|
});
|
|
550
|
-
case
|
|
551
|
-
|
|
552
|
-
if (
|
|
553
|
-
_context6.next =
|
|
443
|
+
case 4:
|
|
444
|
+
response = _context6.sent;
|
|
445
|
+
if (response.ok) {
|
|
446
|
+
_context6.next = 7;
|
|
554
447
|
break;
|
|
555
448
|
}
|
|
556
|
-
throw new BlockError(
|
|
557
|
-
case
|
|
558
|
-
_context6.next =
|
|
559
|
-
return
|
|
560
|
-
case
|
|
449
|
+
throw new BlockError(response.status);
|
|
450
|
+
case 7:
|
|
451
|
+
_context6.next = 9;
|
|
452
|
+
return response.json();
|
|
453
|
+
case 9:
|
|
561
454
|
result = _context6.sent;
|
|
562
455
|
if (!(result.errors && result.errors.length > 0)) {
|
|
563
|
-
_context6.next =
|
|
456
|
+
_context6.next = 12;
|
|
564
457
|
break;
|
|
565
458
|
}
|
|
566
459
|
throw new Error(result.errors.map(function (e) {
|
|
567
460
|
return e.message;
|
|
568
461
|
}).join(', '));
|
|
569
|
-
case
|
|
462
|
+
case 12:
|
|
570
463
|
if ((_result$data4 = result.data) !== null && _result$data4 !== void 0 && _result$data4.blockService_createBlock) {
|
|
571
|
-
_context6.next =
|
|
464
|
+
_context6.next = 14;
|
|
572
465
|
break;
|
|
573
466
|
}
|
|
574
467
|
throw new Error('No data returned from GraphQL mutation');
|
|
575
|
-
case
|
|
468
|
+
case 14:
|
|
576
469
|
return _context6.abrupt("return", result.data.blockService_createBlock);
|
|
577
|
-
case
|
|
578
|
-
requestBody = {
|
|
579
|
-
blockAri: blockAri,
|
|
580
|
-
blockInstanceId: blockInstanceId,
|
|
581
|
-
sourceAri: sourceAri,
|
|
582
|
-
product: product,
|
|
583
|
-
content: content
|
|
584
|
-
};
|
|
585
|
-
if (stepVersion !== undefined) {
|
|
586
|
-
requestBody.stepVersion = stepVersion;
|
|
587
|
-
}
|
|
588
|
-
if (status !== undefined) {
|
|
589
|
-
requestBody.status = status;
|
|
590
|
-
}
|
|
591
|
-
_context6.next = 21;
|
|
592
|
-
return fetchWithRetry("".concat(BLOCK_SERVICE_API_URL, "/block"), {
|
|
593
|
-
method: 'POST',
|
|
594
|
-
headers: COMMON_HEADERS,
|
|
595
|
-
body: JSON.stringify(requestBody)
|
|
596
|
-
});
|
|
597
|
-
case 21:
|
|
598
|
-
response = _context6.sent;
|
|
599
|
-
if (response.ok) {
|
|
600
|
-
_context6.next = 24;
|
|
601
|
-
break;
|
|
602
|
-
}
|
|
603
|
-
throw new BlockError(response.status);
|
|
604
|
-
case 24:
|
|
605
|
-
_context6.next = 26;
|
|
606
|
-
return response.json();
|
|
607
|
-
case 26:
|
|
608
|
-
return _context6.abrupt("return", _context6.sent);
|
|
609
|
-
case 27:
|
|
470
|
+
case 15:
|
|
610
471
|
case "end":
|
|
611
472
|
return _context6.stop();
|
|
612
473
|
}
|
|
@@ -618,86 +479,54 @@ export var createSyncedBlock = /*#__PURE__*/function () {
|
|
|
618
479
|
}();
|
|
619
480
|
export var updateReferenceSyncedBlockOnDocument = /*#__PURE__*/function () {
|
|
620
481
|
var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref10) {
|
|
621
|
-
var documentAri, blocks, _ref10$noContent, noContent, bodyData,
|
|
482
|
+
var documentAri, blocks, _ref10$noContent, noContent, bodyData, response, result, _result$data5;
|
|
622
483
|
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
623
484
|
while (1) switch (_context7.prev = _context7.next) {
|
|
624
485
|
case 0:
|
|
625
486
|
documentAri = _ref10.documentAri, blocks = _ref10.blocks, _ref10$noContent = _ref10.noContent, noContent = _ref10$noContent === void 0 ? true : _ref10$noContent;
|
|
626
|
-
if (!fg('platform_synced_block_patch_1')) {
|
|
627
|
-
_context7.next = 18;
|
|
628
|
-
break;
|
|
629
|
-
}
|
|
630
487
|
bodyData = {
|
|
631
488
|
query: buildUpdateDocumentReferencesMutation(documentAri, blocks, noContent),
|
|
632
489
|
operationName: UPDATE_DOCUMENT_REFERENCES_OPERATION_NAME
|
|
633
490
|
};
|
|
634
|
-
_context7.next =
|
|
491
|
+
_context7.next = 4;
|
|
635
492
|
return fetchWithRetry(GRAPHQL_ENDPOINT, {
|
|
636
493
|
method: 'POST',
|
|
637
494
|
headers: COMMON_HEADERS,
|
|
638
495
|
body: JSON.stringify(bodyData),
|
|
639
496
|
keepalive: true
|
|
640
497
|
});
|
|
641
|
-
case
|
|
642
|
-
|
|
643
|
-
if (
|
|
644
|
-
_context7.next =
|
|
498
|
+
case 4:
|
|
499
|
+
response = _context7.sent;
|
|
500
|
+
if (response.ok) {
|
|
501
|
+
_context7.next = 7;
|
|
645
502
|
break;
|
|
646
503
|
}
|
|
647
|
-
throw new BlockError(
|
|
648
|
-
case
|
|
649
|
-
_context7.next =
|
|
650
|
-
return
|
|
651
|
-
case
|
|
504
|
+
throw new BlockError(response.status);
|
|
505
|
+
case 7:
|
|
506
|
+
_context7.next = 9;
|
|
507
|
+
return response.json();
|
|
508
|
+
case 9:
|
|
652
509
|
result = _context7.sent;
|
|
653
510
|
if (!(result.errors && result.errors.length > 0)) {
|
|
654
|
-
_context7.next =
|
|
511
|
+
_context7.next = 12;
|
|
655
512
|
break;
|
|
656
513
|
}
|
|
657
514
|
throw new Error(result.errors.map(function (e) {
|
|
658
515
|
return e.message;
|
|
659
516
|
}).join(', '));
|
|
660
|
-
case
|
|
517
|
+
case 12:
|
|
661
518
|
if (noContent) {
|
|
662
|
-
_context7.next =
|
|
519
|
+
_context7.next = 16;
|
|
663
520
|
break;
|
|
664
521
|
}
|
|
665
522
|
if ((_result$data5 = result.data) !== null && _result$data5 !== void 0 && _result$data5.blockService_updateDocumentReferences) {
|
|
666
|
-
_context7.next =
|
|
523
|
+
_context7.next = 15;
|
|
667
524
|
break;
|
|
668
525
|
}
|
|
669
526
|
throw new Error('No data returned from GraphQL mutation');
|
|
670
|
-
case
|
|
527
|
+
case 15:
|
|
671
528
|
return _context7.abrupt("return", result.data.blockService_updateDocumentReferences);
|
|
672
|
-
case
|
|
673
|
-
return _context7.abrupt("return");
|
|
674
|
-
case 18:
|
|
675
|
-
_context7.next = 20;
|
|
676
|
-
return fetchWithRetry("".concat(BLOCK_SERVICE_API_URL, "/block/document/").concat(encodeURIComponent(documentAri), "/references?noContent=").concat(noContent), {
|
|
677
|
-
method: 'PUT',
|
|
678
|
-
headers: COMMON_HEADERS,
|
|
679
|
-
body: JSON.stringify({
|
|
680
|
-
blocks: blocks
|
|
681
|
-
}),
|
|
682
|
-
keepalive: true
|
|
683
|
-
});
|
|
684
|
-
case 20:
|
|
685
|
-
response = _context7.sent;
|
|
686
|
-
if (response.ok) {
|
|
687
|
-
_context7.next = 23;
|
|
688
|
-
break;
|
|
689
|
-
}
|
|
690
|
-
throw new BlockError(response.status);
|
|
691
|
-
case 23:
|
|
692
|
-
if (noContent) {
|
|
693
|
-
_context7.next = 27;
|
|
694
|
-
break;
|
|
695
|
-
}
|
|
696
|
-
_context7.next = 26;
|
|
697
|
-
return response.json();
|
|
698
|
-
case 26:
|
|
699
|
-
return _context7.abrupt("return", _context7.sent);
|
|
700
|
-
case 27:
|
|
529
|
+
case 16:
|
|
701
530
|
case "end":
|
|
702
531
|
return _context7.stop();
|
|
703
532
|
}
|
|
@@ -709,76 +538,55 @@ export var updateReferenceSyncedBlockOnDocument = /*#__PURE__*/function () {
|
|
|
709
538
|
}();
|
|
710
539
|
export var getReferenceSyncedBlocksByBlockAri = /*#__PURE__*/function () {
|
|
711
540
|
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref12) {
|
|
712
|
-
var
|
|
541
|
+
var _result$data6;
|
|
542
|
+
var blockAri, bodyData, response, result, graphqlResponse;
|
|
713
543
|
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
714
544
|
while (1) switch (_context8.prev = _context8.next) {
|
|
715
545
|
case 0:
|
|
716
546
|
blockAri = _ref12.blockAri;
|
|
717
|
-
if (!fg('platform_synced_block_patch_1')) {
|
|
718
|
-
_context8.next = 17;
|
|
719
|
-
break;
|
|
720
|
-
}
|
|
721
547
|
bodyData = {
|
|
722
548
|
query: buildGetBlockReferencesQuery(blockAri),
|
|
723
549
|
operationName: GET_BLOCK_REFERENCES_OPERATION_NAME
|
|
724
550
|
};
|
|
725
|
-
_context8.next =
|
|
551
|
+
_context8.next = 4;
|
|
726
552
|
return fetchWithRetry(GRAPHQL_ENDPOINT, {
|
|
727
553
|
method: 'POST',
|
|
728
554
|
headers: COMMON_HEADERS,
|
|
729
555
|
body: JSON.stringify(bodyData)
|
|
730
556
|
});
|
|
731
|
-
case
|
|
732
|
-
|
|
733
|
-
if (
|
|
734
|
-
_context8.next =
|
|
557
|
+
case 4:
|
|
558
|
+
response = _context8.sent;
|
|
559
|
+
if (response.ok) {
|
|
560
|
+
_context8.next = 7;
|
|
735
561
|
break;
|
|
736
562
|
}
|
|
737
|
-
throw new BlockError(
|
|
738
|
-
case
|
|
739
|
-
_context8.next =
|
|
740
|
-
return
|
|
741
|
-
case
|
|
563
|
+
throw new BlockError(response.status);
|
|
564
|
+
case 7:
|
|
565
|
+
_context8.next = 9;
|
|
566
|
+
return response.json();
|
|
567
|
+
case 9:
|
|
742
568
|
result = _context8.sent;
|
|
743
569
|
if (!(result.errors && result.errors.length > 0)) {
|
|
744
|
-
_context8.next =
|
|
570
|
+
_context8.next = 12;
|
|
745
571
|
break;
|
|
746
572
|
}
|
|
747
573
|
throw new Error(result.errors.map(function (e) {
|
|
748
574
|
return e.message;
|
|
749
575
|
}).join(', '));
|
|
750
|
-
case
|
|
576
|
+
case 12:
|
|
751
577
|
if ((_result$data6 = result.data) !== null && _result$data6 !== void 0 && _result$data6.blockService_getReferences) {
|
|
752
|
-
_context8.next =
|
|
578
|
+
_context8.next = 14;
|
|
753
579
|
break;
|
|
754
580
|
}
|
|
755
581
|
throw new Error('No data returned from GraphQL query');
|
|
756
|
-
case
|
|
582
|
+
case 14:
|
|
757
583
|
graphqlResponse = result.data.blockService_getReferences;
|
|
758
584
|
return _context8.abrupt("return", {
|
|
759
585
|
blockAri: blockAri,
|
|
760
586
|
references: graphqlResponse.references || [],
|
|
761
587
|
errors: graphqlResponse.errors || []
|
|
762
588
|
});
|
|
763
|
-
case
|
|
764
|
-
_context8.next = 19;
|
|
765
|
-
return fetchWithRetry("".concat(BLOCK_SERVICE_API_URL, "/reference/batch-retrieve/").concat(encodeURIComponent(blockAri)), {
|
|
766
|
-
method: 'GET',
|
|
767
|
-
headers: COMMON_HEADERS
|
|
768
|
-
});
|
|
769
|
-
case 19:
|
|
770
|
-
response = _context8.sent;
|
|
771
|
-
if (response.ok) {
|
|
772
|
-
_context8.next = 22;
|
|
773
|
-
break;
|
|
774
|
-
}
|
|
775
|
-
throw new BlockError(response.status);
|
|
776
|
-
case 22:
|
|
777
|
-
_context8.next = 24;
|
|
778
|
-
return response.json();
|
|
779
|
-
case 24:
|
|
780
|
-
return _context8.abrupt("return", _context8.sent);
|
|
781
|
-
case 25:
|
|
589
|
+
case 16:
|
|
782
590
|
case "end":
|
|
783
591
|
return _context8.stop();
|
|
784
592
|
}
|