@atlaskit/editor-synced-block-provider 3.28.0 → 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 +8 -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 +20 -68
- 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 +34 -80
- 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 +20 -68
- 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 +0 -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 +0 -2
- package/dist/types-ts4.5/store-manager/sourceSyncBlockStoreManager.d.ts +0 -14
- package/package.json +1 -4
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
1
|
import { fetchWithRetry } from '../../utils/retry';
|
|
3
2
|
export const isBlockContentResponse = response => {
|
|
4
3
|
const content = response.content;
|
|
@@ -71,7 +70,6 @@ const COMMON_HEADERS = {
|
|
|
71
70
|
'Content-Type': 'application/json',
|
|
72
71
|
Accept: 'application/json'
|
|
73
72
|
};
|
|
74
|
-
const BLOCK_SERVICE_API_URL = '/gateway/api/blocks/v1';
|
|
75
73
|
const GRAPHQL_ENDPOINT = '/gateway/api/graphql';
|
|
76
74
|
const GET_DOCUMENT_REFERENCE_BLOCKS_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_GET_DOCUMENT_REFERENCE_BLOCKS';
|
|
77
75
|
const UPDATE_BLOCK_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_UPDATE_BLOCK';
|
|
@@ -122,7 +120,7 @@ const buildUpdateBlockMutation = (blockAri, content, stepVersion, status) => {
|
|
|
122
120
|
if (stepVersion !== undefined) {
|
|
123
121
|
inputParts.push(`stepVersion: ${stepVersion}`);
|
|
124
122
|
}
|
|
125
|
-
if (status !== undefined
|
|
123
|
+
if (status !== undefined) {
|
|
126
124
|
inputParts.push(`status: ${JSON.stringify(status)}`);
|
|
127
125
|
}
|
|
128
126
|
const inputArgs = inputParts.join(', ');
|
|
@@ -260,134 +258,91 @@ export class BlockError extends Error {
|
|
|
260
258
|
export const getSyncedBlockContent = async ({
|
|
261
259
|
blockAri
|
|
262
260
|
}) => {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
body: JSON.stringify(bodyData)
|
|
273
|
-
});
|
|
274
|
-
if (!response.ok) {
|
|
275
|
-
throw new BlockError(response.status);
|
|
276
|
-
}
|
|
277
|
-
const result = await response.json();
|
|
278
|
-
if (result.errors && result.errors.length > 0) {
|
|
279
|
-
throw new Error(result.errors.map(e => e.message).join(', '));
|
|
280
|
-
}
|
|
281
|
-
if (!((_result$data = result.data) !== null && _result$data !== void 0 && _result$data.blockService_getBlock)) {
|
|
282
|
-
throw new Error('No data returned from GraphQL query');
|
|
283
|
-
}
|
|
284
|
-
return result.data.blockService_getBlock;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
// Disable sending documentAri for now. We'll add it back if we find a way to update references that follows the save & refresh principle.
|
|
288
|
-
// Slack discussion here: https://atlassian.slack.com/archives/C09DZT1TBNW/p1767836775552099?thread_ts=1767836754.024889&cid=C09DZT1TBNW
|
|
289
|
-
// const queryParams = documentAri ? `?documentAri=${encodeURIComponent(documentAri)}` : '';
|
|
290
|
-
const queryParams = '';
|
|
291
|
-
const response = await fetchWithRetry(`${BLOCK_SERVICE_API_URL}/block/${encodeURIComponent(blockAri)}` + queryParams, {
|
|
292
|
-
method: 'GET',
|
|
293
|
-
headers: COMMON_HEADERS
|
|
261
|
+
var _result$data;
|
|
262
|
+
const bodyData = {
|
|
263
|
+
query: buildGetBlockQuery(blockAri),
|
|
264
|
+
operationName: GET_BLOCK_OPERATION_NAME
|
|
265
|
+
};
|
|
266
|
+
const response = await fetchWithRetry(GRAPHQL_ENDPOINT, {
|
|
267
|
+
method: 'POST',
|
|
268
|
+
headers: COMMON_HEADERS,
|
|
269
|
+
body: JSON.stringify(bodyData)
|
|
294
270
|
});
|
|
295
271
|
if (!response.ok) {
|
|
296
272
|
throw new BlockError(response.status);
|
|
297
273
|
}
|
|
298
|
-
|
|
274
|
+
const result = await response.json();
|
|
275
|
+
if (result.errors && result.errors.length > 0) {
|
|
276
|
+
throw new Error(result.errors.map(e => e.message).join(', '));
|
|
277
|
+
}
|
|
278
|
+
if (!((_result$data = result.data) !== null && _result$data !== void 0 && _result$data.blockService_getBlock)) {
|
|
279
|
+
throw new Error('No data returned from GraphQL query');
|
|
280
|
+
}
|
|
281
|
+
return result.data.blockService_getBlock;
|
|
299
282
|
};
|
|
300
283
|
|
|
301
284
|
/**
|
|
302
285
|
* Batch retrieves multiple synced blocks by their ARIs.
|
|
303
286
|
*
|
|
304
|
-
* Calls the Block Service API
|
|
305
|
-
* or GraphQL query `blockService_batchRetrieveBlocks` when feature flag is enabled
|
|
287
|
+
* Calls the Block Service GraphQL API: `blockService_batchRetrieveBlocks`
|
|
306
288
|
*
|
|
307
|
-
* @param
|
|
289
|
+
* @param blockIdentifiers - Array of block identifiers to retrieve
|
|
308
290
|
* @returns A promise containing arrays of successfully fetched blocks and any errors encountered
|
|
309
291
|
*/
|
|
310
292
|
export const batchRetrieveSyncedBlocks = async ({
|
|
311
|
-
blockIdentifiers
|
|
312
|
-
documentAri
|
|
293
|
+
blockIdentifiers
|
|
313
294
|
}) => {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
const response = await fetchWithRetry(GRAPHQL_ENDPOINT, {
|
|
322
|
-
method: 'POST',
|
|
323
|
-
headers: COMMON_HEADERS,
|
|
324
|
-
body: JSON.stringify(bodyData)
|
|
325
|
-
});
|
|
326
|
-
if (!response.ok) {
|
|
327
|
-
throw new BlockError(response.status);
|
|
328
|
-
}
|
|
329
|
-
const result = await response.json();
|
|
330
|
-
if (result.errors && result.errors.length > 0) {
|
|
331
|
-
throw new Error(result.errors.map(e => e.message).join(', '));
|
|
332
|
-
}
|
|
333
|
-
if (!((_result$data2 = result.data) !== null && _result$data2 !== void 0 && _result$data2.blockService_batchRetrieveBlocks)) {
|
|
334
|
-
throw new Error('No data returned from GraphQL query');
|
|
335
|
-
}
|
|
336
|
-
const graphqlResponse = result.data.blockService_batchRetrieveBlocks;
|
|
337
|
-
return {
|
|
338
|
-
success: graphqlResponse.success,
|
|
339
|
-
error: graphqlResponse.error
|
|
340
|
-
};
|
|
341
|
-
}
|
|
342
|
-
const response = await fetchWithRetry(`${BLOCK_SERVICE_API_URL}/block/batch-retrieve`, {
|
|
295
|
+
var _result$data2;
|
|
296
|
+
const blockAris = blockIdentifiers.map(blockIdentifier => blockIdentifier.blockAri);
|
|
297
|
+
const bodyData = {
|
|
298
|
+
query: buildBatchRetrieveBlocksQuery(blockAris),
|
|
299
|
+
operationName: BATCH_RETRIEVE_BLOCKS_OPERATION_NAME
|
|
300
|
+
};
|
|
301
|
+
const response = await fetchWithRetry(GRAPHQL_ENDPOINT, {
|
|
343
302
|
method: 'POST',
|
|
344
303
|
headers: COMMON_HEADERS,
|
|
345
|
-
body: JSON.stringify(
|
|
346
|
-
documentAri,
|
|
347
|
-
blockIdentifiers,
|
|
348
|
-
blockAris: blockIdentifiers.map(blockIdentifier => blockIdentifier.blockAri)
|
|
349
|
-
})
|
|
304
|
+
body: JSON.stringify(bodyData)
|
|
350
305
|
});
|
|
351
306
|
if (!response.ok) {
|
|
352
307
|
throw new BlockError(response.status);
|
|
353
308
|
}
|
|
354
|
-
|
|
309
|
+
const result = await response.json();
|
|
310
|
+
if (result.errors && result.errors.length > 0) {
|
|
311
|
+
throw new Error(result.errors.map(e => e.message).join(', '));
|
|
312
|
+
}
|
|
313
|
+
if (!((_result$data2 = result.data) !== null && _result$data2 !== void 0 && _result$data2.blockService_batchRetrieveBlocks)) {
|
|
314
|
+
throw new Error('No data returned from GraphQL query');
|
|
315
|
+
}
|
|
316
|
+
const graphqlResponse = result.data.blockService_batchRetrieveBlocks;
|
|
317
|
+
return {
|
|
318
|
+
success: graphqlResponse.success,
|
|
319
|
+
error: graphqlResponse.error
|
|
320
|
+
};
|
|
355
321
|
};
|
|
356
322
|
export const deleteSyncedBlock = async ({
|
|
357
323
|
blockAri,
|
|
358
324
|
deleteReason
|
|
359
325
|
}) => {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
body: JSON.stringify(bodyData)
|
|
370
|
-
});
|
|
371
|
-
if (!response.ok) {
|
|
372
|
-
throw new BlockError(response.status);
|
|
373
|
-
}
|
|
374
|
-
const result = await response.json();
|
|
375
|
-
if (result.errors && result.errors.length > 0) {
|
|
376
|
-
throw new Error(result.errors.map(e => e.message).join(', '));
|
|
377
|
-
}
|
|
378
|
-
if (!((_result$data3 = result.data) !== null && _result$data3 !== void 0 && _result$data3.blockService_deleteBlock.deleted)) {
|
|
379
|
-
throw new Error('Block deletion failed; deleted flag is false');
|
|
380
|
-
}
|
|
381
|
-
return;
|
|
382
|
-
}
|
|
383
|
-
const url = deleteReason ? `${BLOCK_SERVICE_API_URL}/block/${encodeURIComponent(blockAri)}?deletionReason=${encodeURIComponent(deleteReason)}` : `${BLOCK_SERVICE_API_URL}/block/${encodeURIComponent(blockAri)}`;
|
|
384
|
-
const response = await fetchWithRetry(url, {
|
|
385
|
-
method: 'DELETE',
|
|
386
|
-
headers: COMMON_HEADERS
|
|
326
|
+
var _result$data3;
|
|
327
|
+
const bodyData = {
|
|
328
|
+
query: buildDeleteBlockMutation(blockAri, deleteReason),
|
|
329
|
+
operationName: DELETE_BLOCK_OPERATION_NAME
|
|
330
|
+
};
|
|
331
|
+
const response = await fetchWithRetry(GRAPHQL_ENDPOINT, {
|
|
332
|
+
method: 'POST',
|
|
333
|
+
headers: COMMON_HEADERS,
|
|
334
|
+
body: JSON.stringify(bodyData)
|
|
387
335
|
});
|
|
388
336
|
if (!response.ok) {
|
|
389
337
|
throw new BlockError(response.status);
|
|
390
338
|
}
|
|
339
|
+
const result = await response.json();
|
|
340
|
+
if (result.errors && result.errors.length > 0) {
|
|
341
|
+
throw new Error(result.errors.map(e => e.message).join(', '));
|
|
342
|
+
}
|
|
343
|
+
if (!((_result$data3 = result.data) !== null && _result$data3 !== void 0 && _result$data3.blockService_deleteBlock.deleted)) {
|
|
344
|
+
throw new Error('Block deletion failed; deleted flag is false');
|
|
345
|
+
}
|
|
391
346
|
};
|
|
392
347
|
export const updateSyncedBlock = async ({
|
|
393
348
|
blockAri,
|
|
@@ -395,42 +350,22 @@ export const updateSyncedBlock = async ({
|
|
|
395
350
|
stepVersion,
|
|
396
351
|
status
|
|
397
352
|
}) => {
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
operationName: UPDATE_BLOCK_OPERATION_NAME
|
|
402
|
-
};
|
|
403
|
-
const response = await fetchWithRetry(GRAPHQL_ENDPOINT, {
|
|
404
|
-
method: 'POST',
|
|
405
|
-
headers: COMMON_HEADERS,
|
|
406
|
-
body: JSON.stringify(bodyData)
|
|
407
|
-
});
|
|
408
|
-
if (!response.ok) {
|
|
409
|
-
throw new BlockError(response.status);
|
|
410
|
-
}
|
|
411
|
-
const result = await response.json();
|
|
412
|
-
if (result.errors && result.errors.length > 0) {
|
|
413
|
-
throw new Error(result.errors.map(e => e.message).join(', '));
|
|
414
|
-
}
|
|
415
|
-
return;
|
|
416
|
-
}
|
|
417
|
-
const requestBody = {
|
|
418
|
-
content
|
|
353
|
+
const bodyData = {
|
|
354
|
+
query: buildUpdateBlockMutation(blockAri, content, stepVersion, status),
|
|
355
|
+
operationName: UPDATE_BLOCK_OPERATION_NAME
|
|
419
356
|
};
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
}
|
|
423
|
-
if (status !== undefined && fg('platform_synced_block_patch_1')) {
|
|
424
|
-
requestBody.status = status;
|
|
425
|
-
}
|
|
426
|
-
const response = await fetchWithRetry(`${BLOCK_SERVICE_API_URL}/block/${encodeURIComponent(blockAri)}`, {
|
|
427
|
-
method: 'PUT',
|
|
357
|
+
const response = await fetchWithRetry(GRAPHQL_ENDPOINT, {
|
|
358
|
+
method: 'POST',
|
|
428
359
|
headers: COMMON_HEADERS,
|
|
429
|
-
body: JSON.stringify(
|
|
360
|
+
body: JSON.stringify(bodyData)
|
|
430
361
|
});
|
|
431
362
|
if (!response.ok) {
|
|
432
363
|
throw new BlockError(response.status);
|
|
433
364
|
}
|
|
365
|
+
const result = await response.json();
|
|
366
|
+
if (result.errors && result.errors.length > 0) {
|
|
367
|
+
throw new Error(result.errors.map(e => e.message).join(', '));
|
|
368
|
+
}
|
|
434
369
|
};
|
|
435
370
|
export const createSyncedBlock = async ({
|
|
436
371
|
blockAri,
|
|
@@ -441,136 +376,85 @@ export const createSyncedBlock = async ({
|
|
|
441
376
|
stepVersion,
|
|
442
377
|
status
|
|
443
378
|
}) => {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
operationName: CREATE_BLOCK_OPERATION_NAME
|
|
449
|
-
};
|
|
450
|
-
const response = await fetchWithRetry(GRAPHQL_ENDPOINT, {
|
|
451
|
-
method: 'POST',
|
|
452
|
-
headers: COMMON_HEADERS,
|
|
453
|
-
body: JSON.stringify(bodyData)
|
|
454
|
-
});
|
|
455
|
-
if (!response.ok) {
|
|
456
|
-
throw new BlockError(response.status);
|
|
457
|
-
}
|
|
458
|
-
const result = await response.json();
|
|
459
|
-
if (result.errors && result.errors.length > 0) {
|
|
460
|
-
throw new Error(result.errors.map(e => e.message).join(', '));
|
|
461
|
-
}
|
|
462
|
-
if (!((_result$data4 = result.data) !== null && _result$data4 !== void 0 && _result$data4.blockService_createBlock)) {
|
|
463
|
-
throw new Error('No data returned from GraphQL mutation');
|
|
464
|
-
}
|
|
465
|
-
return result.data.blockService_createBlock;
|
|
466
|
-
}
|
|
467
|
-
const requestBody = {
|
|
468
|
-
blockAri,
|
|
469
|
-
blockInstanceId,
|
|
470
|
-
sourceAri,
|
|
471
|
-
product,
|
|
472
|
-
content
|
|
379
|
+
var _result$data4;
|
|
380
|
+
const bodyData = {
|
|
381
|
+
query: buildCreateBlockMutation(blockAri, blockInstanceId, content, product, sourceAri, stepVersion, status),
|
|
382
|
+
operationName: CREATE_BLOCK_OPERATION_NAME
|
|
473
383
|
};
|
|
474
|
-
|
|
475
|
-
requestBody.stepVersion = stepVersion;
|
|
476
|
-
}
|
|
477
|
-
if (status !== undefined) {
|
|
478
|
-
requestBody.status = status;
|
|
479
|
-
}
|
|
480
|
-
const response = await fetchWithRetry(`${BLOCK_SERVICE_API_URL}/block`, {
|
|
384
|
+
const response = await fetchWithRetry(GRAPHQL_ENDPOINT, {
|
|
481
385
|
method: 'POST',
|
|
482
386
|
headers: COMMON_HEADERS,
|
|
483
|
-
body: JSON.stringify(
|
|
387
|
+
body: JSON.stringify(bodyData)
|
|
484
388
|
});
|
|
485
389
|
if (!response.ok) {
|
|
486
390
|
throw new BlockError(response.status);
|
|
487
391
|
}
|
|
488
|
-
|
|
392
|
+
const result = await response.json();
|
|
393
|
+
if (result.errors && result.errors.length > 0) {
|
|
394
|
+
throw new Error(result.errors.map(e => e.message).join(', '));
|
|
395
|
+
}
|
|
396
|
+
if (!((_result$data4 = result.data) !== null && _result$data4 !== void 0 && _result$data4.blockService_createBlock)) {
|
|
397
|
+
throw new Error('No data returned from GraphQL mutation');
|
|
398
|
+
}
|
|
399
|
+
return result.data.blockService_createBlock;
|
|
489
400
|
};
|
|
490
401
|
export const updateReferenceSyncedBlockOnDocument = async ({
|
|
491
402
|
documentAri,
|
|
492
403
|
blocks,
|
|
493
404
|
noContent = true
|
|
494
405
|
}) => {
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
method: 'POST',
|
|
502
|
-
headers: COMMON_HEADERS,
|
|
503
|
-
body: JSON.stringify(bodyData),
|
|
504
|
-
keepalive: true
|
|
505
|
-
});
|
|
506
|
-
if (!response.ok) {
|
|
507
|
-
throw new BlockError(response.status);
|
|
508
|
-
}
|
|
509
|
-
const result = await response.json();
|
|
510
|
-
if (result.errors && result.errors.length > 0) {
|
|
511
|
-
throw new Error(result.errors.map(e => e.message).join(', '));
|
|
512
|
-
}
|
|
513
|
-
if (!noContent) {
|
|
514
|
-
var _result$data5;
|
|
515
|
-
if (!((_result$data5 = result.data) !== null && _result$data5 !== void 0 && _result$data5.blockService_updateDocumentReferences)) {
|
|
516
|
-
throw new Error('No data returned from GraphQL mutation');
|
|
517
|
-
}
|
|
518
|
-
return result.data.blockService_updateDocumentReferences;
|
|
519
|
-
}
|
|
520
|
-
return;
|
|
521
|
-
}
|
|
522
|
-
const response = await fetchWithRetry(`${BLOCK_SERVICE_API_URL}/block/document/${encodeURIComponent(documentAri)}/references?noContent=${noContent}`, {
|
|
523
|
-
method: 'PUT',
|
|
406
|
+
const bodyData = {
|
|
407
|
+
query: buildUpdateDocumentReferencesMutation(documentAri, blocks, noContent),
|
|
408
|
+
operationName: UPDATE_DOCUMENT_REFERENCES_OPERATION_NAME
|
|
409
|
+
};
|
|
410
|
+
const response = await fetchWithRetry(GRAPHQL_ENDPOINT, {
|
|
411
|
+
method: 'POST',
|
|
524
412
|
headers: COMMON_HEADERS,
|
|
525
|
-
body: JSON.stringify(
|
|
526
|
-
blocks
|
|
527
|
-
}),
|
|
413
|
+
body: JSON.stringify(bodyData),
|
|
528
414
|
keepalive: true
|
|
529
415
|
});
|
|
530
416
|
if (!response.ok) {
|
|
531
417
|
throw new BlockError(response.status);
|
|
532
418
|
}
|
|
419
|
+
const result = await response.json();
|
|
420
|
+
if (result.errors && result.errors.length > 0) {
|
|
421
|
+
throw new Error(result.errors.map(e => e.message).join(', '));
|
|
422
|
+
}
|
|
533
423
|
if (!noContent) {
|
|
534
|
-
|
|
424
|
+
var _result$data5;
|
|
425
|
+
if (!((_result$data5 = result.data) !== null && _result$data5 !== void 0 && _result$data5.blockService_updateDocumentReferences)) {
|
|
426
|
+
throw new Error('No data returned from GraphQL mutation');
|
|
427
|
+
}
|
|
428
|
+
return result.data.blockService_updateDocumentReferences;
|
|
535
429
|
}
|
|
536
430
|
};
|
|
537
431
|
export const getReferenceSyncedBlocksByBlockAri = async ({
|
|
538
432
|
blockAri
|
|
539
433
|
}) => {
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
body: JSON.stringify(bodyData)
|
|
550
|
-
});
|
|
551
|
-
if (!response.ok) {
|
|
552
|
-
throw new BlockError(response.status);
|
|
553
|
-
}
|
|
554
|
-
const result = await response.json();
|
|
555
|
-
if (result.errors && result.errors.length > 0) {
|
|
556
|
-
throw new Error(result.errors.map(e => e.message).join(', '));
|
|
557
|
-
}
|
|
558
|
-
if (!((_result$data6 = result.data) !== null && _result$data6 !== void 0 && _result$data6.blockService_getReferences)) {
|
|
559
|
-
throw new Error('No data returned from GraphQL query');
|
|
560
|
-
}
|
|
561
|
-
const graphqlResponse = result.data.blockService_getReferences;
|
|
562
|
-
return {
|
|
563
|
-
blockAri,
|
|
564
|
-
references: graphqlResponse.references || [],
|
|
565
|
-
errors: graphqlResponse.errors || []
|
|
566
|
-
};
|
|
567
|
-
}
|
|
568
|
-
const response = await fetchWithRetry(`${BLOCK_SERVICE_API_URL}/reference/batch-retrieve/${encodeURIComponent(blockAri)}`, {
|
|
569
|
-
method: 'GET',
|
|
570
|
-
headers: COMMON_HEADERS
|
|
434
|
+
var _result$data6;
|
|
435
|
+
const bodyData = {
|
|
436
|
+
query: buildGetBlockReferencesQuery(blockAri),
|
|
437
|
+
operationName: GET_BLOCK_REFERENCES_OPERATION_NAME
|
|
438
|
+
};
|
|
439
|
+
const response = await fetchWithRetry(GRAPHQL_ENDPOINT, {
|
|
440
|
+
method: 'POST',
|
|
441
|
+
headers: COMMON_HEADERS,
|
|
442
|
+
body: JSON.stringify(bodyData)
|
|
571
443
|
});
|
|
572
444
|
if (!response.ok) {
|
|
573
445
|
throw new BlockError(response.status);
|
|
574
446
|
}
|
|
575
|
-
|
|
447
|
+
const result = await response.json();
|
|
448
|
+
if (result.errors && result.errors.length > 0) {
|
|
449
|
+
throw new Error(result.errors.map(e => e.message).join(', '));
|
|
450
|
+
}
|
|
451
|
+
if (!((_result$data6 = result.data) !== null && _result$data6 !== void 0 && _result$data6.blockService_getReferences)) {
|
|
452
|
+
throw new Error('No data returned from GraphQL query');
|
|
453
|
+
}
|
|
454
|
+
const graphqlResponse = result.data.blockService_getReferences;
|
|
455
|
+
return {
|
|
456
|
+
blockAri,
|
|
457
|
+
references: graphqlResponse.references || [],
|
|
458
|
+
errors: graphqlResponse.errors || []
|
|
459
|
+
};
|
|
576
460
|
};
|
|
@@ -174,7 +174,7 @@ export const fetchConfluencePageInfoOld = async (pageAri, localId, fireAnalytics
|
|
|
174
174
|
};
|
|
175
175
|
export const fetchConfluencePageInfo = async (pageAri, hasAccess, urlType, localId, isUnpublished) => {
|
|
176
176
|
// For unpublished pages, use the v2 pages API as GraphQL returns empty content.nodes
|
|
177
|
-
if (isUnpublished
|
|
177
|
+
if (isUnpublished) {
|
|
178
178
|
if (!fg('platform_synced_block_patch_2')) {
|
|
179
179
|
return await fetchCompleteConfluencePageInfo(pageAri, localId);
|
|
180
180
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/* eslint-disable require-unicode-regexp */
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
3
|
import { generateBlockAri, generateBlockAriFromReference } from '../../clients/block-service/ari';
|
|
5
4
|
import { batchRetrieveSyncedBlocks, BlockError, createSyncedBlock, deleteSyncedBlock, getReferenceSyncedBlocks, getReferenceSyncedBlocksByBlockAri, getSyncedBlockContent, updateReferenceSyncedBlockOnDocument, updateSyncedBlock } from '../../clients/block-service/blockService';
|
|
6
5
|
import { subscribeToBlockUpdates as subscribeToBlockUpdatesWS } from '../../clients/block-service/blockSubscription';
|
|
@@ -193,7 +192,6 @@ export const batchFetchData = async (cloudId, parentAri, blockNodeIdentifiers) =
|
|
|
193
192
|
}
|
|
194
193
|
try {
|
|
195
194
|
const response = await batchRetrieveSyncedBlocks({
|
|
196
|
-
documentAri: parentAri,
|
|
197
195
|
blockIdentifiers
|
|
198
196
|
});
|
|
199
197
|
const results = [];
|
|
@@ -315,8 +313,7 @@ class BlockServiceADFFetchProvider {
|
|
|
315
313
|
});
|
|
316
314
|
try {
|
|
317
315
|
const blockContentResponse = await getSyncedBlockContent({
|
|
318
|
-
blockAri
|
|
319
|
-
documentAri: this.parentAri
|
|
316
|
+
blockAri
|
|
320
317
|
});
|
|
321
318
|
const {
|
|
322
319
|
content,
|
|
@@ -463,15 +460,13 @@ class BlockServiceADFWriteProvider {
|
|
|
463
460
|
parentAri,
|
|
464
461
|
parentId,
|
|
465
462
|
product,
|
|
466
|
-
getVersion
|
|
467
|
-
isParentUnpublished
|
|
463
|
+
getVersion
|
|
468
464
|
}) {
|
|
469
465
|
this.cloudId = cloudId;
|
|
470
466
|
this.parentAri = parentAri;
|
|
471
467
|
this.parentId = parentId;
|
|
472
468
|
this.product = product;
|
|
473
469
|
this.getVersion = getVersion;
|
|
474
|
-
this.isParentUnpublished = isParentUnpublished;
|
|
475
470
|
}
|
|
476
471
|
|
|
477
472
|
// it will first try to update and if it can't (404) then it will try to create
|
|
@@ -516,7 +511,6 @@ class BlockServiceADFWriteProvider {
|
|
|
516
511
|
}
|
|
517
512
|
}
|
|
518
513
|
async createData(data) {
|
|
519
|
-
var _this$isParentUnpubli;
|
|
520
514
|
if (!this.parentAri || !this.parentId) {
|
|
521
515
|
return {
|
|
522
516
|
error: SyncBlockError.Errored
|
|
@@ -532,7 +526,7 @@ class BlockServiceADFWriteProvider {
|
|
|
532
526
|
resourceId
|
|
533
527
|
});
|
|
534
528
|
const stepVersion = this.getVersion ? await this.getVersion() : undefined;
|
|
535
|
-
const status =
|
|
529
|
+
const status = 'unpublished';
|
|
536
530
|
try {
|
|
537
531
|
await createSyncedBlock({
|
|
538
532
|
blockAri,
|
|
@@ -657,8 +651,7 @@ const createBlockServiceAPIProviders = ({
|
|
|
657
651
|
parentAri,
|
|
658
652
|
parentId,
|
|
659
653
|
product,
|
|
660
|
-
getVersion
|
|
661
|
-
isParentUnpublished
|
|
654
|
+
getVersion
|
|
662
655
|
}) => {
|
|
663
656
|
return {
|
|
664
657
|
fetchProvider: new BlockServiceADFFetchProvider({
|
|
@@ -670,8 +663,7 @@ const createBlockServiceAPIProviders = ({
|
|
|
670
663
|
parentAri,
|
|
671
664
|
parentId,
|
|
672
665
|
product,
|
|
673
|
-
getVersion
|
|
674
|
-
isParentUnpublished
|
|
666
|
+
getVersion
|
|
675
667
|
})
|
|
676
668
|
};
|
|
677
669
|
};
|
|
@@ -680,8 +672,7 @@ export const useMemoizedBlockServiceAPIProviders = ({
|
|
|
680
672
|
parentAri,
|
|
681
673
|
parentId,
|
|
682
674
|
product,
|
|
683
|
-
getVersion
|
|
684
|
-
isParentUnpublished
|
|
675
|
+
getVersion
|
|
685
676
|
}) => {
|
|
686
677
|
return useMemo(() => {
|
|
687
678
|
return createBlockServiceAPIProviders({
|
|
@@ -689,10 +680,9 @@ export const useMemoizedBlockServiceAPIProviders = ({
|
|
|
689
680
|
parentAri,
|
|
690
681
|
parentId,
|
|
691
682
|
product,
|
|
692
|
-
getVersion
|
|
693
|
-
isParentUnpublished
|
|
683
|
+
getVersion
|
|
694
684
|
});
|
|
695
|
-
}, [cloudId, parentAri, parentId, product, getVersion
|
|
685
|
+
}, [cloudId, parentAri, parentId, product, getVersion]);
|
|
696
686
|
};
|
|
697
687
|
const createBlockServiceFetchOnlyAPIProvider = ({
|
|
698
688
|
cloudId,
|