@atlaskit/editor-synced-block-provider 3.26.2 → 3.27.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.
Files changed (30) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/cjs/clients/block-service/blockService.js +14 -8
  3. package/dist/cjs/clients/confluence/sourceInfo.js +38 -21
  4. package/dist/cjs/index.js +6 -0
  5. package/dist/cjs/providers/block-service/blockServiceAPI.js +401 -375
  6. package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +194 -106
  7. package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +5 -2
  8. package/dist/es2019/clients/block-service/blockService.js +10 -3
  9. package/dist/es2019/clients/confluence/sourceInfo.js +14 -5
  10. package/dist/es2019/index.js +2 -3
  11. package/dist/es2019/providers/block-service/blockServiceAPI.js +147 -135
  12. package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +85 -18
  13. package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +6 -2
  14. package/dist/esm/clients/block-service/blockService.js +14 -8
  15. package/dist/esm/clients/confluence/sourceInfo.js +38 -21
  16. package/dist/esm/index.js +2 -3
  17. package/dist/esm/providers/block-service/blockServiceAPI.js +400 -373
  18. package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +194 -106
  19. package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +5 -2
  20. package/dist/types/clients/block-service/blockService.d.ts +2 -1
  21. package/dist/types/common/types.d.ts +5 -1
  22. package/dist/types/index.d.ts +2 -3
  23. package/dist/types/providers/block-service/blockServiceAPI.d.ts +14 -6
  24. package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +8 -1
  25. package/dist/types-ts4.5/clients/block-service/blockService.d.ts +2 -1
  26. package/dist/types-ts4.5/common/types.d.ts +5 -1
  27. package/dist/types-ts4.5/index.d.ts +2 -3
  28. package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +14 -6
  29. package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +8 -1
  30. package/package.json +5 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @atlaskit/editor-synced-block-provider
2
2
 
3
+ ## 3.27.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`764672ccc7992`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/764672ccc7992) -
8
+ EDITOR-4049 Add support for prefetching of synced blocks data to synced block provider.
9
+ - Updated dependencies
10
+
11
+ ## 3.27.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [`8433176cb97f5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8433176cb97f5) -
16
+ Edit at source for an archived page should not redirect and show ask for edit flag
17
+
18
+ ### Patch Changes
19
+
20
+ - [`328425ff14e85`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/328425ff14e85) -
21
+ Update synced block to active state on flush
22
+ - Updated dependencies
23
+
3
24
  ## 3.26.2
4
25
 
5
26
  ### Patch Changes
@@ -135,11 +135,14 @@ var buildGetDocumentReferenceBlocksQuery = function buildGetDocumentReferenceBlo
135
135
  var buildGetBlockQuery = function buildGetBlockQuery(blockAri) {
136
136
  return "query ".concat(GET_BLOCK_OPERATION_NAME, " {\n\tblockService_getBlock(blockAri: ").concat(JSON.stringify(blockAri), ") {\n\t\tblockAri\n\t\tblockInstanceId\n\t\tcontent\n\t\tcontentUpdatedAt\n\t\tcreatedAt\n\t\tcreatedBy\n\t\tdeletionReason\n\t\tproduct\n\t\tsourceAri\n\t\tstatus\n\t\tversion\n\t}\n}");
137
137
  };
