@atlaskit/editor-synced-block-provider 2.10.5 → 2.11.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 (62) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/cjs/clients/block-service/blockService.js +5 -4
  3. package/dist/cjs/clients/confluence/sourceInfo.js +20 -17
  4. package/dist/cjs/hooks/useFetchSyncBlockData.js +20 -11
  5. package/dist/cjs/hooks/useHandleContentChanges.js +1 -5
  6. package/dist/cjs/index.js +2 -2
  7. package/dist/cjs/providers/block-service/blockServiceAPI.js +17 -26
  8. package/dist/cjs/providers/confluence/confluenceContentAPI.js +0 -15
  9. package/dist/cjs/providers/syncBlockProvider.js +31 -41
  10. package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +138 -63
  11. package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +93 -43
  12. package/dist/cjs/store-manager/syncBlockStoreManager.js +3 -3
  13. package/dist/cjs/utils/errorHandling.js +31 -1
  14. package/dist/es2019/clients/block-service/blockService.js +5 -4
  15. package/dist/es2019/clients/confluence/sourceInfo.js +13 -8
  16. package/dist/es2019/hooks/useFetchSyncBlockData.js +15 -7
  17. package/dist/es2019/hooks/useHandleContentChanges.js +1 -5
  18. package/dist/es2019/index.js +1 -1
  19. package/dist/es2019/providers/block-service/blockServiceAPI.js +13 -20
  20. package/dist/es2019/providers/confluence/confluenceContentAPI.js +1 -14
  21. package/dist/es2019/providers/syncBlockProvider.js +31 -45
  22. package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +124 -49
  23. package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +65 -24
  24. package/dist/es2019/store-manager/syncBlockStoreManager.js +3 -3
  25. package/dist/es2019/utils/errorHandling.js +17 -1
  26. package/dist/esm/clients/block-service/blockService.js +5 -4
  27. package/dist/esm/clients/confluence/sourceInfo.js +19 -16
  28. package/dist/esm/hooks/useFetchSyncBlockData.js +20 -11
  29. package/dist/esm/hooks/useHandleContentChanges.js +1 -5
  30. package/dist/esm/index.js +1 -1
  31. package/dist/esm/providers/block-service/blockServiceAPI.js +17 -26
  32. package/dist/esm/providers/confluence/confluenceContentAPI.js +1 -16
  33. package/dist/esm/providers/syncBlockProvider.js +32 -42
  34. package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +138 -63
  35. package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +93 -43
  36. package/dist/esm/store-manager/syncBlockStoreManager.js +3 -3
  37. package/dist/esm/utils/errorHandling.js +30 -0
  38. package/dist/types/clients/block-service/blockService.d.ts +0 -2
  39. package/dist/types/clients/confluence/sourceInfo.d.ts +2 -1
  40. package/dist/types/hooks/useFetchSyncBlockData.d.ts +2 -1
  41. package/dist/types/index.d.ts +2 -2
  42. package/dist/types/providers/block-service/blockServiceAPI.d.ts +7 -5
  43. package/dist/types/providers/confluence/confluenceContentAPI.d.ts +2 -3
  44. package/dist/types/providers/syncBlockProvider.d.ts +12 -9
  45. package/dist/types/providers/types.d.ts +9 -9
  46. package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +6 -2
  47. package/dist/types/store-manager/sourceSyncBlockStoreManager.d.ts +3 -1
  48. package/dist/types/store-manager/syncBlockStoreManager.d.ts +2 -1
  49. package/dist/types/utils/errorHandling.d.ts +10 -0
  50. package/dist/types-ts4.5/clients/block-service/blockService.d.ts +0 -2
  51. package/dist/types-ts4.5/clients/confluence/sourceInfo.d.ts +2 -1
  52. package/dist/types-ts4.5/hooks/useFetchSyncBlockData.d.ts +2 -1
  53. package/dist/types-ts4.5/index.d.ts +2 -2
  54. package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +7 -5
  55. package/dist/types-ts4.5/providers/confluence/confluenceContentAPI.d.ts +2 -3
  56. package/dist/types-ts4.5/providers/syncBlockProvider.d.ts +12 -9
  57. package/dist/types-ts4.5/providers/types.d.ts +9 -9
  58. package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +6 -2
  59. package/dist/types-ts4.5/store-manager/sourceSyncBlockStoreManager.d.ts +3 -1
  60. package/dist/types-ts4.5/store-manager/syncBlockStoreManager.d.ts +2 -1
  61. package/dist/types-ts4.5/utils/errorHandling.d.ts +10 -0
  62. package/package.json +2 -8
