@atlaskit/editor-synced-block-provider 3.31.2 → 3.31.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/clients/block-service/blockService.js +20 -21
  3. package/dist/cjs/clients/confluence/fetchMediaToken.js +1 -2
  4. package/dist/cjs/clients/confluence/sourceInfo.js +27 -176
  5. package/dist/cjs/hooks/useFetchSyncBlockData.js +2 -9
  6. package/dist/cjs/hooks/useFetchSyncBlockTitle.js +8 -40
  7. package/dist/cjs/providers/block-service/blockServiceAPI.js +11 -27
  8. package/dist/cjs/providers/syncBlockProvider.js +22 -51
  9. package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +14 -29
  10. package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +1 -1
  11. package/dist/cjs/store-manager/syncBlockStoreManager.js +3 -15
  12. package/dist/cjs/store-manager/syncBlockSubscriptionManager.js +2 -2
  13. package/dist/cjs/utils/errorHandling.js +1 -10
  14. package/dist/cjs/utils/resolveSyncBlockInstance.js +11 -12
  15. package/dist/cjs/utils/retry.js +2 -23
  16. package/dist/es2019/clients/block-service/blockService.js +20 -21
  17. package/dist/es2019/clients/confluence/fetchMediaToken.js +1 -2
  18. package/dist/es2019/clients/confluence/sourceInfo.js +8 -126
  19. package/dist/es2019/hooks/useFetchSyncBlockData.js +1 -9
  20. package/dist/es2019/hooks/useFetchSyncBlockTitle.js +4 -33
  21. package/dist/es2019/providers/block-service/blockServiceAPI.js +11 -27
  22. package/dist/es2019/providers/syncBlockProvider.js +7 -29
  23. package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +27 -41
  24. package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +1 -1
  25. package/dist/es2019/store-manager/syncBlockStoreManager.js +3 -13
  26. package/dist/es2019/store-manager/syncBlockSubscriptionManager.js +2 -2
  27. package/dist/es2019/utils/errorHandling.js +1 -10
  28. package/dist/es2019/utils/resolveSyncBlockInstance.js +11 -12
  29. package/dist/es2019/utils/retry.js +2 -21
  30. package/dist/esm/clients/block-service/blockService.js +20 -21
  31. package/dist/esm/clients/confluence/fetchMediaToken.js +1 -2
  32. package/dist/esm/clients/confluence/sourceInfo.js +25 -176
  33. package/dist/esm/hooks/useFetchSyncBlockData.js +2 -9
  34. package/dist/esm/hooks/useFetchSyncBlockTitle.js +8 -40
  35. package/dist/esm/providers/block-service/blockServiceAPI.js +11 -27
  36. package/dist/esm/providers/syncBlockProvider.js +22 -51
  37. package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +14 -29
  38. package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +1 -1
  39. package/dist/esm/store-manager/syncBlockStoreManager.js +3 -15
  40. package/dist/esm/store-manager/syncBlockSubscriptionManager.js +2 -2
  41. package/dist/esm/utils/errorHandling.js +1 -10
  42. package/dist/esm/utils/resolveSyncBlockInstance.js +11 -12
  43. package/dist/esm/utils/retry.js +2 -23
  44. package/dist/types/clients/confluence/sourceInfo.d.ts +1 -3
  45. package/dist/types/providers/syncBlockProvider.d.ts +2 -3
  46. package/dist/types/providers/types.d.ts +1 -2
  47. package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +1 -1
  48. package/dist/types/store-manager/syncBlockStoreManager.d.ts +1 -1
  49. package/dist/types-ts4.5/clients/confluence/sourceInfo.d.ts +1 -3
  50. package/dist/types-ts4.5/providers/syncBlockProvider.d.ts +2 -3
  51. package/dist/types-ts4.5/providers/types.d.ts +1 -2
  52. package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +1 -1
  53. package/dist/types-ts4.5/store-manager/syncBlockStoreManager.d.ts +1 -1
  54. package/package.json +3 -10
@@ -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;
@@ -50,7 +49,7 @@ export const getReferenceSyncedBlocks = async documentAri => {
50
49
  query: buildGetDocumentReferenceBlocksQuery(documentAri),
51
50
  operationName: GET_DOCUMENT_REFERENCE_BLOCKS_OPERATION_NAME
52
51
  };
