@atlaskit/editor-synced-block-provider 3.13.1 → 3.14.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 +15 -0
- package/dist/cjs/clients/block-service/blockService.js +4 -4
- package/dist/cjs/providers/block-service/blockServiceAPI.js +39 -10
- package/dist/es2019/clients/block-service/blockService.js +3 -3
- package/dist/es2019/providers/block-service/blockServiceAPI.js +32 -2
- package/dist/esm/clients/block-service/blockService.js +4 -4
- package/dist/esm/providers/block-service/blockServiceAPI.js +39 -10
- package/dist/types/clients/block-service/blockService.d.ts +3 -2
- package/dist/types/common/types.d.ts +2 -1
- package/dist/types/providers/block-service/blockServiceAPI.d.ts +9 -6
- package/dist/types-ts4.5/clients/block-service/blockService.d.ts +3 -2
- package/dist/types-ts4.5/common/types.d.ts +2 -1
- package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +9 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-synced-block-provider
|
|
2
2
|
|
|
3
|
+
## 3.14.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`55d9a4080dfa8`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/55d9a4080dfa8) -
|
|
8
|
+
parentAri field for fetch/write providers are mandatory
|
|
9
|
+
|
|
10
|
+
## 3.13.2
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [`87abc5dda86fe`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/87abc5dda86fe) -
|
|
15
|
+
[ux] Show last edited time in sync block tooltip
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 3.13.1
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -48,7 +48,7 @@ var isBlockContentResponse = exports.isBlockContentResponse = function isBlockCo
|
|
|
48
48
|
* "status": "active",
|
|
49
49
|
* "createdAt": "2025-10-08T10:30:00.000Z",
|
|
50
50
|
* "createdBy": "557058:xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",
|
|
51
|
-
* "
|
|
51
|
+
* "contentUpdatedAt": "2025-10-08T10:30:00.000Z"
|
|
52
52
|
* }
|
|
53
53
|
* ],
|
|
54
54
|
* "errors": [
|
|
@@ -122,7 +122,7 @@ var BLOCK_SERVICE_API_URL = '/gateway/api/blocks/v1';
|
|
|
122
122
|
var GRAPHQL_ENDPOINT = '/gateway/api/graphql';
|
|
123
123
|
var GET_DOCUMENT_REFERENCE_BLOCKS_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_GET_DOCUMENT_REFERENCE_BLOCKS';
|
|
124
124
|
var buildGetDocumentReferenceBlocksQuery = function buildGetDocumentReferenceBlocksQuery(documentAri) {
|
|
125
|
-
return "query ".concat(GET_DOCUMENT_REFERENCE_BLOCKS_OPERATION_NAME, " {\n\tblockService_getDocumentReferenceBlocks(documentAri: \"").concat(documentAri, "\") {\n\t\tblocks {\n\t\t\tblockAri\n\t\t\tblockInstanceId\n\t\t\tcontent\n\t\t\tcreatedAt\n\t\t\tcreatedBy\n\t\t\tproduct\n\t\t\tsourceAri\n\t\t\tstatus\n\t\t\tversion\n\t\t}\n\t\terrors {\n\t\t\tblockAri\n\t\t\tcode\n\t\t\treason\n\t\t}\n\t}\n}");
|
|
125
|
+
return "query ".concat(GET_DOCUMENT_REFERENCE_BLOCKS_OPERATION_NAME, " {\n\tblockService_getDocumentReferenceBlocks(documentAri: \"").concat(documentAri, "\") {\n\t\tblocks {\n\t\t\tblockAri\n\t\t\tblockInstanceId\n\t\t\tcontent\n\t\t\tcontentUpdatedAt\n\t\t\tcreatedAt\n\t\t\tcreatedBy\n\t\t\tproduct\n\t\t\tsourceAri\n\t\t\tstatus\n\t\t\tversion\n\t\t}\n\t\terrors {\n\t\t\tblockAri\n\t\t\tcode\n\t\t\treason\n\t\t}\n\t}\n}");
|
|
126
126
|
};
|
|
127
127
|
var BlockError = exports.BlockError = /*#__PURE__*/function (_Error) {
|
|
128
128
|
function BlockError(status) {
|
|
@@ -137,11 +137,11 @@ var BlockError = exports.BlockError = /*#__PURE__*/function (_Error) {
|
|
|
137
137
|
}( /*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
|
|
138
138
|
var getSyncedBlockContent = exports.getSyncedBlockContent = /*#__PURE__*/function () {
|
|
139
139
|
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(_ref2) {
|
|
140
|
-
var blockAri,
|
|
140
|
+
var blockAri, queryParams, response;
|
|
141
141
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
142
142
|
while (1) switch (_context2.prev = _context2.next) {
|
|
143
143
|
case 0:
|
|
144
|
-
blockAri = _ref2.blockAri
|
|
144
|
+
blockAri = _ref2.blockAri;
|
|
145
145
|
// Disable sending documentAri for now. We'll add it back if we find a way to update references that follows the save & refresh principle.
|
|
146
146
|
// Slack discussion here: https://atlassian.slack.com/archives/C09DZT1TBNW/p1767836775552099?thread_ts=1767836754.024889&cid=C09DZT1TBNW
|
|
147
147
|
// const queryParams = documentAri ? `?documentAri=${encodeURIComponent(documentAri)}` : '';
|
|
@@ -94,7 +94,6 @@ var blockAriToResourceId = exports.blockAriToResourceId = function blockAriToRes
|
|
|
94
94
|
// convert BlockContentResponse to SyncBlockData
|
|
95
95
|
// throws exception if JSON parsing fails
|
|
96
96
|
// what's missing from BlockContentResponse to SyncBlockData:
|
|
97
|
-
// - updatedAt
|
|
98
97
|
// - sourceURL
|
|
99
98
|
// - sourceTitle
|
|
100
99
|
// - isSynced
|
|
@@ -111,9 +110,18 @@ var convertToSyncBlockData = exports.convertToSyncBlockData = function convertTo
|
|
|
111
110
|
createdAt = undefined;
|
|
112
111
|
}
|
|
113
112
|
}
|
|
113
|
+
var contentUpdatedAt;
|
|
114
|
+
if (typeof data.contentUpdatedAt === 'number' && (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
115
|
+
try {
|
|
116
|
+
contentUpdatedAt = new Date(data.contentUpdatedAt).toISOString();
|
|
117
|
+
} catch (e) {
|
|
118
|
+
contentUpdatedAt = undefined;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
114
121
|
return {
|
|
115
122
|
blockInstanceId: data.blockInstanceId,
|
|
116
123
|
content: JSON.parse(data.content),
|
|
124
|
+
contentUpdatedAt: contentUpdatedAt,
|
|
117
125
|
createdAt: createdAt,
|
|
118
126
|
createdBy: data.createdBy,
|
|
119
127
|
product: data.product,
|
|
@@ -204,7 +212,7 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
204
212
|
key: "fetchData",
|
|
205
213
|
value: function () {
|
|
206
214
|
var _fetchData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(resourceId) {
|
|
207
|
-
var blockAri, blockContentResponse, value, syncedBlockData;
|
|
215
|
+
var blockAri, blockContentResponse, value, syncedBlockData, contentUpdatedAt;
|
|
208
216
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
209
217
|
while (1) switch (_context2.prev = _context2.next) {
|
|
210
218
|
case 0:
|
|
@@ -232,39 +240,47 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
232
240
|
case 8:
|
|
233
241
|
// Parse the synced block content from the response's content
|
|
234
242
|
syncedBlockData = JSON.parse(value);
|
|
243
|
+
if (typeof blockContentResponse.contentUpdatedAt === 'number' && (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
244
|
+
try {
|
|
245
|
+
contentUpdatedAt = new Date(blockContentResponse.contentUpdatedAt).toISOString();
|
|
246
|
+
} catch (e) {
|
|
247
|
+
contentUpdatedAt = undefined;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
235
250
|
return _context2.abrupt("return", {
|
|
236
251
|
data: {
|
|
237
252
|
content: syncedBlockData,
|
|
238
253
|
resourceId: blockAri,
|
|
239
254
|
blockInstanceId: blockContentResponse.blockInstanceId,
|
|
240
255
|
// this was the node's localId, but has become the resourceId.
|
|
256
|
+
contentUpdatedAt: contentUpdatedAt,
|
|
241
257
|
sourceAri: blockContentResponse.sourceAri,
|
|
242
258
|
product: blockContentResponse.product,
|
|
243
259
|
status: blockContentResponse.status
|
|
244
260
|
},
|
|
245
261
|
resourceId: resourceId
|
|
246
262
|
});
|
|
247
|
-
case
|
|
248
|
-
_context2.prev =
|
|
263
|
+
case 13:
|
|
264
|
+
_context2.prev = 13;
|
|
249
265
|
_context2.t0 = _context2["catch"](1);
|
|
250
266
|
if (!(_context2.t0 instanceof _blockService.BlockError)) {
|
|
251
|
-
_context2.next =
|
|
267
|
+
_context2.next = 17;
|
|
252
268
|
break;
|
|
253
269
|
}
|
|
254
270
|
return _context2.abrupt("return", {
|
|
255
271
|
error: mapBlockError(_context2.t0),
|
|
256
272
|
resourceId: resourceId
|
|
257
273
|
});
|
|
258
|
-
case
|
|
274
|
+
case 17:
|
|
259
275
|
return _context2.abrupt("return", {
|
|
260
276
|
error: _types.SyncBlockError.Errored,
|
|
261
277
|
resourceId: resourceId
|
|
262
278
|
});
|
|
263
|
-
case
|
|
279
|
+
case 18:
|
|
264
280
|
case "end":
|
|
265
281
|
return _context2.stop();
|
|
266
282
|
}
|
|
267
|
-
}, _callee2, this, [[1,
|
|
283
|
+
}, _callee2, this, [[1, 13]]);
|
|
268
284
|
}));
|
|
269
285
|
function fetchData(_x2) {
|
|
270
286
|
return _fetchData.apply(this, arguments);
|
|
@@ -357,7 +373,7 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
357
373
|
value: (function () {
|
|
358
374
|
var _batchFetchData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(blockNodeIdentifiers) {
|
|
359
375
|
var _this2 = this;
|
|
360
|
-
var blockIdentifiers, validResourceIds, processedResourceIds, response, results, _iterator, _step, blockContentResponse, resourceId, value, syncedBlockData, _iterator2, _step2, errorResponse, _resourceId, _iterator3, _step3, blockNodeIdentifier;
|
|
376
|
+
var blockIdentifiers, validResourceIds, processedResourceIds, response, results, _iterator, _step, blockContentResponse, resourceId, value, syncedBlockData, contentUpdatedAt, _iterator2, _step2, errorResponse, _resourceId, _iterator3, _step3, blockNodeIdentifier;
|
|
361
377
|
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
362
378
|
while (1) switch (_context4.prev = _context4.next) {
|
|
363
379
|
case 0:
|
|
@@ -429,10 +445,19 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
429
445
|
case 24:
|
|
430
446
|
try {
|
|
431
447
|
syncedBlockData = JSON.parse(value);
|
|
448
|
+
contentUpdatedAt = void 0;
|
|
449
|
+
if (typeof blockContentResponse.contentUpdatedAt === 'number' && (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
450
|
+
try {
|
|
451
|
+
contentUpdatedAt = new Date(blockContentResponse.contentUpdatedAt).toISOString();
|
|
452
|
+
} catch (e) {
|
|
453
|
+
contentUpdatedAt = undefined;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
432
456
|
results.push({
|
|
433
457
|
data: {
|
|
434
458
|
content: syncedBlockData,
|
|
435
459
|
resourceId: blockContentResponse.blockAri,
|
|
460
|
+
contentUpdatedAt: contentUpdatedAt,
|
|
436
461
|
blockInstanceId: blockContentResponse.blockInstanceId,
|
|
437
462
|
sourceAri: blockContentResponse.sourceAri,
|
|
438
463
|
product: blockContentResponse.product,
|
|
@@ -878,7 +903,7 @@ var createBlockServiceAPIProviders = function createBlockServiceAPIProviders(_re
|
|
|
878
903
|
return {
|
|
879
904
|
fetchProvider: new BlockServiceADFFetchProvider({
|
|
880
905
|
cloudId: cloudId,
|
|
881
|
-
parentAri:
|
|
906
|
+
parentAri: parentAri
|
|
882
907
|
}),
|
|
883
908
|
writeProvider: new BlockServiceADFWriteProvider({
|
|
884
909
|
cloudId: cloudId,
|
|
@@ -916,6 +941,10 @@ var createBlockServiceFetchOnlyAPIProvider = function createBlockServiceFetchOnl
|
|
|
916
941
|
writeProvider: undefined
|
|
917
942
|
};
|
|
918
943
|
};
|
|
944
|
+
|
|
945
|
+
/**
|
|
946
|
+
* If the parentAri is not a valid ARI, pass in an empty string.
|
|
947
|
+
*/
|
|
919
948
|
var useMemoizedBlockServiceFetchOnlyAPIProvider = exports.useMemoizedBlockServiceFetchOnlyAPIProvider = function useMemoizedBlockServiceFetchOnlyAPIProvider(_ref8) {
|
|
920
949
|
var cloudId = _ref8.cloudId,
|
|
921
950
|
parentAri = _ref8.parentAri;
|
|
@@ -31,7 +31,7 @@ export const isBlockContentResponse = response => {
|
|
|
31
31
|
* "status": "active",
|
|
32
32
|
* "createdAt": "2025-10-08T10:30:00.000Z",
|
|
33
33
|
* "createdBy": "557058:xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",
|
|
34
|
-
* "
|
|
34
|
+
* "contentUpdatedAt": "2025-10-08T10:30:00.000Z"
|
|
35
35
|
* }
|
|
36
36
|
* ],
|
|
37
37
|
* "errors": [
|
|
@@ -79,6 +79,7 @@ const buildGetDocumentReferenceBlocksQuery = documentAri => `query ${GET_DOCUMEN
|
|
|
79
79
|
blockAri
|
|
80
80
|
blockInstanceId
|
|
81
81
|
content
|
|
82
|
+
contentUpdatedAt
|
|
82
83
|
createdAt
|
|
83
84
|
createdBy
|
|
84
85
|
product
|
|
@@ -100,8 +101,7 @@ export class BlockError extends Error {
|
|
|
100
101
|
}
|
|
101
102
|
}
|
|
102
103
|
export const getSyncedBlockContent = async ({
|
|
103
|
-
blockAri
|
|
104
|
-
documentAri
|
|
104
|
+
blockAri
|
|
105
105
|
}) => {
|
|
106
106
|
// Disable sending documentAri for now. We'll add it back if we find a way to update references that follows the save & refresh principle.
|
|
107
107
|
// Slack discussion here: https://atlassian.slack.com/archives/C09DZT1TBNW/p1767836775552099?thread_ts=1767836754.024889&cid=C09DZT1TBNW
|
|
@@ -77,7 +77,6 @@ export const blockAriToResourceId = blockAri => {
|
|
|
77
77
|
// convert BlockContentResponse to SyncBlockData
|
|
78
78
|
// throws exception if JSON parsing fails
|
|
79
79
|
// what's missing from BlockContentResponse to SyncBlockData:
|
|
80
|
-
// - updatedAt
|
|
81
80
|
// - sourceURL
|
|
82
81
|
// - sourceTitle
|
|
83
82
|
// - isSynced
|
|
@@ -94,9 +93,18 @@ export const convertToSyncBlockData = (data, resourceId) => {
|
|
|
94
93
|
createdAt = undefined;
|
|
95
94
|
}
|
|
96
95
|
}
|
|
96
|
+
let contentUpdatedAt;
|
|
97
|
+
if (typeof data.contentUpdatedAt === 'number' && fg('platform_synced_block_dogfooding')) {
|
|
98
|
+
try {
|
|
99
|
+
contentUpdatedAt = new Date(data.contentUpdatedAt).toISOString();
|
|
100
|
+
} catch (e) {
|
|
101
|
+
contentUpdatedAt = undefined;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
97
104
|
return {
|
|
98
105
|
blockInstanceId: data.blockInstanceId,
|
|
99
106
|
content: JSON.parse(data.content),
|
|
107
|
+
contentUpdatedAt,
|
|
100
108
|
createdAt,
|
|
101
109
|
createdBy: data.createdBy,
|
|
102
110
|
product: data.product,
|
|
@@ -181,12 +189,21 @@ class BlockServiceADFFetchProvider {
|
|
|
181
189
|
|
|
182
190
|
// Parse the synced block content from the response's content
|
|
183
191
|
const syncedBlockData = JSON.parse(value);
|
|
192
|
+
let contentUpdatedAt;
|
|
193
|
+
if (typeof blockContentResponse.contentUpdatedAt === 'number' && fg('platform_synced_block_dogfooding')) {
|
|
194
|
+
try {
|
|
195
|
+
contentUpdatedAt = new Date(blockContentResponse.contentUpdatedAt).toISOString();
|
|
196
|
+
} catch (e) {
|
|
197
|
+
contentUpdatedAt = undefined;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
184
200
|
return {
|
|
185
201
|
data: {
|
|
186
202
|
content: syncedBlockData,
|
|
187
203
|
resourceId: blockAri,
|
|
188
204
|
blockInstanceId: blockContentResponse.blockInstanceId,
|
|
189
205
|
// this was the node's localId, but has become the resourceId.
|
|
206
|
+
contentUpdatedAt,
|
|
190
207
|
sourceAri: blockContentResponse.sourceAri,
|
|
191
208
|
product: blockContentResponse.product,
|
|
192
209
|
status: blockContentResponse.status
|
|
@@ -308,10 +325,19 @@ class BlockServiceADFFetchProvider {
|
|
|
308
325
|
}
|
|
309
326
|
try {
|
|
310
327
|
const syncedBlockData = JSON.parse(value);
|
|
328
|
+
let contentUpdatedAt;
|
|
329
|
+
if (typeof blockContentResponse.contentUpdatedAt === 'number' && fg('platform_synced_block_dogfooding')) {
|
|
330
|
+
try {
|
|
331
|
+
contentUpdatedAt = new Date(blockContentResponse.contentUpdatedAt).toISOString();
|
|
332
|
+
} catch (e) {
|
|
333
|
+
contentUpdatedAt = undefined;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
311
336
|
results.push({
|
|
312
337
|
data: {
|
|
313
338
|
content: syncedBlockData,
|
|
314
339
|
resourceId: blockContentResponse.blockAri,
|
|
340
|
+
contentUpdatedAt,
|
|
315
341
|
blockInstanceId: blockContentResponse.blockInstanceId,
|
|
316
342
|
sourceAri: blockContentResponse.sourceAri,
|
|
317
343
|
product: blockContentResponse.product,
|
|
@@ -595,7 +621,7 @@ const createBlockServiceAPIProviders = ({
|
|
|
595
621
|
return {
|
|
596
622
|
fetchProvider: new BlockServiceADFFetchProvider({
|
|
597
623
|
cloudId,
|
|
598
|
-
parentAri
|
|
624
|
+
parentAri
|
|
599
625
|
}),
|
|
600
626
|
writeProvider: new BlockServiceADFWriteProvider({
|
|
601
627
|
cloudId,
|
|
@@ -635,6 +661,10 @@ const createBlockServiceFetchOnlyAPIProvider = ({
|
|
|
635
661
|
writeProvider: undefined
|
|
636
662
|
};
|
|
637
663
|
};
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* If the parentAri is not a valid ARI, pass in an empty string.
|
|
667
|
+
*/
|
|
638
668
|
export const useMemoizedBlockServiceFetchOnlyAPIProvider = ({
|
|
639
669
|
cloudId,
|
|
640
670
|
parentAri
|
|
@@ -41,7 +41,7 @@ export var isBlockContentResponse = function isBlockContentResponse(response) {
|
|
|
41
41
|
* "status": "active",
|
|
42
42
|
* "createdAt": "2025-10-08T10:30:00.000Z",
|
|
43
43
|
* "createdBy": "557058:xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",
|
|
44
|
-
* "
|
|
44
|
+
* "contentUpdatedAt": "2025-10-08T10:30:00.000Z"
|
|
45
45
|
* }
|
|
46
46
|
* ],
|
|
47
47
|
* "errors": [
|
|
@@ -115,7 +115,7 @@ var BLOCK_SERVICE_API_URL = '/gateway/api/blocks/v1';
|
|
|
115
115
|
var GRAPHQL_ENDPOINT = '/gateway/api/graphql';
|
|
116
116
|
var GET_DOCUMENT_REFERENCE_BLOCKS_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_GET_DOCUMENT_REFERENCE_BLOCKS';
|
|
117
117
|
var buildGetDocumentReferenceBlocksQuery = function buildGetDocumentReferenceBlocksQuery(documentAri) {
|
|
118
|
-
return "query ".concat(GET_DOCUMENT_REFERENCE_BLOCKS_OPERATION_NAME, " {\n\tblockService_getDocumentReferenceBlocks(documentAri: \"").concat(documentAri, "\") {\n\t\tblocks {\n\t\t\tblockAri\n\t\t\tblockInstanceId\n\t\t\tcontent\n\t\t\tcreatedAt\n\t\t\tcreatedBy\n\t\t\tproduct\n\t\t\tsourceAri\n\t\t\tstatus\n\t\t\tversion\n\t\t}\n\t\terrors {\n\t\t\tblockAri\n\t\t\tcode\n\t\t\treason\n\t\t}\n\t}\n}");
|
|
118
|
+
return "query ".concat(GET_DOCUMENT_REFERENCE_BLOCKS_OPERATION_NAME, " {\n\tblockService_getDocumentReferenceBlocks(documentAri: \"").concat(documentAri, "\") {\n\t\tblocks {\n\t\t\tblockAri\n\t\t\tblockInstanceId\n\t\t\tcontent\n\t\t\tcontentUpdatedAt\n\t\t\tcreatedAt\n\t\t\tcreatedBy\n\t\t\tproduct\n\t\t\tsourceAri\n\t\t\tstatus\n\t\t\tversion\n\t\t}\n\t\terrors {\n\t\t\tblockAri\n\t\t\tcode\n\t\t\treason\n\t\t}\n\t}\n}");
|
|
119
119
|
};
|
|
120
120
|
export var BlockError = /*#__PURE__*/function (_Error) {
|
|
121
121
|
function BlockError(status) {
|
|
@@ -130,11 +130,11 @@ export var BlockError = /*#__PURE__*/function (_Error) {
|
|
|
130
130
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
131
131
|
export var getSyncedBlockContent = /*#__PURE__*/function () {
|
|
132
132
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref2) {
|
|
133
|
-
var blockAri,
|
|
133
|
+
var blockAri, queryParams, response;
|
|
134
134
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
135
135
|
while (1) switch (_context2.prev = _context2.next) {
|
|
136
136
|
case 0:
|
|
137
|
-
blockAri = _ref2.blockAri
|
|
137
|
+
blockAri = _ref2.blockAri;
|
|
138
138
|
// Disable sending documentAri for now. We'll add it back if we find a way to update references that follows the save & refresh principle.
|
|
139
139
|
// Slack discussion here: https://atlassian.slack.com/archives/C09DZT1TBNW/p1767836775552099?thread_ts=1767836754.024889&cid=C09DZT1TBNW
|
|
140
140
|
// const queryParams = documentAri ? `?documentAri=${encodeURIComponent(documentAri)}` : '';
|
|
@@ -88,7 +88,6 @@ export var blockAriToResourceId = function blockAriToResourceId(blockAri) {
|
|
|
88
88
|
// convert BlockContentResponse to SyncBlockData
|
|
89
89
|
// throws exception if JSON parsing fails
|
|
90
90
|
// what's missing from BlockContentResponse to SyncBlockData:
|
|
91
|
-
// - updatedAt
|
|
92
91
|
// - sourceURL
|
|
93
92
|
// - sourceTitle
|
|
94
93
|
// - isSynced
|
|
@@ -105,9 +104,18 @@ export var convertToSyncBlockData = function convertToSyncBlockData(data, resour
|
|
|
105
104
|
createdAt = undefined;
|
|
106
105
|
}
|
|
107
106
|
}
|
|
107
|
+
var contentUpdatedAt;
|
|
108
|
+
if (typeof data.contentUpdatedAt === 'number' && fg('platform_synced_block_dogfooding')) {
|
|
109
|
+
try {
|
|
110
|
+
contentUpdatedAt = new Date(data.contentUpdatedAt).toISOString();
|
|
111
|
+
} catch (e) {
|
|
112
|
+
contentUpdatedAt = undefined;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
108
115
|
return {
|
|
109
116
|
blockInstanceId: data.blockInstanceId,
|
|
110
117
|
content: JSON.parse(data.content),
|
|
118
|
+
contentUpdatedAt: contentUpdatedAt,
|
|
111
119
|
createdAt: createdAt,
|
|
112
120
|
createdBy: data.createdBy,
|
|
113
121
|
product: data.product,
|
|
@@ -198,7 +206,7 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
198
206
|
key: "fetchData",
|
|
199
207
|
value: function () {
|
|
200
208
|
var _fetchData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resourceId) {
|
|
201
|
-
var blockAri, blockContentResponse, value, syncedBlockData;
|
|
209
|
+
var blockAri, blockContentResponse, value, syncedBlockData, contentUpdatedAt;
|
|
202
210
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
203
211
|
while (1) switch (_context2.prev = _context2.next) {
|
|
204
212
|
case 0:
|
|
@@ -226,39 +234,47 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
226
234
|
case 8:
|
|
227
235
|
// Parse the synced block content from the response's content
|
|
228
236
|
syncedBlockData = JSON.parse(value);
|
|
237
|
+
if (typeof blockContentResponse.contentUpdatedAt === 'number' && fg('platform_synced_block_dogfooding')) {
|
|
238
|
+
try {
|
|
239
|
+
contentUpdatedAt = new Date(blockContentResponse.contentUpdatedAt).toISOString();
|
|
240
|
+
} catch (e) {
|
|
241
|
+
contentUpdatedAt = undefined;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
229
244
|
return _context2.abrupt("return", {
|
|
230
245
|
data: {
|
|
231
246
|
content: syncedBlockData,
|
|
232
247
|
resourceId: blockAri,
|
|
233
248
|
blockInstanceId: blockContentResponse.blockInstanceId,
|
|
234
249
|
// this was the node's localId, but has become the resourceId.
|
|
250
|
+
contentUpdatedAt: contentUpdatedAt,
|
|
235
251
|
sourceAri: blockContentResponse.sourceAri,
|
|
236
252
|
product: blockContentResponse.product,
|
|
237
253
|
status: blockContentResponse.status
|
|
238
254
|
},
|
|
239
255
|
resourceId: resourceId
|
|
240
256
|
});
|
|
241
|
-
case
|
|
242
|
-
_context2.prev =
|
|
257
|
+
case 13:
|
|
258
|
+
_context2.prev = 13;
|
|
243
259
|
_context2.t0 = _context2["catch"](1);
|
|
244
260
|
if (!(_context2.t0 instanceof BlockError)) {
|
|
245
|
-
_context2.next =
|
|
261
|
+
_context2.next = 17;
|
|
246
262
|
break;
|
|
247
263
|
}
|
|
248
264
|
return _context2.abrupt("return", {
|
|
249
265
|
error: mapBlockError(_context2.t0),
|
|
250
266
|
resourceId: resourceId
|
|
251
267
|
});
|
|
252
|
-
case
|
|
268
|
+
case 17:
|
|
253
269
|
return _context2.abrupt("return", {
|
|
254
270
|
error: SyncBlockError.Errored,
|
|
255
271
|
resourceId: resourceId
|
|
256
272
|
});
|
|
257
|
-
case
|
|
273
|
+
case 18:
|
|
258
274
|
case "end":
|
|
259
275
|
return _context2.stop();
|
|
260
276
|
}
|
|
261
|
-
}, _callee2, this, [[1,
|
|
277
|
+
}, _callee2, this, [[1, 13]]);
|
|
262
278
|
}));
|
|
263
279
|
function fetchData(_x2) {
|
|
264
280
|
return _fetchData.apply(this, arguments);
|
|
@@ -351,7 +367,7 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
351
367
|
value: (function () {
|
|
352
368
|
var _batchFetchData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(blockNodeIdentifiers) {
|
|
353
369
|
var _this2 = this;
|
|
354
|
-
var blockIdentifiers, validResourceIds, processedResourceIds, response, results, _iterator, _step, blockContentResponse, resourceId, value, syncedBlockData, _iterator2, _step2, errorResponse, _resourceId, _iterator3, _step3, blockNodeIdentifier;
|
|
370
|
+
var blockIdentifiers, validResourceIds, processedResourceIds, response, results, _iterator, _step, blockContentResponse, resourceId, value, syncedBlockData, contentUpdatedAt, _iterator2, _step2, errorResponse, _resourceId, _iterator3, _step3, blockNodeIdentifier;
|
|
355
371
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
356
372
|
while (1) switch (_context4.prev = _context4.next) {
|
|
357
373
|
case 0:
|
|
@@ -423,10 +439,19 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
423
439
|
case 24:
|
|
424
440
|
try {
|
|
425
441
|
syncedBlockData = JSON.parse(value);
|
|
442
|
+
contentUpdatedAt = void 0;
|
|
443
|
+
if (typeof blockContentResponse.contentUpdatedAt === 'number' && fg('platform_synced_block_dogfooding')) {
|
|
444
|
+
try {
|
|
445
|
+
contentUpdatedAt = new Date(blockContentResponse.contentUpdatedAt).toISOString();
|
|
446
|
+
} catch (e) {
|
|
447
|
+
contentUpdatedAt = undefined;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
426
450
|
results.push({
|
|
427
451
|
data: {
|
|
428
452
|
content: syncedBlockData,
|
|
429
453
|
resourceId: blockContentResponse.blockAri,
|
|
454
|
+
contentUpdatedAt: contentUpdatedAt,
|
|
430
455
|
blockInstanceId: blockContentResponse.blockInstanceId,
|
|
431
456
|
sourceAri: blockContentResponse.sourceAri,
|
|
432
457
|
product: blockContentResponse.product,
|
|
@@ -872,7 +897,7 @@ var createBlockServiceAPIProviders = function createBlockServiceAPIProviders(_re
|
|
|
872
897
|
return {
|
|
873
898
|
fetchProvider: new BlockServiceADFFetchProvider({
|
|
874
899
|
cloudId: cloudId,
|
|
875
|
-
parentAri:
|
|
900
|
+
parentAri: parentAri
|
|
876
901
|
}),
|
|
877
902
|
writeProvider: new BlockServiceADFWriteProvider({
|
|
878
903
|
cloudId: cloudId,
|
|
@@ -910,6 +935,10 @@ var createBlockServiceFetchOnlyAPIProvider = function createBlockServiceFetchOnl
|
|
|
910
935
|
writeProvider: undefined
|
|
911
936
|
};
|
|
912
937
|
};
|
|
938
|
+
|
|
939
|
+
/**
|
|
940
|
+
* If the parentAri is not a valid ARI, pass in an empty string.
|
|
941
|
+
*/
|
|
913
942
|
export var useMemoizedBlockServiceFetchOnlyAPIProvider = function useMemoizedBlockServiceFetchOnlyAPIProvider(_ref8) {
|
|
914
943
|
var cloudId = _ref8.cloudId,
|
|
915
944
|
parentAri = _ref8.parentAri;
|
|
@@ -3,6 +3,7 @@ export type BlockContentResponse = {
|
|
|
3
3
|
blockAri: string;
|
|
4
4
|
blockInstanceId: string;
|
|
5
5
|
content: string;
|
|
6
|
+
contentUpdatedAt: number;
|
|
6
7
|
createdAt: number;
|
|
7
8
|
createdBy: string;
|
|
8
9
|
product: SyncBlockProduct;
|
|
@@ -49,7 +50,7 @@ export declare const isBlockContentResponse: (response: BlockContentResponse | E
|
|
|
49
50
|
* "status": "active",
|
|
50
51
|
* "createdAt": "2025-10-08T10:30:00.000Z",
|
|
51
52
|
* "createdBy": "557058:xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",
|
|
52
|
-
* "
|
|
53
|
+
* "contentUpdatedAt": "2025-10-08T10:30:00.000Z"
|
|
53
54
|
* }
|
|
54
55
|
* ],
|
|
55
56
|
* "errors": [
|
|
@@ -116,7 +117,7 @@ export declare class BlockError extends Error {
|
|
|
116
117
|
readonly status: number;
|
|
117
118
|
constructor(status: number);
|
|
118
119
|
}
|
|
119
|
-
export declare const getSyncedBlockContent: ({ blockAri
|
|
120
|
+
export declare const getSyncedBlockContent: ({ blockAri }: GetSyncedBlockContentRequest) => Promise<BlockContentResponse>;
|
|
120
121
|
/**
|
|
121
122
|
* Batch retrieves multiple synced blocks by their ARIs.
|
|
122
123
|
*
|
|
@@ -29,6 +29,7 @@ export declare enum SyncBlockError {
|
|
|
29
29
|
export interface SyncBlockData {
|
|
30
30
|
blockInstanceId: BlockInstanceId;
|
|
31
31
|
content: Array<ADFEntity>;
|
|
32
|
+
contentUpdatedAt?: string;
|
|
32
33
|
createdAt?: string;
|
|
33
34
|
createdBy?: string;
|
|
34
35
|
isSynced?: boolean;
|
|
@@ -45,12 +46,12 @@ export interface SyncBlockData {
|
|
|
45
46
|
sourceSubType?: string | null;
|
|
46
47
|
sourceTitle?: string;
|
|
47
48
|
sourceURL?: string;
|
|
48
|
-
updatedAt?: string;
|
|
49
49
|
status?: SyncBlockStatus;
|
|
50
50
|
}
|
|
51
51
|
export interface ReferenceSyncBlockResponse {
|
|
52
52
|
blockAri: string;
|
|
53
53
|
blockInstanceId?: BlockInstanceId;
|
|
54
|
+
contentUpdatedAt?: string;
|
|
54
55
|
createdAt?: string;
|
|
55
56
|
createdBy?: string;
|
|
56
57
|
documentAri: string;
|
|
@@ -22,14 +22,14 @@ export declare const convertToSyncBlockData: (data: BlockContentResponse, resour
|
|
|
22
22
|
export declare const fetchReferences: (documentAri: string) => Promise<SyncBlockInstance[] | SyncBlockError>;
|
|
23
23
|
interface BlockServiceADFFetchProviderProps {
|
|
24
24
|
cloudId: string;
|
|
25
|
-
parentAri
|
|
25
|
+
parentAri: string | undefined;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* ADFFetchProvider implementation that fetches synced block data from Block Service API
|
|
29
29
|
*/
|
|
30
30
|
declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
|
|
31
31
|
private cloudId;
|
|
32
|
-
private parentAri
|
|
32
|
+
private parentAri;
|
|
33
33
|
constructor({ cloudId, parentAri }: BlockServiceADFFetchProviderProps);
|
|
34
34
|
fetchData(resourceId: string): Promise<SyncBlockInstance>;
|
|
35
35
|
fetchReferences(referenceResourceId: string): Promise<ReferenceSyncBlockData>;
|
|
@@ -56,7 +56,7 @@ declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
|
|
|
56
56
|
interface BlockServiceADFWriteProviderProps {
|
|
57
57
|
cloudId: string;
|
|
58
58
|
getVersion?: () => number | undefined;
|
|
59
|
-
parentAri
|
|
59
|
+
parentAri: string | undefined;
|
|
60
60
|
parentId?: string;
|
|
61
61
|
product: SyncBlockProduct;
|
|
62
62
|
}
|
|
@@ -68,7 +68,7 @@ declare class BlockServiceADFWriteProvider implements ADFWriteProvider {
|
|
|
68
68
|
private parentId?;
|
|
69
69
|
private getVersion?;
|
|
70
70
|
product: SyncBlockProduct;
|
|
71
|
-
parentAri
|
|
71
|
+
parentAri: string | undefined;
|
|
72
72
|
constructor({ cloudId, parentAri, parentId, product, getVersion, }: BlockServiceADFWriteProviderProps);
|
|
73
73
|
writeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
74
74
|
createData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
@@ -80,7 +80,7 @@ declare class BlockServiceADFWriteProvider implements ADFWriteProvider {
|
|
|
80
80
|
interface BlockServiceAPIProvidersProps {
|
|
81
81
|
cloudId: string;
|
|
82
82
|
getVersion?: () => number | undefined;
|
|
83
|
-
parentAri
|
|
83
|
+
parentAri: string | undefined;
|
|
84
84
|
parentId?: string;
|
|
85
85
|
product: SyncBlockProduct;
|
|
86
86
|
}
|
|
@@ -90,8 +90,11 @@ export declare const useMemoizedBlockServiceAPIProviders: ({ cloudId, parentAri,
|
|
|
90
90
|
};
|
|
91
91
|
interface BlockServiceFetchOnlyAPIProviderProps {
|
|
92
92
|
cloudId: string;
|
|
93
|
-
parentAri
|
|
93
|
+
parentAri: string | undefined;
|
|
94
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* If the parentAri is not a valid ARI, pass in an empty string.
|
|
97
|
+
*/
|
|
95
98
|
export declare const useMemoizedBlockServiceFetchOnlyAPIProvider: ({ cloudId, parentAri, }: BlockServiceFetchOnlyAPIProviderProps) => {
|
|
96
99
|
fetchProvider: BlockServiceADFFetchProvider;
|
|
97
100
|
writeProvider: undefined;
|
|
@@ -3,6 +3,7 @@ export type BlockContentResponse = {
|
|
|
3
3
|
blockAri: string;
|
|
4
4
|
blockInstanceId: string;
|
|
5
5
|
content: string;
|
|
6
|
+
contentUpdatedAt: number;
|
|
6
7
|
createdAt: number;
|
|
7
8
|
createdBy: string;
|
|
8
9
|
product: SyncBlockProduct;
|
|
@@ -49,7 +50,7 @@ export declare const isBlockContentResponse: (response: BlockContentResponse | E
|
|
|
49
50
|
* "status": "active",
|
|
50
51
|
* "createdAt": "2025-10-08T10:30:00.000Z",
|
|
51
52
|
* "createdBy": "557058:xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",
|
|
52
|
-
* "
|
|
53
|
+
* "contentUpdatedAt": "2025-10-08T10:30:00.000Z"
|
|
53
54
|
* }
|
|
54
55
|
* ],
|
|
55
56
|
* "errors": [
|
|
@@ -116,7 +117,7 @@ export declare class BlockError extends Error {
|
|
|
116
117
|
readonly status: number;
|
|
117
118
|
constructor(status: number);
|
|
118
119
|
}
|
|
119
|
-
export declare const getSyncedBlockContent: ({ blockAri
|
|
120
|
+
export declare const getSyncedBlockContent: ({ blockAri }: GetSyncedBlockContentRequest) => Promise<BlockContentResponse>;
|
|
120
121
|
/**
|
|
121
122
|
* Batch retrieves multiple synced blocks by their ARIs.
|
|
122
123
|
*
|
|
@@ -29,6 +29,7 @@ export declare enum SyncBlockError {
|
|
|
29
29
|
export interface SyncBlockData {
|
|
30
30
|
blockInstanceId: BlockInstanceId;
|
|
31
31
|
content: Array<ADFEntity>;
|
|
32
|
+
contentUpdatedAt?: string;
|
|
32
33
|
createdAt?: string;
|
|
33
34
|
createdBy?: string;
|
|
34
35
|
isSynced?: boolean;
|
|
@@ -45,12 +46,12 @@ export interface SyncBlockData {
|
|
|
45
46
|
sourceSubType?: string | null;
|
|
46
47
|
sourceTitle?: string;
|
|
47
48
|
sourceURL?: string;
|
|
48
|
-
updatedAt?: string;
|
|
49
49
|
status?: SyncBlockStatus;
|
|
50
50
|
}
|
|
51
51
|
export interface ReferenceSyncBlockResponse {
|
|
52
52
|
blockAri: string;
|
|
53
53
|
blockInstanceId?: BlockInstanceId;
|
|
54
|
+
contentUpdatedAt?: string;
|
|
54
55
|
createdAt?: string;
|
|
55
56
|
createdBy?: string;
|
|
56
57
|
documentAri: string;
|
|
@@ -22,14 +22,14 @@ export declare const convertToSyncBlockData: (data: BlockContentResponse, resour
|
|
|
22
22
|
export declare const fetchReferences: (documentAri: string) => Promise<SyncBlockInstance[] | SyncBlockError>;
|
|
23
23
|
interface BlockServiceADFFetchProviderProps {
|
|
24
24
|
cloudId: string;
|
|
25
|
-
parentAri
|
|
25
|
+
parentAri: string | undefined;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* ADFFetchProvider implementation that fetches synced block data from Block Service API
|
|
29
29
|
*/
|
|
30
30
|
declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
|
|
31
31
|
private cloudId;
|
|
32
|
-
private parentAri
|
|
32
|
+
private parentAri;
|
|
33
33
|
constructor({ cloudId, parentAri }: BlockServiceADFFetchProviderProps);
|
|
34
34
|
fetchData(resourceId: string): Promise<SyncBlockInstance>;
|
|
35
35
|
fetchReferences(referenceResourceId: string): Promise<ReferenceSyncBlockData>;
|
|
@@ -56,7 +56,7 @@ declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
|
|
|
56
56
|
interface BlockServiceADFWriteProviderProps {
|
|
57
57
|
cloudId: string;
|
|
58
58
|
getVersion?: () => number | undefined;
|
|
59
|
-
parentAri
|
|
59
|
+
parentAri: string | undefined;
|
|
60
60
|
parentId?: string;
|
|
61
61
|
product: SyncBlockProduct;
|
|
62
62
|
}
|
|
@@ -68,7 +68,7 @@ declare class BlockServiceADFWriteProvider implements ADFWriteProvider {
|
|
|
68
68
|
private parentId?;
|
|
69
69
|
private getVersion?;
|
|
70
70
|
product: SyncBlockProduct;
|
|
71
|
-
parentAri
|
|
71
|
+
parentAri: string | undefined;
|
|
72
72
|
constructor({ cloudId, parentAri, parentId, product, getVersion, }: BlockServiceADFWriteProviderProps);
|
|
73
73
|
writeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
74
74
|
createData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
@@ -80,7 +80,7 @@ declare class BlockServiceADFWriteProvider implements ADFWriteProvider {
|
|
|
80
80
|
interface BlockServiceAPIProvidersProps {
|
|
81
81
|
cloudId: string;
|
|
82
82
|
getVersion?: () => number | undefined;
|
|
83
|
-
parentAri
|
|
83
|
+
parentAri: string | undefined;
|
|
84
84
|
parentId?: string;
|
|
85
85
|
product: SyncBlockProduct;
|
|
86
86
|
}
|
|
@@ -90,8 +90,11 @@ export declare const useMemoizedBlockServiceAPIProviders: ({ cloudId, parentAri,
|
|
|
90
90
|
};
|
|
91
91
|
interface BlockServiceFetchOnlyAPIProviderProps {
|
|
92
92
|
cloudId: string;
|
|
93
|
-
parentAri
|
|
93
|
+
parentAri: string | undefined;
|
|
94
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* If the parentAri is not a valid ARI, pass in an empty string.
|
|
97
|
+
*/
|
|
95
98
|
export declare const useMemoizedBlockServiceFetchOnlyAPIProvider: ({ cloudId, parentAri, }: BlockServiceFetchOnlyAPIProviderProps) => {
|
|
96
99
|
fetchProvider: BlockServiceADFFetchProvider;
|
|
97
100
|
writeProvider: undefined;
|
package/package.json
CHANGED