@@ -1,7 +1,37 @@
1
+ import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from "@atlaskit/editor-common/analytics";
1
2
  export var stringifyError = function stringifyError(error) {
2
3
  try {
3
4
  return JSON.stringify(error);
4
5
  } catch (_unused) {
5
6
  return undefined;
6
7
  }
8
+ };
9
+ export var getErrorPayload = function getErrorPayload(actionSubjectId, error) {
10
+ return {
11
+ action: ACTION.ERROR,
12
+ actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
13
+ actionSubjectId: actionSubjectId,
14
+ eventType: EVENT_TYPE.OPERATIONAL,
15
+ attributes: {
16
+ error: error
17
+ }
18
+ };
19
+ };
20
+ export var fetchErrorPayload = function fetchErrorPayload(error) {
21
+ return getErrorPayload(ACTION_SUBJECT_ID.SYNCED_BLOCK_FETCH, error);
22
+ };
23
+ export var getSourceInfoErrorPayload = function getSourceInfoErrorPayload(error) {
24
+ return getErrorPayload(ACTION_SUBJECT_ID.SYNCED_BLOCK_GET_SOURCE_INFO, error);
25
+ };
26
+ export var updateErrorPayload = function updateErrorPayload(error) {
27
+ return getErrorPayload(ACTION_SUBJECT_ID.SYNCED_BLOCK_UPDATE, error);
28
+ };
29
+ export var createErrorPayload = function createErrorPayload(error) {
30
+ return getErrorPayload(ACTION_SUBJECT_ID.SYNCED_BLOCK_CREATE, error);
31
+ };
32
+ export var deleteErrorPayload = function deleteErrorPayload(error) {
33
+ return getErrorPayload(ACTION_SUBJECT_ID.SYNCED_BLOCK_DELETE, error);
34
+ };
35
+ export var updateCacheErrorPayload = function updateCacheErrorPayload(error) {
36
+ return getErrorPayload(ACTION_SUBJECT_ID.SYNCED_BLOCK_UPDATE_CACHE, error);
7
37
  };
@@ -3,10 +3,8 @@ export type BlockContentResponse = {
3
3
  blockAri: string;
4
4
  blockInstanceId: string;
5
5
  content: string;
6
- contentUpdatedAt: number;
7
6
  createdAt: number;
8
7
  createdBy: string;
9
- isSynced: boolean;
10
8
  product: SyncBlockProduct;
11
9
  sourceAri: string;
12
10
  status: 'active' | 'deleted';
@@ -1,2 +1,3 @@
1
+ import { type RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
1
2
  import type { SyncBlockSourceInfo } from '../../providers/types';
2
- export declare const fetchConfluenceSourceInfo: (pageAri: string, localId?: string) => Promise<SyncBlockSourceInfo | undefined>;
3
+ export declare const fetchConfluencePageInfo: (pageAri: string, localId?: string, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void) => Promise<SyncBlockSourceInfo | undefined>;
@@ -1,3 +1,4 @@
1
+ import { type RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
1
2
  import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
2
3
  import type { SyncBlockInstance } from '../providers/types';
3
4
  import type { SyncBlockStoreManager } from '../store-manager/syncBlockStoreManager';
@@ -7,4 +8,4 @@ export interface UseFetchSyncBlockDataResult {
7
8
  reloadData: () => Promise<void>;
8
9
  syncBlockInstance: SyncBlockInstance | null;
9
10
  }
10
- export declare const useFetchSyncBlockData: (manager: SyncBlockStoreManager, resourceId?: string, localId?: string) => UseFetchSyncBlockDataResult;
11
+ export declare const useFetchSyncBlockData: (manager: SyncBlockStoreManager, resourceId?: string, localId?: string, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void) => UseFetchSyncBlockDataResult;
@@ -1,6 +1,6 @@
1
1
  export { rebaseTransaction } from './common/rebase-transaction';
2
2
  export { SyncBlockError } from './common/types';
3
- export type { SyncBlockData, SyncBlockNode } from './common/types';
3
+ export type { SyncBlockData, SyncBlockNode, SyncBlockProduct, BlockInstanceId, } 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';
@@ -8,7 +8,7 @@ export { blockResourceIdFromSourceAndLocalId, getLocalIdFromBlockResourceId, } f
8
8
  export { getConfluencePageAri, getLocalIdFromConfluencePageAri, getPageARIFromContentPropertyResourceId, getPageIdAndTypeFromConfluencePageAri, resourceIdFromConfluencePageSourceIdAndLocalId, } from './clients/confluence/ari';
9
9
  export { useMemoizedBlockServiceAPIProviders } from './providers/block-service/blockServiceAPI';
10
10
  export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders, } from './providers/confluence/confluenceContentAPI';
11
- export { fetchConfluenceSourceInfo } from './clients/confluence/sourceInfo';
11
+ export { fetchConfluencePageInfo } from './clients/confluence/sourceInfo';
12
12
  export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider, } from './providers/syncBlockProvider';
13
13
  export type { ADFFetchProvider, ADFWriteProvider, SyncBlockDataProvider, SyncBlockInstance, MediaEmojiProviderOptions, SyncedBlockRendererProviderOptions, SyncBlockRendererProviderCreator, } from './providers/types';
14
14
  export { ReferenceSyncBlockStoreManager } from './store-manager/referenceSyncBlockStoreManager';
@@ -1,21 +1,23 @@
1
- import { type ResourceId, type SyncBlockData } from '../../common/types';
2
- import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SourceInfoFetchData, SyncBlockInstance, WriteSyncBlockResult } from '../types';
1
+ import { type SyncBlockData, type SyncBlockProduct } from '../../common/types';
2
+ import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SyncBlockInstance, WriteSyncBlockResult } from '../types';
3
3
  /**
4
4
  * ADFFetchProvider implementation that fetches synced block data from Block Service API
5
5
  */