53
- const url = fg('platform_synced_block_patch_3') ? `${GRAPHQL_ENDPOINT}?operation=editorSyncedBlockGetDocumentReferenceBlocks` : GRAPHQL_ENDPOINT;
52
+ const url = `${GRAPHQL_ENDPOINT}?operation=editorSyncedBlockGetDocumentReferenceBlocks`;
54
53
  const response = await fetchWithRetry(url, {
55
54
  method: 'POST',
56
55
  headers: COMMON_HEADERS,
@@ -83,7 +82,7 @@ const GET_BLOCK_REFERENCES_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_GET_REFERENCES'
83
82
  const GET_BLOCK_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_GET_BLOCK';
84
83
  const BATCH_UPDATE_BLOCKS_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_BATCH_UPDATE_BLOCKS';
85
84
  const buildGetDocumentReferenceBlocksQuery = documentAri => `query ${GET_DOCUMENT_REFERENCE_BLOCKS_OPERATION_NAME} {
86
- blockService_getDocumentReferenceBlocks(documentAri: ${fg('platform_synced_block_patch_4') ? JSON.stringify(documentAri) : `"${documentAri}"`}) {
85
+ blockService_getDocumentReferenceBlocks(documentAri: ${JSON.stringify(documentAri)}) {
87
86
  blocks {
88
87
  blockAri
89
88
  blockInstanceId
@@ -306,7 +305,7 @@ export const getSyncedBlockContent = async ({
306
305
  query: buildGetBlockQuery(blockAri),
307
306
  operationName: GET_BLOCK_OPERATION_NAME
308
307
  };
309
- const url = fg('platform_synced_block_patch_3') ? `${GRAPHQL_ENDPOINT}?operation=editorSyncedBlockGetBlock` : GRAPHQL_ENDPOINT;
308
+ const url = `${GRAPHQL_ENDPOINT}?operation=editorSyncedBlockGetBlock`;
310
309
  const response = await fetchWithRetry(url, {
311
310
  method: 'POST',
312
311
  headers: COMMON_HEADERS,
@@ -342,7 +341,7 @@ export const batchRetrieveSyncedBlocks = async ({
342
341
  query: buildBatchRetrieveBlocksQuery(blockAris),
343
342
  operationName: BATCH_RETRIEVE_BLOCKS_OPERATION_NAME
344
343
  };
345
- const url = fg('platform_synced_block_patch_3') ? `${GRAPHQL_ENDPOINT}?operation=editorSyncedBlockBatchRetrieveBlocks` : GRAPHQL_ENDPOINT;
344
+ const url = `${GRAPHQL_ENDPOINT}?operation=editorSyncedBlockBatchRetrieveBlocks`;
346
345
  const response = await fetchWithRetry(url, {
347
346
  method: 'POST',
348
347
  headers: COMMON_HEADERS,
@@ -368,12 +367,12 @@ export const deleteSyncedBlock = async ({
368
367
  blockAri,
369
368
  deleteReason
370
369
  }) => {
371
- var _result$data3, _result$data3$blockSe, _result$data4;
370
+ var _result$data3, _result$data3$blockSe;
372
371
  const bodyData = {
373
372
  query: buildDeleteBlockMutation(blockAri, deleteReason),
374
373
  operationName: DELETE_BLOCK_OPERATION_NAME
375
374
  };
376
- const url = fg('platform_synced_block_patch_3') ? `${GRAPHQL_ENDPOINT}?operation=editorSyncedBlockDeleteBlock` : GRAPHQL_ENDPOINT;
375
+ const url = `${GRAPHQL_ENDPOINT}?operation=editorSyncedBlockDeleteBlock`;
377
376
  const response = await fetchWithRetry(url, {
378
377
  method: 'POST',
379
378
  headers: COMMON_HEADERS,
@@ -386,7 +385,7 @@ export const deleteSyncedBlock = async ({
386
385
  if (result.errors && result.errors.length > 0) {
387
386
  throw new Error(result.errors.map(e => e.message).join(', '));
388
387
  }
389
- const isDeleted = fg('platform_synced_block_patch_4') ? (_result$data3 = result.data) === null || _result$data3 === void 0 ? void 0 : (_result$data3$blockSe = _result$data3.blockService_deleteBlock) === null || _result$data3$blockSe === void 0 ? void 0 : _result$data3$blockSe.deleted : (_result$data4 = result.data) === null || _result$data4 === void 0 ? void 0 : _result$data4.blockService_deleteBlock.deleted;
388
+ const isDeleted = (_result$data3 = result.data) === null || _result$data3 === void 0 ? void 0 : (_result$data3$blockSe = _result$data3.blockService_deleteBlock) === null || _result$data3$blockSe === void 0 ? void 0 : _result$data3$blockSe.deleted;
390
389
  if (!isDeleted) {
391
390
  throw new Error('Block deletion failed; deleted flag is false');
392
391
  }
@@ -401,7 +400,7 @@ export const updateSyncedBlock = async ({
401
400
  query: buildUpdateBlockMutation(blockAri, content, stepVersion, status),
402
401
  operationName: UPDATE_BLOCK_OPERATION_NAME
403
402
  };
404
- const url = fg('platform_synced_block_patch_3') ? `${GRAPHQL_ENDPOINT}?operation=editorSyncedBlockUpdateBlock` : GRAPHQL_ENDPOINT;
403
+ const url = `${GRAPHQL_ENDPOINT}?operation=editorSyncedBlockUpdateBlock`;
405
404
  const response = await fetchWithRetry(url, {
406
405
  method: 'POST',
407
406
  headers: COMMON_HEADERS,
@@ -424,12 +423,12 @@ export const createSyncedBlock = async ({
424
423
  stepVersion,
425
424
  status
426
425
  }) => {
427
- var _result$data5;
426
+ var _result$data4;
428
427
  const bodyData = {
429
428
  query: buildCreateBlockMutation(blockAri, blockInstanceId, content, product, sourceAri, stepVersion, status),
430
429
  operationName: CREATE_BLOCK_OPERATION_NAME
431
430
  };
432
- const url = fg('platform_synced_block_patch_3') ? `${GRAPHQL_ENDPOINT}?operation=editorSyncedBlockCreateBlock` : GRAPHQL_ENDPOINT;
431
+ const url = `${GRAPHQL_ENDPOINT}?operation=editorSyncedBlockCreateBlock`;
433
432
  const response = await fetchWithRetry(url, {
434
433
  method: 'POST',
435
434
  headers: COMMON_HEADERS,
@@ -442,7 +441,7 @@ export const createSyncedBlock = async ({
442
441
  if (result.errors && result.errors.length > 0) {
443
442
  throw new Error(result.errors.map(e => e.message).join(', '));
444
443
  }
445
- if (!((_result$data5 = result.data) !== null && _result$data5 !== void 0 && _result$data5.blockService_createBlock)) {
444
+ if (!((_result$data4 = result.data) !== null && _result$data4 !== void 0 && _result$data4.blockService_createBlock)) {
446
445
  throw new Error('No data returned from GraphQL mutation');
447
446
  }
448
447
  return result.data.blockService_createBlock;
@@ -456,7 +455,7 @@ export const updateReferenceSyncedBlockOnDocument = async ({
456
455
  query: buildUpdateDocumentReferencesMutation(documentAri, blocks, noContent),
457
456
  operationName: UPDATE_DOCUMENT_REFERENCES_OPERATION_NAME
458
457
  };
459
- const url = fg('platform_synced_block_patch_3') ? `${GRAPHQL_ENDPOINT}?operation=editorSyncedBlockUpdateDocumentReferences` : GRAPHQL_ENDPOINT;
458
+ const url = `${GRAPHQL_ENDPOINT}?operation=editorSyncedBlockUpdateDocumentReferences`;
460
459
  const response = await fetchWithRetry(url, {
461
460
  method: 'POST',
462
461
  headers: COMMON_HEADERS,
@@ -471,8 +470,8 @@ export const updateReferenceSyncedBlockOnDocument = async ({
471
470
  throw new Error(result.errors.map(e => e.message).join(', '));
472
471
  }
473
472
  if (!noContent) {
474
- var _result$data6;
475
- if (!((_result$data6 = result.data) !== null && _result$data6 !== void 0 && _result$data6.blockService_updateDocumentReferences)) {
473
+ var _result$data5;
474
+ if (!((_result$data5 = result.data) !== null && _result$data5 !== void 0 && _result$data5.blockService_updateDocumentReferences)) {
476
475
  throw new Error('No data returned from GraphQL mutation');
477
476
  }
478
477
  return result.data.blockService_updateDocumentReferences;
@@ -481,12 +480,12 @@ export const updateReferenceSyncedBlockOnDocument = async ({
481
480
  export const getReferenceSyncedBlocksByBlockAri = async ({
482
481
  blockAri
483
482
  }) => {
484
- var _result$data7;
483
+ var _result$data6;
485
484
  const bodyData = {
486
485
  query: buildGetBlockReferencesQuery(blockAri),
487
486
  operationName: GET_BLOCK_REFERENCES_OPERATION_NAME
488
487
  };
489
- const url = fg('platform_synced_block_patch_3') ? `${GRAPHQL_ENDPOINT}?operation=editorSyncedBlockGetReferences` : GRAPHQL_ENDPOINT;
488
+ const url = `${GRAPHQL_ENDPOINT}?operation=editorSyncedBlockGetReferences`;
490
489
  const response = await fetchWithRetry(url, {
491
490
  method: 'POST',
492
491
  headers: COMMON_HEADERS,
@@ -499,7 +498,7 @@ export const getReferenceSyncedBlocksByBlockAri = async ({
499
498
  if (result.errors && result.errors.length > 0) {
500
499
  throw new Error(result.errors.map(e => e.message).join(', '));
501
500
  }
502
- if (!((_result$data7 = result.data) !== null && _result$data7 !== void 0 && _result$data7.blockService_getReferences)) {
501
+ if (!((_result$data6 = result.data) !== null && _result$data6 !== void 0 && _result$data6.blockService_getReferences)) {
503
502
  throw new Error('No data returned from GraphQL query');
504
503
  }
505
504
  const graphqlResponse = result.data.blockService_getReferences;
@@ -535,12 +534,12 @@ export const getReferenceSyncedBlocksByBlockAri = async ({
535
534
  export const updateSyncedBlocks = async ({
536
535
  blocks
537
536
  }) => {
538
- var _result$data8;
537
+ var _result$data7;
539
538
  const bodyData = {
540
539
  query: buildBatchUpdateBlocksMutation(blocks),
541
540
  operationName: BATCH_UPDATE_BLOCKS_OPERATION_NAME
542
541
  };
543
- const url = fg('platform_synced_block_patch_3') ? `${GRAPHQL_ENDPOINT}?operation=editorSyncedBlockBatchUpdateBlocks` : GRAPHQL_ENDPOINT;
542
+ const url = `${GRAPHQL_ENDPOINT}?operation=editorSyncedBlockBatchUpdateBlocks`;
544
543
  const response = await fetchWithRetry(url, {
545
544
  method: 'POST',
546
545
  headers: COMMON_HEADERS,
@@ -553,7 +552,7 @@ export const updateSyncedBlocks = async ({
553
552
  if (result.errors && result.errors.length > 0) {
554
553
  throw new Error(result.errors.map(e => e.message).join(', '));
555
554
  }
556
- if (!((_result$data8 = result.data) !== null && _result$data8 !== void 0 && _result$data8.blockService_batchUpdateBlocks)) {
555
+ if (!((_result$data7 = result.data) !== null && _result$data7 !== void 0 && _result$data7.blockService_batchUpdateBlocks)) {
557
556
  throw new Error('No data returned from GraphQL mutation');
558
557
  }
559
558
  const graphqlResponse = result.data.blockService_batchUpdateBlocks;
@@ -1,5 +1,4 @@
1
1
  import { logException } from '@atlaskit/editor-common/monitoring';
2
- import { fg } from '@atlaskit/platform-feature-flags';
3
2
  import { fetchWithRetry } from '../../utils/retry';
4
3
  const COMMON_HEADERS = {
5
4
  'Content-Type': 'application/json',
@@ -64,7 +63,7 @@ export const fetchMediaToken = async contentId => {
64
63
  logException(error, {
65
64
  location: 'editor-synced-block-provider/fetchMediaToken'
66
65
  });
67
- const errorMsg = fg('platform_synced_block_patch_4') ? error instanceof Error ? error.message : String(error) : String(error);
66
+ const errorMsg = error instanceof Error ? error.message : String(error);
68
67
  throw new Error(`Failed to get content media session: ${errorMsg}`);
69
68
  }
70
69
  };
@@ -1,11 +1,4 @@
1
- /* eslint-disable require-unicode-regexp */
2
-
3
- import { logException } from '@atlaskit/editor-common/monitoring';
4
- import { fg } from '@atlaskit/platform-feature-flags';
5
- import { getSourceInfoErrorPayload } from '../../utils/errorHandling';
6
1
  import { fetchWithRetry } from '../../utils/retry';
7
- import { getPageIdAndTypeFromConfluencePageAri } from './ari';
8
- import { isBlogPageType } from './utils';
9
2
  const COMMON_HEADERS = {
10
3
  'Content-Type': 'application/json',
11
4
  Accept: 'application/json'
@@ -88,110 +81,12 @@ const resolveNoAccessPageInfo = async ari => {
88
81
  throw new Error(`Failed to resolve ari: ${response.statusText}`);
89
82
  }
90
83
  };
91
-
92
- /**
93
- * Fetches unpublished page info from the v2 pages API
94
- * Used when the GraphQL query returns empty content.nodes for unpublished pages
95
- * @param pageAri - The page ARI
96
- * @param localId - Optional local ID to append as block anchor
97
- * @returns Source info with URL, title, and optional subtype
98
- */
99
- const fetchCompleteConfluencePageInfo = async (pageAri, localId) => {
100
- try {
101
- var _pageData$_links, _pageData$_links2;
102
- const {
103
- id: pageId
104
- } = getPageIdAndTypeFromConfluencePageAri({
105
- ari: pageAri
106
- });
107
- const response = await fetchWithRetry(`/wiki/api/v2/pages/${pageId}?draft=true`, {
108
- method: 'GET',
109
- headers: COMMON_HEADERS
110
- });
111
- if (!response.ok) {
112
- throw new Error(`Failed to get unpublished page info: ${response.statusText}`);
113
- }
114
- const pageData = await response.json();
115
- const base = (_pageData$_links = pageData._links) === null || _pageData$_links === void 0 ? void 0 : _pageData$_links.base;
116
- const edituiv2 = (_pageData$_links2 = pageData._links) === null || _pageData$_links2 === void 0 ? void 0 : _pageData$_links2.edituiv2;
117
- const title = pageData.title;
118
- const subType = pageData.subtype;
119
- let url;
120
- if (base && edituiv2) {
121
- url = `${base}${edituiv2}`;
122
- url = url && localId ? `${url}#block-${localId}` : url;
123
- }
124
- return {
125
- title,
126
- url,
127
- sourceAri: pageAri,
128
- subType
129
- };
130
- } catch (error) {
131
- logException(error, {
132
- location: 'editor-synced-block-provider/sourceInfo/fetchUnpublishedConfluencePageInfo'
133
- });
134
- return Promise.resolve(undefined);
135
- }
136
- };
137
- export const fetchConfluencePageInfoOld = async (pageAri, localId, fireAnalyticsEvent) => {
138
- try {
139
- var _response$data, _response$data$conten, _response$data$conten2, _contentData$space;
140
- const {
141
- type: pageType
142
- } = getPageIdAndTypeFromConfluencePageAri({
143
- ari: pageAri
144
- });
145
- const status = fg('platform_synced_block_patch_3') ? ['draft', 'archived', 'current'] : undefined;
146
- const response = await getConfluenceSourceInfo(pageAri, status);
147
- const contentData = (_response$data = response.data) === null || _response$data === void 0 ? void 0 : (_response$data$conten = _response$data.content) === null || _response$data$conten === void 0 ? void 0 : (_response$data$conten2 = _response$data$conten.nodes) === null || _response$data$conten2 === void 0 ? void 0 : _response$data$conten2[0];
148
- const title = contentData === null || contentData === void 0 ? void 0 : contentData.title;
149
- let url;
150
- const {
151
- base
152
- } = (contentData === null || contentData === void 0 ? void 0 : contentData.links) || {};
153
- if (base && contentData !== null && contentData !== void 0 && (_contentData$space = contentData.space) !== null && _contentData$space !== void 0 && _contentData$space.key && contentData !== null && contentData !== void 0 && contentData.id) {
154
- if (isBlogPageType(pageType)) {
155
- url = `${base}/spaces/${contentData.space.key}/blog/edit-v2/${contentData.id}`;
156
- } else if (contentData.subType === 'live') {
157
- url = `${base}/spaces/${contentData.space.key}/pages/${contentData.id}`;
158
- } else {
159
- url = `${base}/spaces/${contentData.space.key}/pages/edit-v2/${contentData.id}`;
160
- }
161
- }
162
- url = url && localId ? `${url}#block-${localId}` : url;
163
- if (!title || !url) {
164
- fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 ? void 0 : fireAnalyticsEvent(getSourceInfoErrorPayload('Failed to get confluence page source info'));
165
- }
166
- return Promise.resolve({
167
- title,
168
- url,
169
- sourceAri: pageAri
170
- });
171
- } catch (error) {
172
- logException(error, {
173
- location: 'editor-synced-block-provider/sourceInfo'
174
- });
175
- fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 ? void 0 : fireAnalyticsEvent(getSourceInfoErrorPayload(error.message));
176
- return Promise.resolve(undefined);
177
- }
178
- };
179
- export const fetchConfluencePageInfo = async (pageAri, hasAccess, urlType, localId, isUnpublished) => {
180
- // For unpublished pages, use the v2 pages API as GraphQL returns empty content.nodes
181
- // We don't want to use the Rest API at all because it doesn't work if accessed from a custom base URL (e.g in Jira)
182
- if (isUnpublished && !fg('platform_synced_block_patch_3')) {
183
- return await fetchCompleteConfluencePageInfo(pageAri, localId);
184
- }
84
+ export const fetchConfluencePageInfo = async (pageAri, hasAccess, localId) => {
185
85
  if (hasAccess) {
186
- var _response$data2, _response$data2$conte, _response$data2$conte2;
187
- const {
188
- type: pageType
189
- } = getPageIdAndTypeFromConfluencePageAri({
190
- ari: pageAri
191
- });
192
- const status = fg('platform_synced_block_patch_3') ? ['draft', 'archived', 'current'] : undefined;
86
+ var _response$data, _response$data$conten, _response$data$conten2;
87
+ const status = ['draft', 'archived', 'current'];
193
88
  const response = await getConfluenceSourceInfo(pageAri, status);
194
- const contentData = (_response$data2 = response.data) === null || _response$data2 === void 0 ? void 0 : (_response$data2$conte = _response$data2.content) === null || _response$data2$conte === void 0 ? void 0 : (_response$data2$conte2 = _response$data2$conte.nodes) === null || _response$data2$conte2 === void 0 ? void 0 : _response$data2$conte2[0];
89
+ const contentData = (_response$data = response.data) === null || _response$data === void 0 ? void 0 : (_response$data$conten = _response$data.content) === null || _response$data$conten === void 0 ? void 0 : (_response$data$conten2 = _response$data$conten.nodes) === null || _response$data$conten2 === void 0 ? void 0 : _response$data$conten2[0];
195
90
  const {
196
91
  title,
197
92
  subType
@@ -203,23 +98,10 @@ export const fetchConfluencePageInfo = async (pageAri, hasAccess, urlType, local
203
98
  webui
204
99
  } = (contentData === null || contentData === void 0 ? void 0 : contentData.links) || {};
205
100
  const pageStatus = contentData === null || contentData === void 0 ? void 0 : contentData.status;
206
- if (fg('platform_synced_block_patch_3')) {
207
- if (base && editui && pageStatus !== 'archived') {
208
- url = `${base}${editui}`;
209
- } else if (base && webui && pageStatus === 'archived') {
210
- url = `${base}${webui}`;
211
- }
212
- } else {
213
- var _contentData$space2;
214
- if (base && contentData !== null && contentData !== void 0 && (_contentData$space2 = contentData.space) !== null && _contentData$space2 !== void 0 && _contentData$space2.key && contentData !== null && contentData !== void 0 && contentData.id) {
215
- if (isBlogPageType(pageType)) {
216
- url = `${base}/spaces/${contentData.space.key}/blog${urlType === 'edit' ? '/edit-v2' : ''}/${contentData.id}`;
217
- } else if (contentData.subType === 'live') {
218
- url = `${base}/spaces/${contentData.space.key}/pages/${contentData.id}`;
219
- } else {
220
- url = `${base}/spaces/${contentData.space.key}/pages${urlType === 'edit' ? '/edit-v2' : ''}/${contentData.id}`;
221
- }
222
- }
101
+ if (base && editui && pageStatus !== 'archived') {
102
+ url = `${base}${editui}`;
103
+ } else if (base && webui && pageStatus === 'archived') {
104
+ url = `${base}${webui}`;
223
105
  }
224
106
  url = url && localId ? `${url}#block-${localId}` : url;
225
107
  return Promise.resolve({
@@ -1,7 +1,6 @@
1
1
  import { useCallback, useEffect, useMemo, useState } from 'react';
2
2
  import { isSSR } from '@atlaskit/editor-common/core-utils';
3
3
  import { logException } from '@atlaskit/editor-common/monitoring';
4
- import { fg } from '@atlaskit/platform-feature-flags';
5
4
  import { SyncBlockError } from '../common/types';
6
5
  import { fetchErrorPayload } from '../utils/errorHandling';
7
6
  import { createSyncBlockNode } from '../utils/utils';
@@ -47,14 +46,7 @@ export const useFetchSyncBlockData = (manager, resourceId, localId, fireAnalytic
47
46
  logException(error, {
48
47
  location: 'editor-synced-block-provider/useFetchSyncBlockData'
49
48
  });
50
- if (fg('platform_synced_block_patch_3')) {
51
- fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 ? void 0 : fireAnalyticsEvent(fetchErrorPayload(error.message));
52
- } else {
53
- var _manager$referenceMan2, _manager$referenceMan3;
54
- manager === null || manager === void 0 ? void 0 : (_manager$referenceMan2 = manager.referenceManager) === null || _manager$referenceMan2 === void 0 ? void 0 : (_manager$referenceMan3 = _manager$referenceMan2.fetchExperience) === null || _manager$referenceMan3 === void 0 ? void 0 : _manager$referenceMan3.failure({
55
- reason: error.message
56
- });
57
- }
49
+ fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 ? void 0 : fireAnalyticsEvent(fetchErrorPayload(error.message));
58
50
 
59
51
  // Set error state if fetching fails
60
52
  setFetchState({
@@ -1,33 +1,5 @@
1
1
  import { useEffect, useRef, useState } from 'react';
2
- import { fg } from '@atlaskit/platform-feature-flags';
3
- import { conditionalHooksFactory } from '@atlaskit/platform-feature-flags-react';
4
- const useFetchSyncBlockTitleBase = (manager, syncBlockNode) => {
5
- // Initialize state from cache to prevent flickering during re-renders
6
- const [sourceTitle, setSourceTitle] = useState(() => {
7
- var _cachedData$data;
8
- if (syncBlockNode.type.name !== 'syncBlock') {
9
- return undefined;
10
- }
11
- const {
12
- resourceId
13
- } = syncBlockNode.attrs;
14
- if (!resourceId) {
15
- return undefined;
16
- }
17
- const cachedData = manager.referenceManager.getFromCache(resourceId);
18
- return cachedData === null || cachedData === void 0 ? void 0 : (_cachedData$data = cachedData.data) === null || _cachedData$data === void 0 ? void 0 : _cachedData$data.sourceTitle;
19
- });
20
- useEffect(() => {
21
- const unsubscribe = manager.referenceManager.subscribeToSourceTitle(syncBlockNode, title => {
22
- setSourceTitle(title);
23
- });
24
- return () => {
25
- unsubscribe();
26
- };
27
- }, [manager, syncBlockNode]);
28
- return sourceTitle;
29
- };
30
- const useFetchSyncBlockTitlePatched = (manager, syncBlockNode) => {
2
+ export const useFetchSyncBlockTitle = (manager, syncBlockNode) => {
31
3
  var _syncBlockNode$attrs, _syncBlockNode$attrs2;
32
4
  const nodeRef = useRef(syncBlockNode);
33
5
  nodeRef.current = syncBlockNode;
@@ -37,7 +9,7 @@ const useFetchSyncBlockTitlePatched = (manager, syncBlockNode) => {
37
9
 
38
10
  // Initialize state from cache to prevent flickering during re-renders
39
11
  const [sourceTitle, setSourceTitle] = useState(() => {
40
- var _cachedData$data2;
12
+ var _cachedData$data;
41
13
  if (nodeTypeName !== 'syncBlock') {
42
14
  return undefined;
43
15
  }
@@ -45,7 +17,7 @@ const useFetchSyncBlockTitlePatched = (manager, syncBlockNode) => {
45
17
  return undefined;
46
18
  }
47
19
  const cachedData = manager.referenceManager.getFromCache(resourceId);
48
- return cachedData === null || cachedData === void 0 ? void 0 : (_cachedData$data2 = cachedData.data) === null || _cachedData$data2 === void 0 ? void 0 : _cachedData$data2.sourceTitle;
20
+ return cachedData === null || cachedData === void 0 ? void 0 : (_cachedData$data = cachedData.data) === null || _cachedData$data === void 0 ? void 0 : _cachedData$data.sourceTitle;
49
21
  });
50
22
  useEffect(() => {
51
23
  const unsubscribe = manager.referenceManager.subscribeToSourceTitle(nodeRef.current, title => {
@@ -56,5 +28,4 @@ const useFetchSyncBlockTitlePatched = (manager, syncBlockNode) => {
56
28
  };
57
29
  }, [manager, nodeTypeName, resourceId, localId]);
58
30
  return sourceTitle;
59
- };
60
- export const useFetchSyncBlockTitle = conditionalHooksFactory(() => fg('platform_synced_block_patch_4'), useFetchSyncBlockTitlePatched, useFetchSyncBlockTitleBase);
31
+ };
@@ -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, updateSyncedBlocks } from '../../clients/block-service/blockService';
6
5
  import { subscribeToBlockUpdates as subscribeToBlockUpdatesWS } from '../../clients/block-service/blockSubscription';
@@ -243,22 +242,13 @@ export const batchFetchData = async (cloudId, parentAri, blockNodeIdentifiers) =
243
242
  resourceId
244
243
  });
245
244
  } catch {
246
- if (fg('platform_synced_block_patch_3')) {
247
- results.push({
248
- error: {
249
- type: SyncBlockError.Errored,
250
- reason: `parsing JSON content response failed for resourceId: ${resourceId} localId: ${blockAri}`
251
- },
252
- resourceId
253
- });
254
- } else {
255
- results.push({
256
- error: {
257
- type: SyncBlockError.Errored
258
- },
259
- resourceId
260
- });
261
- }
245
+ results.push({
246
+ error: {
247
+ type: SyncBlockError.Errored,
248
+ reason: `parsing JSON content response failed for resourceId: ${resourceId} localId: ${blockAri}`
249
+ },
250
+ resourceId
251
+ });
262
252
  }
263
253
  }
264
254
  }
@@ -273,11 +263,9 @@ export const batchFetchData = async (cloudId, parentAri, blockNodeIdentifiers) =
273
263
  }
274
264
  processedResourceIds.add(resourceId);
275
265
  results.push({
276
- error: fg('platform_synced_block_patch_3') ? {
266
+ error: {
277
267
  type: mapErrorResponseCode(errorResponse.code),
278
268
  reason: errorResponse.reason
279
- } : {
280
- type: mapErrorResponseCode(errorResponse.code)
281
269
  },
282
270
  resourceId
283
271
  });
@@ -301,7 +289,7 @@ export const batchFetchData = async (cloudId, parentAri, blockNodeIdentifiers) =
301
289
  return blockNodeIdentifiers.map(blockNodeIdentifier => ({
302
290
  error: {
303
291
  type: error instanceof BlockError ? mapBlockError(error) : SyncBlockError.Errored,
304
- reason: fg('platform_synced_block_patch_3') ? error.message : undefined
292
+ reason: error.message
305
293
  },
306
294
  resourceId: blockNodeIdentifier.resourceId
307
295
  }));
@@ -455,21 +443,17 @@ class BlockServiceADFFetchProvider {
455
443
  } catch (error) {
456
444
  if (error instanceof BlockError) {
457
445
  return {
458
- error: fg('platform_synced_block_patch_3') ? {
446
+ error: {
459
447
  type: mapBlockError(error),
460
448
  reason: error.message
461
- } : {
462
- type: mapBlockError(error)
463
449
  },
464
450
  resourceId
465
451
  };
466
452
  }
467
453
  return {
468
- error: fg('platform_synced_block_patch_3') ? {
454
+ error: {
469
455
  type: SyncBlockError.Errored,
470
456
  reason: error.message
471
- } : {
472
- type: SyncBlockError.Errored
473
457
  },
474
458
  resourceId
475
459
  };
@@ -1,7 +1,5 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { useMemo, useRef } from 'react';
3
- import { fg } from '@atlaskit/platform-feature-flags';
4
- import { conditionalHooksFactory } from '@atlaskit/platform-feature-flags-react';
5
3
  import { getProductFromSourceAri } from '../clients/block-service/ari';
6
4
  import { getPageIdAndTypeFromConfluencePageAri } from '../clients/confluence/ari';
7
5
  import { fetchConfluencePageInfo } from '../clients/confluence/sourceInfo';
@@ -74,11 +72,9 @@ export class SyncedBlockProvider extends SyncBlockDataProviderInterface {
74
72
  return data;
75
73
  }, error => {
76
74
  return {
77
- error: fg('platform_synced_block_patch_3') ? {
75
+ error: {
78
76
  type: SyncBlockError.Errored,
79
77
  reason: error
80
- } : {
81
- type: SyncBlockError.Errored
82
78
  },
83
79
  resourceId: blockIdentifier.resourceId
84
80
  };
@@ -105,8 +101,8 @@ export class SyncedBlockProvider extends SyncBlockDataProviderInterface {
105
101
  return Promise.reject(new Error('Write provider not set'));
106
102
  }
107
103
 
108
- // Use batch write only when feature flag is enabled and method is available
109
- if (this.writeProvider.writeDataBatch && fg('platform_synced_block_patch_4')) {
104
+ // Use batch write only when method is available
105
+ if (this.writeProvider.writeDataBatch) {
110
106
  // Separate data into valid (with content) and invalid (without content)
111
107
  const validDataWithIndices = [];
112
108
  const invalidResults = [];
@@ -198,7 +194,7 @@ export class SyncedBlockProvider extends SyncBlockDataProviderInterface {
198
194
  *
199
195
  * @returns The source info
200
196
  */
201
- async fetchSyncBlockSourceInfo(localId, sourceAri, sourceProduct, fireAnalyticsEvent, hasAccess = true, urlType = 'edit', isUnpublished) {
197
+ async fetchSyncBlockSourceInfo(localId, sourceAri, sourceProduct, hasAccess = true) {
202
198
  var _this$writeProvider2, _this$writeProvider4;
203
199
  const ari = sourceAri !== null && sourceAri !== void 0 ? sourceAri : (_this$writeProvider2 = this.writeProvider) === null || _this$writeProvider2 === void 0 ? void 0 : _this$writeProvider2.parentAri;
204
200
  const product = sourceProduct !== null && sourceProduct !== void 0 ? sourceProduct : getProductFromSourceAri(ari);
@@ -209,7 +205,7 @@ export class SyncedBlockProvider extends SyncBlockDataProviderInterface {
209
205
  case 'confluence-page':
210
206
  {
211
207
  var _this$writeProvider3;
212
- const sourceInfo = await fetchConfluencePageInfo(ari, hasAccess, urlType, localId, isUnpublished);
208
+ const sourceInfo = await fetchConfluencePageInfo(ari, hasAccess, localId);
213
209
  if (!sourceInfo) {
214
210
  return Promise.resolve(undefined);
215
211
  }
@@ -316,24 +312,7 @@ const createSyncedBlockProvider = ({
316
312
  }) => {
317
313
  return new SyncedBlockProvider(fetchProvider, writeProvider);
318
314
  };
319
- const useMemoizedSyncedBlockProviderBase = ({
320
- fetchProvider,
321
- writeProvider,
322
- providerOptions,
323
- getSSRData
324
- }) => {
325
- const syncBlockProvider = useMemo(() => createSyncedBlockProvider({
326
- fetchProvider,
327
- writeProvider
328
- }), [fetchProvider, writeProvider]);
329
- syncBlockProvider.setProviderOptions(providerOptions);
330
- const ssrData = getSSRData ? getSSRData() : undefined;
331
- if (ssrData) {
332
- syncBlockProvider.setSSRData(ssrData);
333
- }
334
- return syncBlockProvider;
335
- };
336
- const useMemoizedSyncedBlockProviderPatched = ({
315
+ export const useMemoizedSyncedBlockProvider = ({
337
316
  fetchProvider,
338
317
  writeProvider,
339
318
  providerOptions,
@@ -357,5 +336,4 @@ const useMemoizedSyncedBlockProviderPatched = ({
357
336
  }
358
337
  }
359
338
  return syncBlockProvider;
360
- };
361
- export const useMemoizedSyncedBlockProvider = conditionalHooksFactory(() => fg('platform_synced_block_patch_4'), useMemoizedSyncedBlockProviderPatched, useMemoizedSyncedBlockProviderBase);
339
+ };