@atlaskit/editor-synced-block-provider 3.12.0 → 3.13.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.
- package/CHANGELOG.md +25 -0
- package/dist/cjs/clients/block-service/blockSubscription.js +124 -0
- package/dist/cjs/clients/jira/sourceInfo.js +152 -0
- package/dist/cjs/providers/block-service/blockServiceAPI.js +43 -6
- package/dist/cjs/providers/syncBlockProvider.js +40 -8
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +393 -204
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +95 -124
- package/dist/cjs/store-manager/syncBlockStoreManager.js +2 -2
- package/dist/cjs/utils/errorHandling.js +79 -19
- package/dist/cjs/utils/experienceTracking.js +119 -0
- package/dist/cjs/utils/resolveSyncBlockInstance.js +1 -1
- package/dist/es2019/clients/block-service/blockSubscription.js +125 -0
- package/dist/es2019/clients/jira/sourceInfo.js +87 -0
- package/dist/es2019/providers/block-service/blockServiceAPI.js +40 -5
- package/dist/es2019/providers/syncBlockProvider.js +26 -2
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +286 -139
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +80 -89
- package/dist/es2019/store-manager/syncBlockStoreManager.js +2 -2
- package/dist/es2019/utils/errorHandling.js +61 -10
- package/dist/es2019/utils/experienceTracking.js +113 -0
- package/dist/es2019/utils/resolveSyncBlockInstance.js +1 -1
- package/dist/esm/clients/block-service/blockSubscription.js +118 -0
- package/dist/esm/clients/jira/sourceInfo.js +147 -0
- package/dist/esm/providers/block-service/blockServiceAPI.js +43 -6
- package/dist/esm/providers/syncBlockProvider.js +38 -6
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +394 -205
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +96 -125
- package/dist/esm/store-manager/syncBlockStoreManager.js +2 -2
- package/dist/esm/utils/errorHandling.js +77 -18
- package/dist/esm/utils/experienceTracking.js +113 -0
- package/dist/esm/utils/resolveSyncBlockInstance.js +1 -1
- package/dist/types/clients/block-service/blockService.d.ts +2 -2
- package/dist/types/clients/block-service/blockSubscription.d.ts +38 -0
- package/dist/types/clients/jira/sourceInfo.d.ts +2 -0
- package/dist/types/common/types.d.ts +4 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/providers/block-service/blockServiceAPI.d.ts +8 -0
- package/dist/types/providers/syncBlockProvider.d.ts +9 -1
- package/dist/types/providers/types.d.ts +22 -6
- package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +59 -1
- package/dist/types/store-manager/sourceSyncBlockStoreManager.d.ts +1 -5
- package/dist/types/utils/errorHandling.d.ts +14 -9
- package/dist/types/utils/experienceTracking.d.ts +51 -0
- package/dist/types-ts4.5/clients/block-service/blockService.d.ts +2 -2
- package/dist/types-ts4.5/clients/block-service/blockSubscription.d.ts +38 -0
- package/dist/types-ts4.5/clients/jira/sourceInfo.d.ts +2 -0
- package/dist/types-ts4.5/common/types.d.ts +4 -2
- package/dist/types-ts4.5/index.d.ts +2 -2
- package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +8 -0
- package/dist/types-ts4.5/providers/syncBlockProvider.d.ts +9 -1
- package/dist/types-ts4.5/providers/types.d.ts +22 -6
- package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +59 -1
- package/dist/types-ts4.5/store-manager/sourceSyncBlockStoreManager.d.ts +1 -5
- package/dist/types-ts4.5/utils/errorHandling.d.ts +14 -9
- package/dist/types-ts4.5/utils/experienceTracking.d.ts +51 -0
- package/package.json +2 -1
|
@@ -34,7 +34,7 @@ export var resolveSyncBlockInstance = function resolveSyncBlockInstance(oldResul
|
|
|
34
34
|
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
|
|
35
35
|
}, fg('platform_synced_block_dogfooding') && {
|
|
36
36
|
sourceSubType: ((_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,
|
|
37
|
-
|
|
37
|
+
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
|
|
38
38
|
})
|
|
39
39
|
});
|
|
40
40
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ReferenceSyncBlockResponse, SyncBlockProduct } from '../../common/types';
|
|
1
|
+
import type { ReferenceSyncBlockResponse, SyncBlockProduct, SyncBlockStatus } from '../../common/types';
|
|
2
2
|
export type BlockContentResponse = {
|
|
3
3
|
blockAri: string;
|
|
4
4
|
blockInstanceId: string;
|
|
@@ -7,7 +7,7 @@ export type BlockContentResponse = {
|
|
|
7
7
|
createdBy: string;
|
|
8
8
|
product: SyncBlockProduct;
|
|
9
9
|
sourceAri: string;
|
|
10
|
-
status:
|
|
10
|
+
status: SyncBlockStatus;
|
|
11
11
|
version: number;
|
|
12
12
|
};
|
|
13
13
|
export type ErrorResponse = {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ADFEntity } from '@atlaskit/adf-utils/types';
|
|
2
|
+
import type { SyncBlockProduct } from '../../common/types';
|
|
3
|
+
export type BlockSubscriptionPayload = {
|
|
4
|
+
blockAri: string;
|
|
5
|
+
blockInstanceId: string;
|
|
6
|
+
content: string;
|
|
7
|
+
contentUpdatedAt?: number;
|
|
8
|
+
createdAt: number;
|
|
9
|
+
createdBy: string;
|
|
10
|
+
deletionReason?: string;
|
|
11
|
+
product: string;
|
|
12
|
+
sourceAri: string;
|
|
13
|
+
status: string;
|
|
14
|
+
};
|
|
15
|
+
export type ParsedBlockSubscriptionData = {
|
|
16
|
+
blockAri: string;
|
|
17
|
+
blockInstanceId: string;
|
|
18
|
+
content: ADFEntity[];
|
|
19
|
+
createdAt?: string;
|
|
20
|
+
createdBy: string;
|
|
21
|
+
product: SyncBlockProduct;
|
|
22
|
+
resourceId: string;
|
|
23
|
+
sourceAri: string;
|
|
24
|
+
status: string;
|
|
25
|
+
};
|
|
26
|
+
type SubscriptionCallback = (data: ParsedBlockSubscriptionData) => void;
|
|
27
|
+
type ErrorCallback = (error: Error) => void;
|
|
28
|
+
type Unsubscribe = () => void;
|
|
29
|
+
/**
|
|
30
|
+
* Creates a GraphQL subscription to block updates using the shared graphql-ws client.
|
|
31
|
+
*
|
|
32
|
+
* @param blockAri - The full block ARI to subscribe to (ari:cloud:blocks:{cloudId}:synced-block/{resourceId})
|
|
33
|
+
* @param onData - Callback function invoked when block data is updated
|
|
34
|
+
* @param onError - Optional callback function invoked on subscription errors
|
|
35
|
+
* @returns Unsubscribe function to close the subscription
|
|
36
|
+
*/
|
|
37
|
+
export declare const subscribeToBlockUpdates: (blockAri: string, onData: SubscriptionCallback, onError?: ErrorCallback) => Unsubscribe;
|
|
38
|
+
export {};
|
|
@@ -5,6 +5,7 @@ import type { SYNC_BLOCK_PRODUCTS } from './consts';
|
|
|
5
5
|
export type BlockInstanceId = string;
|
|
6
6
|
export type ResourceId = string;
|
|
7
7
|
export type SyncBlockProduct = (typeof SYNC_BLOCK_PRODUCTS)[number];
|
|
8
|
+
export type SyncBlockStatus = 'active' | 'deleted' | 'unpublished';
|
|
8
9
|
export type SyncBlockAttrs = {
|
|
9
10
|
localId: BlockInstanceId;
|
|
10
11
|
resourceId: ResourceId;
|
|
@@ -34,7 +35,7 @@ export interface SyncBlockData {
|
|
|
34
35
|
/**
|
|
35
36
|
* Whether the block is on the same page as the source block
|
|
36
37
|
*/
|
|
37
|
-
|
|
38
|
+
onSameDocument?: boolean;
|
|
38
39
|
product?: SyncBlockProduct;
|
|
39
40
|
/**
|
|
40
41
|
* The ARI of the block. E.G ari:cloud:blocks:<cloudId>:synced-block/<product>/<pageId>/<resourceId>
|
|
@@ -45,6 +46,7 @@ export interface SyncBlockData {
|
|
|
45
46
|
sourceTitle?: string;
|
|
46
47
|
sourceURL?: string;
|
|
47
48
|
updatedAt?: string;
|
|
49
|
+
status?: SyncBlockStatus;
|
|
48
50
|
}
|
|
49
51
|
export interface ReferenceSyncBlockResponse {
|
|
50
52
|
blockAri: string;
|
|
@@ -55,7 +57,7 @@ export interface ReferenceSyncBlockResponse {
|
|
|
55
57
|
}
|
|
56
58
|
export interface ReferenceSyncBlock extends ReferenceSyncBlockResponse {
|
|
57
59
|
hasAccess: boolean;
|
|
58
|
-
|
|
60
|
+
onSameDocument: boolean;
|
|
59
61
|
}
|
|
60
62
|
export type ReferenceSyncBlockData = {
|
|
61
63
|
error?: SyncBlockError;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { rebaseTransaction } from './common/rebase-transaction';
|
|
2
2
|
export { SyncBlockError } from './common/types';
|
|
3
|
-
export type { SyncBlockData, SyncBlockNode, SyncBlockProduct, BlockInstanceId, SyncBlockAttrs, ReferenceSyncBlockData, ReferencesSourceInfo } from './common/types';
|
|
3
|
+
export type { ResourceId, SyncBlockData, SyncBlockNode, SyncBlockProduct, SyncBlockStatus, BlockInstanceId, SyncBlockAttrs, ReferenceSyncBlockData, ReferencesSourceInfo } from './common/types';
|
|
4
4
|
export { useFetchSyncBlockData, type UseFetchSyncBlockDataResult, } from './hooks/useFetchSyncBlockData';
|
|
5
5
|
export { useFetchSyncBlockTitle } from './hooks/useFetchSyncBlockTitle';
|
|
6
6
|
export { useHandleContentChanges } from './hooks/useHandleContentChanges';
|
|
@@ -11,7 +11,7 @@ export { getJiraWorkItemAri, getJiraWorkItemIdFromAri } from './clients/jira/ari
|
|
|
11
11
|
export { useMemoizedBlockServiceAPIProviders, useMemoizedBlockServiceFetchOnlyAPIProvider, } from './providers/block-service/blockServiceAPI';
|
|
12
12
|
export { fetchConfluencePageInfo } from './clients/confluence/sourceInfo';
|
|
13
13
|
export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider, } from './providers/syncBlockProvider';
|
|
14
|
-
export type { ADFFetchProvider, ADFWriteProvider, BlockNodeIdentifiers, SyncBlockDataProvider, SyncBlockInstance, MediaEmojiProviderOptions, SyncedBlockRendererProviderOptions, SyncBlockRendererProviderCreator, SyncedBlockRendererDataProviders, UpdateReferenceSyncBlockResult, WriteSyncBlockResult, SyncBlockParentInfo, SyncBlockSourceInfo, } from './providers/types';
|
|
14
|
+
export type { ADFFetchProvider, ADFWriteProvider, BlockNodeIdentifiers, BlockSubscriptionErrorCallback, BlockUpdateCallback, SyncBlockDataProvider, SyncBlockInstance, MediaEmojiProviderOptions, SyncedBlockRendererProviderOptions, SyncBlockRendererProviderCreator, SyncedBlockRendererDataProviders, Unsubscribe, UpdateReferenceSyncBlockResult, WriteSyncBlockResult, SyncBlockParentInfo, SyncBlockSourceInfo, } from './providers/types';
|
|
15
15
|
export { type ReferenceSyncBlockStoreManager } from './store-manager/referenceSyncBlockStoreManager';
|
|
16
16
|
export { SyncBlockStoreManager, useMemoizedSyncBlockStoreManager, } from './store-manager/syncBlockStoreManager';
|
|
17
17
|
export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
|
|
@@ -44,6 +44,14 @@ declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
|
|
|
44
44
|
* @returns Array of SyncBlockInstance results
|
|
45
45
|
*/
|
|
46
46
|
batchFetchData(blockNodeIdentifiers: BlockNodeIdentifiers[]): Promise<SyncBlockInstance[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Subscribes to real-time updates for a specific block using GraphQL WebSocket subscriptions.
|
|
49
|
+
* @param resourceId - The resource ID of the block to subscribe to
|
|
50
|
+
* @param onUpdate - Callback function invoked when the block is updated
|
|
51
|
+
* @param onError - Optional callback function invoked on subscription errors
|
|
52
|
+
* @returns Unsubscribe function to stop receiving updates
|
|
53
|
+
*/
|
|
54
|
+
subscribeToBlockUpdates(resourceId: ResourceId, onUpdate: (data: SyncBlockInstance) => void, onError?: (error: Error) => void): () => void;
|
|
47
55
|
}
|
|
48
56
|
interface BlockServiceADFWriteProviderProps {
|
|
49
57
|
cloudId: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import type { JSONNode } from '@atlaskit/editor-json-transformer/types';
|
|
3
3
|
import { type BlockInstanceId, type ReferenceSyncBlockData, type ResourceId, type SyncBlockAttrs, type SyncBlockData, type SyncBlockNode, type SyncBlockProduct } from '../common/types';
|
|
4
|
-
import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type DeleteSyncBlockResult, type SyncBlockInstance, type SyncBlockParentInfo, type SyncBlockSourceInfo, type SyncedBlockRendererProviderOptions, type UpdateReferenceSyncBlockResult, type WriteSyncBlockResult } from './types';
|
|
4
|
+
import { SyncBlockDataProvider, 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';
|
|
5
5
|
export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
6
6
|
name: string;
|
|
7
7
|
private fetchProvider;
|
|
@@ -91,6 +91,14 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
|
91
91
|
retrieveSyncBlockParentInfo(sourceAri: string, sourceProduct: SyncBlockProduct): SyncBlockParentInfo | undefined;
|
|
92
92
|
updateReferenceData(blocks: SyncBlockAttrs[], noContent?: boolean): Promise<UpdateReferenceSyncBlockResult>;
|
|
93
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): Unsubscribe | undefined;
|
|
94
102
|
}
|
|
95
103
|
type UseMemoizedSyncedBlockProviderProps = {
|
|
96
104
|
fetchProvider: ADFFetchProvider;
|
|
@@ -5,10 +5,6 @@ import type { MentionProvider } from '@atlaskit/mention/types';
|
|
|
5
5
|
import { NodeDataProvider } from '@atlaskit/node-data-provider';
|
|
6
6
|
import type { TaskDecisionProvider } from '@atlaskit/task-decision/types';
|
|
7
7
|
import type { SyncBlockData, ResourceId, SyncBlockError, SyncBlockNode, SyncBlockProduct, BlockInstanceId, SyncBlockAttrs, ReferenceSyncBlockData } from '../common/types';
|
|
8
|
-
export type BlockNodeIdentifiers = {
|
|
9
|
-
blockInstanceId: string;
|
|
10
|
-
resourceId: string;
|
|
11
|
-
};
|
|
12
8
|
/**
|
|
13
9
|
* The instance of a sync block, containing its data and metadata.
|
|
14
10
|
* Mainly used for representing the state of a sync block after fetching from a data provider.
|
|
@@ -33,7 +29,7 @@ export type SyncBlockSourceInfo = {
|
|
|
33
29
|
* Whether the source info is for a source synced block
|
|
34
30
|
*/
|
|
35
31
|
isSource?: boolean;
|
|
36
|
-
|
|
32
|
+
onSameDocument?: boolean;
|
|
37
33
|
productType?: SyncBlockProduct;
|
|
38
34
|
sourceAri: string;
|
|
39
35
|
subType?: string | null;
|
|
@@ -56,10 +52,21 @@ export type UpdateReferenceSyncBlockResult = {
|
|
|
56
52
|
error?: string;
|
|
57
53
|
success: boolean;
|
|
58
54
|
};
|
|
55
|
+
export type BlockNodeIdentifiers = {
|
|
56
|
+
blockInstanceId: string;
|
|
57
|
+
resourceId: string;
|
|
58
|
+
};
|
|
59
|
+
export type BlockUpdateCallback = (data: SyncBlockInstance) => void;
|
|
60
|
+
export type BlockSubscriptionErrorCallback = (error: Error) => void;
|
|
61
|
+
export type Unsubscribe = () => void;
|
|
59
62
|
export interface ADFFetchProvider {
|
|
60
63
|
batchFetchData: (blockNodeIdentifiers: BlockNodeIdentifiers[]) => Promise<SyncBlockInstance[]>;
|
|
61
64
|
fetchData: (resourceId: ResourceId) => Promise<SyncBlockInstance>;
|
|
62
65
|
fetchReferences: (referenceResourceId: string) => Promise<ReferenceSyncBlockData>;
|
|
66
|
+
/**
|
|
67
|
+
* Subscribes to real-time updates for a specific block.
|
|
68
|
+
*/
|
|
69
|
+
subscribeToBlockUpdates?: (resourceId: ResourceId, onUpdate: BlockUpdateCallback, onError?: BlockSubscriptionErrorCallback) => Unsubscribe;
|
|
63
70
|
}
|
|
64
71
|
export interface ADFWriteProvider {
|
|
65
72
|
createData: (data: SyncBlockData) => Promise<WriteSyncBlockResult>;
|
|
@@ -88,8 +95,8 @@ export type SyncedBlockRendererDataProviders = {
|
|
|
88
95
|
export type SyncBlockRendererProviderCreator = {
|
|
89
96
|
createEmojiProvider: ((options: MediaEmojiProviderOptions) => Promise<EmojiProvider> | undefined) | undefined;
|
|
90
97
|
createMediaProvider: ((options: MediaEmojiProviderOptions) => Promise<MediaProvider> | undefined) | undefined;
|
|
91
|
-
createSSRMediaProvider?: ((options: MediaEmojiProviderOptions) => MediaProvider | undefined) | undefined;
|
|
92
98
|
createSmartLinkProvider: (() => Promise<CardProvider>) | undefined;
|
|
99
|
+
createSSRMediaProvider?: ((options: MediaEmojiProviderOptions) => MediaProvider | undefined) | undefined;
|
|
93
100
|
};
|
|
94
101
|
export type SyncedBlockRendererProviderOptions = {
|
|
95
102
|
parentDataProviders?: SyncedBlockRendererDataProviders;
|
|
@@ -119,6 +126,15 @@ export declare abstract class SyncBlockDataProvider extends NodeDataProvider<Syn
|
|
|
119
126
|
abstract generateResourceIdForReference(sourceId: ResourceId): ResourceId;
|
|
120
127
|
abstract updateReferenceData(blocks: SyncBlockAttrs[], noContent?: boolean): Promise<UpdateReferenceSyncBlockResult>;
|
|
121
128
|
abstract fetchReferences(resourceId: string, isSource: boolean): Promise<ReferenceSyncBlockData>;
|
|
129
|
+
/**
|
|
130
|
+
* Subscribes to real-time updates for a specific block.
|
|
131
|
+
* Returns undefined if subscriptions are not supported.
|
|
132
|
+
* @param resourceId - The resource ID of the block to subscribe to
|
|
133
|
+
* @param onUpdate - Callback function invoked when the block is updated
|
|
134
|
+
* @param onError - Optional callback function invoked on subscription errors
|
|
135
|
+
* @returns Unsubscribe function to stop receiving updates, or undefined if not supported
|
|
136
|
+
*/
|
|
137
|
+
subscribeToBlockUpdates?(resourceId: ResourceId, onUpdate: BlockUpdateCallback, onError?: BlockSubscriptionErrorCallback): Unsubscribe | undefined;
|
|
122
138
|
}
|
|
123
139
|
export type SubscriptionCallback = (data: SyncBlockInstance) => void;
|
|
124
140
|
export type TitleSubscriptionCallback = (title: string) => void;
|
|
@@ -17,20 +17,78 @@ export declare class ReferenceSyncBlockStoreManager {
|
|
|
17
17
|
private syncBlockSourceInfoRequests;
|
|
18
18
|
private isRefreshingSubscriptions;
|
|
19
19
|
private pendingCacheDeletions;
|
|
20
|
+
private graphqlSubscriptions;
|
|
21
|
+
private useRealTimeSubscriptions;
|
|
22
|
+
private subscriptionChangeListeners;
|
|
20
23
|
fetchExperience: Experience | undefined;
|
|
21
24
|
private fetchSourceInfoExperience;
|
|
22
25
|
private saveExperience;
|
|
23
26
|
constructor(dataProvider?: SyncBlockDataProvider);
|
|
27
|
+
/**
|
|
28
|
+
* Enables or disables real-time GraphQL subscriptions for block updates.
|
|
29
|
+
* When enabled, the store manager will subscribe to real-time updates
|
|
30
|
+
* instead of relying on polling.
|
|
31
|
+
* @param enabled - Whether to enable real-time subscriptions
|
|
32
|
+
*/
|
|
33
|
+
setRealTimeSubscriptionsEnabled(enabled: boolean): void;
|
|
34
|
+
/**
|
|
35
|
+
* Checks if real-time subscriptions are currently enabled.
|
|
36
|
+
*/
|
|
37
|
+
isRealTimeSubscriptionsEnabled(): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Returns all resource IDs that are currently subscribed to.
|
|
40
|
+
* Used by React components to render subscription components.
|
|
41
|
+
*/
|
|
42
|
+
getSubscribedResourceIds(): ResourceId[];
|
|
43
|
+
/**
|
|
44
|
+
* Registers a listener that will be called when subscriptions change.
|
|
45
|
+
* @param listener - Callback function to invoke when subscriptions change
|
|
46
|
+
* @returns Unsubscribe function to remove the listener
|
|
47
|
+
*/
|
|
48
|
+
onSubscriptionsChanged(listener: () => void): () => void;
|
|
49
|
+
/**
|
|
50
|
+
* Notifies all subscription change listeners.
|
|
51
|
+
*/
|
|
52
|
+
private notifySubscriptionChangeListeners;
|
|
53
|
+
/**
|
|
54
|
+
* Handles incoming data from a GraphQL subscription.
|
|
55
|
+
* Called by React subscription components when they receive updates.
|
|
56
|
+
* @param syncBlockInstance - The updated sync block instance
|
|
57
|
+
*/
|
|
58
|
+
handleSubscriptionUpdate(syncBlockInstance: SyncBlockInstance): void;
|
|
24
59
|
setFireAnalyticsEvent(fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void): void;
|
|
25
|
-
setExperiences(fetchExperience: Experience, fetchSourceInfoExperience: Experience, saveExperience: Experience): void;
|
|
26
60
|
generateResourceIdForReference(sourceId: ResourceId): ResourceId;
|
|
27
61
|
updateFireAnalyticsEvent(fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void): void;
|
|
28
62
|
getInitialSyncBlockData(resourceId: ResourceId): SyncBlockInstance | undefined;
|
|
29
63
|
/**
|
|
30
64
|
* Refreshes the subscriptions for all sync blocks.
|
|
65
|
+
* This is a fallback polling mechanism when real-time subscriptions are not enabled.
|
|
31
66
|
* @returns {Promise<void>}
|
|
32
67
|
*/
|
|
33
68
|
refreshSubscriptions(): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Sets up a GraphQL subscription for a specific block.
|
|
71
|
+
* @param resourceId - The resource ID of the block to subscribe to
|
|
72
|
+
*/
|
|
73
|
+
private setupGraphQLSubscription;
|
|
74
|
+
/**
|
|
75
|
+
* Handles updates received from GraphQL subscriptions.
|
|
76
|
+
* @param syncBlockInstance - The updated sync block instance
|
|
77
|
+
*/
|
|
78
|
+
private handleGraphQLSubscriptionUpdate;
|
|
79
|
+
/**
|
|
80
|
+
* Cleans up the GraphQL subscription for a specific block.
|
|
81
|
+
* @param resourceId - The resource ID of the block to unsubscribe from
|
|
82
|
+
*/
|
|
83
|
+
private cleanupGraphQLSubscription;
|
|
84
|
+
/**
|
|
85
|
+
* Sets up GraphQL subscriptions for all currently subscribed blocks.
|
|
86
|
+
*/
|
|
87
|
+
private setupGraphQLSubscriptionsForAllBlocks;
|
|
88
|
+
/**
|
|
89
|
+
* Cleans up all GraphQL subscriptions.
|
|
90
|
+
*/
|
|
91
|
+
private cleanupAllGraphQLSubscriptions;
|
|
34
92
|
fetchSyncBlockSourceInfo(resourceId: ResourceId): Promise<SyncBlockSourceInfo | undefined>;
|
|
35
93
|
/**
|
|
36
94
|
* Fetch sync block data for a given array of sync block nodes.
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type SyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import type { Experience } from '@atlaskit/editor-common/experiences';
|
|
3
2
|
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
3
|
import { type ResourceId, type SyncBlockAttrs, type BlockInstanceId } from '../common/types';
|
|
5
4
|
import type { SyncBlockDataProvider, SyncBlockSourceInfo } from '../providers/types';
|
|
@@ -16,14 +15,11 @@ export declare class SourceSyncBlockStoreManager {
|
|
|
16
15
|
private deletionRetryInfo?;
|
|
17
16
|
private pendingResourceId?;
|
|
18
17
|
private creationCallback?;
|
|
19
|
-
createExperience
|
|
18
|
+
private createExperience;
|
|
20
19
|
private saveExperience;
|
|
21
20
|
private deleteExperience;
|
|
22
21
|
constructor(dataProvider?: SyncBlockDataProvider);
|
|
23
22
|
setFireAnalyticsEvent(fireAnalyticsEvent?: (payload: SyncBlockEventPayload) => void): void;
|
|
24
|
-
setCreateExperience(createExperience: Experience): void;
|
|
25
|
-
setSaveExperience(saveExperience: Experience): void;
|
|
26
|
-
setDeleteExperience(deleteExperience: Experience): void;
|
|
27
23
|
isSourceBlock(node: PMNode): boolean;
|
|
28
24
|
/**
|
|
29
25
|
* Add/update a sync block node to/from the local cache
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, type RendererSyncBlockEventPayload, type OperationalAEP, type SyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
export declare const stringifyError: (error: unknown) => string | undefined;
|
|
3
|
-
export declare const getErrorPayload: <T extends ACTION_SUBJECT_ID>(actionSubjectId: T, error: string) => OperationalAEP<ACTION.ERROR, ACTION_SUBJECT.SYNCED_BLOCK, T, {
|
|
3
|
+
export declare const getErrorPayload: <T extends ACTION_SUBJECT_ID>(actionSubjectId: T, error: string, resourceId?: string) => OperationalAEP<ACTION.ERROR, ACTION_SUBJECT.SYNCED_BLOCK, T, {
|
|
4
4
|
error: string;
|
|
5
|
+
resourceId?: string;
|
|
5
6
|
}>;
|
|
6
|
-
export declare const fetchErrorPayload: (error: string) => RendererSyncBlockEventPayload;
|
|
7
|
-
export declare const getSourceInfoErrorPayload: (error: string) => RendererSyncBlockEventPayload;
|
|
8
|
-
export declare const updateErrorPayload: (error: string) => SyncBlockEventPayload;
|
|
9
|
-
export declare const updateReferenceErrorPayload: (error: string) => RendererSyncBlockEventPayload;
|
|
10
|
-
export declare const createErrorPayload: (error: string) => SyncBlockEventPayload;
|
|
11
|
-
export declare const deleteErrorPayload: (error: string) => SyncBlockEventPayload;
|
|
12
|
-
export declare const updateCacheErrorPayload: (error: string) => SyncBlockEventPayload;
|
|
13
|
-
export declare const fetchReferencesErrorPayload: (error: string) => SyncBlockEventPayload;
|
|
7
|
+
export declare const fetchErrorPayload: (error: string, resourceId?: string) => RendererSyncBlockEventPayload;
|
|
8
|
+
export declare const getSourceInfoErrorPayload: (error: string, resourceId?: string) => RendererSyncBlockEventPayload;
|
|
9
|
+
export declare const updateErrorPayload: (error: string, resourceId?: string) => SyncBlockEventPayload;
|
|
10
|
+
export declare const updateReferenceErrorPayload: (error: string, resourceId?: string) => RendererSyncBlockEventPayload;
|
|
11
|
+
export declare const createErrorPayload: (error: string, resourceId?: string) => SyncBlockEventPayload;
|
|
12
|
+
export declare const deleteErrorPayload: (error: string, resourceId?: string) => SyncBlockEventPayload;
|
|
13
|
+
export declare const updateCacheErrorPayload: (error: string, resourceId?: string) => SyncBlockEventPayload;
|
|
14
|
+
export declare const fetchReferencesErrorPayload: (error: string, resourceId?: string) => SyncBlockEventPayload;
|
|
15
|
+
export declare const fetchSuccessPayload: (resourceId: string, blockInstanceId?: string, sourceProduct?: string) => RendererSyncBlockEventPayload;
|
|
16
|
+
export declare const createSuccessPayload: (resourceId: string) => SyncBlockEventPayload;
|
|
17
|
+
export declare const updateSuccessPayload: (resourceId: string, hasReference?: boolean) => SyncBlockEventPayload;
|
|
18
|
+
export declare const deleteSuccessPayload: (resourceId: string) => SyncBlockEventPayload;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type DispatchAnalyticsEvent, type SyncBlockEventPayload, type RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { Experience } from '@atlaskit/editor-common/experiences';
|
|
3
|
+
export declare const createExperienceDispatcher: (fireAnalyticsEvent?: ((payload: SyncBlockEventPayload) => void) | ((payload: RendererSyncBlockEventPayload) => void)) => DispatchAnalyticsEvent;
|
|
4
|
+
/**
|
|
5
|
+
* This experience tracks when a source sync block is saved to the BE.
|
|
6
|
+
*
|
|
7
|
+
* Start: When the flush source sync block function is called.
|
|
8
|
+
* Success: When the sync block save is successful within the timeout duration of start.
|
|
9
|
+
* Failure: When the timeout duration passes without the sync block being successfully saved
|
|
10
|
+
*/
|
|
11
|
+
export declare const getSaveSourceExperience: (fireAnalyticsEvent?: (payload: SyncBlockEventPayload) => void) => Experience;
|
|
12
|
+
/**
|
|
13
|
+
* This experience tracks when a reference sync block is saved to the BE.
|
|
14
|
+
*
|
|
15
|
+
* Start: When the flush sync block function is called.
|
|
16
|
+
* Success: When the sync block save is successful within the timeout duration of start.
|
|
17
|
+
* Failure: When the timeout duration passes without the sync block being successfully saved
|
|
18
|
+
*/
|
|
19
|
+
export declare const getSaveReferenceExperience: (fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void) => Experience;
|
|
20
|
+
/**
|
|
21
|
+
* This experience tracks when a reference sync block data is fetched from the BE.
|
|
22
|
+
*
|
|
23
|
+
* Start: When the fetchNodesData function is called.
|
|
24
|
+
* Success: When the fetching the data is successful within the timeout duration of start.
|
|
25
|
+
* Failure: When the timeout duration passes without the data being successfully fetched, or the fetch fails
|
|
26
|
+
*/
|
|
27
|
+
export declare const getFetchExperience: (fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void) => Experience;
|
|
28
|
+
/**
|
|
29
|
+
* This experience tracks when a reference sync block source info data (title, url) is fetched from the BE.
|
|
30
|
+
*
|
|
31
|
+
* Start: When the fetchSourceInfo function is called.
|
|
32
|
+
* Success: When the fetching the data is successful within the timeout duration of start.
|
|
33
|
+
* Failure: When the timeout duration passes without the data being successfully fetched, or the fetch fails
|
|
34
|
+
*/
|
|
35
|
+
export declare const getFetchSourceInfoExperience: (fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void) => Experience;
|
|
36
|
+
/**
|
|
37
|
+
* This experience tracks when a source sync block is deleted from the BE.
|
|
38
|
+
*
|
|
39
|
+
* Start: When the fetchSourceInfo function is called.
|
|
40
|
+
* Success: When the fetching the data is successful within the timeout duration of start.
|
|
41
|
+
* Failure: When the timeout duration passes without the data being successfully fetched, or the fetch fails
|
|
42
|
+
*/
|
|
43
|
+
export declare const getDeleteSourceExperience: (fireAnalyticsEvent?: (payload: SyncBlockEventPayload) => void) => Experience;
|
|
44
|
+
/**
|
|
45
|
+
* This experience tracks when a source sync block is created and registered to the BE.
|
|
46
|
+
*
|
|
47
|
+
* Start: When the fetchSourceInfo function is called.
|
|
48
|
+
* Success: When the fetching the data is successful within the timeout duration of start.
|
|
49
|
+
* Failure: When the timeout duration passes without the data being successfully fetched, or the fetch fails
|
|
50
|
+
*/
|
|
51
|
+
export declare const getCreateSourceExperience: (fireAnalyticsEvent?: (payload: SyncBlockEventPayload) => void) => Experience;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ReferenceSyncBlockResponse, SyncBlockProduct } from '../../common/types';
|
|
1
|
+
import type { ReferenceSyncBlockResponse, SyncBlockProduct, SyncBlockStatus } from '../../common/types';
|
|
2
2
|
export type BlockContentResponse = {
|
|
3
3
|
blockAri: string;
|
|
4
4
|
blockInstanceId: string;
|
|
@@ -7,7 +7,7 @@ export type BlockContentResponse = {
|
|
|
7
7
|
createdBy: string;
|
|
8
8
|
product: SyncBlockProduct;
|
|
9
9
|
sourceAri: string;
|
|
10
|
-
status:
|
|
10
|
+
status: SyncBlockStatus;
|
|
11
11
|
version: number;
|
|
12
12
|
};
|
|
13
13
|
export type ErrorResponse = {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ADFEntity } from '@atlaskit/adf-utils/types';
|
|
2
|
+
import type { SyncBlockProduct } from '../../common/types';
|
|
3
|
+
export type BlockSubscriptionPayload = {
|
|
4
|
+
blockAri: string;
|
|
5
|
+
blockInstanceId: string;
|
|
6
|
+
content: string;
|
|
7
|
+
contentUpdatedAt?: number;
|
|
8
|
+
createdAt: number;
|
|
9
|
+
createdBy: string;
|
|
10
|
+
deletionReason?: string;
|
|
11
|
+
product: string;
|
|
12
|
+
sourceAri: string;
|
|
13
|
+
status: string;
|
|
14
|
+
};
|
|
15
|
+
export type ParsedBlockSubscriptionData = {
|
|
16
|
+
blockAri: string;
|
|
17
|
+
blockInstanceId: string;
|
|
18
|
+
content: ADFEntity[];
|
|
19
|
+
createdAt?: string;
|
|
20
|
+
createdBy: string;
|
|
21
|
+
product: SyncBlockProduct;
|
|
22
|
+
resourceId: string;
|
|
23
|
+
sourceAri: string;
|
|
24
|
+
status: string;
|
|
25
|
+
};
|
|
26
|
+
type SubscriptionCallback = (data: ParsedBlockSubscriptionData) => void;
|
|
27
|
+
type ErrorCallback = (error: Error) => void;
|
|
28
|
+
type Unsubscribe = () => void;
|
|
29
|
+
/**
|
|
30
|
+
* Creates a GraphQL subscription to block updates using the shared graphql-ws client.
|
|
31
|
+
*
|
|
32
|
+
* @param blockAri - The full block ARI to subscribe to (ari:cloud:blocks:{cloudId}:synced-block/{resourceId})
|
|
33
|
+
* @param onData - Callback function invoked when block data is updated
|
|
34
|
+
* @param onError - Optional callback function invoked on subscription errors
|
|
35
|
+
* @returns Unsubscribe function to close the subscription
|
|
36
|
+
*/
|
|
37
|
+
export declare const subscribeToBlockUpdates: (blockAri: string, onData: SubscriptionCallback, onError?: ErrorCallback) => Unsubscribe;
|
|
38
|
+
export {};
|
|
@@ -5,6 +5,7 @@ import type { SYNC_BLOCK_PRODUCTS } from './consts';
|
|
|
5
5
|
export type BlockInstanceId = string;
|
|
6
6
|
export type ResourceId = string;
|
|
7
7
|
export type SyncBlockProduct = (typeof SYNC_BLOCK_PRODUCTS)[number];
|
|
8
|
+
export type SyncBlockStatus = 'active' | 'deleted' | 'unpublished';
|
|
8
9
|
export type SyncBlockAttrs = {
|
|
9
10
|
localId: BlockInstanceId;
|
|
10
11
|
resourceId: ResourceId;
|
|
@@ -34,7 +35,7 @@ export interface SyncBlockData {
|
|
|
34
35
|
/**
|
|
35
36
|
* Whether the block is on the same page as the source block
|
|
36
37
|
*/
|
|
37
|
-
|
|
38
|
+
onSameDocument?: boolean;
|
|
38
39
|
product?: SyncBlockProduct;
|
|
39
40
|
/**
|
|
40
41
|
* The ARI of the block. E.G ari:cloud:blocks:<cloudId>:synced-block/<product>/<pageId>/<resourceId>
|
|
@@ -45,6 +46,7 @@ export interface SyncBlockData {
|
|
|
45
46
|
sourceTitle?: string;
|
|
46
47
|
sourceURL?: string;
|
|
47
48
|
updatedAt?: string;
|
|
49
|
+
status?: SyncBlockStatus;
|
|
48
50
|
}
|
|
49
51
|
export interface ReferenceSyncBlockResponse {
|
|
50
52
|
blockAri: string;
|
|
@@ -55,7 +57,7 @@ export interface ReferenceSyncBlockResponse {
|
|
|
55
57
|
}
|
|
56
58
|
export interface ReferenceSyncBlock extends ReferenceSyncBlockResponse {
|
|
57
59
|
hasAccess: boolean;
|
|
58
|
-
|
|
60
|
+
onSameDocument: boolean;
|
|
59
61
|
}
|
|
60
62
|
export type ReferenceSyncBlockData = {
|
|
61
63
|
error?: SyncBlockError;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { rebaseTransaction } from './common/rebase-transaction';
|
|
2
2
|
export { SyncBlockError } from './common/types';
|
|
3
|
-
export type { SyncBlockData, SyncBlockNode, SyncBlockProduct, BlockInstanceId, SyncBlockAttrs, ReferenceSyncBlockData, ReferencesSourceInfo } from './common/types';
|
|
3
|
+
export type { ResourceId, SyncBlockData, SyncBlockNode, SyncBlockProduct, SyncBlockStatus, BlockInstanceId, SyncBlockAttrs, ReferenceSyncBlockData, ReferencesSourceInfo } from './common/types';
|
|
4
4
|
export { useFetchSyncBlockData, type UseFetchSyncBlockDataResult, } from './hooks/useFetchSyncBlockData';
|
|
5
5
|
export { useFetchSyncBlockTitle } from './hooks/useFetchSyncBlockTitle';
|
|
6
6
|
export { useHandleContentChanges } from './hooks/useHandleContentChanges';
|
|
@@ -11,7 +11,7 @@ export { getJiraWorkItemAri, getJiraWorkItemIdFromAri } from './clients/jira/ari
|
|
|
11
11
|
export { useMemoizedBlockServiceAPIProviders, useMemoizedBlockServiceFetchOnlyAPIProvider, } from './providers/block-service/blockServiceAPI';
|
|
12
12
|
export { fetchConfluencePageInfo } from './clients/confluence/sourceInfo';
|
|
13
13
|
export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider, } from './providers/syncBlockProvider';
|
|
14
|
-
export type { ADFFetchProvider, ADFWriteProvider, BlockNodeIdentifiers, SyncBlockDataProvider, SyncBlockInstance, MediaEmojiProviderOptions, SyncedBlockRendererProviderOptions, SyncBlockRendererProviderCreator, SyncedBlockRendererDataProviders, UpdateReferenceSyncBlockResult, WriteSyncBlockResult, SyncBlockParentInfo, SyncBlockSourceInfo, } from './providers/types';
|
|
14
|
+
export type { ADFFetchProvider, ADFWriteProvider, BlockNodeIdentifiers, BlockSubscriptionErrorCallback, BlockUpdateCallback, SyncBlockDataProvider, SyncBlockInstance, MediaEmojiProviderOptions, SyncedBlockRendererProviderOptions, SyncBlockRendererProviderCreator, SyncedBlockRendererDataProviders, Unsubscribe, UpdateReferenceSyncBlockResult, WriteSyncBlockResult, SyncBlockParentInfo, SyncBlockSourceInfo, } from './providers/types';
|
|
15
15
|
export { type ReferenceSyncBlockStoreManager } from './store-manager/referenceSyncBlockStoreManager';
|
|
16
16
|
export { SyncBlockStoreManager, useMemoizedSyncBlockStoreManager, } from './store-manager/syncBlockStoreManager';
|
|
17
17
|
export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
|
|
@@ -44,6 +44,14 @@ declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
|
|
|
44
44
|
* @returns Array of SyncBlockInstance results
|
|
45
45
|
*/
|
|
46
46
|
batchFetchData(blockNodeIdentifiers: BlockNodeIdentifiers[]): Promise<SyncBlockInstance[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Subscribes to real-time updates for a specific block using GraphQL WebSocket subscriptions.
|
|
49
|
+
* @param resourceId - The resource ID of the block to subscribe to
|
|
50
|
+
* @param onUpdate - Callback function invoked when the block is updated
|
|
51
|
+
* @param onError - Optional callback function invoked on subscription errors
|
|
52
|
+
* @returns Unsubscribe function to stop receiving updates
|
|
53
|
+
*/
|
|
54
|
+
subscribeToBlockUpdates(resourceId: ResourceId, onUpdate: (data: SyncBlockInstance) => void, onError?: (error: Error) => void): () => void;
|
|
47
55
|
}
|
|
48
56
|
interface BlockServiceADFWriteProviderProps {
|
|
49
57
|
cloudId: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import type { JSONNode } from '@atlaskit/editor-json-transformer/types';
|
|
3
3
|
import { type BlockInstanceId, type ReferenceSyncBlockData, type ResourceId, type SyncBlockAttrs, type SyncBlockData, type SyncBlockNode, type SyncBlockProduct } from '../common/types';
|
|
4
|
-
import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type DeleteSyncBlockResult, type SyncBlockInstance, type SyncBlockParentInfo, type SyncBlockSourceInfo, type SyncedBlockRendererProviderOptions, type UpdateReferenceSyncBlockResult, type WriteSyncBlockResult } from './types';
|
|
4
|
+
import { SyncBlockDataProvider, 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';
|
|
5
5
|
export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
6
6
|
name: string;
|
|
7
7
|
private fetchProvider;
|
|
@@ -91,6 +91,14 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
|
91
91
|
retrieveSyncBlockParentInfo(sourceAri: string, sourceProduct: SyncBlockProduct): SyncBlockParentInfo | undefined;
|
|
92
92
|
updateReferenceData(blocks: SyncBlockAttrs[], noContent?: boolean): Promise<UpdateReferenceSyncBlockResult>;
|
|
93
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): Unsubscribe | undefined;
|
|
94
102
|
}
|
|
95
103
|
type UseMemoizedSyncedBlockProviderProps = {
|
|
96
104
|
fetchProvider: ADFFetchProvider;
|
|
@@ -5,10 +5,6 @@ import type { MentionProvider } from '@atlaskit/mention/types';
|
|
|
5
5
|
import { NodeDataProvider } from '@atlaskit/node-data-provider';
|
|
6
6
|
import type { TaskDecisionProvider } from '@atlaskit/task-decision/types';
|
|
7
7
|
import type { SyncBlockData, ResourceId, SyncBlockError, SyncBlockNode, SyncBlockProduct, BlockInstanceId, SyncBlockAttrs, ReferenceSyncBlockData } from '../common/types';
|
|
8
|
-
export type BlockNodeIdentifiers = {
|
|
9
|
-
blockInstanceId: string;
|
|
10
|
-
resourceId: string;
|
|
11
|
-
};
|
|
12
8
|
/**
|
|
13
9
|
* The instance of a sync block, containing its data and metadata.
|
|
14
10
|
* Mainly used for representing the state of a sync block after fetching from a data provider.
|
|
@@ -33,7 +29,7 @@ export type SyncBlockSourceInfo = {
|
|
|
33
29
|
* Whether the source info is for a source synced block
|
|
34
30
|
*/
|
|
35
31
|
isSource?: boolean;
|
|
36
|
-
|
|
32
|
+
onSameDocument?: boolean;
|
|
37
33
|
productType?: SyncBlockProduct;
|
|
38
34
|
sourceAri: string;
|
|
39
35
|
subType?: string | null;
|
|
@@ -56,10 +52,21 @@ export type UpdateReferenceSyncBlockResult = {
|
|
|
56
52
|
error?: string;
|
|
57
53
|
success: boolean;
|
|
58
54
|
};
|
|
55
|
+
export type BlockNodeIdentifiers = {
|
|
56
|
+
blockInstanceId: string;
|
|
57
|
+
resourceId: string;
|
|
58
|
+
};
|
|
59
|
+
export type BlockUpdateCallback = (data: SyncBlockInstance) => void;
|
|
60
|
+
export type BlockSubscriptionErrorCallback = (error: Error) => void;
|
|
61
|
+
export type Unsubscribe = () => void;
|
|
59
62
|
export interface ADFFetchProvider {
|
|
60
63
|
batchFetchData: (blockNodeIdentifiers: BlockNodeIdentifiers[]) => Promise<SyncBlockInstance[]>;
|
|
61
64
|
fetchData: (resourceId: ResourceId) => Promise<SyncBlockInstance>;
|
|
62
65
|
fetchReferences: (referenceResourceId: string) => Promise<ReferenceSyncBlockData>;
|
|
66
|
+
/**
|
|
67
|
+
* Subscribes to real-time updates for a specific block.
|
|
68
|
+
*/
|
|
69
|
+
subscribeToBlockUpdates?: (resourceId: ResourceId, onUpdate: BlockUpdateCallback, onError?: BlockSubscriptionErrorCallback) => Unsubscribe;
|
|
63
70
|
}
|
|
64
71
|
export interface ADFWriteProvider {
|
|
65
72
|
createData: (data: SyncBlockData) => Promise<WriteSyncBlockResult>;
|
|
@@ -88,8 +95,8 @@ export type SyncedBlockRendererDataProviders = {
|
|
|
88
95
|
export type SyncBlockRendererProviderCreator = {
|
|
89
96
|
createEmojiProvider: ((options: MediaEmojiProviderOptions) => Promise<EmojiProvider> | undefined) | undefined;
|
|
90
97
|
createMediaProvider: ((options: MediaEmojiProviderOptions) => Promise<MediaProvider> | undefined) | undefined;
|
|
91
|
-
createSSRMediaProvider?: ((options: MediaEmojiProviderOptions) => MediaProvider | undefined) | undefined;
|
|
92
98
|
createSmartLinkProvider: (() => Promise<CardProvider>) | undefined;
|
|
99
|
+
createSSRMediaProvider?: ((options: MediaEmojiProviderOptions) => MediaProvider | undefined) | undefined;
|
|
93
100
|
};
|
|
94
101
|
export type SyncedBlockRendererProviderOptions = {
|
|
95
102
|
parentDataProviders?: SyncedBlockRendererDataProviders;
|
|
@@ -119,6 +126,15 @@ export declare abstract class SyncBlockDataProvider extends NodeDataProvider<Syn
|
|
|
119
126
|
abstract generateResourceIdForReference(sourceId: ResourceId): ResourceId;
|
|
120
127
|
abstract updateReferenceData(blocks: SyncBlockAttrs[], noContent?: boolean): Promise<UpdateReferenceSyncBlockResult>;
|
|
121
128
|
abstract fetchReferences(resourceId: string, isSource: boolean): Promise<ReferenceSyncBlockData>;
|
|
129
|
+
/**
|
|
130
|
+
* Subscribes to real-time updates for a specific block.
|
|
131
|
+
* Returns undefined if subscriptions are not supported.
|
|
132
|
+
* @param resourceId - The resource ID of the block to subscribe to
|
|
133
|
+
* @param onUpdate - Callback function invoked when the block is updated
|
|
134
|
+
* @param onError - Optional callback function invoked on subscription errors
|
|
135
|
+
* @returns Unsubscribe function to stop receiving updates, or undefined if not supported
|
|
136
|
+
*/
|
|
137
|
+
subscribeToBlockUpdates?(resourceId: ResourceId, onUpdate: BlockUpdateCallback, onError?: BlockSubscriptionErrorCallback): Unsubscribe | undefined;
|
|
122
138
|
}
|
|
123
139
|
export type SubscriptionCallback = (data: SyncBlockInstance) => void;
|
|
124
140
|
export type TitleSubscriptionCallback = (title: string) => void;
|