6
6
  declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
7
7
  fetchData(resourceId: string): Promise<SyncBlockInstance>;
8
- retrieveSourceInfoFetchData(resourceId: ResourceId, pageARI: string): SourceInfoFetchData;
9
8
  }
10
9
  /**
11
10
  * ADFWriteProvider implementation that writes synced block data to Block Service API
12
11
  */
13
12
  declare class BlockServiceADFWriteProvider implements ADFWriteProvider {
13
+ private sourceAri;
14
+ private product;
15
+ constructor(sourceAri: string, product: SyncBlockProduct);
14
16
  writeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
15
17
  deleteData(resourceId: string): Promise<DeleteSyncBlockResult>;
16
- generateResourceId(sourceId: string, localId: string): string;
18
+ generateResourceId(sourceAri: string, localId: string): string;
17
19
  }
18
- export declare const useMemoizedBlockServiceAPIProviders: () => {
20
+ export declare const useMemoizedBlockServiceAPIProviders: (sourceAri: string, product: SyncBlockProduct) => {
19
21
  fetchProvider: BlockServiceADFFetchProvider;
20
22
  writeProvider: BlockServiceADFWriteProvider;
21
23
  };
@@ -1,5 +1,5 @@
1
- import { type ResourceId, type SyncBlockData } from '../../common/types';
2
- import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SourceInfoFetchData, SyncBlockInstance, WriteSyncBlockResult } from '../types';
1
+ import { type SyncBlockData } from '../../common/types';
2
+ import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SyncBlockInstance, WriteSyncBlockResult } from '../types';
3
3
  /**
4
4
  * Configuration for Content API providers
5
5
  */
@@ -14,7 +14,6 @@ declare class ConfluenceADFFetchProvider implements ADFFetchProvider {
14
14
  private config;
15
15
  constructor(config: ContentAPIConfig);
16
16
  fetchData(resourceId: string): Promise<SyncBlockInstance>;
17
- retrieveSourceInfoFetchData(resourceId: ResourceId): SourceInfoFetchData;
18
17
  }
19
18
  /**
20
19
  * ADFWriteProvider implementation that writes synced block data to Confluence Content API
@@ -1,5 +1,6 @@
1
+ import type { RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
1
2
  import type { JSONNode } from '@atlaskit/editor-json-transformer/types';
2
- import { type SyncBlockData, type SyncBlockNode } from '../common/types';
3
+ import { type BlockInstanceId, type ResourceId, type SyncBlockData, type SyncBlockNode, type SyncBlockProduct } from '../common/types';
3
4
  import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type DeleteSyncBlockResult, type SyncBlockInstance, type SyncBlockParentInfo, type SyncBlockSourceInfo, type SyncedBlockRendererProviderOptions, type WriteSyncBlockResult } from '../providers/types';
4
5
  export declare class SyncBlockProvider extends SyncBlockDataProvider {
5
6
  name: string;
@@ -57,7 +58,7 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
57
58
  *
58
59
  * @returns Array of {resourceId?: string, error?: string}.
59
60
  */
60
- deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
61
+ deleteNodesData(resourceIds: ResourceId[]): Promise<Array<DeleteSyncBlockResult>>;
61
62
  /**
62
63
  * Get the source id
63
64
  *
@@ -65,14 +66,16 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
65
66
  */
66
67
  getSourceId(): string;
67
68
  /**
68
- * Retrieve the source info from the source id
69
+ * Fetch the source info from the source id
69
70
  *
70
- * @param node
71
+ * @param params
72
+ * @param params.sourceAri - The source ARI
73
+ * @param params.sourceProduct - The source product. e.g. 'confluence-page', 'jira-work-item'
71
74
  *
72
75
  * @returns The source info
73
76
  */
74
- retrieveSyncBlockSourceInfo(node: SyncBlockNode): Promise<SyncBlockSourceInfo | undefined>;
75
- generateResourceId(sourceId: string, localId: string): string;
77
+ fetchSyncBlockSourceInfo(localId: BlockInstanceId, sourceAri: string, sourceProduct: SyncBlockProduct, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void): Promise<SyncBlockSourceInfo | undefined>;
78
+ generateResourceId(sourceId: string, localId: BlockInstanceId): string;
76
79
  /**
77
80
  * Get the synced block renderer provider options
78
81
  *
@@ -82,11 +85,11 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
82
85
  /**
83
86
  * Retrieve the parent info for the sync block
84
87
  *
85
- * @param resourceId
86
- * @param syncBlockInstance
88
+ * @param sourceAri - The source ARI
89
+ * @param sourceProduct - The source product. e.g. 'confluence-page', 'jira-work-item'
87
90
  *
88
91
  * @returns The parent info for the sync block
89
92
  */
90
- retrieveSyncBlockParentInfo(syncBlockInstance: SyncBlockInstance | undefined): SyncBlockParentInfo | undefined;
93
+ retrieveSyncBlockParentInfo(sourceAri: string, sourceProduct: SyncBlockProduct): SyncBlockParentInfo | undefined;
91
94
  }
92
95
  export declare const useMemoizedSyncedBlockProvider: (fetchProvider: ADFFetchProvider, writeProvider: ADFWriteProvider, sourceId: string, providerOptions: SyncedBlockRendererProviderOptions) => SyncBlockProvider;