138
- var buildUpdateBlockMutation = function buildUpdateBlockMutation(blockAri, content, stepVersion) {
138
+ var buildUpdateBlockMutation = function buildUpdateBlockMutation(blockAri, content, stepVersion, status) {
139
139
  var inputParts = ["blockAri: ".concat(JSON.stringify(blockAri)), "content: ".concat(JSON.stringify(content))];
140
140
  if (stepVersion !== undefined) {
141
141
  inputParts.push("stepVersion: ".concat(stepVersion));
142
142
  }
143
+ if (status !== undefined && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_1')) {
144
+ inputParts.push("status: ".concat(JSON.stringify(status)));
145
+ }
143
146
  var inputArgs = inputParts.join(', ');
144
147
  return "mutation ".concat(UPDATE_BLOCK_OPERATION_NAME, " {\n\tblockService_updateBlock(input: { ").concat(inputArgs, " }) {\n\t\t__typename\n\t}\n}");
145
148
  };
@@ -457,17 +460,17 @@ var deleteSyncedBlock = exports.deleteSyncedBlock = /*#__PURE__*/function () {
457
460
  }();
458
461
  var updateSyncedBlock = exports.updateSyncedBlock = /*#__PURE__*/function () {
459
462
  var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(_ref8) {
460
- var blockAri, content, stepVersion, bodyData, _response4, result, requestBody, response;
463
+ var blockAri, content, stepVersion, status, bodyData, _response4, result, requestBody, response;
461
464
  return _regenerator.default.wrap(function _callee5$(_context5) {
462
465
  while (1) switch (_context5.prev = _context5.next) {
463
466
  case 0:
464
- blockAri = _ref8.blockAri, content = _ref8.content, stepVersion = _ref8.stepVersion;
467
+ blockAri = _ref8.blockAri, content = _ref8.content, stepVersion = _ref8.stepVersion, status = _ref8.status;
465
468
  if (!(0, _platformFeatureFlags.fg)('platform_synced_block_patch_1')) {
466
469
  _context5.next = 14;
467
470
  break;
468
471
  }
469
472
  bodyData = {
470
- query: buildUpdateBlockMutation(blockAri, content, stepVersion),
473
+ query: buildUpdateBlockMutation(blockAri, content, stepVersion, status),
471
474
  operationName: UPDATE_BLOCK_OPERATION_NAME
472
475
  };
473
476
  _context5.next = 5;
@@ -504,20 +507,23 @@ var updateSyncedBlock = exports.updateSyncedBlock = /*#__PURE__*/function () {
504
507
  if (stepVersion !== undefined) {
505
508
  requestBody.stepVersion = stepVersion;
506
509
  }
507
- _context5.next = 18;
510
+ if (status !== undefined && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_1')) {
511
+ requestBody.status = status;
512
+ }
513
+ _context5.next = 19;
508
514
  return (0, _retry.fetchWithRetry)("".concat(BLOCK_SERVICE_API_URL, "/block/").concat(encodeURIComponent(blockAri)), {
509
515
  method: 'PUT',
510
516
  headers: COMMON_HEADERS,
511
517
  body: JSON.stringify(requestBody)
512
518
  });
513
- case 18:
519
+ case 19:
514
520
  response = _context5.sent;
515
521
  if (response.ok) {
516
- _context5.next = 21;
522
+ _context5.next = 22;
517
523
  break;
518
524
  }
519
525
  throw new BlockError(response.status);
520
- case 21:
526
+ case 22:
521
527
  case "end":
522
528
  return _context5.stop();
523
529
  }
@@ -126,9 +126,9 @@ var resolveNoAccessPageInfo = /*#__PURE__*/function () {
126
126
  * @param localId - Optional local ID to append as block anchor
127
127
  * @returns Source info with URL, title, and optional subtype
128
128
  */
129
- var fetchUnpublishedConfluencePageInfo = /*#__PURE__*/function () {
129
+ var fetchCompleteConfluencePageInfo = /*#__PURE__*/function () {
130
130
  var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(pageAri, localId) {
131
- var _pageData$_links, _pageData$_links2, _getPageIdAndTypeFrom, pageId, response, pageData, base, edituiv2, title, subType, url;
131
+ var _pageData$_links, _pageData$_links2, _pageData$_links3, _getPageIdAndTypeFrom, pageId, response, pageData, base, edituiv2, webui, title, subType, status, url;
132
132
  return _regenerator.default.wrap(function _callee3$(_context3) {
133
133
  while (1) switch (_context3.prev = _context3.next) {
134
134
  case 0:
@@ -155,11 +155,15 @@ var fetchUnpublishedConfluencePageInfo = /*#__PURE__*/function () {
155
155
  pageData = _context3.sent;
156
156
  base = (_pageData$_links = pageData._links) === null || _pageData$_links === void 0 ? void 0 : _pageData$_links.base;
157
157
  edituiv2 = (_pageData$_links2 = pageData._links) === null || _pageData$_links2 === void 0 ? void 0 : _pageData$_links2.edituiv2;
158
+ webui = (_pageData$_links3 = pageData._links) === null || _pageData$_links3 === void 0 ? void 0 : _pageData$_links3.webui;
158
159
  title = pageData.title;
159
160
  subType = pageData.subtype;
160
- if (base && edituiv2) {
161
+ status = pageData.status;
162
+ if (base && edituiv2 && ((0, _platformFeatureFlags.fg)('platform_synced_block_patch_2') ? status !== 'archived' : true)) {
161
163
  url = "".concat(base).concat(edituiv2);
162
164
  url = url && localId ? "".concat(url, "#block-").concat(localId) : url;
165
+ } else if (base && webui && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_2')) {
166
+ url = "".concat(base).concat(webui);
163
167
  }
164
168
  return _context3.abrupt("return", {
165
169
  title: title,
@@ -167,20 +171,20 @@ var fetchUnpublishedConfluencePageInfo = /*#__PURE__*/function () {
167
171
  sourceAri: pageAri,
168
172
  subType: subType
169
173
  });
170
- case 18:
171
- _context3.prev = 18;
174
+ case 20:
175
+ _context3.prev = 20;
172
176
  _context3.t0 = _context3["catch"](0);
173
177
  (0, _monitoring.logException)(_context3.t0, {
174
- location: 'editor-synced-block-provider/sourceInfo/fetchUnpublishedConfluencePageInfo'
178
+ location: 'editor-synced-block-provider/sourceInfo/fetchCompleteConfluencePageInfo'
175
179
  });
176
180
  return _context3.abrupt("return", Promise.resolve(undefined));
177
- case 22:
181
+ case 24:
178
182
  case "end":
179
183
  return _context3.stop();
180
184
  }
181
- }, _callee3, null, [[0, 18]]);
185
+ }, _callee3, null, [[0, 20]]);
182
186
  }));
183
- return function fetchUnpublishedConfluencePageInfo(_x3, _x4) {
187
+ return function fetchCompleteConfluencePageInfo(_x3, _x4) {
184
188
  return _ref3.apply(this, arguments);
185
189
  };
186
190
  }();
@@ -244,24 +248,37 @@ var fetchConfluencePageInfo = exports.fetchConfluencePageInfo = /*#__PURE__*/fun
244
248
  while (1) switch (_context5.prev = _context5.next) {
245
249
  case 0:
246
250
  if (!(isUnpublished && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_1'))) {
247
- _context5.next = 4;
251
+ _context5.next = 5;
248
252
  break;
249
253
  }
250
- _context5.next = 3;
251
- return fetchUnpublishedConfluencePageInfo(pageAri, localId);
252
- case 3:
253
- return _context5.abrupt("return", _context5.sent);
254
+ if ((0, _platformFeatureFlags.fg)('platform_synced_block_patch_2')) {
255
+ _context5.next = 5;
256
+ break;
257
+ }
258
+ _context5.next = 4;
259
+ return fetchCompleteConfluencePageInfo(pageAri, localId);
254
260
  case 4:
261
+ return _context5.abrupt("return", _context5.sent);
262
+ case 5:
255
263
  if (!hasAccess) {
256
- _context5.next = 17;
264
+ _context5.next = 22;
257
265
  break;
258
266
  }
259
267
  _getPageIdAndTypeFrom3 = (0, _ari.getPageIdAndTypeFromConfluencePageAri)({
260
268
  ari: pageAri
261
269
  }), pageType = _getPageIdAndTypeFrom3.type;
262
- _context5.next = 8;
270
+ if (!(pageType === 'page' && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_2'))) {
271
+ _context5.next = 11;
272
+ break;
273
+ }
274
+ _context5.next = 10;
275
+ return fetchCompleteConfluencePageInfo(pageAri, localId);
276
+ case 10:
277
+ return _context5.abrupt("return", _context5.sent);
278
+ case 11:
279
+ _context5.next = 13;
263
280
  return getConfluenceSourceInfo(pageAri);
264
- case 8:
281
+ case 13:
265
282
  response = _context5.sent;
266
283
  contentData = (_response$data2 = response.data) === null || _response$data2 === void 0 || (_response$data2 = _response$data2.content) === null || _response$data2 === void 0 || (_response$data2 = _response$data2.nodes) === null || _response$data2 === void 0 ? void 0 : _response$data2[0];
267
284
  _ref7 = contentData || {}, title = _ref7.title, subType = _ref7.subType;
@@ -282,12 +299,12 @@ var fetchConfluencePageInfo = exports.fetchConfluencePageInfo = /*#__PURE__*/fun
282
299
  sourceAri: pageAri,
283
300
  subType: subType
284
301
  }));
285
- case 17:
286
- _context5.next = 19;
302
+ case 22:
303
+ _context5.next = 24;
287
304
  return resolveNoAccessPageInfo(pageAri);
288
- case 19:
305
+ case 24:
289
306
  return _context5.abrupt("return", _context5.sent);
290
- case 20:
307
+ case 25:
291
308
  case "end":
292
309
  return _context5.stop();
293
310
  }
package/dist/cjs/index.js CHANGED
@@ -21,6 +21,12 @@ Object.defineProperty(exports, "SyncedBlockProvider", {
21
21
  return _syncBlockProvider.SyncBlockProvider;
22
22
  }
23
23
  });
24
+ Object.defineProperty(exports, "batchFetchData", {
25
+ enumerable: true,
26
+ get: function get() {
27
+ return _blockServiceAPI.batchFetchData;
28
+ }
29
+ });
24
30
  Object.defineProperty(exports, "convertPMNodesToSyncBlockNodes", {
25
31
  enumerable: true,
26
32
  get: function get() {