@atlaskit/editor-synced-block-provider 2.2.3 → 2.3.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 +14 -0
- package/dist/cjs/hooks/useFetchSyncBlockData.js +5 -30
- package/dist/cjs/providers/confluence/confluenceContentAPI.js +50 -0
- package/dist/cjs/providers/in-memory/inMemory.js +7 -0
- package/dist/cjs/providers/syncBlockProvider.js +75 -19
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +319 -63
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +35 -11
- package/dist/cjs/store-manager/syncBlockStoreManager.js +27 -4
- package/dist/cjs/utils/contentProperty.js +54 -1
- package/dist/cjs/utils/mergeFetchSyncBlockDataResult.js +38 -0
- package/dist/es2019/hooks/useFetchSyncBlockData.js +6 -31
- package/dist/es2019/providers/confluence/confluenceContentAPI.js +31 -1
- package/dist/es2019/providers/in-memory/inMemory.js +7 -0
- package/dist/es2019/providers/syncBlockProvider.js +31 -3
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +172 -44
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +16 -4
- package/dist/es2019/store-manager/syncBlockStoreManager.js +21 -4
- package/dist/es2019/utils/contentProperty.js +54 -0
- package/dist/es2019/utils/mergeFetchSyncBlockDataResult.js +30 -0
- package/dist/esm/hooks/useFetchSyncBlockData.js +6 -31
- package/dist/esm/providers/confluence/confluenceContentAPI.js +51 -1
- package/dist/esm/providers/in-memory/inMemory.js +7 -0
- package/dist/esm/providers/syncBlockProvider.js +73 -17
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +320 -64
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +35 -11
- package/dist/esm/store-manager/syncBlockStoreManager.js +27 -4
- package/dist/esm/utils/contentProperty.js +53 -0
- package/dist/esm/utils/mergeFetchSyncBlockDataResult.js +31 -0
- package/dist/types/common/schema.d.ts +1 -1
- package/dist/types/providers/confluence/confluenceContentAPI.d.ts +2 -1
- package/dist/types/providers/syncBlockProvider.d.ts +3 -2
- package/dist/types/providers/types.d.ts +8 -0
- package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +24 -8
- package/dist/types/store-manager/sourceSyncBlockStoreManager.d.ts +1 -1
- package/dist/types/store-manager/syncBlockStoreManager.d.ts +12 -4
- package/dist/types/utils/contentProperty.d.ts +35 -0
- package/dist/types/utils/mergeFetchSyncBlockDataResult.d.ts +12 -0
- package/dist/types-ts4.5/common/schema.d.ts +1 -1
- package/dist/types-ts4.5/providers/confluence/confluenceContentAPI.d.ts +2 -1
- package/dist/types-ts4.5/providers/syncBlockProvider.d.ts +3 -2
- package/dist/types-ts4.5/providers/types.d.ts +8 -0
- package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +24 -8
- package/dist/types-ts4.5/store-manager/sourceSyncBlockStoreManager.d.ts +1 -1
- package/dist/types-ts4.5/store-manager/syncBlockStoreManager.d.ts +12 -4
- package/dist/types-ts4.5/utils/contentProperty.d.ts +35 -0
- package/dist/types-ts4.5/utils/mergeFetchSyncBlockDataResult.d.ts +12 -0
- package/package.json +1 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
/**
|
|
5
|
+
* Merges two FetchSyncBlockDataResult objects,
|
|
6
|
+
* currently it only preserves the sourceURL from the old result,
|
|
7
|
+
* but this can be extended in the future to preserve other fields and resolve conflicts as needed.
|
|
8
|
+
* e.g. compare timestamps or version numbers to determine which data is more recent.
|
|
9
|
+
*
|
|
10
|
+
* @param oldResult - The existing FetchSyncBlockDataResult object.
|
|
11
|
+
* @param newResult - The new FetchSyncBlockDataResult object to merge.
|
|
12
|
+
* @returns A merged FetchSyncBlockDataResult object.
|
|
13
|
+
*/
|
|
14
|
+
export var resolveFetchSyncBlockDataResult = function resolveFetchSyncBlockDataResult(oldResult, newResult) {
|
|
15
|
+
var _newResult$data, _oldResult$data;
|
|
16
|
+
// if the old result has no data, we simple return the new result
|
|
17
|
+
if (!oldResult.data) {
|
|
18
|
+
return newResult;
|
|
19
|
+
} else if (!newResult.data) {
|
|
20
|
+
// if the new result has no data, we simply return the old result
|
|
21
|
+
// TODO: EDITOR-2533 - handle this case based on the error type and whether we should keep old data or not
|
|
22
|
+
return oldResult;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// otherwise, we merge the two results, preserving the sourceURL from the old result if it exists
|
|
26
|
+
return _objectSpread(_objectSpread({}, newResult), {}, {
|
|
27
|
+
data: _objectSpread(_objectSpread({}, newResult.data), {}, {
|
|
28
|
+
sourceURL: ((_newResult$data = newResult.data) === null || _newResult$data === void 0 ? void 0 : _newResult$data.sourceURL) || ((_oldResult$data = oldResult.data) === null || _oldResult$data === void 0 ? void 0 : _oldResult$data.sourceURL) || undefined
|
|
29
|
+
})
|
|
30
|
+
});
|
|
31
|
+
};
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Otherwise we could import defaultSchemaConfig from '@atlaskit/adf-schema/schema-default';
|
|
4
4
|
* @returns
|
|
5
5
|
*/
|
|
6
|
-
export declare const getDefaultSyncBlockSchema: () => import("prosemirror-model").Schema<"doc" | "paragraph" | "text" | "bulletList" | "orderedList" | "listItem" | "heading" | "blockquote" | "codeBlock" | "panel" | "rule" | "expand" | "nestedExpand" | "table" | "tableCell" | "tableHeader" | "tableRow" | "date" | "
|
|
6
|
+
export declare const getDefaultSyncBlockSchema: () => import("prosemirror-model").Schema<"status" | "doc" | "paragraph" | "text" | "bulletList" | "orderedList" | "listItem" | "heading" | "blockquote" | "codeBlock" | "panel" | "rule" | "expand" | "nestedExpand" | "table" | "tableCell" | "tableHeader" | "tableRow" | "date" | "layoutSection" | "layoutColumn" | "unsupportedBlock" | "unsupportedInline", "link" | "em" | "strong" | "strike" | "subsup" | "underline" | "code" | "textColor" | "backgroundColor" | "alignment" | "indentation" | "border" | "unsupportedMark" | "unsupportedNodeAttribute" | "typeAheadQuery">;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type SyncBlockData } from '../../common/types';
|
|
2
|
-
import type { ADFFetchProvider, ADFWriteProvider, FetchSyncBlockDataResult } from '../types';
|
|
2
|
+
import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, FetchSyncBlockDataResult } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* Configuration for Content API providers
|
|
5
5
|
*/
|
|
@@ -23,6 +23,7 @@ declare class ConfluenceADFWriteProvider implements ADFWriteProvider {
|
|
|
23
23
|
constructor(config: ContentAPIConfig);
|
|
24
24
|
private createNewContentProperty;
|
|
25
25
|
writeData(data: SyncBlockData): Promise<string>;
|
|
26
|
+
deleteData(resourceId: string): Promise<DeleteSyncBlockResult>;
|
|
26
27
|
}
|
|
27
28
|
/**
|
|
28
29
|
* Convenience function to create providers with default content property key
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { JSONNode } from '@atlaskit/editor-json-transformer/types';
|
|
2
|
-
import type
|
|
3
|
-
import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type FetchSyncBlockDataResult } from '../providers/types';
|
|
2
|
+
import { type SyncBlockData, type SyncBlockNode } from '../common/types';
|
|
3
|
+
import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type DeleteSyncBlockResult, type FetchSyncBlockDataResult } from '../providers/types';
|
|
4
4
|
export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
5
5
|
name: string;
|
|
6
6
|
private fetchProvider;
|
|
@@ -18,6 +18,7 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
|
18
18
|
* @returns the resource ids of the nodes that were written
|
|
19
19
|
*/
|
|
20
20
|
writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<string | undefined>>;
|
|
21
|
+
deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
|
|
21
22
|
getSourceId(): string;
|
|
22
23
|
retrieveSyncBlockSourceUrl(node: SyncBlockNode): Promise<string | undefined>;
|
|
23
24
|
}
|
|
@@ -5,14 +5,22 @@ export type FetchSyncBlockDataResult = {
|
|
|
5
5
|
error?: SyncBlockError;
|
|
6
6
|
resourceId?: string;
|
|
7
7
|
};
|
|
8
|
+
export type DeleteSyncBlockResult = {
|
|
9
|
+
error?: string;
|
|
10
|
+
resourceId: string;
|
|
11
|
+
success: boolean;
|
|
12
|
+
};
|
|
8
13
|
export interface ADFFetchProvider {
|
|
9
14
|
fetchData: (resourceId: ResourceId) => Promise<FetchSyncBlockDataResult>;
|
|
10
15
|
}
|
|
11
16
|
export interface ADFWriteProvider {
|
|
17
|
+
deleteData: (resourceId: string) => Promise<DeleteSyncBlockResult>;
|
|
12
18
|
writeData: (data: SyncBlockData) => Promise<string>;
|
|
13
19
|
}
|
|
14
20
|
export declare abstract class SyncBlockDataProvider extends NodeDataProvider<SyncBlockNode, FetchSyncBlockDataResult> {
|
|
15
21
|
abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<ResourceId | undefined>>;
|
|
22
|
+
abstract deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
|
|
16
23
|
abstract getSourceId(): ResourceId;
|
|
17
24
|
abstract retrieveSyncBlockSourceUrl(node: SyncBlockNode): Promise<string | undefined>;
|
|
18
25
|
}
|
|
26
|
+
export type SubscriptionCallback = (data: FetchSyncBlockDataResult) => void;
|
|
@@ -1,23 +1,39 @@
|
|
|
1
1
|
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
2
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
import type { ResourceId, SyncBlockNode } from '../common/types';
|
|
4
|
+
import type { FetchSyncBlockDataResult, SubscriptionCallback, SyncBlockDataProvider } from '../providers/types';
|
|
4
5
|
export declare class ReferenceSyncBlockStoreManager {
|
|
5
6
|
private dataProvider?;
|
|
6
7
|
private syncBlockCache;
|
|
8
|
+
private subscriptions;
|
|
7
9
|
private syncBlockURLRequests;
|
|
10
|
+
private editorView?;
|
|
11
|
+
private isInitialized;
|
|
12
|
+
private isRefreshingSubscriptions;
|
|
8
13
|
constructor(dataProvider?: SyncBlockDataProvider);
|
|
14
|
+
init(editorView: EditorView): Promise<void>;
|
|
9
15
|
/**
|
|
10
|
-
*
|
|
11
|
-
* @
|
|
12
|
-
* @param resourceId - The resource ID of the sync block to get the source URL for
|
|
13
|
-
* Fetches source URl for a sync block and updates sync block data with the source URL asynchronously.
|
|
16
|
+
* Refreshes the subscriptions for all sync blocks.
|
|
17
|
+
* @returns {Promise<void>}
|
|
14
18
|
*/
|
|
19
|
+
refreshSubscriptions(): Promise<void>;
|
|
15
20
|
private fetchSyncBlockSourceURL;
|
|
21
|
+
/**
|
|
22
|
+
* Fetch sync block data for a given sync block node.
|
|
23
|
+
* @param syncBlockNode - The sync block node to fetch data for
|
|
24
|
+
* @returns The fetched sync block data result
|
|
25
|
+
*/
|
|
16
26
|
fetchSyncBlockData(syncBlockNode: PMNode): Promise<FetchSyncBlockDataResult>;
|
|
27
|
+
fetchSyncBlocksData(syncBlockNodes: SyncBlockNode[]): Promise<FetchSyncBlockDataResult[]>;
|
|
28
|
+
private updateCache;
|
|
29
|
+
private getFromCache;
|
|
30
|
+
private deleteFromCache;
|
|
31
|
+
subscribe(node: PMNode, callback: SubscriptionCallback): () => void;
|
|
17
32
|
/**
|
|
18
33
|
* Get the URL for a sync block.
|
|
19
|
-
* @param
|
|
34
|
+
* @param resourceId - The resource ID of the sync block
|
|
20
35
|
* @returns
|
|
21
36
|
*/
|
|
22
|
-
getSyncBlockURL(
|
|
37
|
+
getSyncBlockURL(resourceId: ResourceId): string | undefined;
|
|
38
|
+
destroy(): void;
|
|
23
39
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import type { SyncBlockAttrs, SyncBlockNode } from '../common/types';
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import type { EditorView } from '@atlaskit/editor-prosemirror/dist/types/view';
|
|
2
2
|
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
import type {
|
|
5
|
-
import type { FetchSyncBlockDataResult, SyncBlockDataProvider } from '../providers/types';
|
|
4
|
+
import type { ResourceId, SyncBlockAttrs, SyncBlockNode } from '../common/types';
|
|
5
|
+
import type { FetchSyncBlockDataResult, SubscriptionCallback, SyncBlockDataProvider } from '../providers/types';
|
|
6
6
|
import { type ConfirmationCallback } from './sourceSyncBlockStoreManager';
|
|
7
7
|
export declare class SyncBlockStoreManager {
|
|
8
8
|
private referenceSyncBlockStoreManager;
|
|
9
9
|
private sourceSyncBlockStoreManager;
|
|
10
10
|
constructor(dataProvider?: SyncBlockDataProvider);
|
|
11
|
+
/**
|
|
12
|
+
* Fetch sync block data for a given sync block node.
|
|
13
|
+
* @param syncBlockNode - The sync block node to fetch data for
|
|
14
|
+
* @returns The fetched sync block data result
|
|
15
|
+
*/
|
|
11
16
|
fetchSyncBlockData(syncBlockNode: PMNode): Promise<FetchSyncBlockDataResult | undefined>;
|
|
12
17
|
/**
|
|
13
18
|
* Add/update a sync block node to/from the local cache
|
|
@@ -22,15 +27,18 @@ export declare class SyncBlockStoreManager {
|
|
|
22
27
|
flushBodiedSyncBlocks(): Promise<boolean>;
|
|
23
28
|
/**
|
|
24
29
|
* Get the URL for a sync block.
|
|
25
|
-
* @param
|
|
30
|
+
* @param resourceId - The resource ID of the sync block to get the URL for
|
|
26
31
|
* @returns
|
|
27
32
|
*/
|
|
28
|
-
getSyncBlockURL(
|
|
33
|
+
getSyncBlockURL(resourceId: ResourceId): string | undefined;
|
|
29
34
|
setEditorView(editorView: EditorView | undefined): void;
|
|
30
35
|
isSourceBlock(node: PMNode): boolean;
|
|
31
36
|
registerConfirmationCallback(callback: ConfirmationCallback): () => void;
|
|
32
37
|
requireConfirmationBeforeDelete(): boolean;
|
|
33
38
|
createSyncBlockNode(): SyncBlockNode;
|
|
39
|
+
subscribeToSyncBlockData(node: PMNode, callback: SubscriptionCallback): () => void;
|
|
40
|
+
refreshSubscriptions(): void;
|
|
34
41
|
deleteSyncBlocksWithConfirmation(tr: Transaction, syncBlockIds: SyncBlockAttrs[]): Promise<void>;
|
|
35
42
|
rebaseTransaction(incomingTr: Transaction, state: EditorState): void;
|
|
43
|
+
destroy(): void;
|
|
36
44
|
}
|
|
@@ -22,6 +22,12 @@ type UpdateContentPropertyOptions = {
|
|
|
22
22
|
signal?: AbortSignal;
|
|
23
23
|
value: SyncBlockData;
|
|
24
24
|
};
|
|
25
|
+
type DeleteContentPropertyOptions = {
|
|
26
|
+
cloudId: string;
|
|
27
|
+
key: string;
|
|
28
|
+
pageId: string;
|
|
29
|
+
pageType: PAGE_TYPE;
|
|
30
|
+
};
|
|
25
31
|
export type GetContentPropertyResult = {
|
|
26
32
|
data: {
|
|
27
33
|
confluence: {
|
|
@@ -98,7 +104,36 @@ export type CreateBlogPostContentPropertyResult = {
|
|
|
98
104
|
};
|
|
99
105
|
};
|
|
100
106
|
};
|
|
107
|
+
export type DeletePageContentPropertyResult = {
|
|
108
|
+
data: {
|
|
109
|
+
confluence: {
|
|
110
|
+
deletePageProperty: {
|
|
111
|
+
errors: [
|
|
112
|
+
{
|
|
113
|
+
message: string;
|
|
114
|
+
}
|
|
115
|
+
];
|
|
116
|
+
success: boolean;
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
export type DeleteBlogPostPropertyResult = {
|
|
122
|
+
data: {
|
|
123
|
+
confluence: {
|
|
124
|
+
deleteBlogPostProperty: {
|
|
125
|
+
errors: [
|
|
126
|
+
{
|
|
127
|
+
message: string;
|
|
128
|
+
}
|
|
129
|
+
];
|
|
130
|
+
success: boolean;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
};
|
|
101
135
|
export declare const getContentProperty: <T extends GetContentPropertyResult | GetBlogPostContentPropertyResult>({ pageId, key, cloudId, pageType, }: GetContentPropertyOptions) => Promise<T>;
|
|
102
136
|
export declare const updateContentProperty: <T extends UpdateContentPropertyResult | UpdateBlogPostContentPropertyResult>({ pageId, key, value, cloudId, pageType, }: UpdateContentPropertyOptions) => Promise<T>;
|
|
103
137
|
export declare const createContentProperty: <T extends CreateContentPropertyResult | CreateBlogPostContentPropertyResult>({ pageId, key, value, cloudId, pageType, }: CreateContentPropertyOptions) => Promise<T>;
|
|
138
|
+
export declare const deleteContentProperty: <T extends DeletePageContentPropertyResult | DeleteBlogPostPropertyResult>({ pageId, cloudId, pageType, key, }: DeleteContentPropertyOptions) => Promise<T>;
|
|
104
139
|
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FetchSyncBlockDataResult } from '../providers/types';
|
|
2
|
+
/**
|
|
3
|
+
* Merges two FetchSyncBlockDataResult objects,
|
|
4
|
+
* currently it only preserves the sourceURL from the old result,
|
|
5
|
+
* but this can be extended in the future to preserve other fields and resolve conflicts as needed.
|
|
6
|
+
* e.g. compare timestamps or version numbers to determine which data is more recent.
|
|
7
|
+
*
|
|
8
|
+
* @param oldResult - The existing FetchSyncBlockDataResult object.
|
|
9
|
+
* @param newResult - The new FetchSyncBlockDataResult object to merge.
|
|
10
|
+
* @returns A merged FetchSyncBlockDataResult object.
|
|
11
|
+
*/
|
|
12
|
+
export declare const resolveFetchSyncBlockDataResult: (oldResult: FetchSyncBlockDataResult, newResult: FetchSyncBlockDataResult) => FetchSyncBlockDataResult;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Otherwise we could import defaultSchemaConfig from '@atlaskit/adf-schema/schema-default';
|
|
4
4
|
* @returns
|
|
5
5
|
*/
|
|
6
|
-
export declare const getDefaultSyncBlockSchema: () => import("prosemirror-model").Schema<"doc" | "paragraph" | "text" | "bulletList" | "orderedList" | "listItem" | "heading" | "blockquote" | "codeBlock" | "panel" | "rule" | "expand" | "nestedExpand" | "table" | "tableCell" | "tableHeader" | "tableRow" | "date" | "
|
|
6
|
+
export declare const getDefaultSyncBlockSchema: () => import("prosemirror-model").Schema<"status" | "doc" | "paragraph" | "text" | "bulletList" | "orderedList" | "listItem" | "heading" | "blockquote" | "codeBlock" | "panel" | "rule" | "expand" | "nestedExpand" | "table" | "tableCell" | "tableHeader" | "tableRow" | "date" | "layoutSection" | "layoutColumn" | "unsupportedBlock" | "unsupportedInline", "link" | "em" | "strong" | "strike" | "subsup" | "underline" | "code" | "textColor" | "backgroundColor" | "alignment" | "indentation" | "border" | "unsupportedMark" | "unsupportedNodeAttribute" | "typeAheadQuery">;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type SyncBlockData } from '../../common/types';
|
|
2
|
-
import type { ADFFetchProvider, ADFWriteProvider, FetchSyncBlockDataResult } from '../types';
|
|
2
|
+
import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, FetchSyncBlockDataResult } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* Configuration for Content API providers
|
|
5
5
|
*/
|
|
@@ -23,6 +23,7 @@ declare class ConfluenceADFWriteProvider implements ADFWriteProvider {
|
|
|
23
23
|
constructor(config: ContentAPIConfig);
|
|
24
24
|
private createNewContentProperty;
|
|
25
25
|
writeData(data: SyncBlockData): Promise<string>;
|
|
26
|
+
deleteData(resourceId: string): Promise<DeleteSyncBlockResult>;
|
|
26
27
|
}
|
|
27
28
|
/**
|
|
28
29
|
* Convenience function to create providers with default content property key
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { JSONNode } from '@atlaskit/editor-json-transformer/types';
|
|
2
|
-
import type
|
|
3
|
-
import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type FetchSyncBlockDataResult } from '../providers/types';
|
|
2
|
+
import { type SyncBlockData, type SyncBlockNode } from '../common/types';
|
|
3
|
+
import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type DeleteSyncBlockResult, type FetchSyncBlockDataResult } from '../providers/types';
|
|
4
4
|
export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
5
5
|
name: string;
|
|
6
6
|
private fetchProvider;
|
|
@@ -18,6 +18,7 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
|
18
18
|
* @returns the resource ids of the nodes that were written
|
|
19
19
|
*/
|
|
20
20
|
writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<string | undefined>>;
|
|
21
|
+
deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
|
|
21
22
|
getSourceId(): string;
|
|
22
23
|
retrieveSyncBlockSourceUrl(node: SyncBlockNode): Promise<string | undefined>;
|
|
23
24
|
}
|
|
@@ -5,14 +5,22 @@ export type FetchSyncBlockDataResult = {
|
|
|
5
5
|
error?: SyncBlockError;
|
|
6
6
|
resourceId?: string;
|
|
7
7
|
};
|
|
8
|
+
export type DeleteSyncBlockResult = {
|
|
9
|
+
error?: string;
|
|
10
|
+
resourceId: string;
|
|
11
|
+
success: boolean;
|
|
12
|
+
};
|
|
8
13
|
export interface ADFFetchProvider {
|
|
9
14
|
fetchData: (resourceId: ResourceId) => Promise<FetchSyncBlockDataResult>;
|
|
10
15
|
}
|
|
11
16
|
export interface ADFWriteProvider {
|
|
17
|
+
deleteData: (resourceId: string) => Promise<DeleteSyncBlockResult>;
|
|
12
18
|
writeData: (data: SyncBlockData) => Promise<string>;
|
|
13
19
|
}
|
|
14
20
|
export declare abstract class SyncBlockDataProvider extends NodeDataProvider<SyncBlockNode, FetchSyncBlockDataResult> {
|
|
15
21
|
abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<ResourceId | undefined>>;
|
|
22
|
+
abstract deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
|
|
16
23
|
abstract getSourceId(): ResourceId;
|
|
17
24
|
abstract retrieveSyncBlockSourceUrl(node: SyncBlockNode): Promise<string | undefined>;
|
|
18
25
|
}
|
|
26
|
+
export type SubscriptionCallback = (data: FetchSyncBlockDataResult) => void;
|
|
@@ -1,23 +1,39 @@
|
|
|
1
1
|
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
2
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
import type { ResourceId, SyncBlockNode } from '../common/types';
|
|
4
|
+
import type { FetchSyncBlockDataResult, SubscriptionCallback, SyncBlockDataProvider } from '../providers/types';
|
|
4
5
|
export declare class ReferenceSyncBlockStoreManager {
|
|
5
6
|
private dataProvider?;
|
|
6
7
|
private syncBlockCache;
|
|
8
|
+
private subscriptions;
|
|
7
9
|
private syncBlockURLRequests;
|
|
10
|
+
private editorView?;
|
|
11
|
+
private isInitialized;
|
|
12
|
+
private isRefreshingSubscriptions;
|
|
8
13
|
constructor(dataProvider?: SyncBlockDataProvider);
|
|
14
|
+
init(editorView: EditorView): Promise<void>;
|
|
9
15
|
/**
|
|
10
|
-
*
|
|
11
|
-
* @
|
|
12
|
-
* @param resourceId - The resource ID of the sync block to get the source URL for
|
|
13
|
-
* Fetches source URl for a sync block and updates sync block data with the source URL asynchronously.
|
|
16
|
+
* Refreshes the subscriptions for all sync blocks.
|
|
17
|
+
* @returns {Promise<void>}
|
|
14
18
|
*/
|
|
19
|
+
refreshSubscriptions(): Promise<void>;
|
|
15
20
|
private fetchSyncBlockSourceURL;
|
|
21
|
+
/**
|
|
22
|
+
* Fetch sync block data for a given sync block node.
|
|
23
|
+
* @param syncBlockNode - The sync block node to fetch data for
|
|
24
|
+
* @returns The fetched sync block data result
|
|
25
|
+
*/
|
|
16
26
|
fetchSyncBlockData(syncBlockNode: PMNode): Promise<FetchSyncBlockDataResult>;
|
|
27
|
+
fetchSyncBlocksData(syncBlockNodes: SyncBlockNode[]): Promise<FetchSyncBlockDataResult[]>;
|
|
28
|
+
private updateCache;
|
|
29
|
+
private getFromCache;
|
|
30
|
+
private deleteFromCache;
|
|
31
|
+
subscribe(node: PMNode, callback: SubscriptionCallback): () => void;
|
|
17
32
|
/**
|
|
18
33
|
* Get the URL for a sync block.
|
|
19
|
-
* @param
|
|
34
|
+
* @param resourceId - The resource ID of the sync block
|
|
20
35
|
* @returns
|
|
21
36
|
*/
|
|
22
|
-
getSyncBlockURL(
|
|
37
|
+
getSyncBlockURL(resourceId: ResourceId): string | undefined;
|
|
38
|
+
destroy(): void;
|
|
23
39
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import type { SyncBlockAttrs, SyncBlockNode } from '../common/types';
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import type { EditorView } from '@atlaskit/editor-prosemirror/dist/types/view';
|
|
2
2
|
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
import type {
|
|
5
|
-
import type { FetchSyncBlockDataResult, SyncBlockDataProvider } from '../providers/types';
|
|
4
|
+
import type { ResourceId, SyncBlockAttrs, SyncBlockNode } from '../common/types';
|
|
5
|
+
import type { FetchSyncBlockDataResult, SubscriptionCallback, SyncBlockDataProvider } from '../providers/types';
|
|
6
6
|
import { type ConfirmationCallback } from './sourceSyncBlockStoreManager';
|
|
7
7
|
export declare class SyncBlockStoreManager {
|
|
8
8
|
private referenceSyncBlockStoreManager;
|
|
9
9
|
private sourceSyncBlockStoreManager;
|
|
10
10
|
constructor(dataProvider?: SyncBlockDataProvider);
|
|
11
|
+
/**
|
|
12
|
+
* Fetch sync block data for a given sync block node.
|
|
13
|
+
* @param syncBlockNode - The sync block node to fetch data for
|
|
14
|
+
* @returns The fetched sync block data result
|
|
15
|
+
*/
|
|
11
16
|
fetchSyncBlockData(syncBlockNode: PMNode): Promise<FetchSyncBlockDataResult | undefined>;
|
|
12
17
|
/**
|
|
13
18
|
* Add/update a sync block node to/from the local cache
|
|
@@ -22,15 +27,18 @@ export declare class SyncBlockStoreManager {
|
|
|
22
27
|
flushBodiedSyncBlocks(): Promise<boolean>;
|
|
23
28
|
/**
|
|
24
29
|
* Get the URL for a sync block.
|
|
25
|
-
* @param
|
|
30
|
+
* @param resourceId - The resource ID of the sync block to get the URL for
|
|
26
31
|
* @returns
|
|
27
32
|
*/
|
|
28
|
-
getSyncBlockURL(
|
|
33
|
+
getSyncBlockURL(resourceId: ResourceId): string | undefined;
|
|
29
34
|
setEditorView(editorView: EditorView | undefined): void;
|
|
30
35
|
isSourceBlock(node: PMNode): boolean;
|
|
31
36
|
registerConfirmationCallback(callback: ConfirmationCallback): () => void;
|
|
32
37
|
requireConfirmationBeforeDelete(): boolean;
|
|
33
38
|
createSyncBlockNode(): SyncBlockNode;
|
|
39
|
+
subscribeToSyncBlockData(node: PMNode, callback: SubscriptionCallback): () => void;
|
|
40
|
+
refreshSubscriptions(): void;
|
|
34
41
|
deleteSyncBlocksWithConfirmation(tr: Transaction, syncBlockIds: SyncBlockAttrs[]): Promise<void>;
|
|
35
42
|
rebaseTransaction(incomingTr: Transaction, state: EditorState): void;
|
|
43
|
+
destroy(): void;
|
|
36
44
|
}
|
|
@@ -22,6 +22,12 @@ type UpdateContentPropertyOptions = {
|
|
|
22
22
|
signal?: AbortSignal;
|
|
23
23
|
value: SyncBlockData;
|
|
24
24
|
};
|
|
25
|
+
type DeleteContentPropertyOptions = {
|
|
26
|
+
cloudId: string;
|
|
27
|
+
key: string;
|
|
28
|
+
pageId: string;
|
|
29
|
+
pageType: PAGE_TYPE;
|
|
30
|
+
};
|
|
25
31
|
export type GetContentPropertyResult = {
|
|
26
32
|
data: {
|
|
27
33
|
confluence: {
|
|
@@ -98,7 +104,36 @@ export type CreateBlogPostContentPropertyResult = {
|
|
|
98
104
|
};
|
|
99
105
|
};
|
|
100
106
|
};
|
|
107
|
+
export type DeletePageContentPropertyResult = {
|
|
108
|
+
data: {
|
|
109
|
+
confluence: {
|
|
110
|
+
deletePageProperty: {
|
|
111
|
+
errors: [
|
|
112
|
+
{
|
|
113
|
+
message: string;
|
|
114
|
+
}
|
|
115
|
+
];
|
|
116
|
+
success: boolean;
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
export type DeleteBlogPostPropertyResult = {
|
|
122
|
+
data: {
|
|
123
|
+
confluence: {
|
|
124
|
+
deleteBlogPostProperty: {
|
|
125
|
+
errors: [
|
|
126
|
+
{
|
|
127
|
+
message: string;
|
|
128
|
+
}
|
|
129
|
+
];
|
|
130
|
+
success: boolean;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
};
|
|
101
135
|
export declare const getContentProperty: <T extends GetContentPropertyResult | GetBlogPostContentPropertyResult>({ pageId, key, cloudId, pageType, }: GetContentPropertyOptions) => Promise<T>;
|
|
102
136
|
export declare const updateContentProperty: <T extends UpdateContentPropertyResult | UpdateBlogPostContentPropertyResult>({ pageId, key, value, cloudId, pageType, }: UpdateContentPropertyOptions) => Promise<T>;
|
|
103
137
|
export declare const createContentProperty: <T extends CreateContentPropertyResult | CreateBlogPostContentPropertyResult>({ pageId, key, value, cloudId, pageType, }: CreateContentPropertyOptions) => Promise<T>;
|
|
138
|
+
export declare const deleteContentProperty: <T extends DeletePageContentPropertyResult | DeleteBlogPostPropertyResult>({ pageId, cloudId, pageType, key, }: DeleteContentPropertyOptions) => Promise<T>;
|
|
104
139
|
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FetchSyncBlockDataResult } from '../providers/types';
|
|
2
|
+
/**
|
|
3
|
+
* Merges two FetchSyncBlockDataResult objects,
|
|
4
|
+
* currently it only preserves the sourceURL from the old result,
|
|
5
|
+
* but this can be extended in the future to preserve other fields and resolve conflicts as needed.
|
|
6
|
+
* e.g. compare timestamps or version numbers to determine which data is more recent.
|
|
7
|
+
*
|
|
8
|
+
* @param oldResult - The existing FetchSyncBlockDataResult object.
|
|
9
|
+
* @param newResult - The new FetchSyncBlockDataResult object to merge.
|
|
10
|
+
* @returns A merged FetchSyncBlockDataResult object.
|
|
11
|
+
*/
|
|
12
|
+
export declare const resolveFetchSyncBlockDataResult: (oldResult: FetchSyncBlockDataResult, newResult: FetchSyncBlockDataResult) => FetchSyncBlockDataResult;
|
package/package.json
CHANGED