@atlaskit/editor-synced-block-provider 3.31.2 → 3.32.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.
Files changed (63) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/clients/block-service/blockService.js +21 -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 +28 -41
  8. package/dist/cjs/providers/syncBlockProvider.js +22 -51
  9. package/dist/cjs/providers/types.js +3 -0
  10. package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +14 -29
  11. package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +1 -1
  12. package/dist/cjs/store-manager/syncBlockStoreManager.js +3 -15
  13. package/dist/cjs/store-manager/syncBlockSubscriptionManager.js +2 -2
  14. package/dist/cjs/utils/errorHandling.js +1 -10
  15. package/dist/cjs/utils/resolveSyncBlockInstance.js +11 -12
  16. package/dist/cjs/utils/retry.js +2 -23
  17. package/dist/es2019/clients/block-service/blockService.js +21 -21
  18. package/dist/es2019/clients/confluence/fetchMediaToken.js +1 -2
  19. package/dist/es2019/clients/confluence/sourceInfo.js +8 -126
  20. package/dist/es2019/hooks/useFetchSyncBlockData.js +1 -9
  21. package/dist/es2019/hooks/useFetchSyncBlockTitle.js +4 -33
  22. package/dist/es2019/providers/block-service/blockServiceAPI.js +18 -31
  23. package/dist/es2019/providers/syncBlockProvider.js +7 -29
  24. package/dist/es2019/providers/types.js +4 -0
  25. package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +27 -41
  26. package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +1 -1
  27. package/dist/es2019/store-manager/syncBlockStoreManager.js +3 -13
  28. package/dist/es2019/store-manager/syncBlockSubscriptionManager.js +2 -2
  29. package/dist/es2019/utils/errorHandling.js +1 -10
  30. package/dist/es2019/utils/resolveSyncBlockInstance.js +11 -12
  31. package/dist/es2019/utils/retry.js +2 -21
  32. package/dist/esm/clients/block-service/blockService.js +21 -21
  33. package/dist/esm/clients/confluence/fetchMediaToken.js +1 -2
  34. package/dist/esm/clients/confluence/sourceInfo.js +25 -176
  35. package/dist/esm/hooks/useFetchSyncBlockData.js +2 -9
  36. package/dist/esm/hooks/useFetchSyncBlockTitle.js +8 -40
  37. package/dist/esm/providers/block-service/blockServiceAPI.js +28 -41
  38. package/dist/esm/providers/syncBlockProvider.js +22 -51
  39. package/dist/esm/providers/types.js +4 -0
  40. package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +14 -29
  41. package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +1 -1
  42. package/dist/esm/store-manager/syncBlockStoreManager.js +3 -15
  43. package/dist/esm/store-manager/syncBlockSubscriptionManager.js +2 -2
  44. package/dist/esm/utils/errorHandling.js +1 -10
  45. package/dist/esm/utils/resolveSyncBlockInstance.js +11 -12
  46. package/dist/esm/utils/retry.js +2 -23
  47. package/dist/types/clients/block-service/blockService.d.ts +3 -0
  48. package/dist/types/clients/confluence/sourceInfo.d.ts +1 -3
  49. package/dist/types/index.d.ts +1 -1
  50. package/dist/types/providers/block-service/blockServiceAPI.d.ts +5 -3
  51. package/dist/types/providers/syncBlockProvider.d.ts +2 -3
  52. package/dist/types/providers/types.d.ts +13 -3
  53. package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +1 -1
  54. package/dist/types/store-manager/syncBlockStoreManager.d.ts +1 -1
  55. package/dist/types-ts4.5/clients/block-service/blockService.d.ts +3 -0
  56. package/dist/types-ts4.5/clients/confluence/sourceInfo.d.ts +1 -3
  57. package/dist/types-ts4.5/index.d.ts +1 -1
  58. package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +5 -3
  59. package/dist/types-ts4.5/providers/syncBlockProvider.d.ts +2 -3
  60. package/dist/types-ts4.5/providers/types.d.ts +13 -3
  61. package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +1 -1
  62. package/dist/types-ts4.5/store-manager/syncBlockStoreManager.d.ts +1 -1
  63. package/package.json +3 -10
@@ -1,7 +1,6 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
- import { fg } from '@atlaskit/platform-feature-flags';
5
4
  import { getPageIdAndTypeFromConfluencePageAri } from '../clients/confluence/ari';
6
5
  import { SyncBlockError } from '../common/types';
7
6
  /**
@@ -16,7 +15,7 @@ import { SyncBlockError } from '../common/types';
16
15
  * @returns A merged SyncBlockInstance object.
17
16
  */
