@atlaskit/editor-synced-block-provider 7.0.14 → 8.0.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 (91) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/blockService/ari/package.json +1 -8
  3. package/blockService/package.json +1 -8
  4. package/blockSubscription/package.json +1 -8
  5. package/clients/confluence/ari/package.json +1 -8
  6. package/common/types/package.json +1 -8
  7. package/errorHandling/package.json +1 -8
  8. package/fetchJiraMediaToken/package.json +1 -8
  9. package/fetchMediaToken/package.json +1 -8
  10. package/jira/ari/package.json +1 -8
  11. package/package.json +8 -16
  12. package/providers/block-service/blockServiceAPI/package.json +1 -8
  13. package/providers/types/package.json +1 -8
  14. package/rebaseTransaction/package.json +1 -8
  15. package/referenceSyncBlockStoreManager/package.json +1 -8
  16. package/requestJiraIssueAccess/package.json +1 -8
  17. package/resolveSyncBlockInstance/package.json +1 -8
  18. package/sourceInfo/package.json +1 -8
  19. package/syncBlockInMemorySessionCache/package.json +1 -8
  20. package/syncBlockProvider/package.json +1 -8
  21. package/syncBlockStoreManager/package.json +1 -8
  22. package/tokenRouting/package.json +1 -8
  23. package/types/package.json +1 -8
  24. package/useFetchSyncBlockData/package.json +1 -8
  25. package/useFetchSyncBlockTitle/package.json +1 -8
  26. package/useHandleContentChanges/package.json +1 -8
  27. package/utils/package.json +1 -8
  28. package/utils/resourceId/package.json +1 -8
  29. package/validValue/package.json +1 -8
  30. package/dist/types-ts4.5/clients/block-service/ari.d.ts +0 -34
  31. package/dist/types-ts4.5/clients/block-service/blockService.d.ts +0 -187
  32. package/dist/types-ts4.5/clients/block-service/blockSubscription.d.ts +0 -52
  33. package/dist/types-ts4.5/clients/confluence/ari.d.ts +0 -27
  34. package/dist/types-ts4.5/clients/confluence/fetchMediaToken.d.ts +0 -10
  35. package/dist/types-ts4.5/clients/confluence/sourceInfo.d.ts +0 -2
  36. package/dist/types-ts4.5/clients/confluence/utils.d.ts +0 -2
  37. package/dist/types-ts4.5/clients/jira/ari.d.ts +0 -18
  38. package/dist/types-ts4.5/clients/jira/fetchMediaToken.d.ts +0 -9
  39. package/dist/types-ts4.5/clients/jira/requestJiraIssueAccess.d.ts +0 -13
  40. package/dist/types-ts4.5/clients/jira/sourceInfo.d.ts +0 -22
  41. package/dist/types-ts4.5/clients/tokenRouting.d.ts +0 -11
  42. package/dist/types-ts4.5/common/consts.d.ts +0 -4
  43. package/dist/types-ts4.5/common/rebase-transaction.d.ts +0 -11
  44. package/dist/types-ts4.5/common/types.d.ts +0 -82
  45. package/dist/types-ts4.5/entry-points/blockService-ari.d.ts +0 -1
  46. package/dist/types-ts4.5/entry-points/blockService.d.ts +0 -2
  47. package/dist/types-ts4.5/entry-points/blockServiceAPI.d.ts +0 -1
  48. package/dist/types-ts4.5/entry-points/blockSubscription.d.ts +0 -1
  49. package/dist/types-ts4.5/entry-points/common-types.d.ts +0 -2
  50. package/dist/types-ts4.5/entry-points/confluence-ari.d.ts +0 -1
  51. package/dist/types-ts4.5/entry-points/errorHandling.d.ts +0 -1
  52. package/dist/types-ts4.5/entry-points/fetchJiraMediaToken.d.ts +0 -1
  53. package/dist/types-ts4.5/entry-points/fetchMediaToken.d.ts +0 -2
  54. package/dist/types-ts4.5/entry-points/jira-ari.d.ts +0 -1
  55. package/dist/types-ts4.5/entry-points/providers-types.d.ts +0 -1
  56. package/dist/types-ts4.5/entry-points/rebaseTransaction.d.ts +0 -1
  57. package/dist/types-ts4.5/entry-points/referenceSyncBlockStoreManager.d.ts +0 -1
  58. package/dist/types-ts4.5/entry-points/requestJiraIssueAccess.d.ts +0 -2
  59. package/dist/types-ts4.5/entry-points/resolveSyncBlockInstance.d.ts +0 -1
  60. package/dist/types-ts4.5/entry-points/resourceId.d.ts +0 -1
  61. package/dist/types-ts4.5/entry-points/sourceInfo.d.ts +0 -1
  62. package/dist/types-ts4.5/entry-points/syncBlockInMemorySessionCache.d.ts +0 -1
  63. package/dist/types-ts4.5/entry-points/syncBlockProvider.d.ts +0 -1
  64. package/dist/types-ts4.5/entry-points/syncBlockStoreManager.d.ts +0 -1
  65. package/dist/types-ts4.5/entry-points/tokenRouting.d.ts +0 -1
  66. package/dist/types-ts4.5/entry-points/useFetchSyncBlockData.d.ts +0 -2
  67. package/dist/types-ts4.5/entry-points/useFetchSyncBlockTitle.d.ts +0 -1
  68. package/dist/types-ts4.5/entry-points/useHandleContentChanges.d.ts +0 -1
  69. package/dist/types-ts4.5/entry-points/utils.d.ts +0 -1
  70. package/dist/types-ts4.5/entry-points/validValue.d.ts +0 -1
  71. package/dist/types-ts4.5/hooks/useFetchSyncBlockData.d.ts +0 -16
  72. package/dist/types-ts4.5/hooks/useFetchSyncBlockTitle.d.ts +0 -3
  73. package/dist/types-ts4.5/hooks/useHandleContentChanges.d.ts +0 -3
  74. package/dist/types-ts4.5/index.d.ts +0 -25
  75. package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +0 -127
  76. package/dist/types-ts4.5/providers/syncBlockProvider.d.ts +0 -110
  77. package/dist/types-ts4.5/providers/types.d.ts +0 -185
  78. package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +0 -147
  79. package/dist/types-ts4.5/store-manager/sourceSyncBlockStoreManager.d.ts +0 -128
  80. package/dist/types-ts4.5/store-manager/syncBlockBatchFetcher.d.ts +0 -33
  81. package/dist/types-ts4.5/store-manager/syncBlockInMemorySessionCache.d.ts +0 -41
  82. package/dist/types-ts4.5/store-manager/syncBlockProviderFactoryManager.d.ts +0 -26
  83. package/dist/types-ts4.5/store-manager/syncBlockStoreManager.d.ts +0 -24
  84. package/dist/types-ts4.5/store-manager/syncBlockSubscriptionManager.d.ts +0 -84
  85. package/dist/types-ts4.5/utils/errorHandling.d.ts +0 -36
  86. package/dist/types-ts4.5/utils/experienceTracking.d.ts +0 -59
  87. package/dist/types-ts4.5/utils/resolveSyncBlockInstance.d.ts +0 -13
  88. package/dist/types-ts4.5/utils/resourceId.d.ts +0 -7
  89. package/dist/types-ts4.5/utils/retry.d.ts +0 -1
  90. package/dist/types-ts4.5/utils/utils.d.ts +0 -15
  91. package/dist/types-ts4.5/utils/validValue.d.ts +0 -3