@@ -1,9 +1,10 @@
1
+ import type { RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
1
2
  import type { MediaProvider, ProfilecardProvider } from '@atlaskit/editor-common/provider-factory';
2
3
  import type { EmojiProvider } from '@atlaskit/emoji';
3
4
  import type { MentionProvider } from '@atlaskit/mention/types';
4
5
  import { NodeDataProvider } from '@atlaskit/node-data-provider';
5
6
  import type { TaskDecisionProvider } from '@atlaskit/task-decision/types';
6
- import type { SyncBlockData, ResourceId, SyncBlockError, SyncBlockNode, SyncBlockProduct } from '../common/types';
7
+ import type { SyncBlockData, ResourceId, SyncBlockError, SyncBlockNode, SyncBlockProduct, BlockInstanceId } from '../common/types';
7
8
  /**
8
9
  * The instance of a sync block, containing its data and metadata.
9
10
  * Mainly used for representing the state of a sync block after fetching from a data provider.
@@ -12,11 +13,11 @@ import type { SyncBlockData, ResourceId, SyncBlockError, SyncBlockNode, SyncBloc
12
13
  export type SyncBlockInstance = {
13
14
  data?: SyncBlockData;
14
15
  error?: SyncBlockError;
15
- resourceId: string;
16
+ resourceId: ResourceId;
16
17
  };
17
18
  export type DeleteSyncBlockResult = {
18
19
  error?: string;
19
- resourceId: string;
20
+ resourceId: ResourceId;
20
21
  success: boolean;
21
22
  };
22
23
  export type SyncBlockSourceInfo = {
@@ -29,7 +30,7 @@ export type SyncBlockParentInfo = {
29
30
  };
30
31
  export type WriteSyncBlockResult = {
31
32
  error?: string;
32
- resourceId?: string;
33
+ resourceId?: ResourceId;
33
34
  };
34
35
  export type SourceInfoFetchData = {
35
36
  pageARI: string;
@@ -37,10 +38,9 @@ export type SourceInfoFetchData = {
37
38
  };
38
39
  export interface ADFFetchProvider {
39
40
  fetchData: (resourceId: ResourceId) => Promise<SyncBlockInstance>;
40
- retrieveSourceInfoFetchData: (resourceId: ResourceId, pageAri: string) => SourceInfoFetchData;
41
41
  }
42
42
  export interface ADFWriteProvider {
43
- deleteData: (resourceId: string) => Promise<DeleteSyncBlockResult>;
43
+ deleteData: (resourceId: ResourceId) => Promise<DeleteSyncBlockResult>;
44
44
  generateResourceId: (sourceId: string, localId: string) => ResourceId;
45
45
  writeData: (data: SyncBlockData) => Promise<WriteSyncBlockResult>;
46
46
  }
@@ -65,16 +65,16 @@ export declare abstract class SyncBlockDataProvider extends NodeDataProvider<Syn
65
65
  abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<WriteSyncBlockResult>>;
66
66
  abstract deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
67
67
  abstract getSourceId(): ResourceId;
68
- abstract retrieveSyncBlockSourceInfo(node: SyncBlockNode): Promise<SyncBlockSourceInfo | undefined>;
68
+ abstract fetchSyncBlockSourceInfo(localId: BlockInstanceId, sourceAri: string, sourceProduct: SyncBlockProduct, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void): Promise<SyncBlockSourceInfo | undefined>;
69
69
  abstract getSyncedBlockRendererProviderOptions(): SyncedBlockRendererProviderOptions;
70
- abstract retrieveSyncBlockParentInfo(syncBlockInstance: SyncBlockInstance | undefined): SyncBlockParentInfo | undefined;
70
+ abstract retrieveSyncBlockParentInfo(sourceAri: string, sourceProduct: SyncBlockProduct): SyncBlockParentInfo | undefined;
71
71
  /**
72
72
  * Generates a resource ID from a source ID and local ID.
73
73
  * @param sourceId - The source document ID (e.g., page ARI)
74
74
  * @param localId - The local block ID (usually a UUID)
75
75
  * @returns The generated resource ID
76
76
  */
77
- abstract generateResourceId(sourceId: ResourceId, localId: string): ResourceId;
77
+ abstract generateResourceId(sourceId: ResourceId, localId: BlockInstanceId): ResourceId;
78
78
  }
79
79
  export type SubscriptionCallback = (data: SyncBlockInstance) => void;
80
80
  export type TitleSubscriptionCallback = (title: string) => void;