18
17
  export var resolveSyncBlockInstance = function resolveSyncBlockInstance(oldResult, newResult) {
19
- var _newResult$data, _oldResult$data, _newResult$data2, _oldResult$data2, _newResult$data3, _oldResult$data3, _newResult$data4, _oldResult$data4;
18
+ var _newResult$data, _oldResult$data, _newResult$data2, _oldResult$data2, _newResult$data3, _oldResult$data3;
20
19
  // if the old result has no data, we simply return the new result
21
20
  if (!oldResult.data) {
22
21
  return newResult;
@@ -35,30 +34,30 @@ export var resolveSyncBlockInstance = function resolveSyncBlockInstance(oldResul
35
34
  data: _objectSpread(_objectSpread({}, newResult.data), {}, {
36
35
  sourceURL: ((_newResult$data = newResult.data) === null || _newResult$data === void 0 ? void 0 : _newResult$data.sourceURL) || ((_oldResult$data = oldResult.data) === null || _oldResult$data === void 0 ? void 0 : _oldResult$data.sourceURL) || undefined,
37
36
  sourceTitle: ((_newResult$data2 = newResult.data) === null || _newResult$data2 === void 0 ? void 0 : _newResult$data2.sourceTitle) || ((_oldResult$data2 = oldResult.data) === null || _oldResult$data2 === void 0 ? void 0 : _oldResult$data2.sourceTitle) || undefined,
38
- sourceSubType: fg('platform_synced_block_patch_3') ? mergeSubType(oldResult, newResult) : ((_newResult$data3 = newResult.data) === null || _newResult$data3 === void 0 ? void 0 : _newResult$data3.sourceSubType) || ((_oldResult$data3 = oldResult.data) === null || _oldResult$data3 === void 0 ? void 0 : _oldResult$data3.sourceSubType) || undefined,
39
- onSameDocument: ((_newResult$data4 = newResult.data) === null || _newResult$data4 === void 0 ? void 0 : _newResult$data4.onSameDocument) || ((_oldResult$data4 = oldResult.data) === null || _oldResult$data4 === void 0 ? void 0 : _oldResult$data4.onSameDocument) || undefined
37
+ sourceSubType: mergeSubType(oldResult, newResult),
38
+ onSameDocument: ((_newResult$data3 = newResult.data) === null || _newResult$data3 === void 0 ? void 0 : _newResult$data3.onSameDocument) || ((_oldResult$data3 = oldResult.data) === null || _oldResult$data3 === void 0 ? void 0 : _oldResult$data3.onSameDocument) || undefined
40
39
  })
41
40
  });
42
41
  };
