@atlaskit/editor-synced-block-provider 3.6.0 → 3.6.1

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 (53) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cjs/clients/block-service/ari.js +12 -1
  3. package/dist/cjs/clients/block-service/blockService.js +35 -2
  4. package/dist/cjs/clients/confluence/sourceInfo.js +109 -52
  5. package/dist/cjs/providers/block-service/blockServiceAPI.js +195 -125
  6. package/dist/cjs/providers/syncBlockProvider.js +83 -14
  7. package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +50 -16
  8. package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +17 -0
  9. package/dist/cjs/store-manager/syncBlockStoreManager.js +121 -0
  10. package/dist/cjs/utils/errorHandling.js +4 -1
  11. package/dist/es2019/clients/block-service/ari.js +11 -0
  12. package/dist/es2019/clients/block-service/blockService.js +12 -1
  13. package/dist/es2019/clients/confluence/sourceInfo.js +64 -29
  14. package/dist/es2019/providers/block-service/blockServiceAPI.js +45 -2
  15. package/dist/es2019/providers/syncBlockProvider.js +37 -5
  16. package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +51 -17
  17. package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +16 -1
  18. package/dist/es2019/store-manager/syncBlockStoreManager.js +64 -0
  19. package/dist/es2019/utils/errorHandling.js +2 -1
  20. package/dist/esm/clients/block-service/ari.js +11 -0
  21. package/dist/esm/clients/block-service/blockService.js +34 -1
  22. package/dist/esm/clients/confluence/sourceInfo.js +109 -52
  23. package/dist/esm/providers/block-service/blockServiceAPI.js +195 -125
  24. package/dist/esm/providers/syncBlockProvider.js +81 -12
  25. package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +50 -16
  26. package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +18 -1
  27. package/dist/esm/store-manager/syncBlockStoreManager.js +121 -0
  28. package/dist/esm/utils/errorHandling.js +3 -0
  29. package/dist/types/clients/block-service/ari.d.ts +1 -0
  30. package/dist/types/clients/block-service/blockService.d.ts +15 -5
  31. package/dist/types/clients/confluence/sourceInfo.d.ts +2 -2
  32. package/dist/types/common/types.d.ts +25 -0
  33. package/dist/types/index.d.ts +2 -2
  34. package/dist/types/providers/block-service/blockServiceAPI.d.ts +3 -2
  35. package/dist/types/providers/syncBlockProvider.d.ts +3 -2
  36. package/dist/types/providers/types.d.ts +14 -2
  37. package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +3 -2
  38. package/dist/types/store-manager/sourceSyncBlockStoreManager.d.ts +3 -2
  39. package/dist/types/store-manager/syncBlockStoreManager.d.ts +4 -0
  40. package/dist/types/utils/errorHandling.d.ts +1 -0
  41. package/dist/types-ts4.5/clients/block-service/ari.d.ts +1 -0
  42. package/dist/types-ts4.5/clients/block-service/blockService.d.ts +15 -5
  43. package/dist/types-ts4.5/clients/confluence/sourceInfo.d.ts +2 -2
  44. package/dist/types-ts4.5/common/types.d.ts +25 -0
  45. package/dist/types-ts4.5/index.d.ts +2 -2
  46. package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +3 -2
  47. package/dist/types-ts4.5/providers/syncBlockProvider.d.ts +3 -2
  48. package/dist/types-ts4.5/providers/types.d.ts +14 -2
  49. package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +3 -2
  50. package/dist/types-ts4.5/store-manager/sourceSyncBlockStoreManager.d.ts +3 -2
  51. package/dist/types-ts4.5/store-manager/syncBlockStoreManager.d.ts +4 -0
  52. package/dist/types-ts4.5/utils/errorHandling.d.ts +1 -0
  53. package/package.json +1 -1
@@ -4,7 +4,7 @@ import type { EmojiProvider } from '@atlaskit/emoji';
4
4
  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
