@atlaskit/editor-synced-block-provider 7.0.14 → 7.0.15

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 +6 -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 +2 -2
  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,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
- }
@@ -1,128 +0,0 @@
1
- import type { SyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
2
- import type { ViewMode } from '@atlaskit/editor-plugin-editor-viewmode';
3
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
- import type { ResourceId, SyncBlockAttrs, BlockInstanceId, DeletionReason, ReferenceSyncBlockData } from '../common/types';
5
- import type { SyncBlockDataProviderInterface, SyncBlockSourceInfo } from '../providers/types';
6
- export type ConfirmationCallback = (syncBlockIds: SyncBlockAttrs[], deleteReason: DeletionReason | undefined) => Promise<boolean>;
7
- type OnDelete = () => void;
8
- type OnCompletion = (success: boolean) => void;
9
- type DestroyCallback = () => void;
10
- export declare class SourceSyncBlockStoreManager {
11
- private viewMode?;
12
- private isLivePage?;
13
- private dataProvider?;
14
- private fireAnalyticsEvent?;
15
- private syncBlockCache;
16
- private hasReceivedContentChange;
17
- private confirmationCallback?;
18
- private deletionRetryInfo?;
19
- private creationCompletionCallbacks;
20
- private flushCompletionCallback?;
21
- private postCreationFlushCallback?;
22
- /**
23
- * Promises for in-flight block creations, keyed by resourceId.
24
- * `flush()` awaits these so that blocks created from existing content are
25
- * persisted even if no further edits trigger a subsequent flush.
26
- * See EDITOR-7112.
27
- */
28
- private pendingCreationPromises;
29
- /**
30
- * Set of resource IDs whose creation was still in-flight when a `flush()`
31
- * timed out. Each completion (success or failure) is removed from this set;
32
- * the first successful completion of any of these IDs triggers
33
- * `postCreationFlushCallback` so the content is eventually persisted.
34
- * Tracking IDs (not just a boolean) avoids dropping late completions when
35
- * multiple blocks are created concurrently. See EDITOR-7112.
36
- */
37
- private creationsTimedOutDuringFlush;
38
- private createExperience;
39
- private saveExperience;
40
- private deleteExperience;
41
- private fetchSourceInfoExperience;
42
- constructor(dataProvider?: SyncBlockDataProviderInterface, viewMode?: ViewMode, isLivePage?: boolean);
43
- /**
44
- * Register a callback to be invoked after flush() completes.
45
- * Used by the pm-plugin to dispatch a transaction so that
46
- * hasUnsavedBodiedSyncBlockChanges is recalculated in plugin state.
47
- */
48
- registerFlushCompletionCallback(callback: () => void): void;
49
- /**
50
- * Register a callback to be invoked when flush() timed out waiting for a
51
- * pending block creation and that creation subsequently completes. The
52
- * callback should trigger a deferred flush to persist the content that
53
- * was skipped due to the timeout. See EDITOR-7112.
54
- */
55
- registerPostCreationFlushCallback(callback: () => void): void;
56
- setFireAnalyticsEvent(fireAnalyticsEvent?: (payload: SyncBlockEventPayload) => void): void;
57
- isSourceBlock(node: PMNode): boolean;
58
- /**
59
- * Add/update a sync block node to/from the local cache
60
- * @param syncBlockNode - The sync block node to update
61
- */
62
- updateSyncBlockData(syncBlockNode: PMNode, isRemote: boolean): boolean;
63
- /**
64
- * Save content of bodiedSyncBlock nodes in local cache to backend
65
- *
66
- * @returns true if saving all nodes successfully, false if fail to save some/all nodes
67
- */
68
- flush(): Promise<boolean>;
69
- hasUnsavedChanges(): boolean;
70
- isPendingCreation(resourceId: ResourceId): boolean;
71
- /**
72
- * Returns `true` when at least one sync block is waiting for its backend
73
- * creation call to complete. Used as a cheap pre-check in the decoration
74
- * rebuild path to avoid a full `doc.descendants()` walk when no creations
75
- * are in flight (see EDITOR-6930).
76
- */
77
- hasPendingCreations(): boolean;
78
- /**
79
- * Fires callback to insert node (if creation is successful) and clears pending creation data
80
- * @param success
81
- */
82
- commitPendingCreation(success: boolean, resourceId: ResourceId): void;
83
- registerConfirmationCallback(callback: ConfirmationCallback): () => void;
84
- requireConfirmationBeforeDelete(): boolean;
85
- /**
86
- * @returns attributes for a new bodiedSyncBlock node
87
- */
88
- generateBodiedSyncBlockAttrs(): SyncBlockAttrs;
89
- /**
90
- * Create a bodiedSyncBlock node with empty content to backend
91
- * @param attrs attributes Ids of the node
92
- * @param node the ProseMirror node to cache
93
- * @param onCompletion callback invoked when creation completes
94
- */
95
- createBodiedSyncBlockNode(attrs: SyncBlockAttrs, node: PMNode, onCompletion: OnCompletion): void;
96
- private setPendingDeletion;
97
- private delete;
98
- isRetryingDeletion(): boolean;
99
- retryDeletion(): Promise<void>;
100
- clearPendingDeletion(): void;
101
- /**
102
- * Fetches the current status of all source sync blocks in the cache from the backend
103
- * and updates the cache entries with the fetched status.
104
- * This is called on editor init so we know which blocks are 'unpublished' vs 'active'.
105
- */
106
- fetchAndCacheStatuses(): Promise<void>;
107
- /**
108
- * Deletes all source sync blocks that have 'unpublished' status.
109
- * Used to clean up orphaned blocks when a user cancels editing without saving.
110
- * Blocks that were already saved (status 'active') are not affected.
111
- *
112
- * @returns true if all deletions succeeded, false otherwise
113
- */
114
- discardUnpublishedBlocks(): Promise<boolean>;
115
- /**
116
- * Deletes sync blocks with confirmation from the backend
117
- *
118
- * @param syncBlockIds - The sync block ids to delete
119
- * @param onDelete - The callback to delete sync block node from document
120
- * @param onDeleteCompleted - The callback for after the deletion is saved to BE (whether successful or not)
121
- * @param destroyCallback - The callback to clear any reference stored for deletion (regardless if deletion is completed or abort)
122
- */
123
- deleteSyncBlocksWithConfirmation(syncBlockIds: SyncBlockAttrs[], deletionReason: DeletionReason, onDelete: OnDelete, onDeleteCompleted: OnCompletion, destroyCallback: DestroyCallback): Promise<void>;
124
- getSyncBlockSourceInfo(localId: BlockInstanceId): Promise<SyncBlockSourceInfo | undefined>;
125
- fetchReferences(resourceId: string): Promise<ReferenceSyncBlockData>;
126
- destroy(): void;
127
- }
128
- export {};
@@ -1,33 +0,0 @@
1
- import type { RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
2
- import type { ResourceId, BlockInstanceId, SyncBlockNode } from '../common/types';
3
- import type { SubscriptionCallback } from '../providers/types';
4
- export interface SyncBlockBatchFetcherDeps {
5
- fetchSyncBlocksData: (nodes: SyncBlockNode[]) => Promise<void>;
6
- getFireAnalyticsEvent: () => ((payload: RendererSyncBlockEventPayload) => void) | undefined;
7
- getSubscriptions: () => Map<ResourceId, {
8
- [localId: BlockInstanceId]: SubscriptionCallback;
9
- }>;
10
- }
11
- /**
12
- * Handles debounced batch-fetching of sync block data via `raf-schd`.
13
- * Accumulates resource IDs and flushes them in a single fetch per
14
- * animation frame.
15
- */
16
- export declare class SyncBlockBatchFetcher {
17
- private deps;
18
- private pendingFetchRequests;
19
- private inFlightFetches;
20
- private isDestroyed;
21
- private scheduledBatchFetch;
22
- constructor(deps: SyncBlockBatchFetcherDeps);
23
- queueFetch(resourceId: string): void;
24
- /**
25
- * Returns true if a batched fetch is queued or in flight for `resourceId`.
26
- * Used by cache deletion guards to prevent deleting while a fetch is
27
- * about to populate the entry.
28
- */
29
- hasPendingFetch(resourceId: string): boolean;
30
- cancel(): void;
31
- clearPending(): void;
32
- destroy(): void;
33
- }
@@ -1,41 +0,0 @@
1
- /**
2
- * In-memory session cache for sync block data with size-based LRU eviction.
3
- *
4
- * Backed by a plain Map so that potentially private ADF content is never
5
- * written to any browser-persistent storage (sessionStorage, localStorage,
6
- * IndexedDB). The module-level singleton survives SPA transitions (no full
7
- * page reload) and is naturally cleared on hard navigation or tab close.
8
- *
9
- * Uses JavaScript Map's insertion-order guarantee to implement LRU:
10
- * on every read or write the accessed entry is moved to the end of the
11
- * iteration order; when total cached size exceeds `maxSize`, the oldest
12
- * (least-recently-used) entries are evicted first.
13
- */
14
- export declare class SyncBlockInMemorySessionCache {
15
- private store;
16
- private currentSize;
17
- /**
18
- * Maximum total size of all cached values, measured in **UTF-16 code
19
- * units** (i.e. `String.prototype.length`), not bytes. For ASCII-only
20
- * content the two are equivalent; for content with characters outside
21
- * the BMP each surrogate pair counts as 2.
22
- */
23
- private maxSize;
24
- constructor(maxSize?: number);
25
- /**
26
- * Retrieves a cached value by key.
27
- *
28
- * **Side-effect:** promotes the entry to the most-recently-used
29
- * position by re-inserting it at the end of the underlying Map's
30
- * iteration order.
31
- */
32
- getItem(key: string): string | null;
33
- setItem(key: string, value: string): void;
34
- removeItem(key: string): void;
35
- /**
36
- * Removes all entries from the cache and resets the tracked size to zero.
37
- * Useful for cleaning up the singleton on SPA navigation boundaries.
38
- */
39
- clear(): void;
40
- }
41
- export declare const syncBlockInMemorySessionCache: SyncBlockInMemorySessionCache;
@@ -1,26 +0,0 @@
1
- import type { RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
2
- import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
3
- import type { MediaProvider } from '@atlaskit/editor-common/provider-factory';
4
- import type { ResourceId } from '../common/types';
5
- import type { SyncBlockInstance, SyncBlockDataProviderInterface } from '../providers/types';
6
- export interface SyncBlockProviderFactoryManagerDeps {
7
- getDataProvider: () => SyncBlockDataProviderInterface | undefined;
8
- getFireAnalyticsEvent: () => ((payload: RendererSyncBlockEventPayload) => void) | undefined;
9
- getFromCache: (resourceId: ResourceId) => SyncBlockInstance | undefined;
10
- }
11
- /**
12
- * Manages creation and caching of ProviderFactory instances used to
13
- * render synced block content (media, emoji, smart links, etc.).
14
- */
15
- export declare class SyncBlockProviderFactoryManager {
16
- private deps;
17
- private providerFactories;
18
- constructor(deps: SyncBlockProviderFactoryManagerDeps);
19
- getProviderFactory(resourceId: ResourceId): ProviderFactory | undefined;
20
- getSSRProviders(resourceId: ResourceId): {
21
- media: MediaProvider;
22
- } | null;
23
- deleteFactory(resourceId: ResourceId): void;
24
- destroy(): void;
25
- private retrieveDynamicProviders;
26
- }