@atlaskit/editor-synced-block-provider 2.11.3 → 2.12.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 +7 -0
- package/dist/cjs/clients/block-service/blockService.js +130 -50
- package/dist/cjs/common/types.js +1 -0
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/providers/block-service/blockServiceAPI.js +135 -59
- package/dist/es2019/clients/block-service/blockService.js +57 -0
- package/dist/es2019/common/types.js +1 -0
- package/dist/es2019/index.js +2 -1
- package/dist/es2019/providers/block-service/blockServiceAPI.js +54 -1
- package/dist/esm/clients/block-service/blockService.js +130 -50
- package/dist/esm/common/types.js +1 -0
- package/dist/esm/index.js +2 -1
- package/dist/esm/providers/block-service/blockServiceAPI.js +135 -59
- package/dist/types/clients/block-service/blockService.d.ts +52 -0
- package/dist/types/common/types.d.ts +2 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/providers/block-service/blockServiceAPI.d.ts +2 -1
- package/dist/types-ts4.5/clients/block-service/blockService.d.ts +52 -0
- package/dist/types-ts4.5/common/types.d.ts +2 -1
- package/dist/types-ts4.5/index.d.ts +1 -0
- package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +2 -1
- package/package.json +2 -2
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
4
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
6
|
import { useMemo } from 'react';
|
|
6
7
|
import { blockResourceIdFromSourceAndLocalId, getLocalIdFromBlockResourceId } from '../../clients/block-service/ari';
|
|
7
|
-
import { BlockError, createSyncedBlock, deleteSyncedBlock, getSyncedBlockContent, updateSyncedBlock } from '../../clients/block-service/blockService';
|
|
8
|
+
import { BlockError, createSyncedBlock, deleteSyncedBlock, getReferenceSyncedBlocks, getSyncedBlockContent, updateSyncedBlock } from '../../clients/block-service/blockService';
|
|
8
9
|
import { SyncBlockError } from '../../common/types';
|
|
9
10
|
import { stringifyError } from '../../utils/errorHandling';
|
|
10
11
|
var mapBlockError = function mapBlockError(error) {
|
|
@@ -17,6 +18,81 @@ var mapBlockError = function mapBlockError(error) {
|
|
|
17
18
|
return SyncBlockError.Errored;
|
|
18
19
|
};
|
|
19
20
|
|
|
21
|
+
// convert BlockContentResponse to SyncBlockData
|
|
22
|
+
// throws exception if JSON parsing fails
|
|
23
|
+
// what's missing from BlockContentResponse to SyncBlockData:
|
|
24
|
+
// - updatedAt
|
|
25
|
+
// - sourceURL
|
|
26
|
+
// - sourceTitle
|
|
27
|
+
// - isSynced
|
|
28
|
+
var convertToSyncBlockData = function convertToSyncBlockData(data) {
|
|
29
|
+
return {
|
|
30
|
+
blockInstanceId: data.blockInstanceId,
|
|
31
|
+
content: JSON.parse(data.content),
|
|
32
|
+
createdAt: new Date(data.createdAt).toISOString(),
|
|
33
|
+
createdBy: data.createdBy,
|
|
34
|
+
product: data.product,
|
|
35
|
+
resourceId: data.blockAri,
|
|
36
|
+
sourceAri: data.sourceAri
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export var fetchReferences = /*#__PURE__*/function () {
|
|
40
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(documentAri) {
|
|
41
|
+
var response, _ref2, blocks, errors, blocksInstances, errorInstances;
|
|
42
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
43
|
+
while (1) switch (_context.prev = _context.next) {
|
|
44
|
+
case 0:
|
|
45
|
+
_context.prev = 0;
|
|
46
|
+
_context.next = 3;
|
|
47
|
+
return getReferenceSyncedBlocks(documentAri);
|
|
48
|
+
case 3:
|
|
49
|
+
response = _context.sent;
|
|
50
|
+
_context.next = 11;
|
|
51
|
+
break;
|
|
52
|
+
case 6:
|
|
53
|
+
_context.prev = 6;
|
|
54
|
+
_context.t0 = _context["catch"](0);
|
|
55
|
+
if (!(_context.t0 instanceof BlockError)) {
|
|
56
|
+
_context.next = 10;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
return _context.abrupt("return", mapBlockError(_context.t0));
|
|
60
|
+
case 10:
|
|
61
|
+
return _context.abrupt("return", SyncBlockError.Errored);
|
|
62
|
+
case 11:
|
|
63
|
+
_ref2 = response || {}, blocks = _ref2.blocks, errors = _ref2.errors;
|
|
64
|
+
blocksInstances = (blocks || []).map(function (blockContentResponse) {
|
|
65
|
+
try {
|
|
66
|
+
return {
|
|
67
|
+
data: convertToSyncBlockData(blockContentResponse),
|
|
68
|
+
resourceId: blockContentResponse.blockAri
|
|
69
|
+
};
|
|
70
|
+
} catch (_unused) {
|
|
71
|
+
// JSON parsing error, return InvalidContent error
|
|
72
|
+
return {
|
|
73
|
+
error: SyncBlockError.InvalidContent,
|
|
74
|
+
resourceId: blockContentResponse.blockAri
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
errorInstances = (errors || []).map(function (errorBlock) {
|
|
79
|
+
return {
|
|
80
|
+
error: SyncBlockError.Errored,
|
|
81
|
+
resourceId: errorBlock.blockAri
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
return _context.abrupt("return", [].concat(_toConsumableArray(blocksInstances), _toConsumableArray(errorInstances)));
|
|
85
|
+
case 15:
|
|
86
|
+
case "end":
|
|
87
|
+
return _context.stop();
|
|
88
|
+
}
|
|
89
|
+
}, _callee, null, [[0, 6]]);
|
|
90
|
+
}));
|
|
91
|
+
return function fetchReferences(_x) {
|
|
92
|
+
return _ref.apply(this, arguments);
|
|
93
|
+
};
|
|
94
|
+
}();
|
|
95
|
+
|
|
20
96
|
/**
|
|
21
97
|
* ADFFetchProvider implementation that fetches synced block data from Block Service API
|
|
22
98
|
*/
|
|
@@ -29,32 +105,32 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
29
105
|
value: // resourceId is the ARI of the block. E.G ari:cloud:blocks:site-123:synced-block/uuid-456
|
|
30
106
|
// in the content API provider, this was the concatenation of the source document's ARI and the local ID. E.G ari:cloud:confluence:site-123:page/pageId/uuid-456
|
|
31
107
|
function () {
|
|
32
|
-
var _fetchData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
108
|
+
var _fetchData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resourceId) {
|
|
33
109
|
var localId, blockContentResponse, value, syncedBlockData;
|
|
34
|
-
return _regeneratorRuntime.wrap(function
|
|
35
|
-
while (1) switch (
|
|
110
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
111
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
36
112
|
case 0:
|
|
37
113
|
localId = getLocalIdFromBlockResourceId(resourceId);
|
|
38
|
-
|
|
39
|
-
|
|
114
|
+
_context2.prev = 1;
|
|
115
|
+
_context2.next = 4;
|
|
40
116
|
return getSyncedBlockContent({
|
|
41
117
|
blockAri: resourceId
|
|
42
118
|
});
|
|
43
119
|
case 4:
|
|
44
|
-
blockContentResponse =
|
|
120
|
+
blockContentResponse = _context2.sent;
|
|
45
121
|
value = blockContentResponse.content;
|
|
46
122
|
if (value) {
|
|
47
|
-
|
|
123
|
+
_context2.next = 8;
|
|
48
124
|
break;
|
|
49
125
|
}
|
|
50
|
-
return
|
|
126
|
+
return _context2.abrupt("return", {
|
|
51
127
|
error: SyncBlockError.NotFound,
|
|
52
128
|
resourceId: resourceId
|
|
53
129
|
});
|
|
54
130
|
case 8:
|
|
55
131
|
// Parse the synced block content from the response's content
|
|
56
132
|
syncedBlockData = JSON.parse(value);
|
|
57
|
-
return
|
|
133
|
+
return _context2.abrupt("return", {
|
|
58
134
|
data: {
|
|
59
135
|
content: syncedBlockData,
|
|
60
136
|
resourceId: resourceId,
|
|
@@ -65,28 +141,28 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
65
141
|
resourceId: resourceId
|
|
66
142
|
});
|
|
67
143
|
case 12:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (!(
|
|
71
|
-
|
|
144
|
+
_context2.prev = 12;
|
|
145
|
+
_context2.t0 = _context2["catch"](1);
|
|
146
|
+
if (!(_context2.t0 instanceof BlockError)) {
|
|
147
|
+
_context2.next = 16;
|
|
72
148
|
break;
|
|
73
149
|
}
|
|
74
|
-
return
|
|
75
|
-
error: mapBlockError(
|
|
150
|
+
return _context2.abrupt("return", {
|
|
151
|
+
error: mapBlockError(_context2.t0),
|
|
76
152
|
resourceId: resourceId
|
|
77
153
|
});
|
|
78
154
|
case 16:
|
|
79
|
-
return
|
|
155
|
+
return _context2.abrupt("return", {
|
|
80
156
|
error: SyncBlockError.Errored,
|
|
81
157
|
resourceId: resourceId
|
|
82
158
|
});
|
|
83
159
|
case 17:
|
|
84
160
|
case "end":
|
|
85
|
-
return
|
|
161
|
+
return _context2.stop();
|
|
86
162
|
}
|
|
87
|
-
},
|
|
163
|
+
}, _callee2, null, [[1, 12]]);
|
|
88
164
|
}));
|
|
89
|
-
function fetchData(
|
|
165
|
+
function fetchData(_x2) {
|
|
90
166
|
return _fetchData.apply(this, arguments);
|
|
91
167
|
}
|
|
92
168
|
return fetchData;
|
|
@@ -107,34 +183,34 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
107
183
|
return _createClass(BlockServiceADFWriteProvider, [{
|
|
108
184
|
key: "writeData",
|
|
109
185
|
value: function () {
|
|
110
|
-
var _writeData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
186
|
+
var _writeData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(data) {
|
|
111
187
|
var resourceId;
|
|
112
|
-
return _regeneratorRuntime.wrap(function
|
|
113
|
-
while (1) switch (
|
|
188
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
189
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
114
190
|
case 0:
|
|
115
191
|
resourceId = data.resourceId;
|
|
116
|
-
|
|
117
|
-
|
|
192
|
+
_context3.prev = 1;
|
|
193
|
+
_context3.next = 4;
|
|
118
194
|
return updateSyncedBlock({
|
|
119
195
|
blockAri: resourceId,
|
|
120
196
|
content: JSON.stringify(data.content)
|
|
121
197
|
});
|
|
122
198
|
case 4:
|
|
123
|
-
return
|
|
199
|
+
return _context3.abrupt("return", {
|
|
124
200
|
resourceId: resourceId
|
|
125
201
|
});
|
|
126
202
|
case 7:
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if (!(
|
|
130
|
-
|
|
203
|
+
_context3.prev = 7;
|
|
204
|
+
_context3.t0 = _context3["catch"](1);
|
|
205
|
+
if (!(_context3.t0 instanceof BlockError)) {
|
|
206
|
+
_context3.next = 16;
|
|
131
207
|
break;
|
|
132
208
|
}
|
|
133
|
-
if (!(
|
|
134
|
-
|
|
209
|
+
if (!(_context3.t0.status === 404)) {
|
|
210
|
+
_context3.next = 15;
|
|
135
211
|
break;
|
|
136
212
|
}
|
|
137
|
-
|
|
213
|
+
_context3.next = 13;
|
|
138
214
|
return createSyncedBlock({
|
|
139
215
|
blockAri: resourceId,
|
|
140
216
|
blockInstanceId: data.blockInstanceId,
|
|
@@ -143,25 +219,25 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
143
219
|
content: JSON.stringify(data.content)
|
|
144
220
|
});
|
|
145
221
|
case 13:
|
|
146
|
-
|
|
222
|
+
_context3.next = 16;
|
|
147
223
|
break;
|
|
148
224
|
case 15:
|
|
149
|
-
return
|
|
150
|
-
error: mapBlockError(
|
|
225
|
+
return _context3.abrupt("return", {
|
|
226
|
+
error: mapBlockError(_context3.t0),
|
|
151
227
|
resourceId: resourceId
|
|
152
228
|
});
|
|
153
229
|
case 16:
|
|
154
|
-
return
|
|
155
|
-
error: stringifyError(
|
|
230
|
+
return _context3.abrupt("return", {
|
|
231
|
+
error: stringifyError(_context3.t0),
|
|
156
232
|
resourceId: resourceId
|
|
157
233
|
});
|
|
158
234
|
case 17:
|
|
159
235
|
case "end":
|
|
160
|
-
return
|
|
236
|
+
return _context3.stop();
|
|
161
237
|
}
|
|
162
|
-
},
|
|
238
|
+
}, _callee3, this, [[1, 7]]);
|
|
163
239
|
}));
|
|
164
|
-
function writeData(
|
|
240
|
+
function writeData(_x3) {
|
|
165
241
|
return _writeData.apply(this, arguments);
|
|
166
242
|
}
|
|
167
243
|
return writeData;
|
|
@@ -169,46 +245,46 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
169
245
|
}, {
|
|
170
246
|
key: "deleteData",
|
|
171
247
|
value: function () {
|
|
172
|
-
var _deleteData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
173
|
-
return _regeneratorRuntime.wrap(function
|
|
174
|
-
while (1) switch (
|
|
248
|
+
var _deleteData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(resourceId) {
|
|
249
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
250
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
175
251
|
case 0:
|
|
176
|
-
|
|
177
|
-
|
|
252
|
+
_context4.prev = 0;
|
|
253
|
+
_context4.next = 3;
|
|
178
254
|
return deleteSyncedBlock({
|
|
179
255
|
blockAri: resourceId
|
|
180
256
|
});
|
|
181
257
|
case 3:
|
|
182
|
-
return
|
|
258
|
+
return _context4.abrupt("return", {
|
|
183
259
|
resourceId: resourceId,
|
|
184
260
|
success: true,
|
|
185
261
|
error: undefined
|
|
186
262
|
});
|
|
187
263
|
case 6:
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
if (!(
|
|
191
|
-
|
|
264
|
+
_context4.prev = 6;
|
|
265
|
+
_context4.t0 = _context4["catch"](0);
|
|
266
|
+
if (!(_context4.t0 instanceof BlockError)) {
|
|
267
|
+
_context4.next = 10;
|
|
192
268
|
break;
|
|
193
269
|
}
|
|
194
|
-
return
|
|
270
|
+
return _context4.abrupt("return", {
|
|
195
271
|
resourceId: resourceId,
|
|
196
272
|
success: false,
|
|
197
|
-
error: mapBlockError(
|
|
273
|
+
error: mapBlockError(_context4.t0)
|
|
198
274
|
});
|
|
199
275
|
case 10:
|
|
200
|
-
return
|
|
276
|
+
return _context4.abrupt("return", {
|
|
201
277
|
resourceId: resourceId,
|
|
202
278
|
success: false,
|
|
203
|
-
error: stringifyError(
|
|
279
|
+
error: stringifyError(_context4.t0)
|
|
204
280
|
});
|
|
205
281
|
case 11:
|
|
206
282
|
case "end":
|
|
207
|
-
return
|
|
283
|
+
return _context4.stop();
|
|
208
284
|
}
|
|
209
|
-
},
|
|
285
|
+
}, _callee4, null, [[0, 6]]);
|
|
210
286
|
}));
|
|
211
|
-
function deleteData(
|
|
287
|
+
function deleteData(_x4) {
|
|
212
288
|
return _deleteData.apply(this, arguments);
|
|
213
289
|
}
|
|
214
290
|
return deleteData;
|
|
@@ -10,6 +10,58 @@ export type BlockContentResponse = {
|
|
|
10
10
|
status: 'active' | 'deleted';
|
|
11
11
|
version: number;
|
|
12
12
|
};
|
|
13
|
+
export type BlockContentErrorResponse = {
|
|
14
|
+
blockAri: string;
|
|
15
|
+
code: string;
|
|
16
|
+
reason: string;
|
|
17
|
+
};
|
|
18
|
+
export declare const isBlockContentResponse: (response: BlockContentResponse | BlockContentErrorResponse) => response is BlockContentResponse;
|
|
19
|
+
/**
|
|
20
|
+
* Retrieves all synced blocks referenced in a document.
|
|
21
|
+
*
|
|
22
|
+
* Calls the Block Service API endpoint: `/v1/block/document/reference/{documentAri}`
|
|
23
|
+
*
|
|
24
|
+
* @param documentAri - The ARI of the document to fetch synced blocks for
|
|
25
|
+
* @returns A promise containing arrays of successfully fetched blocks and any errors encountered
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const { blocks, errors } = await getReferenceSyncedBlocks(
|
|
30
|
+
* 'ari:cloud:confluence:xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx:page/88888888'
|
|
31
|
+
* );
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* Example response:
|
|
35
|
+
* ```json
|
|
36
|
+
* {
|
|
37
|
+
* "blocks": [
|
|
38
|
+
* {
|
|
39
|
+
* "blockAri": "ari:cloud:blocks:xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx:synced-block/xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",
|
|
40
|
+
* "version": 1,
|
|
41
|
+
* "sourceDocumentAri": "ari:cloud:confluence:xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx:page/88888888",
|
|
42
|
+
* "blockInstanceId": "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",
|
|
43
|
+
* "content": "string",
|
|
44
|
+
* "status": "active",
|
|
45
|
+
* "createdAt": "2025-10-08T10:30:00.000Z",
|
|
46
|
+
* "createdBy": "557058:xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",
|
|
47
|
+
* "updatedAt": "2025-10-08T10:30:00.000Z"
|
|
48
|
+
* }
|
|
49
|
+
* ],
|
|
50
|
+
* "errors": [
|
|
51
|
+
* {
|
|
52
|
+
* "blockAri": "ari:cloud:blocks:xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx:synced-block/xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",
|
|
53
|
+
* "code": "error",
|
|
54
|
+
* "reason": "some error reason"
|
|
55
|
+
* }
|
|
56
|
+
* ]
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
* Check https://block-service.dev.atl-paas.net/ for latest API documentation.
|
|
60
|
+
*/
|
|
61
|
+
export declare const getReferenceSyncedBlocks: (documentAri: string) => Promise<{
|
|
62
|
+
blocks?: Array<BlockContentResponse>;
|
|
63
|
+
errors?: Array<BlockContentErrorResponse>;
|
|
64
|
+
}>;
|
|
13
65
|
export type GetSyncedBlockContentRequest = {
|
|
14
66
|
blockAri: string;
|
|
15
67
|
};
|
|
@@ -15,7 +15,8 @@ export interface SyncBlockNode extends JSONNode {
|
|
|
15
15
|
export declare enum SyncBlockError {
|
|
16
16
|
Errored = "errored",
|
|
17
17
|
NotFound = "not_found",
|
|
18
|
-
Forbidden = "forbidden"
|
|
18
|
+
Forbidden = "forbidden",
|
|
19
|
+
InvalidContent = "invalid_content"
|
|
19
20
|
}
|
|
20
21
|
export interface SyncBlockData {
|
|
21
22
|
blockInstanceId: BlockInstanceId;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -15,3 +15,4 @@ export { ReferenceSyncBlockStoreManager } from './store-manager/referenceSyncBlo
|
|
|
15
15
|
export { SyncBlockStoreManager } from './store-manager/syncBlockStoreManager';
|
|
16
16
|
export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
|
|
17
17
|
export { createSyncBlockNode, convertSyncBlockPMNodeToSyncBlockData, convertSyncBlockJSONNodeToSyncBlockNode, convertPMNodesToSyncBlockNodes, } from './utils/utils';
|
|
18
|
+
export { fetchReferences } from './providers/block-service/blockServiceAPI';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { type SyncBlockData, type SyncBlockProduct } from '../../common/types';
|
|
1
|
+
import { SyncBlockError, type SyncBlockData, type SyncBlockProduct } from '../../common/types';
|
|
2
2
|
import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SyncBlockInstance, WriteSyncBlockResult } from '../types';
|
|
3
|
+
export declare const fetchReferences: (documentAri: string) => Promise<SyncBlockInstance[] | SyncBlockError>;
|
|
3
4
|
/**
|
|
4
5
|
* ADFFetchProvider implementation that fetches synced block data from Block Service API
|
|
5
6
|
*/
|
|
@@ -10,6 +10,58 @@ export type BlockContentResponse = {
|
|
|
10
10
|
status: 'active' | 'deleted';
|
|
11
11
|
version: number;
|
|
12
12
|
};
|
|
13
|
+
export type BlockContentErrorResponse = {
|
|
14
|
+
blockAri: string;
|
|
15
|
+
code: string;
|
|
16
|
+
reason: string;
|
|
17
|
+
};
|
|
18
|
+
export declare const isBlockContentResponse: (response: BlockContentResponse | BlockContentErrorResponse) => response is BlockContentResponse;
|
|
19
|
+
/**
|
|
20
|
+
* Retrieves all synced blocks referenced in a document.
|
|
21
|
+
*
|
|
22
|
+
* Calls the Block Service API endpoint: `/v1/block/document/reference/{documentAri}`
|
|
23
|
+
*
|
|
24
|
+
* @param documentAri - The ARI of the document to fetch synced blocks for
|
|
25
|
+
* @returns A promise containing arrays of successfully fetched blocks and any errors encountered
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const { blocks, errors } = await getReferenceSyncedBlocks(
|
|
30
|
+
* 'ari:cloud:confluence:xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx:page/88888888'
|
|
31
|
+
* );
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* Example response:
|
|
35
|
+
* ```json
|
|
36
|
+
* {
|
|
37
|
+
* "blocks": [
|
|
38
|
+
* {
|
|
39
|
+
* "blockAri": "ari:cloud:blocks:xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx:synced-block/xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",
|
|
40
|
+
* "version": 1,
|
|
41
|
+
* "sourceDocumentAri": "ari:cloud:confluence:xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx:page/88888888",
|
|
42
|
+
* "blockInstanceId": "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",
|
|
43
|
+
* "content": "string",
|
|
44
|
+
* "status": "active",
|
|
45
|
+
* "createdAt": "2025-10-08T10:30:00.000Z",
|
|
46
|
+
* "createdBy": "557058:xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",
|
|
47
|
+
* "updatedAt": "2025-10-08T10:30:00.000Z"
|
|
48
|
+
* }
|
|
49
|
+
* ],
|
|
50
|
+
* "errors": [
|
|
51
|
+
* {
|
|
52
|
+
* "blockAri": "ari:cloud:blocks:xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx:synced-block/xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",
|
|
53
|
+
* "code": "error",
|
|
54
|
+
* "reason": "some error reason"
|
|
55
|
+
* }
|
|
56
|
+
* ]
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
* Check https://block-service.dev.atl-paas.net/ for latest API documentation.
|
|
60
|
+
*/
|
|
61
|
+
export declare const getReferenceSyncedBlocks: (documentAri: string) => Promise<{
|
|
62
|
+
blocks?: Array<BlockContentResponse>;
|
|
63
|
+
errors?: Array<BlockContentErrorResponse>;
|
|
64
|
+
}>;
|
|
13
65
|
export type GetSyncedBlockContentRequest = {
|
|
14
66
|
blockAri: string;
|
|
15
67
|
};
|
|
@@ -15,7 +15,8 @@ export interface SyncBlockNode extends JSONNode {
|
|
|
15
15
|
export declare enum SyncBlockError {
|
|
16
16
|
Errored = "errored",
|
|
17
17
|
NotFound = "not_found",
|
|
18
|
-
Forbidden = "forbidden"
|
|
18
|
+
Forbidden = "forbidden",
|
|
19
|
+
InvalidContent = "invalid_content"
|
|
19
20
|
}
|
|
20
21
|
export interface SyncBlockData {
|
|
21
22
|
blockInstanceId: BlockInstanceId;
|
|
@@ -15,3 +15,4 @@ export { ReferenceSyncBlockStoreManager } from './store-manager/referenceSyncBlo
|
|
|
15
15
|
export { SyncBlockStoreManager } from './store-manager/syncBlockStoreManager';
|
|
16
16
|
export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
|
|
17
17
|
export { createSyncBlockNode, convertSyncBlockPMNodeToSyncBlockData, convertSyncBlockJSONNodeToSyncBlockNode, convertPMNodesToSyncBlockNodes, } from './utils/utils';
|
|
18
|
+
export { fetchReferences } from './providers/block-service/blockServiceAPI';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { type SyncBlockData, type SyncBlockProduct } from '../../common/types';
|
|
1
|
+
import { SyncBlockError, type SyncBlockData, type SyncBlockProduct } from '../../common/types';
|
|
2
2
|
import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SyncBlockInstance, WriteSyncBlockResult } from '../types';
|
|
3
|
+
export declare const fetchReferences: (documentAri: string) => Promise<SyncBlockInstance[] | SyncBlockError>;
|
|
3
4
|
/**
|
|
4
5
|
* ADFFetchProvider implementation that fetches synced block data from Block Service API
|
|
5
6
|
*/
|
package/package.json
CHANGED
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"uuid": "^3.1.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@atlaskit/editor-common": "^110.
|
|
37
|
+
"@atlaskit/editor-common": "^110.37.0",
|
|
38
38
|
"react": "^18.2.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
79
|
"name": "@atlaskit/editor-synced-block-provider",
|
|
80
|
-
"version": "2.
|
|
80
|
+
"version": "2.12.0",
|
|
81
81
|
"description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
|
|
82
82
|
"author": "Atlassian Pty Ltd",
|
|
83
83
|
"license": "Apache-2.0",
|