43
42
  var mergeSubType = function mergeSubType(oldResult, newResult) {
44
- var _newResult$data5, _newResult$data6, _oldResult$data5;
43
+ var _newResult$data4, _newResult$data5, _oldResult$data4;
45
44
  // for classic pages, subType is 'null'
46
- if (((_newResult$data5 = newResult.data) === null || _newResult$data5 === void 0 ? void 0 : _newResult$data5.sourceSubType) !== undefined) {
45
+ if (((_newResult$data4 = newResult.data) === null || _newResult$data4 === void 0 ? void 0 : _newResult$data4.sourceSubType) !== undefined) {
47
46
  return newResult.data.sourceSubType;
48
47
  }
49
- if ((_newResult$data6 = newResult.data) !== null && _newResult$data6 !== void 0 && _newResult$data6.sourceAri) {
48
+ if ((_newResult$data5 = newResult.data) !== null && _newResult$data5 !== void 0 && _newResult$data5.sourceAri) {
50
49
  // for blogposts, subType is always undefined
51
50
  try {
52
- var _newResult$data7;
51
+ var _newResult$data6;
53
52
  var _getPageIdAndTypeFrom = getPageIdAndTypeFromConfluencePageAri({
54
- ari: (_newResult$data7 = newResult.data) === null || _newResult$data7 === void 0 ? void 0 : _newResult$data7.sourceAri
53
+ ari: (_newResult$data6 = newResult.data) === null || _newResult$data6 === void 0 ? void 0 : _newResult$data6.sourceAri
55
54
  }),
56
55
  pageType = _getPageIdAndTypeFrom.type;
57
56
  if (pageType === 'blogpost') {
58
- var _newResult$data8;
59
- return (_newResult$data8 = newResult.data) === null || _newResult$data8 === void 0 ? void 0 : _newResult$data8.sourceSubType;
57
+ var _newResult$data7;
58
+ return (_newResult$data7 = newResult.data) === null || _newResult$data7 === void 0 ? void 0 : _newResult$data7.sourceSubType;
60
59
  }
61
60
  } catch (_unused) {}
62
61
  }
63
- return (_oldResult$data5 = oldResult.data) === null || _oldResult$data5 === void 0 ? void 0 : _oldResult$data5.sourceSubType;
62
+ return (_oldResult$data4 = oldResult.data) === null || _oldResult$data4 === void 0 ? void 0 : _oldResult$data4.sourceSubType;
64
63
  };
@@ -1,25 +1,7 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _regeneratorRuntime from "@babel/runtime/regenerator";
3
- import { fg } from '@atlaskit/platform-feature-flags';
4
- import { functionWithCondition } from '@atlaskit/platform-feature-flags-react';
5
3
  var MAX_RETRY_DELAY = 30000;
6
- var parseRetryAfterBase = function parseRetryAfterBase(retryAfter) {
7
- var newDelay;
8
-
9
- // retryAfter can either be in seconds or HTTP date
10
- var parsedRetryAfter = parseInt(retryAfter);
11
- if (!isNaN(parsedRetryAfter)) {
12
- newDelay = parsedRetryAfter * 1000;
13
- } else {
14
- var retryDate = new Date(retryAfter);
15
- var delayFromDate = retryDate.getTime() - Date.now();
16
- if (delayFromDate > 0) {
17
- newDelay = delayFromDate;
18
- }
19
- }
20
- return newDelay;
21
- };
22
- var parseRetryAfterPatched = function parseRetryAfterPatched(retryAfter) {
4
+ var parseRetryAfter = function parseRetryAfter(retryAfter) {
23
5
  // retryAfter can either be in seconds or HTTP date
24
6
  var parsedRetryAfter = parseInt(retryAfter, 10);
25
7
  if (!isNaN(parsedRetryAfter) && parsedRetryAfter > 0) {
@@ -35,9 +17,6 @@ var parseRetryAfterPatched = function parseRetryAfterPatched(retryAfter) {
35
17
  }
36
18
  return undefined;
37
19
  };
38
- var parseRetryAfter = functionWithCondition(function () {
39
- return fg('platform_synced_block_patch_4');
40
- }, parseRetryAfterPatched, parseRetryAfterBase);
41
20
  var _fetchWithRetry = /*#__PURE__*/function () {
42
21
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(url, options) {
43
22
  var _ref2;
@@ -67,7 +46,7 @@ var _fetchWithRetry = /*#__PURE__*/function () {
67
46
  case 8:
68
47
  retryAfter = response.headers.get('Retry-After');
69
48
  parsedDelay = (_ref2 = retryAfter ? parseRetryAfter(retryAfter) : undefined) !== null && _ref2 !== void 0 ? _ref2 : delay;
70
- retryDelay = fg('platform_synced_block_patch_4') ? Math.min(parsedDelay, MAX_RETRY_DELAY) : parsedDelay;
49
+ retryDelay = Math.min(parsedDelay, MAX_RETRY_DELAY);
71
50
  _context.next = 13;
72
51
  return new Promise(function (resolve) {
73
52
  return setTimeout(resolve, retryDelay);
@@ -1,4 +1,5 @@
1
1
  import type { ReferenceSyncBlockResponse, SyncBlockProduct, SyncBlockStatus, DeletionReason } from '../../common/types';
2
+ import type { BatchFetchConfig } from '../../providers/types';
2
3
  export type BlockContentResponse = {
3
4
  blockAri: string;
4
5
  blockInstanceId: string;
@@ -111,6 +112,7 @@ type UpdateReferenceSyncedBlockOnDocumentRequest = {
111
112
  };
112
113
  export type BatchRetrieveSyncedBlocksRequest = {
113
114
  blockIdentifiers: BlockIdentifier[];
115
+ config?: BatchFetchConfig;
114
116
  };
115
117
  type BlockIdentifier = {
116
118
  blockAri: string;
@@ -139,6 +141,7 @@ export declare const getSyncedBlockContent: ({ blockAri, }: GetSyncedBlockConten
139
141
  * Calls the Block Service GraphQL API: `blockService_batchRetrieveBlocks`
140
142
  *
141
143
  * @param blockIdentifiers - Array of block identifiers to retrieve
144
+ * @param config - Optional batch fetch configuration (e.g. timeout)
142
145
  * @returns A promise containing arrays of successfully fetched blocks and any errors encountered
143
146
  */
144
147
  export declare const batchRetrieveSyncedBlocks: ({ blockIdentifiers, }: BatchRetrieveSyncedBlocksRequest) => Promise<BatchRetrieveSyncedBlocksResponse>;
@@ -1,4 +1,2 @@
1
- import { type RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
2
1
  import type { SyncBlockSourceInfo } from '../../providers/types';
3
- export declare const fetchConfluencePageInfoOld: (pageAri: string, localId?: string, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void) => Promise<SyncBlockSourceInfo | undefined>;
4
- export declare const fetchConfluencePageInfo: (pageAri: string, hasAccess: boolean, urlType: "view" | "edit", localId?: string, isUnpublished?: boolean) => Promise<SyncBlockSourceInfo | undefined>;
2
+ export declare const fetchConfluencePageInfo: (pageAri: string, hasAccess: boolean, localId?: string) => Promise<SyncBlockSourceInfo | undefined>;
@@ -13,7 +13,7 @@ export { getJiraWorkItemAri, getJiraWorkItemIdFromAri } from './clients/jira/ari
13
13
  export { useMemoizedBlockServiceAPIProviders, useMemoizedBlockServiceFetchOnlyAPIProvider, fetchReferences, batchFetchData, writeDataBatch, blockAriToResourceId, convertToSyncBlockData, extractResourceIdFromBlockAri, } from './providers/block-service/blockServiceAPI';
14
14
  export { fetchConfluencePageInfo } from './clients/confluence/sourceInfo';
15
15
  export { SyncedBlockProvider, useMemoizedSyncedBlockProvider } from './providers/syncBlockProvider';
16
- export type { ADFFetchProvider, ADFWriteProvider, BlockNodeIdentifiers, BlockSubscriptionErrorCallback, BlockUpdateCallback, SyncBlockDataProviderInterface, SyncBlockInstance, MediaEmojiProviderOptions, SyncedBlockRendererProviderOptions, SyncBlockRendererProviderCreator, SyncedBlockRendererDataProviders, Unsubscribe, UpdateReferenceSyncBlockResult, WriteSyncBlockResult, SyncBlockParentInfo, SyncBlockSourceInfo, } from './providers/types';
16
+ export type { ADFFetchProvider, ADFWriteProvider, BatchFetchConfig, BlockNodeIdentifiers, BlockSubscriptionErrorCallback, BlockUpdateCallback, SyncBlockDataProviderInterface, SyncBlockInstance, MediaEmojiProviderOptions, SyncedBlockRendererProviderOptions, SyncBlockRendererProviderCreator, SyncedBlockRendererDataProviders, Unsubscribe, UpdateReferenceSyncBlockResult, WriteSyncBlockResult, SyncBlockParentInfo, SyncBlockSourceInfo, } from './providers/types';
17
17
  export { ReferenceSyncBlockStoreManager } from './store-manager/referenceSyncBlockStoreManager';
18
18
  export { SyncBlockInMemorySessionCache, syncBlockInMemorySessionCache, } from './store-manager/syncBlockInMemorySessionCache';
19
19
  export { SyncBlockStoreManager, useMemoizedSyncBlockStoreManager, } from './store-manager/syncBlockStoreManager';
@@ -1,6 +1,6 @@
1
1
  import { type BlockContentResponse } from '../../clients/block-service/blockService';
2
2
  import { SyncBlockError, type ReferenceSyncBlockData, type ResourceId, type SyncBlockAttrs, type SyncBlockData, type SyncBlockProduct } from '../../common/types';
3
- import type { ADFFetchProvider, ADFWriteProvider, BlockNodeIdentifiers, DeleteSyncBlockResult, SyncBlockInstance, UpdateReferenceSyncBlockResult, WriteSyncBlockResult } from '../types';
3
+ import type { ADFFetchProvider, ADFWriteProvider, BatchFetchConfig, BlockNodeIdentifiers, DeleteSyncBlockResult, SyncBlockInstance, UpdateReferenceSyncBlockResult, WriteSyncBlockResult } from '../types';
4
4
  /**
5
5
  * Extracts the ResourceId from a block ARI by returning the full path after synced-block/.
6
6
  *
@@ -30,9 +30,10 @@ export declare const extractResourceIdFromBlockAri: (blockAri: string) => string
30
30
  * @param cloudId - The cloudId of the block. E.G the cloudId of the confluence page, or the cloudId of the Jira instance
31
31
  * @param parentAri - The ARI of the parent of the block. E.G the ARI of the confluence page, or the ARI of the Jira work item
32
32
  * @param blockNodeIdentifiers - Array of block node identifiers to fetch
33
+ * @param config - Optional batch fetch configuration
33
34
  * @returns Array of SyncBlockInstance results
34
35
  */
35
- export declare const batchFetchData: (cloudId: string, parentAri: string | undefined, blockNodeIdentifiers: BlockNodeIdentifiers[]) => Promise<SyncBlockInstance[]>;
36
+ export declare const batchFetchData: (cloudId: string, parentAri: string | undefined, blockNodeIdentifiers: BlockNodeIdentifiers[], config?: BatchFetchConfig) => Promise<SyncBlockInstance[]>;
36
37
  /**
37
38
  * Batch writes multiple synced blocks.
38
39
  * @param cloudId - The cloudId of the block. E.G the cloudId of the confluence page, or the cloudId of the Jira instance
@@ -60,9 +61,10 @@ declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
60
61
  /**
61
62
  * Batch fetches multiple synced blocks by their resource IDs.
62
63
  * @param blockNodeIdentifiers - Array of block node identifiers to fetch
64
+ * @param config - Optional batch fetch configuration
63
65
  * @returns Array of SyncBlockInstance results
64
66
  */
65
- batchFetchData(blockNodeIdentifiers: BlockNodeIdentifiers[]): Promise<SyncBlockInstance[]>;
67
+ batchFetchData(blockNodeIdentifiers: BlockNodeIdentifiers[], config?: BatchFetchConfig): Promise<SyncBlockInstance[]>;
66
68
  /**
67
69
  * Subscribes to real-time updates for a specific block using GraphQL WebSocket subscriptions.
68
70
  * @param resourceId - The resource ID of the block to subscribe to
@@ -1,4 +1,3 @@
1
- import type { RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
2
1
  import type { JSONNode } from '@atlaskit/editor-json-transformer/types';
3
2
  import { type BlockInstanceId, type DeletionReason, type ReferenceSyncBlockData, type ResourceId, type SyncBlockAttrs, type SyncBlockData, type SyncBlockNode, type SyncBlockProduct } from '../common/types';
4
3
  import { SyncBlockDataProviderInterface, type ADFFetchProvider, type ADFWriteProvider, type BlockSubscriptionErrorCallback, type BlockUpdateCallback, type DeleteSyncBlockResult, type SyncBlockInstance, type SyncBlockParentInfo, type SyncBlockSourceInfo, type SyncedBlockRendererProviderOptions, type Unsubscribe, type UpdateReferenceSyncBlockResult, type WriteSyncBlockResult } from './types';
@@ -68,7 +67,7 @@ export declare class SyncedBlockProvider extends SyncBlockDataProviderInterface
68
67
  *
69
68
  * @returns The source info
70
69
  */
71
- fetchSyncBlockSourceInfo(localId?: BlockInstanceId, sourceAri?: string, sourceProduct?: SyncBlockProduct, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void, hasAccess?: boolean, urlType?: 'view' | 'edit', isUnpublished?: boolean): Promise<SyncBlockSourceInfo | undefined>;
70
+ fetchSyncBlockSourceInfo(localId?: BlockInstanceId, sourceAri?: string, sourceProduct?: SyncBlockProduct, hasAccess?: boolean): Promise<SyncBlockSourceInfo | undefined>;
72
71
  generateResourceId(): {
73
72
  localId: BlockInstanceId;
74
73
  resourceId: ResourceId;
@@ -106,5 +105,5 @@ type UseMemoizedSyncedBlockProviderProps = {
106
105
  providerOptions: SyncedBlockRendererProviderOptions;
107
106
  writeProvider: ADFWriteProvider | undefined;
108
107
  };
109
- export declare const useMemoizedSyncedBlockProvider: (args_0: UseMemoizedSyncedBlockProviderProps) => SyncedBlockProvider;
108
+ export declare const useMemoizedSyncedBlockProvider: ({ fetchProvider, writeProvider, providerOptions, getSSRData, }: UseMemoizedSyncedBlockProviderProps) => SyncedBlockProvider;
110
109
  export {};
@@ -1,4 +1,3 @@
1
- import type { RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
2
1
  import type { CardProvider, MediaProvider, ProfilecardProvider } from '@atlaskit/editor-common/provider-factory';
3
2
  import type { EmojiProvider } from '@atlaskit/emoji';
4
3
  import type { MentionProvider } from '@atlaskit/mention/types';
@@ -61,11 +60,22 @@ export type BlockNodeIdentifiers = {
61
60
  blockInstanceId: string;
62
61
  resourceId: string;
63
62
  };
63
+ /**
64
+ * Configuration options for batch fetch operations
65
+ */
66
+ export type BatchFetchConfig = {
67
+ /** Whether the batch fetch is being performed in a server-side rendering context */
68
+ isSSR?: boolean;
69
+ /** Maximum number of blocks to fetch in a single batch request */
70
+ maxBatchSize?: number;
71
+ /** Timeout in milliseconds for batch fetch requests */
72
+ timeoutMs?: number;
73
+ };
64
74
  export type BlockUpdateCallback = (data: SyncBlockInstance) => void;
65
75
  export type BlockSubscriptionErrorCallback = (error: Error) => void;
66
76
  export type Unsubscribe = () => void;
67
77
  export interface ADFFetchProvider {
68
- batchFetchData: (blockNodeIdentifiers: BlockNodeIdentifiers[]) => Promise<SyncBlockInstance[]>;
78
+ batchFetchData: (blockNodeIdentifiers: BlockNodeIdentifiers[], config?: BatchFetchConfig) => Promise<SyncBlockInstance[]>;
69
79
  fetchData: (resourceId: ResourceId) => Promise<SyncBlockInstance>;
70
80
  fetchReferences: (referenceResourceId: string) => Promise<ReferenceSyncBlockData>;
71
81
  /**
@@ -118,7 +128,7 @@ export declare abstract class SyncBlockDataProviderInterface extends NodeDataPro
118
128
  abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<WriteSyncBlockResult>>;
119
129
  abstract createNodeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
120
130
  abstract deleteNodesData(resourceIds: string[], deleteReason: DeletionReason): Promise<Array<DeleteSyncBlockResult>>;
121
- abstract fetchSyncBlockSourceInfo(localId?: BlockInstanceId, sourceAri?: string, sourceProduct?: SyncBlockProduct, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void, hasAccess?: boolean, urlType?: 'view' | 'edit', isUnpublished?: boolean): Promise<SyncBlockSourceInfo | undefined>;
131
+ abstract fetchSyncBlockSourceInfo(localId?: BlockInstanceId, sourceAri?: string, sourceProduct?: SyncBlockProduct, hasAccess?: boolean): Promise<SyncBlockSourceInfo | undefined>;
122
132
  abstract setProviderOptions(providerOptions: SyncedBlockRendererProviderOptions): void;
123
133
  abstract getSyncedBlockRendererProviderOptions(): SyncedBlockRendererProviderOptions;
124
134
  abstract retrieveSyncBlockParentInfo(sourceAri: string, sourceProduct: SyncBlockProduct): SyncBlockParentInfo | undefined;
@@ -107,7 +107,7 @@ export declare class ReferenceSyncBlockStoreManager {
107
107
  * Cleans up all GraphQL subscriptions.
108
108
  */
109
109
  private cleanupAllGraphQLSubscriptions;
110
- fetchSyncBlockSourceInfoBySourceAri(sourceAri: string, hasAccess?: boolean, urlType?: 'view' | 'edit'): Promise<SyncBlockSourceInfo | undefined>;
110
+ fetchSyncBlockSourceInfoBySourceAri(sourceAri: string, hasAccess?: boolean): Promise<SyncBlockSourceInfo | undefined>;
111
111
  fetchSyncBlockSourceInfo(resourceId: ResourceId): Promise<SyncBlockSourceInfo | undefined>;
112
112
  /**
113
113
  * Processes prefetched data and updates the cache.
@@ -17,4 +17,4 @@ export declare class SyncBlockStoreManager {
17
17
  get sourceManager(): SourceSyncBlockStoreManager;
18
18
  destroy(): void;
19
19
  }
20
- export declare const useMemoizedSyncBlockStoreManager: (dataProvider?: SyncBlockDataProviderInterface | undefined, fireAnalyticsEvent?: ((payload: SyncBlockEventPayload) => void) | undefined) => SyncBlockStoreManager;
20
+ export declare const useMemoizedSyncBlockStoreManager: (dataProvider?: SyncBlockDataProviderInterface, fireAnalyticsEvent?: (payload: SyncBlockEventPayload) => void) => SyncBlockStoreManager;
@@ -1,4 +1,5 @@
1
1
  import type { ReferenceSyncBlockResponse, SyncBlockProduct, SyncBlockStatus, DeletionReason } from '../../common/types';
2
+ import type { BatchFetchConfig } from '../../providers/types';
2
3
  export type BlockContentResponse = {
3
4
  blockAri: string;
4
5
  blockInstanceId: string;
@@ -111,6 +112,7 @@ type UpdateReferenceSyncedBlockOnDocumentRequest = {
111
112
  };
112
113
  export type BatchRetrieveSyncedBlocksRequest = {
113
114
  blockIdentifiers: BlockIdentifier[];
115
+ config?: BatchFetchConfig;
114
116
  };
115
117
  type BlockIdentifier = {
116
118
  blockAri: string;
@@ -139,6 +141,7 @@ export declare const getSyncedBlockContent: ({ blockAri, }: GetSyncedBlockConten
139
141
  * Calls the Block Service GraphQL API: `blockService_batchRetrieveBlocks`
140
142
  *
141
143
  * @param blockIdentifiers - Array of block identifiers to retrieve
144
+ * @param config - Optional batch fetch configuration (e.g. timeout)
142
145
  * @returns A promise containing arrays of successfully fetched blocks and any errors encountered
143
146
  */
144
147
  export declare const batchRetrieveSyncedBlocks: ({ blockIdentifiers, }: BatchRetrieveSyncedBlocksRequest) => Promise<BatchRetrieveSyncedBlocksResponse>;
@@ -1,4 +1,2 @@
1
- import { type RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
2
1
  import type { SyncBlockSourceInfo } from '../../providers/types';
3
- export declare const fetchConfluencePageInfoOld: (pageAri: string, localId?: string, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void) => Promise<SyncBlockSourceInfo | undefined>;
4
- export declare const fetchConfluencePageInfo: (pageAri: string, hasAccess: boolean, urlType: "view" | "edit", localId?: string, isUnpublished?: boolean) => Promise<SyncBlockSourceInfo | undefined>;
2
+ export declare const fetchConfluencePageInfo: (pageAri: string, hasAccess: boolean, localId?: string) => Promise<SyncBlockSourceInfo | undefined>;
@@ -13,7 +13,7 @@ export { getJiraWorkItemAri, getJiraWorkItemIdFromAri } from './clients/jira/ari
13
13
  export { useMemoizedBlockServiceAPIProviders, useMemoizedBlockServiceFetchOnlyAPIProvider, fetchReferences, batchFetchData, writeDataBatch, blockAriToResourceId, convertToSyncBlockData, extractResourceIdFromBlockAri, } from './providers/block-service/blockServiceAPI';
14
14
  export { fetchConfluencePageInfo } from './clients/confluence/sourceInfo';
15
15
  export { SyncedBlockProvider, useMemoizedSyncedBlockProvider } from './providers/syncBlockProvider';
16
- export type { ADFFetchProvider, ADFWriteProvider, BlockNodeIdentifiers, BlockSubscriptionErrorCallback, BlockUpdateCallback, SyncBlockDataProviderInterface, SyncBlockInstance, MediaEmojiProviderOptions, SyncedBlockRendererProviderOptions, SyncBlockRendererProviderCreator, SyncedBlockRendererDataProviders, Unsubscribe, UpdateReferenceSyncBlockResult, WriteSyncBlockResult, SyncBlockParentInfo, SyncBlockSourceInfo, } from './providers/types';
16
+ export type { ADFFetchProvider, ADFWriteProvider, BatchFetchConfig, BlockNodeIdentifiers, BlockSubscriptionErrorCallback, BlockUpdateCallback, SyncBlockDataProviderInterface, SyncBlockInstance, MediaEmojiProviderOptions, SyncedBlockRendererProviderOptions, SyncBlockRendererProviderCreator, SyncedBlockRendererDataProviders, Unsubscribe, UpdateReferenceSyncBlockResult, WriteSyncBlockResult, SyncBlockParentInfo, SyncBlockSourceInfo, } from './providers/types';
17
17
  export { ReferenceSyncBlockStoreManager } from './store-manager/referenceSyncBlockStoreManager';
18
18
  export { SyncBlockInMemorySessionCache, syncBlockInMemorySessionCache, } from './store-manager/syncBlockInMemorySessionCache';
19
19
  export { SyncBlockStoreManager, useMemoizedSyncBlockStoreManager, } from './store-manager/syncBlockStoreManager';
@@ -1,6 +1,6 @@
1
1
  import { type BlockContentResponse } from '../../clients/block-service/blockService';
2
2
  import { SyncBlockError, type ReferenceSyncBlockData, type ResourceId, type SyncBlockAttrs, type SyncBlockData, type SyncBlockProduct } from '../../common/types';
3
- import type { ADFFetchProvider, ADFWriteProvider, BlockNodeIdentifiers, DeleteSyncBlockResult, SyncBlockInstance, UpdateReferenceSyncBlockResult, WriteSyncBlockResult } from '../types';
3
+ import type { ADFFetchProvider, ADFWriteProvider, BatchFetchConfig, BlockNodeIdentifiers, DeleteSyncBlockResult, SyncBlockInstance, UpdateReferenceSyncBlockResult, WriteSyncBlockResult } from '../types';
4
4
  /**
5
5
  * Extracts the ResourceId from a block ARI by returning the full path after synced-block/.
6
6
  *
@@ -30,9 +30,10 @@ export declare const extractResourceIdFromBlockAri: (blockAri: string) => string
30
30
  * @param cloudId - The cloudId of the block. E.G the cloudId of the confluence page, or the cloudId of the Jira instance
31
31
  * @param parentAri - The ARI of the parent of the block. E.G the ARI of the confluence page, or the ARI of the Jira work item
32
32
  * @param blockNodeIdentifiers - Array of block node identifiers to fetch
33
+ * @param config - Optional batch fetch configuration
33
34
  * @returns Array of SyncBlockInstance results
34
35
  */
35
- export declare const batchFetchData: (cloudId: string, parentAri: string | undefined, blockNodeIdentifiers: BlockNodeIdentifiers[]) => Promise<SyncBlockInstance[]>;
36
+ export declare const batchFetchData: (cloudId: string, parentAri: string | undefined, blockNodeIdentifiers: BlockNodeIdentifiers[], config?: BatchFetchConfig) => Promise<SyncBlockInstance[]>;
36
37
  /**
37
38
  * Batch writes multiple synced blocks.
38
39
  * @param cloudId - The cloudId of the block. E.G the cloudId of the confluence page, or the cloudId of the Jira instance
@@ -60,9 +61,10 @@ declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
60
61
  /**
61
62
  * Batch fetches multiple synced blocks by their resource IDs.
62
63
  * @param blockNodeIdentifiers - Array of block node identifiers to fetch
64
+ * @param config - Optional batch fetch configuration
63
65
  * @returns Array of SyncBlockInstance results
64
66
  */
65
- batchFetchData(blockNodeIdentifiers: BlockNodeIdentifiers[]): Promise<SyncBlockInstance[]>;
67
+ batchFetchData(blockNodeIdentifiers: BlockNodeIdentifiers[], config?: BatchFetchConfig): Promise<SyncBlockInstance[]>;
66
68
  /**
67
69
  * Subscribes to real-time updates for a specific block using GraphQL WebSocket subscriptions.
68
70
  * @param resourceId - The resource ID of the block to subscribe to
@@ -1,4 +1,3 @@
1
- import type { RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
2
1
  import type { JSONNode } from '@atlaskit/editor-json-transformer/types';
3
2
  import { type BlockInstanceId, type DeletionReason, type ReferenceSyncBlockData, type ResourceId, type SyncBlockAttrs, type SyncBlockData, type SyncBlockNode, type SyncBlockProduct } from '../common/types';
4
3
  import { SyncBlockDataProviderInterface, type ADFFetchProvider, type ADFWriteProvider, type BlockSubscriptionErrorCallback, type BlockUpdateCallback, type DeleteSyncBlockResult, type SyncBlockInstance, type SyncBlockParentInfo, type SyncBlockSourceInfo, type SyncedBlockRendererProviderOptions, type Unsubscribe, type UpdateReferenceSyncBlockResult, type WriteSyncBlockResult } from './types';
@@ -68,7 +67,7 @@ export declare class SyncedBlockProvider extends SyncBlockDataProviderInterface
68
67
  *
69
68
  * @returns The source info
70
69
  */
71
- fetchSyncBlockSourceInfo(localId?: BlockInstanceId, sourceAri?: string, sourceProduct?: SyncBlockProduct, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void, hasAccess?: boolean, urlType?: 'view' | 'edit', isUnpublished?: boolean): Promise<SyncBlockSourceInfo | undefined>;
70
+ fetchSyncBlockSourceInfo(localId?: BlockInstanceId, sourceAri?: string, sourceProduct?: SyncBlockProduct, hasAccess?: boolean): Promise<SyncBlockSourceInfo | undefined>;
72
71
  generateResourceId(): {
73
72
  localId: BlockInstanceId;
74
73
  resourceId: ResourceId;
@@ -106,5 +105,5 @@ type UseMemoizedSyncedBlockProviderProps = {
106
105
  providerOptions: SyncedBlockRendererProviderOptions;
107
106
  writeProvider: ADFWriteProvider | undefined;
108
107
  };
109
- export declare const useMemoizedSyncedBlockProvider: (args_0: UseMemoizedSyncedBlockProviderProps) => SyncedBlockProvider;
108
+ export declare const useMemoizedSyncedBlockProvider: ({ fetchProvider, writeProvider, providerOptions, getSSRData, }: UseMemoizedSyncedBlockProviderProps) => SyncedBlockProvider;
110
109
  export {};
@@ -1,4 +1,3 @@
1
- import type { RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
2
1
  import type { CardProvider, MediaProvider, ProfilecardProvider } from '@atlaskit/editor-common/provider-factory';
3
2
  import type { EmojiProvider } from '@atlaskit/emoji';
4
3
  import type { MentionProvider } from '@atlaskit/mention/types';
@@ -61,11 +60,22 @@ export type BlockNodeIdentifiers = {
61
60
  blockInstanceId: string;
62
61
  resourceId: string;
63
62
  };
63
+ /**
64
+ * Configuration options for batch fetch operations
65
+ */
66
+ export type BatchFetchConfig = {
67
+ /** Whether the batch fetch is being performed in a server-side rendering context */
68
+ isSSR?: boolean;
69
+ /** Maximum number of blocks to fetch in a single batch request */
70
+ maxBatchSize?: number;
71
+ /** Timeout in milliseconds for batch fetch requests */
72
+ timeoutMs?: number;
73
+ };
64
74
  export type BlockUpdateCallback = (data: SyncBlockInstance) => void;
65
75
  export type BlockSubscriptionErrorCallback = (error: Error) => void;
66
76
  export type Unsubscribe = () => void;
67
77
  export interface ADFFetchProvider {
68
- batchFetchData: (blockNodeIdentifiers: BlockNodeIdentifiers[]) => Promise<SyncBlockInstance[]>;
78
+ batchFetchData: (blockNodeIdentifiers: BlockNodeIdentifiers[], config?: BatchFetchConfig) => Promise<SyncBlockInstance[]>;
69
79
  fetchData: (resourceId: ResourceId) => Promise<SyncBlockInstance>;
70
80
  fetchReferences: (referenceResourceId: string) => Promise<ReferenceSyncBlockData>;
71
81
  /**
@@ -118,7 +128,7 @@ export declare abstract class SyncBlockDataProviderInterface extends NodeDataPro
118
128
  abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<WriteSyncBlockResult>>;
119
129
  abstract createNodeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
120
130
  abstract deleteNodesData(resourceIds: string[], deleteReason: DeletionReason): Promise<Array<DeleteSyncBlockResult>>;
121
- abstract fetchSyncBlockSourceInfo(localId?: BlockInstanceId, sourceAri?: string, sourceProduct?: SyncBlockProduct, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void, hasAccess?: boolean, urlType?: 'view' | 'edit', isUnpublished?: boolean): Promise<SyncBlockSourceInfo | undefined>;
131
+ abstract fetchSyncBlockSourceInfo(localId?: BlockInstanceId, sourceAri?: string, sourceProduct?: SyncBlockProduct, hasAccess?: boolean): Promise<SyncBlockSourceInfo | undefined>;
122
132
  abstract setProviderOptions(providerOptions: SyncedBlockRendererProviderOptions): void;
123
133
  abstract getSyncedBlockRendererProviderOptions(): SyncedBlockRendererProviderOptions;
124
134
  abstract retrieveSyncBlockParentInfo(sourceAri: string, sourceProduct: SyncBlockProduct): SyncBlockParentInfo | undefined;
@@ -107,7 +107,7 @@ export declare class ReferenceSyncBlockStoreManager {
107
107
  * Cleans up all GraphQL subscriptions.
108
108
  */
109
109
  private cleanupAllGraphQLSubscriptions;
110
- fetchSyncBlockSourceInfoBySourceAri(sourceAri: string, hasAccess?: boolean, urlType?: 'view' | 'edit'): Promise<SyncBlockSourceInfo | undefined>;
110
+ fetchSyncBlockSourceInfoBySourceAri(sourceAri: string, hasAccess?: boolean): Promise<SyncBlockSourceInfo | undefined>;
111
111
  fetchSyncBlockSourceInfo(resourceId: ResourceId): Promise<SyncBlockSourceInfo | undefined>;
112
112
  /**
113
113
  * Processes prefetched data and updates the cache.
@@ -17,4 +17,4 @@ export declare class SyncBlockStoreManager {
17
17
  get sourceManager(): SourceSyncBlockStoreManager;
18
18
  destroy(): void;
19
19
  }
20
- export declare const useMemoizedSyncBlockStoreManager: (dataProvider?: SyncBlockDataProviderInterface | undefined, fireAnalyticsEvent?: ((payload: SyncBlockEventPayload) => void) | undefined) => SyncBlockStoreManager;
20
+ export declare const useMemoizedSyncBlockStoreManager: (dataProvider?: SyncBlockDataProviderInterface, fireAnalyticsEvent?: (payload: SyncBlockEventPayload) => void) => SyncBlockStoreManager;
package/package.json CHANGED
@@ -29,16 +29,15 @@
29
29
  "@atlaskit/editor-prosemirror": "^7.3.0",
30
30
  "@atlaskit/node-data-provider": "^8.3.0",
31
31
  "@atlaskit/platform-feature-flags": "^1.1.0",
32
- "@atlaskit/platform-feature-flags-react": "^0.4.0",
33
32
  "@babel/runtime": "^7.0.0",
34
- "@compiled/react": "^0.18.6",
33
+ "@compiled/react": "^0.20.0",
35
34
  "graphql-ws": "^5.14.2",
36
35
  "lodash": "^4.17.21",
37
36
  "raf-schd": "^4.0.3",
38
37
  "uuid": "^3.1.0"
39
38
  },
40
39
  "peerDependencies": {
41
- "@atlaskit/editor-common": "^111.21.0",
40
+ "@atlaskit/editor-common": "^111.30.0",
42
41
  "react": "^18.2.0"
43
42
  },
44
43
  "devDependencies": {
@@ -81,7 +80,7 @@
81
80
  }
82
81
  },
83
82
  "name": "@atlaskit/editor-synced-block-provider",
84
- "version": "3.31.2",
83
+ "version": "3.32.0",
85
84
  "description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
86
85
  "author": "Atlassian Pty Ltd",
87
86
  "license": "Apache-2.0",
@@ -89,12 +88,6 @@
89
88
  "registry": "https://registry.npmjs.org/"
90
89
  },
91
90
  "platform-feature-flags": {
92
- "platform_synced_block_patch_3": {
93
- "type": "boolean"
94
- },
95
- "platform_synced_block_patch_4": {
96
- "type": "boolean"
97
- },
98
91
  "platform_synced_block_patch_5": {
99
92
  "type": "boolean"
100
93
  }