- import type { SyncBlockData, ResourceId, SyncBlockError, SyncBlockNode, SyncBlockProduct, BlockInstanceId, SyncBlockAttrs } from '../common/types';
7
+ import type { SyncBlockData, ResourceId, SyncBlockError, SyncBlockNode, SyncBlockProduct, BlockInstanceId, SyncBlockAttrs, ReferenceSyncBlockData } from '../common/types';
8
8
  /**
9
9
  * The instance of a sync block, containing its data and metadata.
10
10
  * Mainly used for representing the state of a sync block after fetching from a data provider.
@@ -24,6 +24,15 @@ export type DeleteSyncBlockResult = {
24
24
  success: boolean;
25
25
  };
26
26
  export type SyncBlockSourceInfo = {
27
+ hasAccess?: boolean;
28
+ /**
29
+ * Whether the source info is for a source synced block
30
+ */
31
+ isSource?: boolean;
32
+ onSamePage?: boolean;
33
+ productType?: SyncBlockProduct;
34
+ sourceAri: string;
35
+ subType?: string | null;
27
36
  title?: string;
28
37
  url?: string;
29
38
  };
@@ -46,6 +55,7 @@ export type UpdateReferenceSyncBlockResult = {
46
55
  export interface ADFFetchProvider {
47
56
  batchFetchData: (resourceIds: ResourceId[]) => Promise<SyncBlockInstance[]>;
48
57
  fetchData: (resourceId: ResourceId) => Promise<SyncBlockInstance>;
58
+ fetchReferences: (referenceResourceId: string) => Promise<ReferenceSyncBlockData>;
49
59
  }
50
60
  export interface ADFWriteProvider {
51
61
  createData: (data: SyncBlockData) => Promise<WriteSyncBlockResult>;
@@ -57,6 +67,7 @@ export interface ADFWriteProvider {
57
67
  */
58
68
  deleteData: (resourceId: ResourceId) => Promise<DeleteSyncBlockResult>;
59
69
  generateResourceIdForReference: (sourceId: ResourceId) => ResourceId;
70
+ parentAri?: string;
60
71
  product: SyncBlockProduct;
61
72
  updateReferenceData: (blocks: SyncBlockAttrs[], noContent?: boolean) => Promise<UpdateReferenceSyncBlockResult>;
62
73
  writeData: (data: SyncBlockData) => Promise<WriteSyncBlockResult>;
@@ -83,7 +94,7 @@ export declare abstract class SyncBlockDataProvider extends NodeDataProvider<Syn
83
94
  abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<WriteSyncBlockResult>>;
84
95
  abstract createNodeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
85
96
  abstract deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
86
- abstract fetchSyncBlockSourceInfo(localId: BlockInstanceId, sourceAri: string, sourceProduct: SyncBlockProduct, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void): Promise<SyncBlockSourceInfo | undefined>;
97
+ abstract fetchSyncBlockSourceInfo(localId: BlockInstanceId, sourceAri?: string, sourceProduct?: SyncBlockProduct, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void, hasAccess?: boolean, urlType?: 'view' | 'edit'): Promise<SyncBlockSourceInfo | undefined>;
87
98
  abstract setProviderOptions(providerOptions: SyncedBlockRendererProviderOptions): void;
88
99
  abstract getSyncedBlockRendererProviderOptions(): SyncedBlockRendererProviderOptions;
89
100
  abstract retrieveSyncBlockParentInfo(sourceAri: string, sourceProduct: SyncBlockProduct): SyncBlockParentInfo | undefined;
@@ -102,6 +113,7 @@ export declare abstract class SyncBlockDataProvider extends NodeDataProvider<Syn
102
113
  */
103
114
  abstract generateResourceIdForReference(sourceId: ResourceId): ResourceId;
104
115
  abstract updateReferenceData(blocks: SyncBlockAttrs[], noContent?: boolean): Promise<UpdateReferenceSyncBlockResult>;
116
+ abstract fetchReferences(resourceId: string, isSource: boolean): Promise<ReferenceSyncBlockData>;
105
117
  }
106
118
  export type SubscriptionCallback = (data: SyncBlockInstance) => void;
107
119
  export type TitleSubscriptionCallback = (title: string) => void;
@@ -3,7 +3,7 @@ import type { Experience } from '@atlaskit/editor-common/experiences';
3
3
  import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
4
4
  import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
5
5
  import { type ResourceId, type SyncBlockNode } from '../common/types';
6
- import type { SyncBlockInstance, SubscriptionCallback, SyncBlockDataProvider, TitleSubscriptionCallback } from '../providers/types';
6
+ import type { SyncBlockInstance, SubscriptionCallback, SyncBlockDataProvider, TitleSubscriptionCallback, SyncBlockSourceInfo } from '../providers/types';
7
7
  export declare class ReferenceSyncBlockStoreManager {
8
8
  private dataProvider?;
9
9
  private syncBlockCache;
@@ -13,6 +13,7 @@ export declare class ReferenceSyncBlockStoreManager {
13
13
  private providerFactories;
14
14
  private fireAnalyticsEvent?;
15
15
  private syncBlockFetchDataRequests;
16
+ private syncBlockSourceInfoRequestsOld;
16
17
  private syncBlockSourceInfoRequests;
17
18
  private isRefreshingSubscriptions;
18
19
  private pendingCacheDeletions;
@@ -30,7 +31,7 @@ export declare class ReferenceSyncBlockStoreManager {
30
31
  * @returns {Promise<void>}
31
32
  */
32
33
  refreshSubscriptions(): Promise<void>;
33
- private fetchSyncBlockSourceInfo;
34
+ fetchSyncBlockSourceInfo(resourceId: ResourceId): Promise<SyncBlockSourceInfo | undefined>;
34
35
  /**
35
36
  * Fetch sync block data for a given array of sync block nodes.
36
37
  * @param syncBlockNodes - The array of sync block nodes to fetch data for
@@ -1,8 +1,8 @@
1
1
  import { type SyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
2
2
  import type { Experience } from '@atlaskit/editor-common/experiences';
3
3
  import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
- import { type ResourceId, type SyncBlockAttrs } from '../common/types';
5
- import type { SyncBlockDataProvider } from '../providers/types';
4
+ import { type ResourceId, type SyncBlockAttrs, type BlockInstanceId } from '../common/types';
5
+ import type { SyncBlockDataProvider, SyncBlockSourceInfo } from '../providers/types';
6
6
  export type ConfirmationCallback = (syncBlockCount: number) => Promise<boolean>;
7
7
  type OnDelete = () => void;
8
8
  type OnDeleteCompleted = (success: boolean) => void;
@@ -75,6 +75,7 @@ export declare class SourceSyncBlockStoreManager {
75
75
  * @param destroyCallback - The callback to clear any reference stored for deletion (regardless if deletion is completed or abort)
76
76
  */
77
77
  deleteSyncBlocksWithConfirmation(syncBlockIds: SyncBlockAttrs[], onDelete: OnDelete, onDeleteCompleted: OnDeleteCompleted, destroyCallback: DestroyCallback): Promise<void>;
78
+ getSyncBlockSourceInfo(localId: BlockInstanceId): Promise<SyncBlockSourceInfo | undefined>;
78
79
  destroy(): void;
79
80
  }
80
81
  export {};
@@ -1,11 +1,15 @@
1
1
  import type { SyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
2
+ import { type BlockInstanceId, type ReferencesSourceInfo, type ResourceId } from '../common/types';
2
3
  import type { SyncBlockDataProvider } from '../providers/types';
3
4
  import { ReferenceSyncBlockStoreManager } from './referenceSyncBlockStoreManager';
4
5
  import { SourceSyncBlockStoreManager } from './sourceSyncBlockStoreManager';
5
6
  export declare class SyncBlockStoreManager {
6
7
  private referenceSyncBlockStoreManager;
7
8
  private sourceSyncBlockStoreManager;
9
+ private dataProvider?;
10
+ private fireAnalyticsEvent?;
8
11
  constructor(dataProvider?: SyncBlockDataProvider);
12
+ fetchReferencesSourceInfo(resourceId: ResourceId, blockInstanceId: BlockInstanceId, isSourceSyncBlock: boolean): Promise<ReferencesSourceInfo>;
9
13
  setFireAnalyticsEvent(fireAnalyticsEvent?: (payload: SyncBlockEventPayload) => void): void;
10
14
  get referenceManager(): ReferenceSyncBlockStoreManager;
11
15
  get sourceManager(): SourceSyncBlockStoreManager;
@@ -10,3 +10,4 @@ export declare const updateReferenceErrorPayload: (error: string) => RendererSyn
10
10
  export declare const createErrorPayload: (error: string) => SyncBlockEventPayload;
11
11
  export declare const deleteErrorPayload: (error: string) => SyncBlockEventPayload;
12
12
  export declare const updateCacheErrorPayload: (error: string) => SyncBlockEventPayload;
13
+ export declare const fetchReferencesErrorPayload: (error: string) => SyncBlockEventPayload;
@@ -29,3 +29,4 @@ export declare const generateBlockAriFromReference: ({ cloudId, resourceId, }: {
29
29
  * @returns the localId of the block node. A randomly generated UUID
30
30
  */
31
31
  export declare const getLocalIdFromBlockResourceId: (ari: string) => string;
32
+ export declare const getProductFromSourceAri: (ari?: string) => SyncBlockProduct | undefined;
@@ -1,4 +1,4 @@
1
- import type { SyncBlockProduct } from '../../common/types';
1
+ import type { ReferenceSyncBlockResponse, SyncBlockProduct } from '../../common/types';
2
2
  export type BlockContentResponse = {
3
3
  blockAri: string;
4
4
  blockInstanceId: string;
@@ -10,16 +10,17 @@ export type BlockContentResponse = {
10
10
  status: 'active' | 'deleted';
11
11
  version: number;
12
12
  };
13
- export type BlockContentErrorResponse = {
13
+ export type ErrorResponse = {
14
14
  blockAri: string;
15
15
  code: string;
16
+ documentAri: string;
16
17
  reason: string;
17
18
  };
18
19
  type ReferenceSyncedBlockResponse = {
19
20
  blocks?: Array<BlockContentResponse>;
20
- errors?: Array<BlockContentErrorResponse>;
21
+ errors?: Array<ErrorResponse>;
21
22
  };
22
- export declare const isBlockContentResponse: (response: BlockContentResponse | BlockContentErrorResponse) => response is BlockContentResponse;
23
+ export declare const isBlockContentResponse: (response: BlockContentResponse | ErrorResponse) => response is BlockContentResponse;
23
24
  /**
24
25
  * Retrieves all synced blocks referenced in a document.
25
26
  *
@@ -95,9 +96,17 @@ export type BatchRetrieveSyncedBlocksRequest = {
95
96
  blockAris: string[];
96
97
  };
97
98
  export type BatchRetrieveSyncedBlocksResponse = {
98
- error?: Array<BlockContentErrorResponse>;
99
+ error?: Array<ErrorResponse>;
99
100
  success?: Array<BlockContentResponse>;
100
101
  };
102
+ type GetReferenceSyncedBlocksByBlockAriRequest = {
103
+ blockAri: string;
104
+ };
105
+ type GetReferenceSyncedBlocksByBlockAriResponse = {
106
+ blockAri?: string;
107
+ errors: Array<ErrorResponse>;
108
+ references: Array<ReferenceSyncBlockResponse>;
109
+ };
101
110
  export declare class BlockError extends Error {
102
111
  readonly status: number;
103
112
  constructor(status: number);
@@ -116,4 +125,5 @@ export declare const deleteSyncedBlock: ({ blockAri }: DeleteSyncedBlockRequest)
116
125
  export declare const updateSyncedBlock: ({ blockAri, content, stepVersion, }: UpdateSyncedBlockRequest) => Promise<void>;
117
126
  export declare const createSyncedBlock: ({ blockAri, blockInstanceId, sourceAri, product, content, stepVersion, }: CreateSyncedBlockRequest) => Promise<BlockContentResponse>;
118
127
  export declare const updateReferenceSyncedBlockOnDocument: ({ documentAri, blocks, noContent, }: UpdateReferenceSyncedBlockOnDocumentRequest) => Promise<ReferenceSyncedBlockResponse | void>;
128
+ export declare const getReferenceSyncedBlocksByBlockAri: ({ blockAri, }: GetReferenceSyncedBlocksByBlockAriRequest) => Promise<GetReferenceSyncedBlocksByBlockAriResponse>;
119
129
  export {};
@@ -1,5 +1,5 @@
1
1
  import { type RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
2
2
  import type { SyncBlockSourceInfo } from '../../providers/types';
3
3
  export declare const fetchConfluencePageInfoOld: (pageAri: string, localId?: string, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void) => Promise<SyncBlockSourceInfo | undefined>;
4
- export declare const fetchConfluencePageInfoNew: (pageAri: string, localId?: string) => Promise<SyncBlockSourceInfo | undefined>;
5
- export declare const fetchConfluencePageInfo: (pageAri: string, localId?: string, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void) => Promise<SyncBlockSourceInfo | undefined>;
4
+ export declare const fetchConfluencePageInfoNew: (pageAri: string, hasAccess: boolean, urlType: "view" | "edit", localId?: string) => Promise<SyncBlockSourceInfo | undefined>;
5
+ export declare const fetchConfluencePageInfo: (pageAri: string, hasAccess: boolean, urlType: "view" | "edit", localId?: string, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void) => Promise<SyncBlockSourceInfo | undefined>;
@@ -1,5 +1,6 @@
1
1
  import type { ADFEntity } from '@atlaskit/adf-utils/types';
2
2
  import type { JSONNode } from '@atlaskit/editor-json-transformer/types';
3
+ import type { SyncBlockSourceInfo } from '../providers/types';
3
4
  import type { SYNC_BLOCK_PRODUCTS } from './consts';
4
5
  export type BlockInstanceId = string;
5
6
  export type ResourceId = string;
@@ -30,13 +31,37 @@ export interface SyncBlockData {
30
31
  createdAt?: string;
31
32
  createdBy?: string;
32
33
  isSynced?: boolean;
34
+ /**
35
+ * Whether the block is on the same page as the source block
36
+ */
37
+ onSamePage?: boolean;
33
38
  product?: SyncBlockProduct;
34
39
  /**
35
40
  * The ARI of the block. E.G ari:cloud:blocks:<cloudId>:synced-block/<product>/<pageId>/<resourceId>
36
41
  */
37
42
  resourceId: ResourceId;
38
43
  sourceAri?: string;
44
+ sourceSubType?: string | null;
39
45
  sourceTitle?: string;
40
46
  sourceURL?: string;
41
47
  updatedAt?: string;
42
48
  }
49
+ export interface ReferenceSyncBlockResponse {
50
+ blockAri: string;
51
+ blockInstanceId?: BlockInstanceId;
52
+ createdAt?: string;
53
+ createdBy?: string;
54
+ documentAri: string;
55
+ }
56
+ export interface ReferenceSyncBlock extends ReferenceSyncBlockResponse {
57
+ hasAccess: boolean;
58
+ onSamePage: boolean;
59
+ }
60
+ export type ReferenceSyncBlockData = {
61
+ error?: SyncBlockError;
62
+ references?: ReferenceSyncBlock[];
63
+ };
64
+ export type ReferencesSourceInfo = {
65
+ error?: SyncBlockError;
66
+ references?: Array<SyncBlockSourceInfo | undefined>;
67
+ };
@@ -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, } from './common/types';
3
+ export type { SyncBlockData, SyncBlockNode, SyncBlockProduct, 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, SyncBlockDataProvider, SyncBlockInstance, MediaEmojiProviderOptions, SyncedBlockRendererProviderOptions, SyncBlockRendererProviderCreator, SyncedBlockRendererDataProviders, UpdateReferenceSyncBlockResult, WriteSyncBlockResult, SyncBlockParentInfo, } from './providers/types';
14
+ export type { ADFFetchProvider, ADFWriteProvider, SyncBlockDataProvider, SyncBlockInstance, MediaEmojiProviderOptions, SyncedBlockRendererProviderOptions, SyncBlockRendererProviderCreator, SyncedBlockRendererDataProviders, 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';
@@ -1,5 +1,5 @@
1
1
  import { type BlockContentResponse } from '../../clients/block-service/blockService';
2
- import { SyncBlockError, type ResourceId, type SyncBlockAttrs, type SyncBlockData, type SyncBlockProduct } from '../../common/types';
2
+ import { SyncBlockError, type ReferenceSyncBlockData, type ResourceId, type SyncBlockAttrs, type SyncBlockData, type SyncBlockProduct } from '../../common/types';
3
3
  import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SyncBlockInstance, UpdateReferenceSyncBlockResult, WriteSyncBlockResult } from '../types';
4
4
  /**
5
5
  * Extracts the ResourceId from a block ARI by returning the full path after synced-block/.
@@ -32,6 +32,7 @@ declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
32
32
  private parentAri?;
33
33
  constructor({ cloudId, parentAri }: BlockServiceADFFetchProviderProps);
34
34
  fetchData(resourceId: string): Promise<SyncBlockInstance>;
35
+ fetchReferences(referenceResourceId: string): Promise<ReferenceSyncBlockData>;
35
36
  /**
36
37
  * Extracts the resourceId from a block ARI.
37
38
  * Block ARI format: ari:cloud:blocks:<cloudId>:synced-block/<resourceId>
@@ -56,10 +57,10 @@ interface BlockServiceADFWriteProviderProps {
56
57
  */
57
58
  declare class BlockServiceADFWriteProvider implements ADFWriteProvider {
58
59
  private cloudId;
59
- private parentAri?;
60
60
  private parentId?;
61
61
  private getVersion?;
62
62
  product: SyncBlockProduct;
63
+ parentAri?: string;
63
64
  constructor({ cloudId, parentAri, parentId, product, getVersion, }: BlockServiceADFWriteProviderProps);
64
65
  writeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
65
66
  createData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
@@ -1,6 +1,6 @@
1
1
  import type { RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
2
2
  import type { JSONNode } from '@atlaskit/editor-json-transformer/types';
3
- import { type BlockInstanceId, type ResourceId, type SyncBlockAttrs, type SyncBlockData, type SyncBlockNode, type SyncBlockProduct } from '../common/types';
3
+ import { type BlockInstanceId, type ReferenceSyncBlockData, type ResourceId, type SyncBlockAttrs, type SyncBlockData, type SyncBlockNode, type SyncBlockProduct } from '../common/types';
4
4
  import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type DeleteSyncBlockResult, type SyncBlockInstance, type SyncBlockParentInfo, type SyncBlockSourceInfo, type SyncedBlockRendererProviderOptions, type UpdateReferenceSyncBlockResult, type WriteSyncBlockResult } from './types';
5
5
  export declare class SyncBlockProvider extends SyncBlockDataProvider {
6
6
  name: string;
@@ -68,7 +68,7 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
68
68
  *
69
69
  * @returns The source info
70
70
  */
71
- fetchSyncBlockSourceInfo(localId: BlockInstanceId, sourceAri: string, sourceProduct: SyncBlockProduct, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void): Promise<SyncBlockSourceInfo | undefined>;
71
+ fetchSyncBlockSourceInfo(localId: BlockInstanceId, sourceAri?: string, sourceProduct?: SyncBlockProduct, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void, hasAccess?: boolean, urlType?: 'view' | 'edit'): Promise<SyncBlockSourceInfo | undefined>;
72
72
  generateResourceId(): {
73
73
  localId: BlockInstanceId;
74
74
  resourceId: ResourceId;
@@ -90,6 +90,7 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
90
90
  */
91
91
  retrieveSyncBlockParentInfo(sourceAri: string, sourceProduct: SyncBlockProduct): SyncBlockParentInfo | undefined;
92
92
  updateReferenceData(blocks: SyncBlockAttrs[], noContent?: boolean): Promise<UpdateReferenceSyncBlockResult>;
93
+ fetchReferences(resourceId: string, isSource: boolean): Promise<ReferenceSyncBlockData>;
93
94
  }
94
95
  type UseMemoizedSyncedBlockProviderProps = {
95
96
  fetchProvider: ADFFetchProvider;
@@ -4,7 +4,7 @@ import type { EmojiProvider } from '@atlaskit/emoji';
4
4
  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
- import type { SyncBlockData, ResourceId, SyncBlockError, SyncBlockNode, SyncBlockProduct, BlockInstanceId, SyncBlockAttrs } from '../common/types';
7
+ import type { SyncBlockData, ResourceId, SyncBlockError, SyncBlockNode, SyncBlockProduct, BlockInstanceId, SyncBlockAttrs, ReferenceSyncBlockData } from '../common/types';
8
8
  /**
9
9
  * The instance of a sync block, containing its data and metadata.
10
10
  * Mainly used for representing the state of a sync block after fetching from a data provider.
@@ -24,6 +24,15 @@ export type DeleteSyncBlockResult = {
24
24
  success: boolean;
25
25
  };
26
26
  export type SyncBlockSourceInfo = {
27
+ hasAccess?: boolean;
28
+ /**
29
+ * Whether the source info is for a source synced block
30
+ */
31
+ isSource?: boolean;
32
+ onSamePage?: boolean;
33
+ productType?: SyncBlockProduct;
34
+ sourceAri: string;
35
+ subType?: string | null;
27
36
  title?: string;
28
37
  url?: string;
29
38
  };
@@ -46,6 +55,7 @@ export type UpdateReferenceSyncBlockResult = {
46
55
  export interface ADFFetchProvider {
47
56
  batchFetchData: (resourceIds: ResourceId[]) => Promise<SyncBlockInstance[]>;
48
57
  fetchData: (resourceId: ResourceId) => Promise<SyncBlockInstance>;
58
+ fetchReferences: (referenceResourceId: string) => Promise<ReferenceSyncBlockData>;
49
59
  }
50
60
  export interface ADFWriteProvider {
51
61
  createData: (data: SyncBlockData) => Promise<WriteSyncBlockResult>;
@@ -57,6 +67,7 @@ export interface ADFWriteProvider {
57
67
  */
58
68
  deleteData: (resourceId: ResourceId) => Promise<DeleteSyncBlockResult>;
59
69
  generateResourceIdForReference: (sourceId: ResourceId) => ResourceId;
70
+ parentAri?: string;
60
71
  product: SyncBlockProduct;
61
72
  updateReferenceData: (blocks: SyncBlockAttrs[], noContent?: boolean) => Promise<UpdateReferenceSyncBlockResult>;
62
73
  writeData: (data: SyncBlockData) => Promise<WriteSyncBlockResult>;
@@ -83,7 +94,7 @@ export declare abstract class SyncBlockDataProvider extends NodeDataProvider<Syn
83
94
  abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<WriteSyncBlockResult>>;
84
95
  abstract createNodeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
85
96
  abstract deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
86
- abstract fetchSyncBlockSourceInfo(localId: BlockInstanceId, sourceAri: string, sourceProduct: SyncBlockProduct, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void): Promise<SyncBlockSourceInfo | undefined>;
97
+ abstract fetchSyncBlockSourceInfo(localId: BlockInstanceId, sourceAri?: string, sourceProduct?: SyncBlockProduct, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void, hasAccess?: boolean, urlType?: 'view' | 'edit'): Promise<SyncBlockSourceInfo | undefined>;
87
98
  abstract setProviderOptions(providerOptions: SyncedBlockRendererProviderOptions): void;
88
99
  abstract getSyncedBlockRendererProviderOptions(): SyncedBlockRendererProviderOptions;
89
100
  abstract retrieveSyncBlockParentInfo(sourceAri: string, sourceProduct: SyncBlockProduct): SyncBlockParentInfo | undefined;
@@ -102,6 +113,7 @@ export declare abstract class SyncBlockDataProvider extends NodeDataProvider<Syn
102
113
  */
103
114
  abstract generateResourceIdForReference(sourceId: ResourceId): ResourceId;
104
115
  abstract updateReferenceData(blocks: SyncBlockAttrs[], noContent?: boolean): Promise<UpdateReferenceSyncBlockResult>;
116
+ abstract fetchReferences(resourceId: string, isSource: boolean): Promise<ReferenceSyncBlockData>;
105
117
  }
106
118
  export type SubscriptionCallback = (data: SyncBlockInstance) => void;
107
119
  export type TitleSubscriptionCallback = (title: string) => void;
@@ -3,7 +3,7 @@ import type { Experience } from '@atlaskit/editor-common/experiences';
3
3
  import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
4
4
  import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
5
5
  import { type ResourceId, type SyncBlockNode } from '../common/types';
6
- import type { SyncBlockInstance, SubscriptionCallback, SyncBlockDataProvider, TitleSubscriptionCallback } from '../providers/types';
6
+ import type { SyncBlockInstance, SubscriptionCallback, SyncBlockDataProvider, TitleSubscriptionCallback, SyncBlockSourceInfo } from '../providers/types';
7
7
  export declare class ReferenceSyncBlockStoreManager {
8
8
  private dataProvider?;
9
9
  private syncBlockCache;
@@ -13,6 +13,7 @@ export declare class ReferenceSyncBlockStoreManager {
13
13
  private providerFactories;
14
14
  private fireAnalyticsEvent?;
15
15
  private syncBlockFetchDataRequests;
16
+ private syncBlockSourceInfoRequestsOld;
16
17
  private syncBlockSourceInfoRequests;
17
18
  private isRefreshingSubscriptions;
18
19
  private pendingCacheDeletions;
@@ -30,7 +31,7 @@ export declare class ReferenceSyncBlockStoreManager {
30
31
  * @returns {Promise<void>}
31
32
  */
32
33
  refreshSubscriptions(): Promise<void>;
33
- private fetchSyncBlockSourceInfo;
34
+ fetchSyncBlockSourceInfo(resourceId: ResourceId): Promise<SyncBlockSourceInfo | undefined>;
34
35
  /**
35
36
  * Fetch sync block data for a given array of sync block nodes.
36
37
  * @param syncBlockNodes - The array of sync block nodes to fetch data for
@@ -1,8 +1,8 @@
1
1
  import { type SyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
2
2
  import type { Experience } from '@atlaskit/editor-common/experiences';
3
3
  import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
- import { type ResourceId, type SyncBlockAttrs } from '../common/types';
5
- import type { SyncBlockDataProvider } from '../providers/types';
4
+ import { type ResourceId, type SyncBlockAttrs, type BlockInstanceId } from '../common/types';
5
+ import type { SyncBlockDataProvider, SyncBlockSourceInfo } from '../providers/types';
6
6
  export type ConfirmationCallback = (syncBlockCount: number) => Promise<boolean>;
7
7
  type OnDelete = () => void;
8
8
  type OnDeleteCompleted = (success: boolean) => void;
@@ -75,6 +75,7 @@ export declare class SourceSyncBlockStoreManager {
75
75
  * @param destroyCallback - The callback to clear any reference stored for deletion (regardless if deletion is completed or abort)
76
76
  */
77
77
  deleteSyncBlocksWithConfirmation(syncBlockIds: SyncBlockAttrs[], onDelete: OnDelete, onDeleteCompleted: OnDeleteCompleted, destroyCallback: DestroyCallback): Promise<void>;
78
+ getSyncBlockSourceInfo(localId: BlockInstanceId): Promise<SyncBlockSourceInfo | undefined>;
78
79
  destroy(): void;
79
80
  }
80
81
  export {};
@@ -1,11 +1,15 @@
1
1
  import type { SyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
2
+ import { type BlockInstanceId, type ReferencesSourceInfo, type ResourceId } from '../common/types';
2
3
  import type { SyncBlockDataProvider } from '../providers/types';
3
4
  import { ReferenceSyncBlockStoreManager } from './referenceSyncBlockStoreManager';
4
5
  import { SourceSyncBlockStoreManager } from './sourceSyncBlockStoreManager';
5
6
  export declare class SyncBlockStoreManager {
6
7
  private referenceSyncBlockStoreManager;
7
8
  private sourceSyncBlockStoreManager;
9
+ private dataProvider?;
10
+ private fireAnalyticsEvent?;
8
11
  constructor(dataProvider?: SyncBlockDataProvider);
12
+ fetchReferencesSourceInfo(resourceId: ResourceId, blockInstanceId: BlockInstanceId, isSourceSyncBlock: boolean): Promise<ReferencesSourceInfo>;
9
13
  setFireAnalyticsEvent(fireAnalyticsEvent?: (payload: SyncBlockEventPayload) => void): void;
10
14
  get referenceManager(): ReferenceSyncBlockStoreManager;
11
15
  get sourceManager(): SourceSyncBlockStoreManager;
@@ -10,3 +10,4 @@ export declare const updateReferenceErrorPayload: (error: string) => RendererSyn
10
10
  export declare const createErrorPayload: (error: string) => SyncBlockEventPayload;
11
11
  export declare const deleteErrorPayload: (error: string) => SyncBlockEventPayload;
12
12
  export declare const updateCacheErrorPayload: (error: string) => SyncBlockEventPayload;
13
+ export declare const fetchReferencesErrorPayload: (error: string) => SyncBlockEventPayload;
package/package.json CHANGED
@@ -77,7 +77,7 @@
77
77
  }
78
78
  },
79
79
  "name": "@atlaskit/editor-synced-block-provider",
80
- "version": "3.6.0",
80
+ "version": "3.6.1",
81
81
  "description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
82
82
  "author": "Atlassian Pty Ltd",
83
83
  "license": "Apache-2.0",