@atlaskit/editor-synced-block-provider 2.7.4 → 2.9.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.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/index.js +37 -0
- package/dist/cjs/providers/block-service/blockServiceAPI.js +238 -0
- package/dist/cjs/providers/confluence/confluenceContentAPI.js +5 -0
- package/dist/cjs/providers/syncBlockProvider.js +5 -0
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +2 -5
- package/dist/cjs/utils/ari.js +32 -4
- package/dist/cjs/utils/blockService.js +168 -0
- package/dist/es2019/index.js +2 -1
- package/dist/es2019/providers/block-service/blockServiceAPI.js +148 -0
- package/dist/es2019/providers/confluence/confluenceContentAPI.js +4 -1
- package/dist/es2019/providers/syncBlockProvider.js +3 -0
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +2 -5
- package/dist/es2019/utils/ari.js +31 -1
- package/dist/es2019/utils/blockService.js +71 -0
- package/dist/esm/index.js +2 -1
- package/dist/esm/providers/block-service/blockServiceAPI.js +231 -0
- package/dist/esm/providers/confluence/confluenceContentAPI.js +6 -1
- package/dist/esm/providers/syncBlockProvider.js +5 -0
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +2 -5
- package/dist/esm/utils/ari.js +31 -3
- package/dist/esm/utils/blockService.js +161 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/providers/block-service/blockServiceAPI.d.ts +21 -0
- package/dist/types/providers/confluence/confluenceContentAPI.d.ts +1 -0
- package/dist/types/providers/syncBlockProvider.d.ts +1 -0
- package/dist/types/providers/types.d.ts +8 -0
- package/dist/types/utils/ari.d.ts +15 -1
- package/dist/types/utils/blockService.d.ts +39 -0
- package/dist/types-ts4.5/index.d.ts +2 -1
- package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +21 -0
- package/dist/types-ts4.5/providers/confluence/confluenceContentAPI.d.ts +1 -0
- package/dist/types-ts4.5/providers/syncBlockProvider.d.ts +1 -0
- package/dist/types-ts4.5/providers/types.d.ts +8 -0
- package/dist/types-ts4.5/utils/ari.d.ts +15 -1
- package/dist/types-ts4.5/utils/blockService.d.ts +39 -0
- package/package.json +8 -2
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
|
+
import _wrapNativeSuper from "@babel/runtime/helpers/wrapNativeSuper";
|
|
8
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
9
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
10
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
11
|
+
var COMMON_HEADERS = {
|
|
12
|
+
'Content-Type': 'application/json',
|
|
13
|
+
Accept: 'application/json'
|
|
14
|
+
};
|
|
15
|
+
var BLOCK_SERVICE_API_URL = '/gateway/api/blocks/v1';
|
|
16
|
+
export var BlockError = /*#__PURE__*/function (_Error) {
|
|
17
|
+
function BlockError(status) {
|
|
18
|
+
var _this;
|
|
19
|
+
_classCallCheck(this, BlockError);
|
|
20
|
+
_this = _callSuper(this, BlockError, ["Block error"]);
|
|
21
|
+
_this.status = status;
|
|
22
|
+
return _this;
|
|
23
|
+
}
|
|
24
|
+
_inherits(BlockError, _Error);
|
|
25
|
+
return _createClass(BlockError);
|
|
26
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
27
|
+
export var getSyncedBlockContent = /*#__PURE__*/function () {
|
|
28
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
29
|
+
var blockAri, response;
|
|
30
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
31
|
+
while (1) switch (_context.prev = _context.next) {
|
|
32
|
+
case 0:
|
|
33
|
+
blockAri = _ref.blockAri;
|
|
34
|
+
_context.next = 3;
|
|
35
|
+
return fetch("".concat(BLOCK_SERVICE_API_URL, "/block/").concat(blockAri), {
|
|
36
|
+
method: 'GET',
|
|
37
|
+
headers: COMMON_HEADERS
|
|
38
|
+
});
|
|
39
|
+
case 3:
|
|
40
|
+
response = _context.sent;
|
|
41
|
+
if (response.ok) {
|
|
42
|
+
_context.next = 6;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
throw new BlockError(response.status);
|
|
46
|
+
case 6:
|
|
47
|
+
_context.next = 8;
|
|
48
|
+
return response.json();
|
|
49
|
+
case 8:
|
|
50
|
+
return _context.abrupt("return", _context.sent);
|
|
51
|
+
case 9:
|
|
52
|
+
case "end":
|
|
53
|
+
return _context.stop();
|
|
54
|
+
}
|
|
55
|
+
}, _callee);
|
|
56
|
+
}));
|
|
57
|
+
return function getSyncedBlockContent(_x) {
|
|
58
|
+
return _ref2.apply(this, arguments);
|
|
59
|
+
};
|
|
60
|
+
}();
|
|
61
|
+
export var deleteSyncedBlock = /*#__PURE__*/function () {
|
|
62
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref3) {
|
|
63
|
+
var blockAri, response;
|
|
64
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
65
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
66
|
+
case 0:
|
|
67
|
+
blockAri = _ref3.blockAri;
|
|
68
|
+
_context2.next = 3;
|
|
69
|
+
return fetch("".concat(BLOCK_SERVICE_API_URL, "/block/").concat(blockAri), {
|
|
70
|
+
method: 'DELETE',
|
|
71
|
+
headers: COMMON_HEADERS
|
|
72
|
+
});
|
|
73
|
+
case 3:
|
|
74
|
+
response = _context2.sent;
|
|
75
|
+
if (response.ok) {
|
|
76
|
+
_context2.next = 6;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
throw new BlockError(response.status);
|
|
80
|
+
case 6:
|
|
81
|
+
case "end":
|
|
82
|
+
return _context2.stop();
|
|
83
|
+
}
|
|
84
|
+
}, _callee2);
|
|
85
|
+
}));
|
|
86
|
+
return function deleteSyncedBlock(_x2) {
|
|
87
|
+
return _ref4.apply(this, arguments);
|
|
88
|
+
};
|
|
89
|
+
}();
|
|
90
|
+
export var updateSyncedBlock = /*#__PURE__*/function () {
|
|
91
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref5) {
|
|
92
|
+
var blockAri, content, response;
|
|
93
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
94
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
95
|
+
case 0:
|
|
96
|
+
blockAri = _ref5.blockAri, content = _ref5.content;
|
|
97
|
+
_context3.next = 3;
|
|
98
|
+
return fetch("".concat(BLOCK_SERVICE_API_URL, "/block/").concat(blockAri), {
|
|
99
|
+
method: 'PUT',
|
|
100
|
+
headers: COMMON_HEADERS,
|
|
101
|
+
body: JSON.stringify({
|
|
102
|
+
content: content
|
|
103
|
+
})
|
|
104
|
+
});
|
|
105
|
+
case 3:
|
|
106
|
+
response = _context3.sent;
|
|
107
|
+
if (response.ok) {
|
|
108
|
+
_context3.next = 6;
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
throw new BlockError(response.status);
|
|
112
|
+
case 6:
|
|
113
|
+
case "end":
|
|
114
|
+
return _context3.stop();
|
|
115
|
+
}
|
|
116
|
+
}, _callee3);
|
|
117
|
+
}));
|
|
118
|
+
return function updateSyncedBlock(_x3) {
|
|
119
|
+
return _ref6.apply(this, arguments);
|
|
120
|
+
};
|
|
121
|
+
}();
|
|
122
|
+
export var createSyncedBlock = /*#__PURE__*/function () {
|
|
123
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref7) {
|
|
124
|
+
var blockAri, blockInstanceId, sourceAri, product, content, response;
|
|
125
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
126
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
127
|
+
case 0:
|
|
128
|
+
blockAri = _ref7.blockAri, blockInstanceId = _ref7.blockInstanceId, sourceAri = _ref7.sourceAri, product = _ref7.product, content = _ref7.content;
|
|
129
|
+
_context4.next = 3;
|
|
130
|
+
return fetch("".concat(BLOCK_SERVICE_API_URL, "/block/").concat(blockAri), {
|
|
131
|
+
method: 'POST',
|
|
132
|
+
headers: COMMON_HEADERS,
|
|
133
|
+
body: JSON.stringify({
|
|
134
|
+
blockInstanceId: blockInstanceId,
|
|
135
|
+
sourceAri: sourceAri,
|
|
136
|
+
product: product,
|
|
137
|
+
content: content
|
|
138
|
+
})
|
|
139
|
+
});
|
|
140
|
+
case 3:
|
|
141
|
+
response = _context4.sent;
|
|
142
|
+
if (response.ok) {
|
|
143
|
+
_context4.next = 6;
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
throw new BlockError(response.status);
|
|
147
|
+
case 6:
|
|
148
|
+
_context4.next = 8;
|
|
149
|
+
return response.json();
|
|
150
|
+
case 8:
|
|
151
|
+
return _context4.abrupt("return", _context4.sent);
|
|
152
|
+
case 9:
|
|
153
|
+
case "end":
|
|
154
|
+
return _context4.stop();
|
|
155
|
+
}
|
|
156
|
+
}, _callee4);
|
|
157
|
+
}));
|
|
158
|
+
return function createSyncedBlock(_x4) {
|
|
159
|
+
return _ref8.apply(this, arguments);
|
|
160
|
+
};
|
|
161
|
+
}();
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,11 +4,12 @@ export type { SyncBlockData, SyncBlockNode } 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
|
+
export { useMemoizedBlockServiceAPIProviders } from './providers/block-service/blockServiceAPI';
|
|
7
8
|
export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders, } from './providers/confluence/confluenceContentAPI';
|
|
8
9
|
export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider, } from './providers/syncBlockProvider';
|
|
9
10
|
export type { ADFFetchProvider, ADFWriteProvider, SyncBlockDataProvider, SyncBlockInstance, } from './providers/types';
|
|
10
11
|
export { ReferenceSyncBlockStoreManager } from './store-manager/referenceSyncBlockStoreManager';
|
|
11
12
|
export { SyncBlockStoreManager } from './store-manager/syncBlockStoreManager';
|
|
12
|
-
export { getConfluencePageAri, getPageIdAndTypeFromAri } from './utils/ari';
|
|
13
|
+
export { blockResourceIdFromSourceAndLocalId, getConfluencePageAri, getLocalIdFromAri, getLocalIdFromResourceId, getPageARIFromResourceId, getPageIdAndTypeFromAri, resourceIdFromSourceAndLocalId, } from './utils/ari';
|
|
13
14
|
export { createSyncBlockNode, convertSyncBlockPMNodeToSyncBlockData, convertSyncBlockJSONNodeToSyncBlockNode, } from './utils/utils';
|
|
14
15
|
export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type SyncBlockData } from '../../common/types';
|
|
2
|
+
import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SyncBlockInstance, WriteSyncBlockResult } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* ADFFetchProvider implementation that fetches synced block data from Block Service API
|
|
5
|
+
*/
|
|
6
|
+
declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
|
|
7
|
+
fetchData(resourceId: string): Promise<SyncBlockInstance>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* ADFWriteProvider implementation that writes synced block data to Block Service API
|
|
11
|
+
*/
|
|
12
|
+
declare class BlockServiceADFWriteProvider implements ADFWriteProvider {
|
|
13
|
+
writeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
14
|
+
deleteData(resourceId: string): Promise<DeleteSyncBlockResult>;
|
|
15
|
+
generateResourceId(sourceId: string, localId: string): string;
|
|
16
|
+
}
|
|
17
|
+
export declare const useMemoizedBlockServiceAPIProviders: () => {
|
|
18
|
+
fetchProvider: BlockServiceADFFetchProvider;
|
|
19
|
+
writeProvider: BlockServiceADFWriteProvider;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
@@ -24,6 +24,7 @@ declare class ConfluenceADFWriteProvider implements ADFWriteProvider {
|
|
|
24
24
|
private createNewContentProperty;
|
|
25
25
|
writeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
26
26
|
deleteData(resourceId: string): Promise<DeleteSyncBlockResult>;
|
|
27
|
+
generateResourceId(sourceId: string, localId: string): string;
|
|
27
28
|
}
|
|
28
29
|
/**
|
|
29
30
|
* Convenience function to create providers with default content property key
|
|
@@ -22,5 +22,6 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
|
22
22
|
deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
|
|
23
23
|
getSourceId(): string;
|
|
24
24
|
retrieveSyncBlockSourceInfo(node: SyncBlockNode): Promise<SyncBlockSourceInfo | undefined>;
|
|
25
|
+
generateResourceId(sourceId: string, localId: string): string;
|
|
25
26
|
}
|
|
26
27
|
export declare const useMemoizedSyncedBlockProvider: (fetchProvider: ADFFetchProvider, writeProvider: ADFWriteProvider, sourceId: string) => SyncBlockProvider;
|
|
@@ -28,6 +28,7 @@ export interface ADFFetchProvider {
|
|
|
28
28
|
}
|
|
29
29
|
export interface ADFWriteProvider {
|
|
30
30
|
deleteData: (resourceId: string) => Promise<DeleteSyncBlockResult>;
|
|
31
|
+
generateResourceId: (sourceId: string, localId: string) => ResourceId;
|
|
31
32
|
writeData: (data: SyncBlockData) => Promise<WriteSyncBlockResult>;
|
|
32
33
|
}
|
|
33
34
|
export declare abstract class SyncBlockDataProvider extends NodeDataProvider<SyncBlockNode, SyncBlockInstance> {
|
|
@@ -35,6 +36,13 @@ export declare abstract class SyncBlockDataProvider extends NodeDataProvider<Syn
|
|
|
35
36
|
abstract deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
|
|
36
37
|
abstract getSourceId(): ResourceId;
|
|
37
38
|
abstract retrieveSyncBlockSourceInfo(node: SyncBlockNode): Promise<SyncBlockSourceInfo | undefined>;
|
|
39
|
+
/**
|
|
40
|
+
* Generates a resource ID from a source ID and local ID.
|
|
41
|
+
* @param sourceId - The source document ID (e.g., page ARI)
|
|
42
|
+
* @param localId - The local block ID (usually a UUID)
|
|
43
|
+
* @returns The generated resource ID
|
|
44
|
+
*/
|
|
45
|
+
abstract generateResourceId(sourceId: ResourceId, localId: string): ResourceId;
|
|
38
46
|
}
|
|
39
47
|
export type SubscriptionCallback = (data: SyncBlockInstance) => void;
|
|
40
48
|
export type TitleSubscriptionCallback = (title: string) => void;
|
|
@@ -6,5 +6,19 @@ export declare const getPageIdAndTypeFromAri: (ari: string) => {
|
|
|
6
6
|
};
|
|
7
7
|
export declare const getLocalIdFromAri: (ari: string) => string;
|
|
8
8
|
export declare const getPageARIFromResourceId: (resourceId: string) => string;
|
|
9
|
-
export declare const getContentPropertyAri: (contentPropertyId: string, cloudId: string) => string;
|
|
10
9
|
export declare const resourceIdFromSourceAndLocalId: (sourceId: string, localId: string) => string;
|
|
10
|
+
/**
|
|
11
|
+
* For the following functions, they are used for the block service API provider.
|
|
12
|
+
* The resourceId/blockResourceId always refers to the block ARI.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* @param sourceId - the ARI of the document. E.G ari:cloud:confluence:cloudId:page/pageId
|
|
16
|
+
* @param localId - the localId of the block node. A randomly generated UUID
|
|
17
|
+
* @returns the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
|
|
18
|
+
*/
|
|
19
|
+
export declare const blockResourceIdFromSourceAndLocalId: (sourceId: string, localId: string) => string;
|
|
20
|
+
/**
|
|
21
|
+
* @param ari - the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
|
|
22
|
+
* @returns the localId of the block node. A randomly generated UUID
|
|
23
|
+
*/
|
|
24
|
+
export declare const getLocalIdFromResourceId: (ari: string) => string;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export type BlockProduct = 'confluence-page' | 'jira-work-item';
|
|
2
|
+
export type BlockContentResponse = {
|
|
3
|
+
blockAri: string;
|
|
4
|
+
blockInstanceId: string;
|
|
5
|
+
content: string;
|
|
6
|
+
contentUpdatedAt: number;
|
|
7
|
+
createdAt: number;
|
|
8
|
+
createdBy: string;
|
|
9
|
+
isSynced: boolean;
|
|
10
|
+
product: BlockProduct;
|
|
11
|
+
sourceAri: string;
|
|
12
|
+
status: 'active' | 'deleted';
|
|
13
|
+
version: number;
|
|
14
|
+
};
|
|
15
|
+
export type GetSyncedBlockContentRequest = {
|
|
16
|
+
blockAri: string;
|
|
17
|
+
};
|
|
18
|
+
export type DeleteSyncedBlockRequest = {
|
|
19
|
+
blockAri: string;
|
|
20
|
+
};
|
|
21
|
+
export type UpdateSyncedBlockRequest = {
|
|
22
|
+
blockAri: string;
|
|
23
|
+
content: string;
|
|
24
|
+
};
|
|
25
|
+
export type CreateSyncedBlockRequest = {
|
|
26
|
+
blockAri: string;
|
|
27
|
+
blockInstanceId: string;
|
|
28
|
+
content: string;
|
|
29
|
+
product: string;
|
|
30
|
+
sourceAri: string;
|
|
31
|
+
};
|
|
32
|
+
export declare class BlockError extends Error {
|
|
33
|
+
readonly status: number;
|
|
34
|
+
constructor(status: number);
|
|
35
|
+
}
|
|
36
|
+
export declare const getSyncedBlockContent: ({ blockAri, }: GetSyncedBlockContentRequest) => Promise<BlockContentResponse>;
|
|
37
|
+
export declare const deleteSyncedBlock: ({ blockAri }: DeleteSyncedBlockRequest) => Promise<void>;
|
|
38
|
+
export declare const updateSyncedBlock: ({ blockAri, content, }: UpdateSyncedBlockRequest) => Promise<void>;
|
|
39
|
+
export declare const createSyncedBlock: ({ blockAri, blockInstanceId, sourceAri, product, content, }: CreateSyncedBlockRequest) => Promise<BlockContentResponse>;
|
|
@@ -4,11 +4,12 @@ export type { SyncBlockData, SyncBlockNode } 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
|
+
export { useMemoizedBlockServiceAPIProviders } from './providers/block-service/blockServiceAPI';
|
|
7
8
|
export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders, } from './providers/confluence/confluenceContentAPI';
|
|
8
9
|
export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider, } from './providers/syncBlockProvider';
|
|
9
10
|
export type { ADFFetchProvider, ADFWriteProvider, SyncBlockDataProvider, SyncBlockInstance, } from './providers/types';
|
|
10
11
|
export { ReferenceSyncBlockStoreManager } from './store-manager/referenceSyncBlockStoreManager';
|
|
11
12
|
export { SyncBlockStoreManager } from './store-manager/syncBlockStoreManager';
|
|
12
|
-
export { getConfluencePageAri, getPageIdAndTypeFromAri } from './utils/ari';
|
|
13
|
+
export { blockResourceIdFromSourceAndLocalId, getConfluencePageAri, getLocalIdFromAri, getLocalIdFromResourceId, getPageARIFromResourceId, getPageIdAndTypeFromAri, resourceIdFromSourceAndLocalId, } from './utils/ari';
|
|
13
14
|
export { createSyncBlockNode, convertSyncBlockPMNodeToSyncBlockData, convertSyncBlockJSONNodeToSyncBlockNode, } from './utils/utils';
|
|
14
15
|
export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type SyncBlockData } from '../../common/types';
|
|
2
|
+
import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SyncBlockInstance, WriteSyncBlockResult } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* ADFFetchProvider implementation that fetches synced block data from Block Service API
|
|
5
|
+
*/
|
|
6
|
+
declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
|
|
7
|
+
fetchData(resourceId: string): Promise<SyncBlockInstance>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* ADFWriteProvider implementation that writes synced block data to Block Service API
|
|
11
|
+
*/
|
|
12
|
+
declare class BlockServiceADFWriteProvider implements ADFWriteProvider {
|
|
13
|
+
writeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
14
|
+
deleteData(resourceId: string): Promise<DeleteSyncBlockResult>;
|
|
15
|
+
generateResourceId(sourceId: string, localId: string): string;
|
|
16
|
+
}
|
|
17
|
+
export declare const useMemoizedBlockServiceAPIProviders: () => {
|
|
18
|
+
fetchProvider: BlockServiceADFFetchProvider;
|
|
19
|
+
writeProvider: BlockServiceADFWriteProvider;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
@@ -24,6 +24,7 @@ declare class ConfluenceADFWriteProvider implements ADFWriteProvider {
|
|
|
24
24
|
private createNewContentProperty;
|
|
25
25
|
writeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
26
26
|
deleteData(resourceId: string): Promise<DeleteSyncBlockResult>;
|
|
27
|
+
generateResourceId(sourceId: string, localId: string): string;
|
|
27
28
|
}
|
|
28
29
|
/**
|
|
29
30
|
* Convenience function to create providers with default content property key
|
|
@@ -22,5 +22,6 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
|
22
22
|
deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
|
|
23
23
|
getSourceId(): string;
|
|
24
24
|
retrieveSyncBlockSourceInfo(node: SyncBlockNode): Promise<SyncBlockSourceInfo | undefined>;
|
|
25
|
+
generateResourceId(sourceId: string, localId: string): string;
|
|
25
26
|
}
|
|
26
27
|
export declare const useMemoizedSyncedBlockProvider: (fetchProvider: ADFFetchProvider, writeProvider: ADFWriteProvider, sourceId: string) => SyncBlockProvider;
|
|
@@ -28,6 +28,7 @@ export interface ADFFetchProvider {
|
|
|
28
28
|
}
|
|
29
29
|
export interface ADFWriteProvider {
|
|
30
30
|
deleteData: (resourceId: string) => Promise<DeleteSyncBlockResult>;
|
|
31
|
+
generateResourceId: (sourceId: string, localId: string) => ResourceId;
|
|
31
32
|
writeData: (data: SyncBlockData) => Promise<WriteSyncBlockResult>;
|
|
32
33
|
}
|
|
33
34
|
export declare abstract class SyncBlockDataProvider extends NodeDataProvider<SyncBlockNode, SyncBlockInstance> {
|
|
@@ -35,6 +36,13 @@ export declare abstract class SyncBlockDataProvider extends NodeDataProvider<Syn
|
|
|
35
36
|
abstract deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
|
|
36
37
|
abstract getSourceId(): ResourceId;
|
|
37
38
|
abstract retrieveSyncBlockSourceInfo(node: SyncBlockNode): Promise<SyncBlockSourceInfo | undefined>;
|
|
39
|
+
/**
|
|
40
|
+
* Generates a resource ID from a source ID and local ID.
|
|
41
|
+
* @param sourceId - The source document ID (e.g., page ARI)
|
|
42
|
+
* @param localId - The local block ID (usually a UUID)
|
|
43
|
+
* @returns The generated resource ID
|
|
44
|
+
*/
|
|
45
|
+
abstract generateResourceId(sourceId: ResourceId, localId: string): ResourceId;
|
|
38
46
|
}
|
|
39
47
|
export type SubscriptionCallback = (data: SyncBlockInstance) => void;
|
|
40
48
|
export type TitleSubscriptionCallback = (title: string) => void;
|
|
@@ -6,5 +6,19 @@ export declare const getPageIdAndTypeFromAri: (ari: string) => {
|
|
|
6
6
|
};
|
|
7
7
|
export declare const getLocalIdFromAri: (ari: string) => string;
|
|
8
8
|
export declare const getPageARIFromResourceId: (resourceId: string) => string;
|
|
9
|
-
export declare const getContentPropertyAri: (contentPropertyId: string, cloudId: string) => string;
|
|
10
9
|
export declare const resourceIdFromSourceAndLocalId: (sourceId: string, localId: string) => string;
|
|
10
|
+
/**
|
|
11
|
+
* For the following functions, they are used for the block service API provider.
|
|
12
|
+
* The resourceId/blockResourceId always refers to the block ARI.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* @param sourceId - the ARI of the document. E.G ari:cloud:confluence:cloudId:page/pageId
|
|
16
|
+
* @param localId - the localId of the block node. A randomly generated UUID
|
|
17
|
+
* @returns the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
|
|
18
|
+
*/
|
|
19
|
+
export declare const blockResourceIdFromSourceAndLocalId: (sourceId: string, localId: string) => string;
|
|
20
|
+
/**
|
|
21
|
+
* @param ari - the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
|
|
22
|
+
* @returns the localId of the block node. A randomly generated UUID
|
|
23
|
+
*/
|
|
24
|
+
export declare const getLocalIdFromResourceId: (ari: string) => string;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export type BlockProduct = 'confluence-page' | 'jira-work-item';
|
|
2
|
+
export type BlockContentResponse = {
|
|
3
|
+
blockAri: string;
|
|
4
|
+
blockInstanceId: string;
|
|
5
|
+
content: string;
|
|
6
|
+
contentUpdatedAt: number;
|
|
7
|
+
createdAt: number;
|
|
8
|
+
createdBy: string;
|
|
9
|
+
isSynced: boolean;
|
|
10
|
+
product: BlockProduct;
|
|
11
|
+
sourceAri: string;
|
|
12
|
+
status: 'active' | 'deleted';
|
|
13
|
+
version: number;
|
|
14
|
+
};
|
|
15
|
+
export type GetSyncedBlockContentRequest = {
|
|
16
|
+
blockAri: string;
|
|
17
|
+
};
|
|
18
|
+
export type DeleteSyncedBlockRequest = {
|
|
19
|
+
blockAri: string;
|
|
20
|
+
};
|
|
21
|
+
export type UpdateSyncedBlockRequest = {
|
|
22
|
+
blockAri: string;
|
|
23
|
+
content: string;
|
|
24
|
+
};
|
|
25
|
+
export type CreateSyncedBlockRequest = {
|
|
26
|
+
blockAri: string;
|
|
27
|
+
blockInstanceId: string;
|
|
28
|
+
content: string;
|
|
29
|
+
product: string;
|
|
30
|
+
sourceAri: string;
|
|
31
|
+
};
|
|
32
|
+
export declare class BlockError extends Error {
|
|
33
|
+
readonly status: number;
|
|
34
|
+
constructor(status: number);
|
|
35
|
+
}
|
|
36
|
+
export declare const getSyncedBlockContent: ({ blockAri, }: GetSyncedBlockContentRequest) => Promise<BlockContentResponse>;
|
|
37
|
+
export declare const deleteSyncedBlock: ({ blockAri }: DeleteSyncedBlockRequest) => Promise<void>;
|
|
38
|
+
export declare const updateSyncedBlock: ({ blockAri, content, }: UpdateSyncedBlockRequest) => Promise<void>;
|
|
39
|
+
export declare const createSyncedBlock: ({ blockAri, blockInstanceId, sourceAri, product, content, }: CreateSyncedBlockRequest) => Promise<BlockContentResponse>;
|
package/package.json
CHANGED
|
@@ -25,11 +25,12 @@
|
|
|
25
25
|
"atlaskit:src": "src/index.ts",
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@atlaskit/adf-schema": "^51.3.2",
|
|
28
|
-
"@atlaskit/adf-utils": "^19.
|
|
28
|
+
"@atlaskit/adf-utils": "^19.26.0",
|
|
29
29
|
"@atlaskit/css": "^0.15.0",
|
|
30
30
|
"@atlaskit/editor-json-transformer": "^8.31.0",
|
|
31
31
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
32
32
|
"@atlaskit/node-data-provider": "^7.5.0",
|
|
33
|
+
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
33
34
|
"@atlaskit/primitives": "^16.1.0",
|
|
34
35
|
"@atlaskit/tokens": "^8.0.0",
|
|
35
36
|
"@babel/runtime": "^7.0.0",
|
|
@@ -82,11 +83,16 @@
|
|
|
82
83
|
}
|
|
83
84
|
},
|
|
84
85
|
"name": "@atlaskit/editor-synced-block-provider",
|
|
85
|
-
"version": "2.
|
|
86
|
+
"version": "2.9.0",
|
|
86
87
|
"description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
|
|
87
88
|
"author": "Atlassian Pty Ltd",
|
|
88
89
|
"license": "Apache-2.0",
|
|
89
90
|
"publishConfig": {
|
|
90
91
|
"registry": "https://registry.npmjs.org/"
|
|
92
|
+
},
|
|
93
|
+
"platform-feature-flags": {
|
|
94
|
+
"platform_editor_synced_block_provider_use_block_service": {
|
|
95
|
+
"type": "boolean"
|
|
96
|
+
}
|
|
91
97
|
}
|
|
92
98
|
}
|