@@ -1,127 +0,0 @@
1
- import type { BlockContentResponse } from '../../clients/block-service/blockService';
2
- import { SyncBlockError } from '../../common/types';
3
- import type { ReferenceSyncBlockData, ResourceId, SyncBlockAttrs, SyncBlockData, SyncBlockProduct } from '../../common/types';
4
- import type { ADFFetchProvider, ADFWriteProvider, BatchFetchConfig, BlockNodeIdentifiers, DeleteSyncBlockResult, SyncBlockInstance, UpdateReferenceSyncBlockResult, WriteSyncBlockResult } from '../types';
5
- /**
6
- * Extracts the ResourceId from a block ARI by returning the full path after synced-block/.
7
- *
8
- * Document ARI format from Block Service API:
9
- * "ari:cloud:blocks:{uuid}:synced-block/{product}/{parentId}/{resourceId}"
10
- *
11
- * ResourceId format (extracted from ARI):
12
- * "{product}/{parentId}/{resourceId}" (the full path after synced-block/)
13
- *
14
- * Example in context:
15
- * Input: "ari:cloud:blocks:{uuid}:synced-block/confluence-page/{pageId}/{resourceId}"
16
- * Output: "confluence-page/{pageId}/{resourceId}"
17
- *
18
- * @param blockAri - The block ARI string from Block Service API
19
- * @returns The ResourceId (full path after synced-block/)
20
- */
21
- export declare const blockAriToResourceId: (blockAri: string) => ResourceId | null;
22
- export declare const convertToSyncBlockData: (data: BlockContentResponse, resourceId: ResourceId) => SyncBlockData;
23
- export declare const fetchReferences: (documentAri: string) => Promise<SyncBlockInstance[] | SyncBlockError>;
24
- /**
25
- * Extracts the resourceId from a block ARI.
26
- * Block ARI format: ari:cloud:blocks:<cloudId>:synced-block/<resourceId>
27
- */
28
- export declare const extractResourceIdFromBlockAri: (blockAri: string) => string | undefined;
29
- /**
30
- * Batch fetches multiple synced blocks by their resource IDs.
31
- * @param cloudId - The cloudId of the block. E.G the cloudId of the confluence page, or the cloudId of the Jira instance
32
- * @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
33
- * @param blockNodeIdentifiers - Array of block node identifiers to fetch
34
- * @param config - Optional batch fetch configuration
35
- * @returns Array of SyncBlockInstance results
36
- */
37
- export declare const batchFetchData: (cloudId: string, parentAri: string | undefined, blockNodeIdentifiers: BlockNodeIdentifiers[], config?: BatchFetchConfig) => Promise<SyncBlockInstance[]>;
38
- /**
39
- * Batch writes multiple synced blocks.
40
- * @param cloudId - The cloudId of the block. E.G the cloudId of the confluence page, or the cloudId of the Jira instance
41
- * @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
42
- * @param parentId - The parentId of the block. E.G the pageId for a confluence page, or the issueId for a Jira work item
43
- * @param product - The product of the block. E.G 'confluence-page', 'jira-work-item'
44
- * @param data - Array of SyncBlockData to write
45
- * @param stepVersion - Optional version number
46
- * @returns Array of WriteSyncBlockResult results
47
- */
48
- export declare const writeDataBatch: (cloudId: string, parentAri: string | undefined, parentId: string | undefined, product: SyncBlockProduct, data: SyncBlockData[], stepVersion?: number) => Promise<WriteSyncBlockResult[]>;
49
- interface BlockServiceADFFetchProviderProps {
50
- cloudId: string;
51
- parentAri: string | undefined;
52
- }
53
- /**
54
- * ADFFetchProvider implementation that fetches synced block data from Block Service API
55
- */
56
- declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
57
- private cloudId;
58
- private parentAri;
59
- constructor({ cloudId, parentAri }: BlockServiceADFFetchProviderProps);
60
- fetchData(resourceId: string): Promise<SyncBlockInstance>;
61
- fetchReferences(referenceResourceId: string): Promise<ReferenceSyncBlockData>;
62
- /**
63
- * Batch fetches multiple synced blocks by their resource IDs.
64
- * @param blockNodeIdentifiers - Array of block node identifiers to fetch
65
- * @param config - Optional batch fetch configuration
66
- * @returns Array of SyncBlockInstance results
67
- */
68
- batchFetchData(blockNodeIdentifiers: BlockNodeIdentifiers[], config?: BatchFetchConfig): Promise<SyncBlockInstance[]>;
69
- /**
70
- * Subscribes to real-time updates for a specific block using GraphQL WebSocket subscriptions.
71
- * @param resourceId - The resource ID of the block to subscribe to
72
- * @param onUpdate - Callback function invoked when the block is updated
73
- * @param onError - Optional callback function invoked on subscription errors
74
- * @returns Unsubscribe function to stop receiving updates
75
- */
76
- subscribeToBlockUpdates(resourceId: ResourceId, onUpdate: (data: SyncBlockInstance) => void, onError?: (error: Error) => void, onComplete?: () => void): () => void;
77
- }
78
- interface BlockServiceADFWriteProviderProps {
79
- cloudId: string;
80
- getVersion?: () => Promise<number | undefined>;
81
- parentAri: string | undefined;
82
- parentId?: string;
83
- product: SyncBlockProduct;
84
- }
85
- /**
86
- * ADFWriteProvider implementation that writes synced block data to Block Service API
87
- */
88
- declare class BlockServiceADFWriteProvider implements ADFWriteProvider {
89
- private cloudId;
90
- private parentId?;
91
- private getVersion?;
92
- product: SyncBlockProduct;
93
- parentAri: string | undefined;
94
- constructor({ cloudId, parentAri, parentId, product, getVersion, }: BlockServiceADFWriteProviderProps);
95
- writeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
96
- createData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
97
- deleteData(resourceId: string, deleteReason: string | undefined): Promise<DeleteSyncBlockResult>;
98
- private deleteOrphanBlock;
99
- generateResourceIdForReference(sourceId: ResourceId): ResourceId;
100
- generateResourceId(): ResourceId;
101
- generateBlockAri(resourceId: ResourceId): string;
102
- updateReferenceData(blocks: SyncBlockAttrs[], noContent?: boolean): Promise<UpdateReferenceSyncBlockResult>;
103
- writeDataBatch(data: SyncBlockData[]): Promise<WriteSyncBlockResult[]>;
104
- }
105
- interface BlockServiceAPIProvidersProps {
106
- cloudId: string;
107
- getVersion?: () => Promise<number | undefined>;
108
- parentAri: string | undefined;
109
- parentId?: string;
110
- product: SyncBlockProduct;
111
- }
112
- export declare const useMemoizedBlockServiceAPIProviders: ({ cloudId, parentAri, parentId, product, getVersion, }: BlockServiceAPIProvidersProps) => {
113
- fetchProvider: BlockServiceADFFetchProvider;
114
- writeProvider: BlockServiceADFWriteProvider;
115
- };
116
- interface BlockServiceFetchOnlyAPIProviderProps {
117
- cloudId: string;
118
- parentAri: string | undefined;
119
- }
120
- /**
121
- * If the parentAri is not a valid ARI, pass in an empty string.
122
- */
123
- export declare const useMemoizedBlockServiceFetchOnlyAPIProvider: ({ cloudId, parentAri, }: BlockServiceFetchOnlyAPIProviderProps) => {
124
- fetchProvider: BlockServiceADFFetchProvider;
125
- writeProvider: undefined;
126
- };
127
- export {};
@@ -1,110 +0,0 @@
1
- import type { JSONNode } from '@atlaskit/editor-json-transformer/types';
2
- import type { BlockInstanceId, DeletionReason, ReferenceSyncBlockData, ResourceId, SyncBlockAttrs, SyncBlockData, SyncBlockNode, SyncBlockProduct } from '../common/types';
3
- import { SyncBlockDataProviderInterface } from './types';
4
- import type { ADFFetchProvider, ADFWriteProvider, BlockSubscriptionErrorCallback, BlockUpdateCallback, DeleteSyncBlockResult, SyncBlockInstance, SyncBlockParentInfo, SyncBlockSourceInfo, SyncedBlockRendererProviderOptions, Unsubscribe, UpdateReferenceSyncBlockResult, WriteSyncBlockResult } from './types';
5
- export declare class SyncedBlockProvider extends SyncBlockDataProviderInterface {
6
- name: string;
7
- private fetchProvider;
8
- private writeProvider;
9
- private providerOptions;
10
- /**
11
- * Constructor for the SyncedBlockProvider
12
- *
13
- * @param fetchProvider
14
- * @param writeProvider
15
- * @param nestedRendererDataProviders
16
- */
17
- constructor(fetchProvider: ADFFetchProvider, writeProvider: ADFWriteProvider | undefined);
18
- setProviderOptions(providerOptions: SyncedBlockRendererProviderOptions): void;
19
- /**
20
- * Check if the node is supported by the provider
21
- *
22
- * @param node
23
- *
24
- * @returns True if the node is supported, false otherwise
25
- */
26
- isNodeSupported(node: JSONNode): node is SyncBlockNode;
27
- /**
28
- * Get the data key for the node
29
- *
30
- * @param node
31
- *
32
- * @returns The data key
33
- */
34
- nodeDataKey(node: SyncBlockNode): string;
35
- /**
36
- * Fetch the data from the fetch provider using batch API
37
- *
38
- * @param nodes
39
- *
40
- * @returns Array of {resourceId?: string, error?: string}.
41
- */
42
- fetchNodesData(nodes: SyncBlockNode[]): Promise<SyncBlockInstance[]>;
43
- /**
44
- * Write the data to the write provider
45
- *
46
- * @param nodes
47
- * @param data
48
- *
49
- * @returns Array of {resourceId?: string, error?: string}.
50
- * resourceId: resource id of the node if write successfully , error: reason for when write failed
51
- */
52
- writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<WriteSyncBlockResult>>;
53
- createNodeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
54
- /**
55
- * Delete the data from the write provider
56
- *
57
- * @param resourceIds
58
- *
59
- * @returns Array of {resourceId?: string, error?: string}.
60
- */
61
- deleteNodesData(resourceIds: ResourceId[], deletionReason: DeletionReason): Promise<Array<DeleteSyncBlockResult>>;
62
- /**
63
- * Fetch the source info from the source id
64
- *
65
- * @param params
66
- * @param params.sourceAri - The source ARI
67
- * @param params.sourceProduct - The source product. e.g. 'confluence-page', 'jira-work-item'
68
- *
69
- * @returns The source info
70
- */
71
- fetchSyncBlockSourceInfo(localId?: BlockInstanceId, sourceAri?: string, sourceProduct?: SyncBlockProduct, hasAccess?: boolean): Promise<SyncBlockSourceInfo | undefined>;
72
- generateResourceId(): {
73
- localId: BlockInstanceId;
74
- resourceId: ResourceId;
75
- };
76
- generateResourceIdForReference(sourceId: ResourceId): ResourceId;
77
- /**
78
- * Get the synced block renderer provider options
79
- *
80
- * @returns The synced block renderer provider options
81
- */
82
- getSyncedBlockRendererProviderOptions(): SyncedBlockRendererProviderOptions;
83
- /**
84
- * Retrieve the parent info for the sync block
85
- *
86
- * @param sourceAri - The source ARI
87
- * @param sourceProduct - The source product. e.g. 'confluence-page', 'jira-work-item'
88
- *
89
- * @returns The parent info for the sync block
90
- */
91
- retrieveSyncBlockParentInfo(sourceAri: string, sourceProduct: SyncBlockProduct): SyncBlockParentInfo | undefined;
92
- updateReferenceData(blocks: SyncBlockAttrs[], noContent?: boolean): Promise<UpdateReferenceSyncBlockResult>;
93
- fetchReferences(resourceId: string, isSource: boolean): Promise<ReferenceSyncBlockData>;
94
- /**
95
- * Subscribes to real-time updates for a specific block.
96
- * @param resourceId - The resource ID of the block to subscribe to
97
- * @param onUpdate - Callback function invoked when the block is updated
98
- * @param onError - Optional callback function invoked on subscription errors
99
- * @returns Unsubscribe function to stop receiving updates, or undefined if not supported
100
- */
101
- subscribeToBlockUpdates(resourceId: string, onUpdate: BlockUpdateCallback, onError?: BlockSubscriptionErrorCallback, onComplete?: () => void): Unsubscribe | undefined;
102
- }
103
- type UseMemoizedSyncedBlockProviderProps = {
104
- fetchProvider: ADFFetchProvider;
105
- getSSRData?: () => Record<string, SyncBlockInstance> | undefined;
106
- providerOptions: SyncedBlockRendererProviderOptions;
107
- writeProvider: ADFWriteProvider | undefined;
108
- };
109
- export declare const useMemoizedSyncedBlockProvider: ({ fetchProvider, writeProvider, providerOptions, getSSRData, }: UseMemoizedSyncedBlockProviderProps) => SyncedBlockProvider;
110
- export {};
@@ -1,185 +0,0 @@
1
- import type { CardProvider, MediaProvider, ProfilecardProvider } from '@atlaskit/editor-common/provider-factory';
2
- import type { EmojiProvider } from '@atlaskit/emoji';
3
- import type { MentionProvider } from '@atlaskit/mention/types';
4
- import { NodeDataProvider } from '@atlaskit/node-data-provider';
5
- import type { TaskDecisionProvider } from '@atlaskit/task-decision/types';
6
- import type { SyncBlockData, SyncBlockStatus, ResourceId, SyncBlockError, SyncBlockNode, SyncBlockProduct, BlockInstanceId, SyncBlockAttrs, ReferenceSyncBlockData, DeletionReason } from '../common/types';
7
- type SyncBlockErrorInfo = {
8
- reason?: string;
9
- sourceAri?: string;
10
- type: SyncBlockError;
11
- };
12
- /**
13
- * The instance of a sync block, containing its data and metadata.
14
- * Mainly used for representing the state of a sync block after fetching from a data provider.
15
- * This will be used in both data processing and rendering contexts.
16
- */
17
- export type SyncBlockInstance = {
18
- data?: SyncBlockData;
19
- error?: SyncBlockErrorInfo;
20
- /**
21
- * The resourceId in the attrs of the block
22
- */
23
- resourceId: ResourceId;
24
- };
25
- export type DeleteSyncBlockResult = {
26
- error?: string;
27
- resourceId: ResourceId;
28
- success: boolean;
29
- };
30
- /**
31
- * Lightweight metadata for a Jira issue's type, surfaced so consumers can render the
32
- * correct ADS issue-type icon (Task / Bug / Story / Epic / Subtask) or fall back to the
33
- * AGG-provided `iconUrl` for custom types. Optional throughout — Confluence references
34
- * leave it `undefined`.
35
- */
36
- export type SyncBlockJiraIssueType = {
37
- /** AGG-served icon URL (from `avatar.xsmall`) — used as the fallback when no ADS icon matches `name`. */
38
- iconUrl?: string;
39
- /** Display name of the issue type, e.g. `"Task"`, `"Bug"`, `"Story"`. */
40
- name: string;
41
- };
42
- export type SyncBlockSourceInfo = {
43
- hasAccess?: boolean;
44
- /**
45
- * Whether the source info is for a source synced block
46
- */
47
- isSource?: boolean;
48
- /**
49
- * Issue-type metadata for `productType === 'jira-work-item'` references. Always
50
- * `undefined` for Confluence references.
51
- */
52
- issueType?: SyncBlockJiraIssueType;
53
- onSameDocument?: boolean;
54
- productType?: SyncBlockProduct;
55
- sourceAri: string;
56
- subType?: string | null;
57
- title?: string;
58
- url?: string;
59
- };
60
- export type SyncBlockParentInfo = {
61
- contentAri: string;
62
- contentId: string;
63
- contentProduct: SyncBlockProduct;
64
- };
65
- export type WriteSyncBlockResult = {
66
- error?: string;
67
- resourceId?: ResourceId;
68
- status?: SyncBlockStatus;
69
- };
70
- export type SourceInfoFetchData = {
71
- pageARI: string;
72
- sourceLocalId?: string;
73
- };
74
- export type UpdateReferenceSyncBlockResult = {
75
- error?: string;
76
- success: boolean;
77
- };
78
- export type BlockNodeIdentifiers = {
79
- blockInstanceId: string;
80
- resourceId: string;
81
- };
82
- /**
83
- * Configuration options for batch fetch operations
84
- */
85
- export type BatchFetchConfig = {
86
- /** Whether the batch fetch is being performed in a server-side rendering context */
87
- isSSR?: boolean;
88
- /** Maximum number of blocks to fetch in a single batch request */
89
- maxBatchSize?: number;
90
- /** Timeout in milliseconds for batch fetch requests */
91
- timeoutMs?: number;
92
- };
93
- export type BlockUpdateCallback = (data: SyncBlockInstance) => void;
94
- export type BlockSubscriptionErrorCallback = (error: Error) => void;
95
- export type BlockSubscriptionCompleteCallback = () => void;
96
- export type Unsubscribe = () => void;
97
- export interface ADFFetchProvider {
98
- batchFetchData: (blockNodeIdentifiers: BlockNodeIdentifiers[], config?: BatchFetchConfig) => Promise<SyncBlockInstance[]>;
99
- fetchData: (resourceId: ResourceId) => Promise<SyncBlockInstance>;
100
- fetchReferences: (referenceResourceId: string) => Promise<ReferenceSyncBlockData>;
101
- /**
102
- * Subscribes to real-time updates for a specific block.
103
- */
104
- subscribeToBlockUpdates?: (resourceId: ResourceId, onUpdate: BlockUpdateCallback, onError?: BlockSubscriptionErrorCallback, onComplete?: BlockSubscriptionCompleteCallback) => Unsubscribe;
105
- }
106
- export interface ADFWriteProvider {
107
- createData: (data: SyncBlockData) => Promise<WriteSyncBlockResult>;
108
- /**
109
- * Delete source block.
110
- * @param resourceId the resourceId of the block to be deleted
111
- * @param deleteReason the reason for the deletion, e.g. 'source-block-unsynced', 'source-block-deleted', 'source-block-unpublished'
112
- * @returns Object representing the result of the deletion. {resourceId: string, success: boolean, error?: string}.
113
- * User should not be blocked by not_found error when deleting, so successful result should be returned for 404 error
114
- */
115
- deleteData: (resourceId: ResourceId, deleteReason: string) => Promise<DeleteSyncBlockResult>;
116
- generateResourceIdForReference: (sourceId: ResourceId) => ResourceId;
117
- parentAri?: string;
118
- product: SyncBlockProduct;
119
- updateReferenceData: (blocks: SyncBlockAttrs[], noContent?: boolean) => Promise<UpdateReferenceSyncBlockResult>;
120
- writeData: (data: SyncBlockData) => Promise<WriteSyncBlockResult>;
121
- /**
122
- * Batch write multiple synced blocks.
123
- * @param data Array of SyncBlockData to write
124
- * @returns Array of write results, one for each block
125
- */
126
- writeDataBatch?: (data: SyncBlockData[]) => Promise<WriteSyncBlockResult[]>;
127
- }
128
- export type MediaEmojiProviderOptions = {
129
- contentAri: string;
130
- contentId: string;
131
- contentProduct: SyncBlockProduct;
132
- };
133
- export type SyncedBlockRendererDataProviders = {
134
- mentionProvider?: Promise<MentionProvider>;
135
- profilecardProvider?: Promise<ProfilecardProvider>;
136
- taskDecisionProvider?: Promise<TaskDecisionProvider>;
137
- };
138
- export type SyncBlockRendererProviderCreator = {
139
- createEmojiProvider: ((options: MediaEmojiProviderOptions) => Promise<EmojiProvider> | undefined) | undefined;
140
- createMediaProvider: ((options: MediaEmojiProviderOptions) => Promise<MediaProvider> | undefined) | undefined;
141
- createSmartLinkProvider: (() => Promise<CardProvider>) | undefined;
142
- createSSRMediaProvider?: ((options: MediaEmojiProviderOptions) => MediaProvider | undefined) | undefined;
143
- };
144
- export type SyncedBlockRendererProviderOptions = {
145
- parentDataProviders?: SyncedBlockRendererDataProviders;
146
- providerCreator?: SyncBlockRendererProviderCreator;
147
- };
148
- export declare abstract class SyncBlockDataProviderInterface extends NodeDataProvider<SyncBlockNode, SyncBlockInstance> {
149
- abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<WriteSyncBlockResult>>;
150
- abstract createNodeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
151
- abstract deleteNodesData(resourceIds: string[], deleteReason: DeletionReason): Promise<Array<DeleteSyncBlockResult>>;
152
- abstract fetchSyncBlockSourceInfo(localId?: BlockInstanceId, sourceAri?: string, sourceProduct?: SyncBlockProduct, hasAccess?: boolean): Promise<SyncBlockSourceInfo | undefined>;
153
- abstract setProviderOptions(providerOptions: SyncedBlockRendererProviderOptions): void;
154
- abstract getSyncedBlockRendererProviderOptions(): SyncedBlockRendererProviderOptions;
155
- abstract retrieveSyncBlockParentInfo(sourceAri: string, sourceProduct: SyncBlockProduct): SyncBlockParentInfo | undefined;
156
- /**
157
- * Generates a resource ID for source synced block.
158
- * @returns The generated resource ID
159
- */
160
- abstract generateResourceId(): {
161
- localId: BlockInstanceId;
162
- resourceId: ResourceId;
163
- };
164
- /**
165
- * Generates a resource ID for reference synced block.
166
- * @param sourceId - The source document ID (e.g., page ARI)
167
- * @returns The generated resource ID
168
- */
169
- abstract generateResourceIdForReference(sourceId: ResourceId): ResourceId;
170
- abstract updateReferenceData(blocks: SyncBlockAttrs[], noContent?: boolean): Promise<UpdateReferenceSyncBlockResult>;
171
- abstract fetchReferences(resourceId: string, isSource: boolean): Promise<ReferenceSyncBlockData>;
172
- /**
173
- * Subscribes to real-time updates for a specific block.
174
- * Returns undefined if subscriptions are not supported.
175
- * @param resourceId - The resource ID of the block to subscribe to
176
- * @param onUpdate - Callback function invoked when the block is updated
177
- * @param onError - Optional callback function invoked on subscription errors
178
- * @param onComplete - Optional callback function invoked when the subscription completes
179
- * @returns Unsubscribe function to stop receiving updates, or undefined if not supported
180
- */
181
- subscribeToBlockUpdates?(resourceId: ResourceId, onUpdate: BlockUpdateCallback, onError?: BlockSubscriptionErrorCallback, onComplete?: BlockSubscriptionCompleteCallback): Unsubscribe | undefined;
182
- }
183
- export type SubscriptionCallback = (data: SyncBlockInstance) => void;
184
- export type TitleSubscriptionCallback = (title: string) => void;
185
- export {};
@@ -1,147 +0,0 @@
1
- import type { RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
2
- import type { Experience } from '@atlaskit/editor-common/experiences';
3
- import type { ProviderFactory, MediaProvider } from '@atlaskit/editor-common/provider-factory';
4
- import type { ViewMode } from '@atlaskit/editor-plugin-editor-viewmode';
5
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
6
- import type { BlockInstanceId, ResourceId, SyncBlockNode, SyncBlockPrefetchData } from '../common/types';
7
- import type { SyncBlockInstance, SubscriptionCallback, SyncBlockDataProviderInterface, TitleSubscriptionCallback, SyncBlockSourceInfo } from '../providers/types';
8
- export declare class ReferenceSyncBlockStoreManager {
9
- private viewMode?;
10
- private dataProvider?;
11
- private isCacheDirty;
12
- private fireAnalyticsEvent?;
13
- private syncBlockFetchDataRequests;
14
- private syncBlockSourceInfoRequests;
15
- private newlyAddedSyncBlocks;
16
- private lastFlushedSyncedBlocks;
17
- private onUnpublishedSyncBlockDetected?;
18
- private isFlushInProgress;
19
- private flushNeededAfterCurrent;
20
- private queuedFlushTimeout?;
21
- private entityNotFoundRetryCount;
22
- private entityNotFoundRetryTimers;
23
- private pendingCacheDeletions;
24
- private cacheDeletionRescheduleCounts;
25
- private isDestroyed;
26
- fetchExperience: Experience | undefined;
27
- private fetchSourceInfoExperience;
28
- private saveExperience;
29
- private _subscriptionManager;
30
- private _providerFactoryManager;
31
- private _batchFetcher;
32
- constructor(dataProvider?: SyncBlockDataProviderInterface, viewMode?: ViewMode);
33
- isReferenceBlock(node: PMNode): boolean;
34
- /**
35
- * Enables or disables real-time GraphQL subscriptions for block updates.
36
- * When enabled, the store manager will subscribe to real-time updates
37
- * instead of relying on polling.
38
- * @param enabled - Whether to enable real-time subscriptions
39
- */
40
- setRealTimeSubscriptionsEnabled(enabled: boolean): void;
41
- /**
42
- * Checks if real-time subscriptions are currently enabled.
43
- */
44
- isRealTimeSubscriptionsEnabled(): boolean;
45
- /**
46
- * Returns all resource IDs that are currently subscribed to.
47
- * Used by React components to render subscription components.
48
- */
49
- getSubscribedResourceIds(): ResourceId[];
50
- /**
51
- * Registers a listener that will be called when subscriptions change.
52
- * @param listener - Callback function to invoke when subscriptions change
53
- * @returns Unsubscribe function to remove the listener
54
- */
55
- onSubscriptionsChanged(listener: () => void): () => void;
56
- /**
57
- * Handles incoming data from a GraphQL subscription.
58
- * Called by React subscription components when they receive updates.
59
- * @param syncBlockInstance - The updated sync block instance
60
- */
61
- handleSubscriptionUpdate(syncBlockInstance: SyncBlockInstance): void;
62
- setFireAnalyticsEvent(fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void): void;
63
- setOnUnpublishedSyncBlockDetected(callback?: (resourceId: ResourceId) => void): void;
64
- /**
65
- * Mark a sync block as newly added to the document.
66
- * This should be called when a sync block node is added via a transaction.
67
- * @param resourceId - The resource ID of the newly added sync block
68
- */
69
- markAsNewlyAdded(resourceId: ResourceId): void;
70
- generateResourceIdForReference(sourceId: ResourceId): ResourceId;
71
- updateFireAnalyticsEvent(fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void): void;
72
- getInitialSyncBlockData(resourceId: ResourceId): SyncBlockInstance | undefined;
73
- private stripAnnotationMarksFromReferenceData;
74
- private updateSessionCache;
75
- private getFromSessionCache;
76
- fetchSyncBlockSourceInfoBySourceAri(sourceAri: string, hasAccess?: boolean): Promise<SyncBlockSourceInfo | undefined>;
77
- fetchSyncBlockSourceInfoByLocalId(localId: BlockInstanceId, hasAccess?: boolean): Promise<SyncBlockSourceInfo | undefined>;
78
- fetchSyncBlockSourceInfo(resourceId: ResourceId): Promise<SyncBlockSourceInfo | undefined>;
79
- /**
80
- * Processes prefetched data and updates the cache.
81
- * @param prefetchedData - The prefetched data to process
82
- * @returns {Promise<void>}
83
- */
84
- processPrefetchedData(prefetchedData: SyncBlockPrefetchData | undefined): Promise<void>;
85
- /**
86
- * Fetch sync block data for a given array of sync block nodes.
87
- * @param syncBlockNodes - The array of sync block nodes to fetch data for
88
- * @returns The fetched sync block data results
89
- */
90
- fetchSyncBlocksData(syncBlockNodes: SyncBlockNode[]): Promise<void>;
91
- private processFetchedData;
92
- private updateCacheWithSourceInfo;
93
- private updateCache;
94
- getFromCache(resourceId: ResourceId): SyncBlockInstance | undefined;
95
- private deleteFromCache;
96
- /**
97
- * Returns true if the cache entry for `resourceId` is safe to delete:
98
- * no active subscribers, no in-flight source-info request, and no
99
- * queued/in-flight batch fetch (gated by `platform_synced_block_patch_14`).
100
- */
101
- private canDeleteCache;
102
- /**
103
- * Schedules cache deletion for `resourceId` after the grace period
104
- * (gated by `platform_synced_block_patch_14`). Called when the last
105
- * subscriber unsubscribes. Guards are re-checked at fire time; if any
106
- * are positive the timer is rescheduled up to MAX_RESCHEDULES times.
107
- */
108
- scheduleCacheDeletion(resourceId: ResourceId): void;
109
- /**
110
- * Cancels any pending cache deletion timer for `resourceId` and resets the
111
- * reschedule counter (gated by `platform_synced_block_patch_14`). Called
112
- * when a new subscriber arrives.
113
- */
114
- cancelPendingCacheDeletion(resourceId: ResourceId): void;
115
- /** Returns whether a cache deletion timer is pending for `resourceId`. */
116
- hasPendingCacheDeletion(resourceId: ResourceId): boolean;
117
- private onCacheDeletionTimerFire;
118
- /**
119
- * Schedules a delayed retry for a block that returned EntityNotFound.
120
- * The block may be in the process of being created by a collaborator —
121
- * the NCS transaction propagates the bodiedSyncBlock ADF node before
122
- * the Block Service createBlock call completes.
123
- */
124
- private scheduleEntityNotFoundRetry;
125
- private debouncedBatchedFetchSyncBlocks;
126
- private setSSRDataInSessionCache;
127
- subscribeToSyncBlock(resourceId: string, localId: string, callback: SubscriptionCallback): () => void;
128
- subscribeToSourceTitle(node: PMNode, callback: TitleSubscriptionCallback): () => void;
129
- subscribe(node: PMNode, callback: SubscriptionCallback): () => void;
130
- /**
131
- * Get the URL for a sync block.
132
- * @param resourceId - The resource ID of the sync block
133
- * @returns
134
- */
135
- getSyncBlockURL(resourceId: ResourceId): string | undefined;
136
- getProviderFactory(resourceId: ResourceId): ProviderFactory | undefined;
137
- getSSRProviders(resourceId: ResourceId): {
138
- media: MediaProvider;
139
- } | null;
140
- /**
141
- * Update reference synced blocks on the document with the BE
142
- *
143
- * @returns true if the reference synced blocks are updated successfully, false otherwise
144
- */
145
- flush(): Promise<boolean>;
146
- destroy(): void;
147
- }