@@ -1,3 +1,4 @@
1
+ import { type RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
1
2
  import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
2
3
  import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
4
  import { type ResourceId, type SyncBlockNode } from '../common/types';
@@ -8,21 +9,24 @@ export declare class ReferenceSyncBlockStoreManager {
8
9
  private subscriptions;
9
10
  private titleSubscriptions;
10
11
  private providerFactories;
12
+ private fireAnalyticsEvent?;
11
13
  private syncBlockURLRequests;
12
14
  private isRefreshingSubscriptions;
13
- constructor(dataProvider?: SyncBlockDataProvider);
15
+ constructor(dataProvider?: SyncBlockDataProvider, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void);
16
+ updateFireAnalyticsEvent(fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void): void;
14
17
  /**
15
18
  * Refreshes the subscriptions for all sync blocks.
16
19
  * @returns {Promise<void>}
17
20
  */
18
21
  refreshSubscriptions(): Promise<void>;
19
- private retrieveSyncBlockSourceInfo;
22
+ private fetchSyncBlockSourceInfo;
20
23
  /**
21
24
  * Fetch sync block data for a given array of sync block nodes.
22
25
  * @param syncBlockNodes - The array of sync block nodes to fetch data for
23
26
  * @returns The fetched sync block data results
24
27
  */
25
28
  fetchSyncBlocksData(syncBlockNodes: SyncBlockNode[]): Promise<SyncBlockInstance[]>;
29
+ private updateCacheWithSourceInfo;
26
30
  private updateCache;
27
31
  private updateSourceTitleSubscriptions;
28
32
  private getFromCache;
@@ -1,3 +1,4 @@
1
+ import { type SyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
1
2
  import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
3
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
3
4
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
@@ -8,12 +9,13 @@ export type CreationCallback = () => void;
8
9
  export declare class SourceSyncBlockStoreManager {
9
10
  private dataProvider?;
10
11
  private editorView?;
12
+ private fireAnalyticsEvent?;
11
13
  private syncBlockCache;
12
14
  private confirmationCallback?;
13
15
  private confirmationTransaction?;
14
16
  private pendingResourceId?;
15
17
  private creationCallback?;
16
- constructor(dataProvider?: SyncBlockDataProvider);
18
+ constructor(dataProvider?: SyncBlockDataProvider, fireAnalyticsEvent?: (payload: SyncBlockEventPayload) => void);
17
19
  isSourceBlock(node: PMNode): boolean;
18
20
  /**
19
21
  * Add/update a sync block node to/from the local cache
@@ -1,10 +1,11 @@
1
+ import type { SyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
1
2
  import type { SyncBlockDataProvider } from '../providers/types';
2
3
  import { ReferenceSyncBlockStoreManager } from './referenceSyncBlockStoreManager';
3
4
  import { SourceSyncBlockStoreManager } from './sourceSyncBlockStoreManager';
4
5
  export declare class SyncBlockStoreManager {
5
6
  private referenceSyncBlockStoreManager;
6
7
  private sourceSyncBlockStoreManager;
7
- constructor(dataProvider?: SyncBlockDataProvider);
8
+ constructor(dataProvider?: SyncBlockDataProvider, fireAnalyticsEvent?: (payload: SyncBlockEventPayload) => void);
8
9
  get referenceManager(): ReferenceSyncBlockStoreManager;
9
10
  get sourceManager(): SourceSyncBlockStoreManager;
10
11
  destroy(): void;
@@ -1 +1,11 @@
1
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, type RendererSyncBlockEventPayload, type OperationalAEP, type SyncBlockEventPayload } from "@atlaskit/editor-common/analytics";
1
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, {
4
+ error: string;
5
+ }>;
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 createErrorPayload: (error: string) => SyncBlockEventPayload;
10
+ export declare const deleteErrorPayload: (error: string) => SyncBlockEventPayload;
11
+ export declare const updateCacheErrorPayload: (error: string) => SyncBlockEventPayload;
@@ -3,10 +3,8 @@ export type BlockContentResponse = {
3
3
  blockAri: string;
4
4
  blockInstanceId: string;
5
5
  content: string;
6
- contentUpdatedAt: number;
7
6
  createdAt: number;
8
7
  createdBy: string;
9
- isSynced: boolean;
10
8
  product: SyncBlockProduct;
11
9
  sourceAri: string;
12
10
  status: 'active' | 'deleted';
@@ -1,2 +1,3 @@
1
+ import { type RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
1
2
  import type { SyncBlockSourceInfo } from '../../providers/types';
2
- export declare const fetchConfluenceSourceInfo: (pageAri: string, localId?: string) => Promise<SyncBlockSourceInfo | undefined>;
3
+ export declare const fetchConfluencePageInfo: (pageAri: string, localId?: string, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void) => Promise<SyncBlockSourceInfo | undefined>;
@@ -1,3 +1,4 @@
1
+ import { type RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
1
2
  import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
2
3
  import type { SyncBlockInstance } from '../providers/types';
3
4
  import type { SyncBlockStoreManager } from '../store-manager/syncBlockStoreManager';
@@ -7,4 +8,4 @@ export interface UseFetchSyncBlockDataResult {
7
8
  reloadData: () => Promise<void>;
8
9
  syncBlockInstance: SyncBlockInstance | null;
9
10
  }
10
- export declare const useFetchSyncBlockData: (manager: SyncBlockStoreManager, resourceId?: string, localId?: string) => UseFetchSyncBlockDataResult;
11
+ export declare const useFetchSyncBlockData: (manager: SyncBlockStoreManager, resourceId?: string, localId?: string, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void) => UseFetchSyncBlockDataResult;
@@ -1,6 +1,6 @@
1
1
  export { rebaseTransaction } from './common/rebase-transaction';
2
2
  export { SyncBlockError } from './common/types';
3
- export type { SyncBlockData, SyncBlockNode } from './common/types';
3
+ export type { SyncBlockData, SyncBlockNode, SyncBlockProduct, BlockInstanceId, } 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';
@@ -8,7 +8,7 @@ export { blockResourceIdFromSourceAndLocalId, getLocalIdFromBlockResourceId, } f
8
8
  export { getConfluencePageAri, getLocalIdFromConfluencePageAri, getPageARIFromContentPropertyResourceId, getPageIdAndTypeFromConfluencePageAri, resourceIdFromConfluencePageSourceIdAndLocalId, } from './clients/confluence/ari';
9
9
  export { useMemoizedBlockServiceAPIProviders } from './providers/block-service/blockServiceAPI';
10
10
  export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders, } from './providers/confluence/confluenceContentAPI';
11
- export { fetchConfluenceSourceInfo } from './clients/confluence/sourceInfo';
11
+ export { fetchConfluencePageInfo } from './clients/confluence/sourceInfo';
12
12
  export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider, } from './providers/syncBlockProvider';
13
13
  export type { ADFFetchProvider, ADFWriteProvider, SyncBlockDataProvider, SyncBlockInstance, MediaEmojiProviderOptions, SyncedBlockRendererProviderOptions, SyncBlockRendererProviderCreator, } from './providers/types';
14
14
  export { ReferenceSyncBlockStoreManager } from './store-manager/referenceSyncBlockStoreManager';
@@ -1,21 +1,23 @@
1
- import { type ResourceId, type SyncBlockData } from '../../common/types';
2
- import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SourceInfoFetchData, SyncBlockInstance, WriteSyncBlockResult } from '../types';
1
+ import { type SyncBlockData, type SyncBlockProduct } from '../../common/types';
2
+ import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SyncBlockInstance, WriteSyncBlockResult } from '../types';
3
3
  /**
4
4
  * ADFFetchProvider implementation that fetches synced block data from Block Service API
5
5
  */
6
6
  declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
7
7
  fetchData(resourceId: string): Promise<SyncBlockInstance>;
8
- retrieveSourceInfoFetchData(resourceId: ResourceId, pageARI: string): SourceInfoFetchData;
9
8
  }
10
9
  /**
11
10
  * ADFWriteProvider implementation that writes synced block data to Block Service API
12
11
  */
13
12
  declare class BlockServiceADFWriteProvider implements ADFWriteProvider {
13
+ private sourceAri;
14
+ private product;
15
+ constructor(sourceAri: string, product: SyncBlockProduct);
14
16
  writeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
15
17
  deleteData(resourceId: string): Promise<DeleteSyncBlockResult>;
16
- generateResourceId(sourceId: string, localId: string): string;
18
+ generateResourceId(sourceAri: string, localId: string): string;
17
19
  }
18
- export declare const useMemoizedBlockServiceAPIProviders: () => {
20
+ export declare const useMemoizedBlockServiceAPIProviders: (sourceAri: string, product: SyncBlockProduct) => {
19
21
  fetchProvider: BlockServiceADFFetchProvider;
20
22
  writeProvider: BlockServiceADFWriteProvider;
21
23
  };
@@ -1,5 +1,5 @@
1
- import { type ResourceId, type SyncBlockData } from '../../common/types';
2
- import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SourceInfoFetchData, SyncBlockInstance, WriteSyncBlockResult } from '../types';
1
+ import { type SyncBlockData } from '../../common/types';
2
+ import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SyncBlockInstance, WriteSyncBlockResult } from '../types';
3
3
  /**
4
4
  * Configuration for Content API providers
5
5
  */
@@ -14,7 +14,6 @@ declare class ConfluenceADFFetchProvider implements ADFFetchProvider {
14
14
  private config;
15
15
  constructor(config: ContentAPIConfig);
16
16
  fetchData(resourceId: string): Promise<SyncBlockInstance>;
17
- retrieveSourceInfoFetchData(resourceId: ResourceId): SourceInfoFetchData;
18
17
  }
19
18
  /**
20
19
  * ADFWriteProvider implementation that writes synced block data to Confluence Content API
@@ -1,5 +1,6 @@
1
+ import type { RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
1
2
  import type { JSONNode } from '@atlaskit/editor-json-transformer/types';
2
- import { type SyncBlockData, type SyncBlockNode } from '../common/types';
3
+ import { type BlockInstanceId, type ResourceId, type SyncBlockData, type SyncBlockNode, type SyncBlockProduct } from '../common/types';
3
4
  import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type DeleteSyncBlockResult, type SyncBlockInstance, type SyncBlockParentInfo, type SyncBlockSourceInfo, type SyncedBlockRendererProviderOptions, type WriteSyncBlockResult } from '../providers/types';
4
5
  export declare class SyncBlockProvider extends SyncBlockDataProvider {
5
6
  name: string;
@@ -57,7 +58,7 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
57
58
  *
58
59
  * @returns Array of {resourceId?: string, error?: string}.
59
60
  */
60
- deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
61
+ deleteNodesData(resourceIds: ResourceId[]): Promise<Array<DeleteSyncBlockResult>>;
61
62
  /**
62
63
  * Get the source id
63
64
  *
@@ -65,14 +66,16 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
65
66
  */
66
67
  getSourceId(): string;
67
68
  /**
68
- * Retrieve the source info from the source id
69
+ * Fetch the source info from the source id
69
70
  *
70
- * @param node
71
+ * @param params
72
+ * @param params.sourceAri - The source ARI
73
+ * @param params.sourceProduct - The source product. e.g. 'confluence-page', 'jira-work-item'
71
74
  *
72
75
  * @returns The source info
73
76
  */
74
- retrieveSyncBlockSourceInfo(node: SyncBlockNode): Promise<SyncBlockSourceInfo | undefined>;
75
- generateResourceId(sourceId: string, localId: string): string;
77
+ fetchSyncBlockSourceInfo(localId: BlockInstanceId, sourceAri: string, sourceProduct: SyncBlockProduct, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void): Promise<SyncBlockSourceInfo | undefined>;
78
+ generateResourceId(sourceId: string, localId: BlockInstanceId): string;
76
79
  /**
77
80
  * Get the synced block renderer provider options
78
81
  *
@@ -82,11 +85,11 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
82
85
  /**
83
86
  * Retrieve the parent info for the sync block
84
87
  *
85
- * @param resourceId
86
- * @param syncBlockInstance
88
+ * @param sourceAri - The source ARI
89
+ * @param sourceProduct - The source product. e.g. 'confluence-page', 'jira-work-item'
87
90
  *
88
91
  * @returns The parent info for the sync block
89
92
  */
90
- retrieveSyncBlockParentInfo(syncBlockInstance: SyncBlockInstance | undefined): SyncBlockParentInfo | undefined;
93
+ retrieveSyncBlockParentInfo(sourceAri: string, sourceProduct: SyncBlockProduct): SyncBlockParentInfo | undefined;
91
94
  }
92
95
  export declare const useMemoizedSyncedBlockProvider: (fetchProvider: ADFFetchProvider, writeProvider: ADFWriteProvider, sourceId: string, providerOptions: SyncedBlockRendererProviderOptions) => SyncBlockProvider;
@@ -1,9 +1,10 @@
1
+ import type { RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
1
2
  import type { MediaProvider, ProfilecardProvider } from '@atlaskit/editor-common/provider-factory';
2
3
  import type { EmojiProvider } from '@atlaskit/emoji';
3
4
  import type { MentionProvider } from '@atlaskit/mention/types';
4
5
  import { NodeDataProvider } from '@atlaskit/node-data-provider';
5
6
  import type { TaskDecisionProvider } from '@atlaskit/task-decision/types';
6
- import type { SyncBlockData, ResourceId, SyncBlockError, SyncBlockNode, SyncBlockProduct } from '../common/types';
7
+ import type { SyncBlockData, ResourceId, SyncBlockError, SyncBlockNode, SyncBlockProduct, BlockInstanceId } from '../common/types';
7
8
  /**
8
9
  * The instance of a sync block, containing its data and metadata.
9
10
  * Mainly used for representing the state of a sync block after fetching from a data provider.
@@ -12,11 +13,11 @@ import type { SyncBlockData, ResourceId, SyncBlockError, SyncBlockNode, SyncBloc
12
13
  export type SyncBlockInstance = {
13
14
  data?: SyncBlockData;
14
15
  error?: SyncBlockError;
15
- resourceId: string;
16
+ resourceId: ResourceId;
16
17
  };
17
18
  export type DeleteSyncBlockResult = {
18
19
  error?: string;
19
- resourceId: string;
20
+ resourceId: ResourceId;
20
21
  success: boolean;
21
22
  };
22
23
  export type SyncBlockSourceInfo = {
@@ -29,7 +30,7 @@ export type SyncBlockParentInfo = {
29
30
  };
30
31
  export type WriteSyncBlockResult = {
31
32
  error?: string;
32
- resourceId?: string;
33
+ resourceId?: ResourceId;
33
34
  };
34
35
  export type SourceInfoFetchData = {
35
36
  pageARI: string;
@@ -37,10 +38,9 @@ export type SourceInfoFetchData = {
37
38
  };
38
39
  export interface ADFFetchProvider {
39
40
  fetchData: (resourceId: ResourceId) => Promise<SyncBlockInstance>;
40
- retrieveSourceInfoFetchData: (resourceId: ResourceId, pageAri: string) => SourceInfoFetchData;
41
41
  }
42
42
  export interface ADFWriteProvider {
43
- deleteData: (resourceId: string) => Promise<DeleteSyncBlockResult>;
43
+ deleteData: (resourceId: ResourceId) => Promise<DeleteSyncBlockResult>;
44
44
  generateResourceId: (sourceId: string, localId: string) => ResourceId;
45
45
  writeData: (data: SyncBlockData) => Promise<WriteSyncBlockResult>;
46
46
  }
@@ -65,16 +65,16 @@ export declare abstract class SyncBlockDataProvider extends NodeDataProvider<Syn
65
65
  abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<WriteSyncBlockResult>>;
66
66
  abstract deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
67
67
  abstract getSourceId(): ResourceId;
68
- abstract retrieveSyncBlockSourceInfo(node: SyncBlockNode): Promise<SyncBlockSourceInfo | undefined>;
68
+ abstract fetchSyncBlockSourceInfo(localId: BlockInstanceId, sourceAri: string, sourceProduct: SyncBlockProduct, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void): Promise<SyncBlockSourceInfo | undefined>;
69
69
  abstract getSyncedBlockRendererProviderOptions(): SyncedBlockRendererProviderOptions;
70
- abstract retrieveSyncBlockParentInfo(syncBlockInstance: SyncBlockInstance | undefined): SyncBlockParentInfo | undefined;
70
+ abstract retrieveSyncBlockParentInfo(sourceAri: string, sourceProduct: SyncBlockProduct): SyncBlockParentInfo | undefined;
71
71
  /**
72
72
  * Generates a resource ID from a source ID and local ID.
73
73
  * @param sourceId - The source document ID (e.g., page ARI)
74
74
  * @param localId - The local block ID (usually a UUID)
75
75
  * @returns The generated resource ID
76
76
  */
77
- abstract generateResourceId(sourceId: ResourceId, localId: string): ResourceId;
77
+ abstract generateResourceId(sourceId: ResourceId, localId: BlockInstanceId): ResourceId;
78
78
  }
79
79
  export type SubscriptionCallback = (data: SyncBlockInstance) => void;
80
80
  export type TitleSubscriptionCallback = (title: string) => void;
@@ -1,3 +1,4 @@
1
+ import { type RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
1
2
  import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
2
3
  import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
4
  import { type ResourceId, type SyncBlockNode } from '../common/types';
@@ -8,21 +9,24 @@ export declare class ReferenceSyncBlockStoreManager {
8
9
  private subscriptions;
9
10
  private titleSubscriptions;
10
11
  private providerFactories;
12
+ private fireAnalyticsEvent?;
11
13
  private syncBlockURLRequests;
12
14
  private isRefreshingSubscriptions;
13
- constructor(dataProvider?: SyncBlockDataProvider);
15
+ constructor(dataProvider?: SyncBlockDataProvider, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void);
16
+ updateFireAnalyticsEvent(fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void): void;
14
17
  /**
15
18
  * Refreshes the subscriptions for all sync blocks.
16
19
  * @returns {Promise<void>}
17
20
  */
18
21
  refreshSubscriptions(): Promise<void>;
19
- private retrieveSyncBlockSourceInfo;
22
+ private fetchSyncBlockSourceInfo;
20
23
  /**
21
24
  * Fetch sync block data for a given array of sync block nodes.
22
25
  * @param syncBlockNodes - The array of sync block nodes to fetch data for
23
26
  * @returns The fetched sync block data results
24
27
  */
25
28
  fetchSyncBlocksData(syncBlockNodes: SyncBlockNode[]): Promise<SyncBlockInstance[]>;
29
+ private updateCacheWithSourceInfo;
26
30
  private updateCache;
27
31
  private updateSourceTitleSubscriptions;
28
32
  private getFromCache;
@@ -1,3 +1,4 @@
1
+ import { type SyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
1
2
  import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
3
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
3
4
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
@@ -8,12 +9,13 @@ export type CreationCallback = () => void;
8
9
  export declare class SourceSyncBlockStoreManager {
9
10
  private dataProvider?;
10
11
  private editorView?;
12
+ private fireAnalyticsEvent?;
11
13
  private syncBlockCache;
12
14
  private confirmationCallback?;
13
15
  private confirmationTransaction?;
14
16
  private pendingResourceId?;
15
17
  private creationCallback?;
16
- constructor(dataProvider?: SyncBlockDataProvider);
18
+ constructor(dataProvider?: SyncBlockDataProvider, fireAnalyticsEvent?: (payload: SyncBlockEventPayload) => void);
17
19
  isSourceBlock(node: PMNode): boolean;
18
20
  /**
19
21
  * Add/update a sync block node to/from the local cache
@@ -1,10 +1,11 @@
1
+ import type { SyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
1
2
  import type { SyncBlockDataProvider } from '../providers/types';
2
3
  import { ReferenceSyncBlockStoreManager } from './referenceSyncBlockStoreManager';
3
4
  import { SourceSyncBlockStoreManager } from './sourceSyncBlockStoreManager';
4
5
  export declare class SyncBlockStoreManager {
5
6
  private referenceSyncBlockStoreManager;
6
7
  private sourceSyncBlockStoreManager;
7
- constructor(dataProvider?: SyncBlockDataProvider);
8
+ constructor(dataProvider?: SyncBlockDataProvider, fireAnalyticsEvent?: (payload: SyncBlockEventPayload) => void);
8
9
  get referenceManager(): ReferenceSyncBlockStoreManager;
9
10
  get sourceManager(): SourceSyncBlockStoreManager;
10
11
  destroy(): void;
@@ -1 +1,11 @@
1
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, type RendererSyncBlockEventPayload, type OperationalAEP, type SyncBlockEventPayload } from "@atlaskit/editor-common/analytics";
1
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, {
4
+ error: string;
5
+ }>;
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 createErrorPayload: (error: string) => SyncBlockEventPayload;
10
+ export declare const deleteErrorPayload: (error: string) => SyncBlockEventPayload;
11
+ export declare const updateCacheErrorPayload: (error: string) => SyncBlockEventPayload;