@atlaskit/editor-synced-block-provider 3.2.0 → 3.2.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.
- package/CHANGELOG.md +7 -0
- package/dist/cjs/clients/block-service/ari.js +13 -16
- package/dist/cjs/clients/confluence/ari.js +7 -40
- package/dist/cjs/clients/confluence/sourceInfo.js +3 -1
- package/dist/cjs/clients/jira/ari.js +5 -2
- package/dist/cjs/index.js +2 -27
- package/dist/cjs/providers/block-service/blockServiceAPI.js +71 -28
- package/dist/cjs/providers/syncBlockProvider.js +57 -38
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +5 -8
- package/dist/es2019/clients/block-service/ari.js +15 -16
- package/dist/es2019/clients/confluence/ari.js +11 -37
- package/dist/es2019/clients/confluence/sourceInfo.js +3 -1
- package/dist/es2019/clients/jira/ari.js +9 -2
- package/dist/es2019/index.js +2 -3
- package/dist/es2019/providers/block-service/blockServiceAPI.js +75 -28
- package/dist/es2019/providers/syncBlockProvider.js +45 -25
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +5 -8
- package/dist/esm/clients/block-service/ari.js +13 -16
- package/dist/esm/clients/confluence/ari.js +6 -39
- package/dist/esm/clients/confluence/sourceInfo.js +3 -1
- package/dist/esm/clients/jira/ari.js +5 -2
- package/dist/esm/index.js +2 -3
- package/dist/esm/providers/block-service/blockServiceAPI.js +70 -27
- package/dist/esm/providers/syncBlockProvider.js +57 -38
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +4 -8
- package/dist/types/clients/block-service/ari.d.ts +14 -4
- package/dist/types/clients/confluence/ari.d.ts +8 -21
- package/dist/types/clients/jira/ari.d.ts +7 -2
- package/dist/types/index.d.ts +5 -6
- package/dist/types/providers/block-service/blockServiceAPI.d.ts +31 -6
- package/dist/types/providers/syncBlockProvider.d.ts +14 -13
- package/dist/types/providers/types.d.ts +9 -6
- package/dist/types-ts4.5/clients/block-service/ari.d.ts +14 -4
- package/dist/types-ts4.5/clients/confluence/ari.d.ts +8 -21
- package/dist/types-ts4.5/clients/jira/ari.d.ts +7 -2
- package/dist/types-ts4.5/index.d.ts +5 -6
- package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +31 -6
- package/dist/types-ts4.5/providers/syncBlockProvider.d.ts +14 -13
- package/dist/types-ts4.5/providers/types.d.ts +9 -6
- package/package.json +1 -1
- package/dist/cjs/clients/confluence/contentProperty.js +0 -284
- package/dist/cjs/providers/confluence/confluenceContentAPI.js +0 -446
- package/dist/es2019/clients/confluence/contentProperty.js +0 -288
- package/dist/es2019/providers/confluence/confluenceContentAPI.js +0 -310
- package/dist/esm/clients/confluence/contentProperty.js +0 -277
- package/dist/esm/providers/confluence/confluenceContentAPI.js +0 -440
- package/dist/types/clients/confluence/contentProperty.d.ts +0 -139
- package/dist/types/providers/confluence/confluenceContentAPI.d.ts +0 -44
- package/dist/types-ts4.5/clients/confluence/contentProperty.d.ts +0 -139
- package/dist/types-ts4.5/providers/confluence/confluenceContentAPI.d.ts +0 -44
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
import type { RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import type { JSONNode } from '@atlaskit/editor-json-transformer/types';
|
|
3
3
|
import { type BlockInstanceId, type ResourceId, type SyncBlockAttrs, type SyncBlockData, type SyncBlockNode, type SyncBlockProduct } from '../common/types';
|
|
4
|
-
import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type DeleteSyncBlockResult, type SyncBlockInstance, type SyncBlockParentInfo, type SyncBlockSourceInfo, type SyncedBlockRendererProviderOptions, type UpdateReferenceSyncBlockResult, type WriteSyncBlockResult } from '
|
|
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;
|
|
7
7
|
private fetchProvider;
|
|
8
8
|
private writeProvider;
|
|
9
|
-
private sourceId;
|
|
10
9
|
private providerOptions;
|
|
11
10
|
/**
|
|
12
11
|
* Constructor for the SyncBlockProvider
|
|
13
12
|
*
|
|
14
13
|
* @param fetchProvider
|
|
15
14
|
* @param writeProvider
|
|
16
|
-
* @param sourceId
|
|
17
15
|
* @param nestedRendererDataProviders
|
|
18
16
|
*/
|
|
19
|
-
constructor(fetchProvider: ADFFetchProvider, writeProvider: ADFWriteProvider
|
|
17
|
+
constructor(fetchProvider: ADFFetchProvider, writeProvider: ADFWriteProvider | undefined);
|
|
20
18
|
setProviderOptions(providerOptions: SyncedBlockRendererProviderOptions): void;
|
|
21
|
-
getProduct(): SyncBlockProduct | undefined;
|
|
22
19
|
/**
|
|
23
20
|
* Check if the node is supported by the provider
|
|
24
21
|
*
|
|
@@ -62,12 +59,6 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
|
62
59
|
* @returns Array of {resourceId?: string, error?: string}.
|
|
63
60
|
*/
|
|
64
61
|
deleteNodesData(resourceIds: ResourceId[]): Promise<Array<DeleteSyncBlockResult>>;
|
|
65
|
-
/**
|
|
66
|
-
* Get the source id
|
|
67
|
-
*
|
|
68
|
-
* @returns The source id
|
|
69
|
-
*/
|
|
70
|
-
getSourceId(): string;
|
|
71
62
|
/**
|
|
72
63
|
* Fetch the source info from the source id
|
|
73
64
|
*
|
|
@@ -78,7 +69,10 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
|
78
69
|
* @returns The source info
|
|
79
70
|
*/
|
|
80
71
|
fetchSyncBlockSourceInfo(localId: BlockInstanceId, sourceAri: string, sourceProduct: SyncBlockProduct, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void): Promise<SyncBlockSourceInfo | undefined>;
|
|
81
|
-
generateResourceId(
|
|
72
|
+
generateResourceId(): {
|
|
73
|
+
localId: BlockInstanceId;
|
|
74
|
+
resourceId: ResourceId;
|
|
75
|
+
};
|
|
82
76
|
generateResourceIdForReference(sourceId: ResourceId): ResourceId;
|
|
83
77
|
/**
|
|
84
78
|
* Get the synced block renderer provider options
|
|
@@ -97,4 +91,11 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
|
97
91
|
retrieveSyncBlockParentInfo(sourceAri: string, sourceProduct: SyncBlockProduct): SyncBlockParentInfo | undefined;
|
|
98
92
|
updateReferenceData(blocks: SyncBlockAttrs[], noContent?: boolean): Promise<UpdateReferenceSyncBlockResult>;
|
|
99
93
|
}
|
|
100
|
-
|
|
94
|
+
type UseMemoizedSyncedBlockProviderProps = {
|
|
95
|
+
fetchProvider: ADFFetchProvider;
|
|
96
|
+
getSSRData?: () => Record<string, SyncBlockInstance> | undefined;
|
|
97
|
+
providerOptions: SyncedBlockRendererProviderOptions;
|
|
98
|
+
writeProvider: ADFWriteProvider | undefined;
|
|
99
|
+
};
|
|
100
|
+
export declare const useMemoizedSyncedBlockProvider: ({ fetchProvider, writeProvider, providerOptions, getSSRData, }: UseMemoizedSyncedBlockProviderProps) => SyncBlockProvider;
|
|
101
|
+
export {};
|
|
@@ -55,7 +55,6 @@ export interface ADFWriteProvider {
|
|
|
55
55
|
* User should not be blocked by not_found error when deleting, so successful result should be returned for 404 error
|
|
56
56
|
*/
|
|
57
57
|
deleteData: (resourceId: ResourceId) => Promise<DeleteSyncBlockResult>;
|
|
58
|
-
generateResourceId: (sourceId: string, localId: string) => ResourceId;
|
|
59
58
|
generateResourceIdForReference: (sourceId: ResourceId) => ResourceId;
|
|
60
59
|
product: SyncBlockProduct;
|
|
61
60
|
updateReferenceData: (blocks: SyncBlockAttrs[], noContent?: boolean) => Promise<UpdateReferenceSyncBlockResult>;
|
|
@@ -82,19 +81,23 @@ export declare abstract class SyncBlockDataProvider extends NodeDataProvider<Syn
|
|
|
82
81
|
abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<WriteSyncBlockResult>>;
|
|
83
82
|
abstract createNodeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
84
83
|
abstract deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
|
|
85
|
-
abstract getSourceId(): ResourceId;
|
|
86
|
-
abstract getProduct(): SyncBlockProduct | undefined;
|
|
87
84
|
abstract fetchSyncBlockSourceInfo(localId: BlockInstanceId, sourceAri: string, sourceProduct: SyncBlockProduct, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void): Promise<SyncBlockSourceInfo | undefined>;
|
|
88
85
|
abstract setProviderOptions(providerOptions: SyncedBlockRendererProviderOptions): void;
|
|
89
86
|
abstract getSyncedBlockRendererProviderOptions(): SyncedBlockRendererProviderOptions;
|
|
90
87
|
abstract retrieveSyncBlockParentInfo(sourceAri: string, sourceProduct: SyncBlockProduct): SyncBlockParentInfo | undefined;
|
|
91
88
|
/**
|
|
92
|
-
* Generates a resource ID
|
|
89
|
+
* Generates a resource ID for source synced block.
|
|
90
|
+
* @returns The generated resource ID
|
|
91
|
+
*/
|
|
92
|
+
abstract generateResourceId(): {
|
|
93
|
+
localId: BlockInstanceId;
|
|
94
|
+
resourceId: ResourceId;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Generates a resource ID for reference synced block.
|
|
93
98
|
* @param sourceId - The source document ID (e.g., page ARI)
|
|
94
|
-
* @param localId - The local block ID (usually a UUID)
|
|
95
99
|
* @returns The generated resource ID
|
|
96
100
|
*/
|
|
97
|
-
abstract generateResourceId(sourceId: ResourceId, localId: BlockInstanceId): ResourceId;
|
|
98
101
|
abstract generateResourceIdForReference(sourceId: ResourceId): ResourceId;
|
|
99
102
|
abstract updateReferenceData(blocks: SyncBlockAttrs[], noContent?: boolean): Promise<UpdateReferenceSyncBlockResult>;
|
|
100
103
|
}
|
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
import { type SyncBlockProduct } from '../../common/types';
|
|
2
2
|
/**
|
|
3
3
|
* Generates the block ARI from the source page ARI and the source block's resource ID.
|
|
4
|
-
* @param
|
|
4
|
+
* @param cloudId - the cloudId of the block. E.G the cloudId of the confluence page, or the cloudId of the Jira instance
|
|
5
|
+
* @param parentId - the parentId of the block. E.G the pageId for a confluence page, or the issueId for a Jira work item
|
|
5
6
|
* @param resourceId - the resource ID of the block node. A randomly generated UUID
|
|
7
|
+
* @param product - the product of the block. E.G 'confluence-page', 'jira-work-item'
|
|
6
8
|
* @returns the block ARI. E.G ari:cloud:blocks:<cloudId>:synced-block/<product>/<pageId>/<resourceId>
|
|
7
9
|
*/
|
|
8
|
-
export declare const generateBlockAri: (
|
|
10
|
+
export declare const generateBlockAri: ({ cloudId, parentId, product, resourceId, }: {
|
|
11
|
+
cloudId: string;
|
|
12
|
+
parentId: string;
|
|
13
|
+
product: SyncBlockProduct;
|
|
14
|
+
resourceId: string;
|
|
15
|
+
}) => string;
|
|
9
16
|
/**
|
|
10
17
|
* Generates the block ARI from the reference synced block ARI and the resource ID
|
|
11
|
-
* @param
|
|
18
|
+
* @param cloudId - the cloudId of the block. E.G the cloudId of the confluence page, or the cloudId of the Jira instance
|
|
12
19
|
* @param resourceId - the resource ID of the reference synced block. E.G confluence-page/pageId/sourceResourceId
|
|
13
20
|
* @returns the block ARI. E.G ari:cloud:blocks:<cloudId>:synced-block/<product>/<pageId>/<resourceId>
|
|
14
21
|
*/
|
|
15
|
-
export declare const generateBlockAriFromReference: (
|
|
22
|
+
export declare const generateBlockAriFromReference: ({ cloudId, resourceId, }: {
|
|
23
|
+
cloudId: string;
|
|
24
|
+
resourceId: string;
|
|
25
|
+
}) => string;
|
|
16
26
|
/**
|
|
17
27
|
* Extracts the local ID from a block ARI.
|
|
18
28
|
* @param ari - the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
|
|
@@ -9,32 +9,19 @@ export type PAGE_TYPE = 'page' | 'blogpost';
|
|
|
9
9
|
* @param pageType - the type of the page
|
|
10
10
|
* @returns the Confluence page ARI
|
|
11
11
|
*/
|
|
12
|
-
export declare const getConfluencePageAri: (pageId
|
|
12
|
+
export declare const getConfluencePageAri: ({ pageId, cloudId, pageType, }: {
|
|
13
|
+
cloudId: string;
|
|
14
|
+
pageId: string;
|
|
15
|
+
pageType: PAGE_TYPE;
|
|
16
|
+
}) => string;
|
|
13
17
|
/**
|
|
14
18
|
* Extracts the page ID and type from the Confluence page ARI
|
|
15
19
|
* @param ari - the Confluence page ARI
|
|
16
20
|
* @returns the page ID and type
|
|
17
21
|
*/
|
|
18
|
-
export declare const getPageIdAndTypeFromConfluencePageAri: (ari:
|
|
22
|
+
export declare const getPageIdAndTypeFromConfluencePageAri: ({ ari, }: {
|
|
23
|
+
ari: string;
|
|
24
|
+
}) => {
|
|
19
25
|
id: string;
|
|
20
26
|
type: PAGE_TYPE;
|
|
21
27
|
};
|
|
22
|
-
/**
|
|
23
|
-
* Extracts the local ID from the Confluence page content property resource ID
|
|
24
|
-
* @param resourceId - the Confluence page content property resource ID
|
|
25
|
-
* @returns the local ID
|
|
26
|
-
*/
|
|
27
|
-
export declare const getLocalIdFromContentPropertyResourceId: (resourceId: string) => string;
|
|
28
|
-
/**
|
|
29
|
-
* Extracts the Confluence page ARI from the Confluence content property resource ID
|
|
30
|
-
* @param resourceId - the Confluence content property resource ID
|
|
31
|
-
* @returns the Confluence page ARI
|
|
32
|
-
*/
|
|
33
|
-
export declare const getPageAriFromContentPropertyResourceId: (resourceId: string) => string;
|
|
34
|
-
/**
|
|
35
|
-
* Generates the Confluence page content property resource ID from the source ID and local ID
|
|
36
|
-
* @param sourceId - the source ID
|
|
37
|
-
* @param localId - the local ID
|
|
38
|
-
* @returns the Confluence page content property resource ID
|
|
39
|
-
*/
|
|
40
|
-
export declare const resourceIdFromConfluencePageSourceIdAndLocalId: (sourceId: string, localId: string) => string;
|
|
@@ -4,10 +4,15 @@
|
|
|
4
4
|
* @param cloudId - the cloud ID
|
|
5
5
|
* @returns the Jira work item ARI
|
|
6
6
|
*/
|
|
7
|
-
export declare const getJiraWorkItemAri: (
|
|
7
|
+
export declare const getJiraWorkItemAri: ({ cloudId, workItemId, }: {
|
|
8
|
+
cloudId: string;
|
|
9
|
+
workItemId: string;
|
|
10
|
+
}) => string;
|
|
8
11
|
/**
|
|
9
12
|
* Extracts the Jira work item ID from the Jira work item ARI
|
|
10
13
|
* @param ari - the Jira work item ARI
|
|
11
14
|
* @returns the Jira work item ID
|
|
12
15
|
*/
|
|
13
|
-
export declare const getJiraWorkItemIdFromAri: (ari:
|
|
16
|
+
export declare const getJiraWorkItemIdFromAri: ({ ari }: {
|
|
17
|
+
ari: string;
|
|
18
|
+
}) => string;
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
export { rebaseTransaction } from './common/rebase-transaction';
|
|
2
2
|
export { SyncBlockError } from './common/types';
|
|
3
|
-
export type { SyncBlockData, SyncBlockNode, SyncBlockProduct, BlockInstanceId, } from './common/types';
|
|
3
|
+
export type { SyncBlockData, SyncBlockNode, SyncBlockProduct, BlockInstanceId, SyncBlockAttrs, } 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';
|
|
7
7
|
export { generateBlockAri, generateBlockAriFromReference, getLocalIdFromBlockResourceId, } from './clients/block-service/ari';
|
|
8
|
-
export { getConfluencePageAri,
|
|
8
|
+
export { getConfluencePageAri, getPageIdAndTypeFromConfluencePageAri, } from './clients/confluence/ari';
|
|
9
9
|
export { getJiraWorkItemAri, getJiraWorkItemIdFromAri } from './clients/jira/ari';
|
|
10
|
-
export { useMemoizedBlockServiceAPIProviders } from './providers/block-service/blockServiceAPI';
|
|
11
|
-
export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders, } from './providers/confluence/confluenceContentAPI';
|
|
10
|
+
export { useMemoizedBlockServiceAPIProviders, useMemoizedBlockServiceFetchOnlyAPIProvider, } from './providers/block-service/blockServiceAPI';
|
|
12
11
|
export { fetchConfluencePageInfo } from './clients/confluence/sourceInfo';
|
|
13
12
|
export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider, } from './providers/syncBlockProvider';
|
|
14
|
-
export type { ADFFetchProvider, ADFWriteProvider, SyncBlockDataProvider, SyncBlockInstance, MediaEmojiProviderOptions, SyncedBlockRendererProviderOptions, SyncBlockRendererProviderCreator, SyncedBlockRendererDataProviders, } from './providers/types';
|
|
13
|
+
export type { ADFFetchProvider, ADFWriteProvider, SyncBlockDataProvider, SyncBlockInstance, MediaEmojiProviderOptions, SyncedBlockRendererProviderOptions, SyncBlockRendererProviderCreator, SyncedBlockRendererDataProviders, UpdateReferenceSyncBlockResult, WriteSyncBlockResult, SyncBlockParentInfo, } from './providers/types';
|
|
15
14
|
export { type ReferenceSyncBlockStoreManager } from './store-manager/referenceSyncBlockStoreManager';
|
|
16
15
|
export { SyncBlockStoreManager, useMemoizedSyncBlockStoreManager, } from './store-manager/syncBlockStoreManager';
|
|
17
16
|
export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
|
|
18
|
-
export { createSyncBlockNode, convertSyncBlockPMNodeToSyncBlockData, convertSyncBlockJSONNodeToSyncBlockNode, convertPMNodesToSyncBlockNodes, getContentIdAndProductFromResourceId } from './utils/utils';
|
|
17
|
+
export { createSyncBlockNode, convertSyncBlockPMNodeToSyncBlockData, convertSyncBlockJSONNodeToSyncBlockNode, convertPMNodesToSyncBlockNodes, getContentIdAndProductFromResourceId, } from './utils/utils';
|
|
19
18
|
export { fetchErrorPayload } from './utils/errorHandling';
|
|
20
19
|
export { fetchReferences } from './providers/block-service/blockServiceAPI';
|
|
@@ -1,23 +1,34 @@
|
|
|
1
1
|
import { SyncBlockError, type ResourceId, type SyncBlockAttrs, type SyncBlockData, type SyncBlockProduct } from '../../common/types';
|
|
2
2
|
import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SyncBlockInstance, UpdateReferenceSyncBlockResult, WriteSyncBlockResult } from '../types';
|
|
3
3
|
export declare const fetchReferences: (documentAri: string) => Promise<SyncBlockInstance[] | SyncBlockError>;
|
|
4
|
+
interface BlockServiceADFFetchProviderProps {
|
|
5
|
+
cloudId: string;
|
|
6
|
+
}
|
|
4
7
|
/**
|
|
5
8
|
* ADFFetchProvider implementation that fetches synced block data from Block Service API
|
|
6
9
|
*/
|
|
7
10
|
declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
|
|
8
|
-
private
|
|
9
|
-
constructor(
|
|
11
|
+
private cloudId;
|
|
12
|
+
constructor({ cloudId }: BlockServiceADFFetchProviderProps);
|
|
10
13
|
fetchData(resourceId: string): Promise<SyncBlockInstance>;
|
|
11
14
|
}
|
|
15
|
+
interface BlockServiceADFWriteProviderProps {
|
|
16
|
+
cloudId: string;
|
|
17
|
+
getVersion?: () => number | undefined;
|
|
18
|
+
parentAri: string;
|
|
19
|
+
parentId: string;
|
|
20
|
+
product: SyncBlockProduct;
|
|
21
|
+
}
|
|
12
22
|
/**
|
|
13
23
|
* ADFWriteProvider implementation that writes synced block data to Block Service API
|
|
14
24
|
*/
|
|
15
25
|
declare class BlockServiceADFWriteProvider implements ADFWriteProvider {
|
|
16
|
-
private
|
|
17
|
-
private
|
|
26
|
+
private cloudId;
|
|
27
|
+
private parentAri;
|
|
28
|
+
private parentId;
|
|
18
29
|
private getVersion?;
|
|
19
30
|
product: SyncBlockProduct;
|
|
20
|
-
constructor(
|
|
31
|
+
constructor({ cloudId, parentAri, parentId, product, getVersion, }: BlockServiceADFWriteProviderProps);
|
|
21
32
|
writeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
22
33
|
createData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
23
34
|
deleteData(resourceId: string): Promise<DeleteSyncBlockResult>;
|
|
@@ -25,8 +36,22 @@ declare class BlockServiceADFWriteProvider implements ADFWriteProvider {
|
|
|
25
36
|
generateResourceId(): ResourceId;
|
|
26
37
|
updateReferenceData(blocks: SyncBlockAttrs[], noContent?: boolean): Promise<UpdateReferenceSyncBlockResult>;
|
|
27
38
|
}
|
|
28
|
-
|
|
39
|
+
interface BlockServiceAPIProvidersProps {
|
|
40
|
+
cloudId: string;
|
|
41
|
+
getVersion?: () => number | undefined;
|
|
42
|
+
parentAri: string;
|
|
43
|
+
parentId: string;
|
|
44
|
+
product: SyncBlockProduct;
|
|
45
|
+
}
|
|
46
|
+
export declare const useMemoizedBlockServiceAPIProviders: ({ cloudId, parentAri, parentId, product, getVersion, }: BlockServiceAPIProvidersProps) => {
|
|
29
47
|
fetchProvider: BlockServiceADFFetchProvider;
|
|
30
48
|
writeProvider: BlockServiceADFWriteProvider;
|
|
31
49
|
};
|
|
50
|
+
interface BlockServiceFetchOnlyAPIProviderProps {
|
|
51
|
+
cloudId: string;
|
|
52
|
+
}
|
|
53
|
+
export declare const useMemoizedBlockServiceFetchOnlyAPIProvider: ({ cloudId, }: BlockServiceFetchOnlyAPIProviderProps) => {
|
|
54
|
+
fetchProvider: BlockServiceADFFetchProvider;
|
|
55
|
+
writeProvider: undefined;
|
|
56
|
+
};
|
|
32
57
|
export {};
|
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
import type { RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import type { JSONNode } from '@atlaskit/editor-json-transformer/types';
|
|
3
3
|
import { type BlockInstanceId, type ResourceId, type SyncBlockAttrs, type SyncBlockData, type SyncBlockNode, type SyncBlockProduct } from '../common/types';
|
|
4
|
-
import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type DeleteSyncBlockResult, type SyncBlockInstance, type SyncBlockParentInfo, type SyncBlockSourceInfo, type SyncedBlockRendererProviderOptions, type UpdateReferenceSyncBlockResult, type WriteSyncBlockResult } from '
|
|
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;
|
|
7
7
|
private fetchProvider;
|
|
8
8
|
private writeProvider;
|
|
9
|
-
private sourceId;
|
|
10
9
|
private providerOptions;
|
|
11
10
|
/**
|
|
12
11
|
* Constructor for the SyncBlockProvider
|
|
13
12
|
*
|
|
14
13
|
* @param fetchProvider
|
|
15
14
|
* @param writeProvider
|
|
16
|
-
* @param sourceId
|
|
17
15
|
* @param nestedRendererDataProviders
|
|
18
16
|
*/
|
|
19
|
-
constructor(fetchProvider: ADFFetchProvider, writeProvider: ADFWriteProvider
|
|
17
|
+
constructor(fetchProvider: ADFFetchProvider, writeProvider: ADFWriteProvider | undefined);
|
|
20
18
|
setProviderOptions(providerOptions: SyncedBlockRendererProviderOptions): void;
|
|
21
|
-
getProduct(): SyncBlockProduct | undefined;
|
|
22
19
|
/**
|
|
23
20
|
* Check if the node is supported by the provider
|
|
24
21
|
*
|
|
@@ -62,12 +59,6 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
|
62
59
|
* @returns Array of {resourceId?: string, error?: string}.
|
|
63
60
|
*/
|
|
64
61
|
deleteNodesData(resourceIds: ResourceId[]): Promise<Array<DeleteSyncBlockResult>>;
|
|
65
|
-
/**
|
|
66
|
-
* Get the source id
|
|
67
|
-
*
|
|
68
|
-
* @returns The source id
|
|
69
|
-
*/
|
|
70
|
-
getSourceId(): string;
|
|
71
62
|
/**
|
|
72
63
|
* Fetch the source info from the source id
|
|
73
64
|
*
|
|
@@ -78,7 +69,10 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
|
78
69
|
* @returns The source info
|
|
79
70
|
*/
|
|
80
71
|
fetchSyncBlockSourceInfo(localId: BlockInstanceId, sourceAri: string, sourceProduct: SyncBlockProduct, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void): Promise<SyncBlockSourceInfo | undefined>;
|
|
81
|
-
generateResourceId(
|
|
72
|
+
generateResourceId(): {
|
|
73
|
+
localId: BlockInstanceId;
|
|
74
|
+
resourceId: ResourceId;
|
|
75
|
+
};
|
|
82
76
|
generateResourceIdForReference(sourceId: ResourceId): ResourceId;
|
|
83
77
|
/**
|
|
84
78
|
* Get the synced block renderer provider options
|
|
@@ -97,4 +91,11 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
|
97
91
|
retrieveSyncBlockParentInfo(sourceAri: string, sourceProduct: SyncBlockProduct): SyncBlockParentInfo | undefined;
|
|
98
92
|
updateReferenceData(blocks: SyncBlockAttrs[], noContent?: boolean): Promise<UpdateReferenceSyncBlockResult>;
|
|
99
93
|
}
|
|
100
|
-
|
|
94
|
+
type UseMemoizedSyncedBlockProviderProps = {
|
|
95
|
+
fetchProvider: ADFFetchProvider;
|
|
96
|
+
getSSRData?: () => Record<string, SyncBlockInstance> | undefined;
|
|
97
|
+
providerOptions: SyncedBlockRendererProviderOptions;
|
|
98
|
+
writeProvider: ADFWriteProvider | undefined;
|
|
99
|
+
};
|
|
100
|
+
export declare const useMemoizedSyncedBlockProvider: ({ fetchProvider, writeProvider, providerOptions, getSSRData, }: UseMemoizedSyncedBlockProviderProps) => SyncBlockProvider;
|
|
101
|
+
export {};
|
|
@@ -55,7 +55,6 @@ export interface ADFWriteProvider {
|
|
|
55
55
|
* User should not be blocked by not_found error when deleting, so successful result should be returned for 404 error
|
|
56
56
|
*/
|
|
57
57
|
deleteData: (resourceId: ResourceId) => Promise<DeleteSyncBlockResult>;
|
|
58
|
-
generateResourceId: (sourceId: string, localId: string) => ResourceId;
|
|
59
58
|
generateResourceIdForReference: (sourceId: ResourceId) => ResourceId;
|
|
60
59
|
product: SyncBlockProduct;
|
|
61
60
|
updateReferenceData: (blocks: SyncBlockAttrs[], noContent?: boolean) => Promise<UpdateReferenceSyncBlockResult>;
|
|
@@ -82,19 +81,23 @@ export declare abstract class SyncBlockDataProvider extends NodeDataProvider<Syn
|
|
|
82
81
|
abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<WriteSyncBlockResult>>;
|
|
83
82
|
abstract createNodeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
84
83
|
abstract deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
|
|
85
|
-
abstract getSourceId(): ResourceId;
|
|
86
|
-
abstract getProduct(): SyncBlockProduct | undefined;
|
|
87
84
|
abstract fetchSyncBlockSourceInfo(localId: BlockInstanceId, sourceAri: string, sourceProduct: SyncBlockProduct, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void): Promise<SyncBlockSourceInfo | undefined>;
|
|
88
85
|
abstract setProviderOptions(providerOptions: SyncedBlockRendererProviderOptions): void;
|
|
89
86
|
abstract getSyncedBlockRendererProviderOptions(): SyncedBlockRendererProviderOptions;
|
|
90
87
|
abstract retrieveSyncBlockParentInfo(sourceAri: string, sourceProduct: SyncBlockProduct): SyncBlockParentInfo | undefined;
|
|
91
88
|
/**
|
|
92
|
-
* Generates a resource ID
|
|
89
|
+
* Generates a resource ID for source synced block.
|
|
90
|
+
* @returns The generated resource ID
|
|
91
|
+
*/
|
|
92
|
+
abstract generateResourceId(): {
|
|
93
|
+
localId: BlockInstanceId;
|
|
94
|
+
resourceId: ResourceId;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Generates a resource ID for reference synced block.
|
|
93
98
|
* @param sourceId - The source document ID (e.g., page ARI)
|
|
94
|
-
* @param localId - The local block ID (usually a UUID)
|
|
95
99
|
* @returns The generated resource ID
|
|
96
100
|
*/
|
|
97
|
-
abstract generateResourceId(sourceId: ResourceId, localId: BlockInstanceId): ResourceId;
|
|
98
101
|
abstract generateResourceIdForReference(sourceId: ResourceId): ResourceId;
|
|
99
102
|
abstract updateReferenceData(blocks: SyncBlockAttrs[], noContent?: boolean): Promise<UpdateReferenceSyncBlockResult>;
|
|
100
103
|
}
|
package/package.json
CHANGED