@atlaskit/editor-synced-block-provider 2.9.1 → 2.10.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 (37) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/cjs/index.js +7 -6
  3. package/dist/cjs/providers/block-service/ari.js +34 -0
  4. package/dist/cjs/providers/block-service/blockServiceAPI.js +15 -1
  5. package/dist/cjs/providers/confluence/confluenceContentAPI.js +15 -0
  6. package/dist/cjs/providers/syncBlockProvider.js +8 -7
  7. package/dist/cjs/utils/ari.js +3 -32
  8. package/dist/cjs/utils/sourceInfo.js +3 -3
  9. package/dist/es2019/index.js +2 -1
  10. package/dist/es2019/providers/block-service/ari.js +28 -0
  11. package/dist/es2019/providers/block-service/blockServiceAPI.js +13 -1
  12. package/dist/es2019/providers/confluence/confluenceContentAPI.js +14 -1
  13. package/dist/es2019/providers/syncBlockProvider.js +8 -7
  14. package/dist/es2019/utils/ari.js +2 -31
  15. package/dist/es2019/utils/sourceInfo.js +3 -3
  16. package/dist/esm/index.js +2 -1
  17. package/dist/esm/providers/block-service/ari.js +28 -0
  18. package/dist/esm/providers/block-service/blockServiceAPI.js +15 -1
  19. package/dist/esm/providers/confluence/confluenceContentAPI.js +16 -1
  20. package/dist/esm/providers/syncBlockProvider.js +8 -7
  21. package/dist/esm/utils/ari.js +2 -31
  22. package/dist/esm/utils/sourceInfo.js +3 -3
  23. package/dist/types/index.d.ts +2 -1
  24. package/dist/types/providers/block-service/ari.d.ts +13 -0
  25. package/dist/types/providers/block-service/blockServiceAPI.d.ts +3 -2
  26. package/dist/types/providers/confluence/confluenceContentAPI.d.ts +3 -2
  27. package/dist/types/providers/types.d.ts +5 -0
  28. package/dist/types/utils/ari.d.ts +0 -15
  29. package/dist/types/utils/sourceInfo.d.ts +1 -1
  30. package/dist/types-ts4.5/index.d.ts +2 -1
  31. package/dist/types-ts4.5/providers/block-service/ari.d.ts +13 -0
  32. package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +3 -2
  33. package/dist/types-ts4.5/providers/confluence/confluenceContentAPI.d.ts +3 -2
  34. package/dist/types-ts4.5/providers/types.d.ts +5 -0
  35. package/dist/types-ts4.5/utils/ari.d.ts +0 -15
  36. package/dist/types-ts4.5/utils/sourceInfo.d.ts +1 -1
  37. package/package.json +3 -9
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @atlaskit/editor-synced-block-provider
2
2
 
3
+ ## 2.10.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`a05464ea42678`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a05464ea42678) -
8
+ EDITOR-2791 bump adf-schema
9
+ - Updated dependencies
10
+
11
+ ## 2.10.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [`00d86f82d23fa`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/00d86f82d23fa) -
16
+ Move ARI checks to providers
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies
21
+
3
22
  ## 2.9.1
4
23
 
5
24
  ### Patch Changes
package/dist/cjs/index.js CHANGED
@@ -60,13 +60,13 @@ Object.defineProperty(exports, "createSyncBlockNode", {
60
60
  Object.defineProperty(exports, "getConfluencePageAri", {
61
61
  enumerable: true,
62
62
  get: function get() {
63
- return _ari.getConfluencePageAri;
63
+ return _ari2.getConfluencePageAri;
64
64
  }
65
65
  });
66
66
  Object.defineProperty(exports, "getLocalIdFromAri", {
67
67
  enumerable: true,
68
68
  get: function get() {
69
- return _ari.getLocalIdFromAri;
69
+ return _ari2.getLocalIdFromAri;
70
70
  }
71
71
  });
72
72
  Object.defineProperty(exports, "getLocalIdFromResourceId", {
@@ -78,13 +78,13 @@ Object.defineProperty(exports, "getLocalIdFromResourceId", {
78
78
  Object.defineProperty(exports, "getPageARIFromResourceId", {
79
79
  enumerable: true,
80
80
  get: function get() {
81
- return _ari.getPageARIFromResourceId;
81
+ return _ari2.getPageARIFromResourceId;
82
82
  }
83
83
  });
84
84
  Object.defineProperty(exports, "getPageIdAndTypeFromAri", {
85
85
  enumerable: true,
86
86
  get: function get() {
87
- return _ari.getPageIdAndTypeFromAri;
87
+ return _ari2.getPageIdAndTypeFromAri;
88
88
  }
89
89
  });
90
90
  Object.defineProperty(exports, "rebaseTransaction", {
@@ -102,7 +102,7 @@ Object.defineProperty(exports, "resolveSyncBlockInstance", {
102
102
  Object.defineProperty(exports, "resourceIdFromSourceAndLocalId", {
103
103
  enumerable: true,
104
104
  get: function get() {
105
- return _ari.resourceIdFromSourceAndLocalId;
105
+ return _ari2.resourceIdFromSourceAndLocalId;
106
106
  }
107
107
  });
108
108
  Object.defineProperty(exports, "useFetchSyncBlockData", {
@@ -146,11 +146,12 @@ var _types = require("./common/types");
146
146
  var _useFetchSyncBlockData = require("./hooks/useFetchSyncBlockData");
147
147
  var _useFetchSyncBlockTitle = require("./hooks/useFetchSyncBlockTitle");
148
148
  var _useHandleContentChanges = require("./hooks/useHandleContentChanges");
149
+ var _ari = require("./providers/block-service/ari");
149
150
  var _blockServiceAPI = require("./providers/block-service/blockServiceAPI");
150
151
  var _confluenceContentAPI = require("./providers/confluence/confluenceContentAPI");
151
152
  var _syncBlockProvider = require("./providers/syncBlockProvider");
152
153
  var _referenceSyncBlockStoreManager = require("./store-manager/referenceSyncBlockStoreManager");
153
154
  var _syncBlockStoreManager = require("./store-manager/syncBlockStoreManager");
154
- var _ari = require("./utils/ari");
155
+ var _ari2 = require("./utils/ari");
155
156
  var _utils = require("./utils/utils");
156
157
  var _resolveSyncBlockInstance = require("./utils/resolveSyncBlockInstance");
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getLocalIdFromResourceId = exports.blockResourceIdFromSourceAndLocalId = void 0;
7
+ /* eslint-disable require-unicode-regexp */
8
+ /**
9
+ * Generates a unique block ARI from a source ARI and a local ID.
10
+ * @param sourceId - the ARI of the document. E.G ari:cloud:confluence:cloudId:page/pageId
11
+ * @param localId - the localId of the block node. A randomly generated UUID
12
+ * @returns the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
13
+ */
14
+ var blockResourceIdFromSourceAndLocalId = exports.blockResourceIdFromSourceAndLocalId = function blockResourceIdFromSourceAndLocalId(sourceId, localId) {
15
+ var match = sourceId.match(/ari:cloud:confluence:([^:]+):(page|blogpost)\/.*/);
16
+ if (!(match !== null && match !== void 0 && match[1])) {
17
+ throw new Error("Invalid source ARI: ".concat(sourceId));
18
+ }
19
+ var cloudId = match[1];
20
+ return "ari:cloud:blocks:".concat(cloudId, ":synced-block/").concat(localId);
21
+ };
22
+
23
+ /**
24
+ * Extracts the local ID from a block ARI.
25
+ * @param ari - the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
26
+ * @returns the localId of the block node. A randomly generated UUID
27
+ */
28
+ var getLocalIdFromResourceId = exports.getLocalIdFromResourceId = function getLocalIdFromResourceId(ari) {
29
+ var match = ari.match(/ari:cloud:blocks:[^:]+:synced-block\/([a-zA-Z0-9-]+)/);
30
+ if (match !== null && match !== void 0 && match[1]) {
31
+ return match[1];
32
+ }
33
+ throw new Error("Invalid page ARI: ".concat(ari));
34
+ };
@@ -11,9 +11,9 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
11
11
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
12
  var _react = require("react");
13
13
  var _types = require("../../common/types");
14
- var _ari = require("../../utils/ari");
15
14
  var _blockService = require("../../utils/blockService");
16
15
  var _errorHandling = require("../../utils/errorHandling");
16
+ var _ari = require("./ari");
17
17
  var mapBlockError = function mapBlockError(error) {
18
18
  switch (error.status) {
19
19
  case 403:
@@ -96,6 +96,20 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
96
96
  }
97
97
  return fetchData;
98
98
  }()
99
+ }, {
100
+ key: "retrieveSourceInfoFetchData",
101
+ value: function retrieveSourceInfoFetchData(resourceId, pageARI) {
102
+ var sourceLocalId;
103
+ try {
104
+ sourceLocalId = (0, _ari.getLocalIdFromResourceId)(resourceId);
105
+ } catch (error) {
106
+ // EDITOR-1921: log analytic here, safe to continue
107
+ }
108
+ return {
109
+ pageARI: pageARI,
110
+ sourceLocalId: sourceLocalId
111
+ };
112
+ }
99
113
  }]);
100
114
  }();
101
115
  /**
@@ -134,6 +134,21 @@ var ConfluenceADFFetchProvider = /*#__PURE__*/function () {
134
134
  }
135
135
  return fetchData;
136
136
  }()
137
+ }, {
138
+ key: "retrieveSourceInfoFetchData",
139
+ value: function retrieveSourceInfoFetchData(resourceId) {
140
+ var pageARI = (0, _ari.getPageARIFromResourceId)(resourceId);
141
+ var sourceLocalId;
142
+ try {
143
+ sourceLocalId = (0, _ari.getLocalIdFromAri)(resourceId);
144
+ } catch (error) {
145
+ // EDITOR-1921: log analytic here, safe to continue
146
+ }
147
+ return {
148
+ pageARI: pageARI,
149
+ sourceLocalId: sourceLocalId
150
+ };
151
+ }
137
152
  }]);
138
153
  }();
139
154
  /**
@@ -17,11 +17,12 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
17
17
  var _react = require("react");
18
18
  var _types = require("../common/types");
19
19
  var _types2 = require("../providers/types");
20
- var _ari = require("../utils/ari");
21
20
  var _sourceInfo = require("../utils/sourceInfo");
22
21
  function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
23
22
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
24
23
  var SyncBlockProvider = exports.SyncBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
24
+ // the source document ARI; that the source sync block is on.
25
+
25
26
  /**
26
27
  * Constructor for the SyncBlockProvider
27
28
  *
@@ -216,20 +217,20 @@ var SyncBlockProvider = exports.SyncBlockProvider = /*#__PURE__*/function (_Sync
216
217
  }, {
217
218
  key: "retrieveSyncBlockSourceInfo",
218
219
  value: function retrieveSyncBlockSourceInfo(node) {
220
+ // with content API, this is the concatenation of the page ARI and the block's localId.
221
+ // with block service, this is the ARI of the block.
222
+ // this can be cleaned up from the specific providers and placed here after platform_synced_blocks_block_service_provider
219
223
  var resourceId = node.attrs.resourceId;
220
224
  var pageARI;
221
225
  var sourceLocalId;
222
226
  if (resourceId && typeof resourceId === 'string') {
223
227
  try {
224
- pageARI = (0, _ari.getPageARIFromResourceId)(resourceId);
228
+ var fetchData = this.fetchProvider.retrieveSourceInfoFetchData(resourceId, this.sourceId);
229
+ pageARI = fetchData.pageARI;
230
+ sourceLocalId = fetchData.sourceLocalId;
225
231
  } catch (error) {
226
232
  return Promise.reject(error);
227
233
  }
228
- try {
229
- sourceLocalId = (0, _ari.getLocalIdFromAri)(resourceId);
230
- } catch (error) {
231
- // EDITOR-1921: log analytic here, safe to continue
232
- }
233
234
  }
234
235
  return pageARI ? (0, _sourceInfo.fetchSourceInfo)(pageARI, sourceLocalId) : Promise.resolve(undefined);
235
236
  }
@@ -3,13 +3,15 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.resourceIdFromSourceAndLocalId = exports.getPageIdAndTypeFromAri = exports.getPageARIFromResourceId = exports.getLocalIdFromResourceId = exports.getLocalIdFromAri = exports.getConfluencePageAri = exports.blockResourceIdFromSourceAndLocalId = void 0;
6
+ exports.resourceIdFromSourceAndLocalId = exports.getPageIdAndTypeFromAri = exports.getPageARIFromResourceId = exports.getLocalIdFromAri = exports.getConfluencePageAri = void 0;
7
7
  /* eslint-disable require-unicode-regexp */
8
8
 
9
9
  var getConfluencePageAri = exports.getConfluencePageAri = function getConfluencePageAri(pageId, cloudId) {
10
10
  var pageType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'page';
11
11
  return "ari:cloud:confluence:".concat(cloudId, ":").concat(pageType, "/").concat(pageId);
12
12
  };
13
+
14
+ // For extracting from Page ARI and also the content property's version of resourceId
13
15
  var getPageIdAndTypeFromAri = exports.getPageIdAndTypeFromAri = function getPageIdAndTypeFromAri(ari) {
14
16
  var match = ari.match(/ari:cloud:confluence:[^:]+:(page|blogpost)\/(\d+)/);
15
17
  if (match !== null && match !== void 0 && match[2]) {
@@ -36,35 +38,4 @@ var getPageARIFromResourceId = exports.getPageARIFromResourceId = function getPa
36
38
  };
37
39
  var resourceIdFromSourceAndLocalId = exports.resourceIdFromSourceAndLocalId = function resourceIdFromSourceAndLocalId(sourceId, localId) {
38
40
  return sourceId + '/' + localId;
39
- };
40
-
41
- /**
42
- * For the following functions, they are used for the block service API provider.
43
- * The resourceId/blockResourceId always refers to the block ARI.
44
- */
45
-
46
- /**
47
- * @param sourceId - the ARI of the document. E.G ari:cloud:confluence:cloudId:page/pageId
48
- * @param localId - the localId of the block node. A randomly generated UUID
49
- * @returns the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
50
- */
51
- var blockResourceIdFromSourceAndLocalId = exports.blockResourceIdFromSourceAndLocalId = function blockResourceIdFromSourceAndLocalId(sourceId, localId) {
52
- var match = sourceId.match(/ari:cloud:confluence:([^:]+):(page|blogpost)\/.*/);
53
- if (!(match !== null && match !== void 0 && match[1])) {
54
- throw new Error("Invalid source ARI: ".concat(sourceId));
55
- }
56
- var cloudId = match[1];
57
- return "ari:cloud:blocks:".concat(cloudId, ":synced-block/").concat(localId);
58
- };
59
-
60
- /**
61
- * @param ari - the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
62
- * @returns the localId of the block node. A randomly generated UUID
63
- */
64
- var getLocalIdFromResourceId = exports.getLocalIdFromResourceId = function getLocalIdFromResourceId(ari) {
65
- var match = ari.match(/ari:cloud:confluence:[^:]+:(page|blogpost)\/\d+\/([a-zA-Z0-9-]+)/);
66
- if (match !== null && match !== void 0 && match[2]) {
67
- return match[2];
68
- }
69
- throw new Error("Invalid page ARI: ".concat(ari));
70
41
  };
@@ -69,15 +69,15 @@ var getSourceInfo = /*#__PURE__*/function () {
69
69
  };
70
70
  }();
71
71
  var fetchSourceInfo = exports.fetchSourceInfo = /*#__PURE__*/function () {
72
- var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(ari, localId) {
72
+ var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(pageAri, localId) {
73
73
  var _response$data, _contentData$space, _getPageIdAndTypeFrom, pageType, response, contentData, title, url, _ref3, base;
74
74
  return _regenerator.default.wrap(function _callee2$(_context2) {
75
75
  while (1) switch (_context2.prev = _context2.next) {
76
76
  case 0:
77
77
  _context2.prev = 0;
78
- _getPageIdAndTypeFrom = (0, _ari.getPageIdAndTypeFromAri)(ari), pageType = _getPageIdAndTypeFrom.type;
78
+ _getPageIdAndTypeFrom = (0, _ari.getPageIdAndTypeFromAri)(pageAri), pageType = _getPageIdAndTypeFrom.type;
79
79
  _context2.next = 4;
80
- return getSourceInfo(ari);
80
+ return getSourceInfo(pageAri);
81
81
  case 4:
82
82
  response = _context2.sent;
83
83
  contentData = (_response$data = response.data) === null || _response$data === void 0 || (_response$data = _response$data.content) === null || _response$data === void 0 || (_response$data = _response$data.nodes) === null || _response$data === void 0 ? void 0 : _response$data[0];
@@ -5,11 +5,12 @@ export { SyncBlockError } from './common/types';
5
5
  export { useFetchSyncBlockData } from './hooks/useFetchSyncBlockData';
6
6
  export { useFetchSyncBlockTitle } from './hooks/useFetchSyncBlockTitle';
7
7
  export { useHandleContentChanges } from './hooks/useHandleContentChanges';
8
+ export { blockResourceIdFromSourceAndLocalId, getLocalIdFromResourceId } from './providers/block-service/ari';
8
9
  export { useMemoizedBlockServiceAPIProviders } from './providers/block-service/blockServiceAPI';
9
10
  export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders } from './providers/confluence/confluenceContentAPI';
10
11
  export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider } from './providers/syncBlockProvider';
11
12
  export { ReferenceSyncBlockStoreManager } from './store-manager/referenceSyncBlockStoreManager';
12
13
  export { SyncBlockStoreManager } from './store-manager/syncBlockStoreManager';
13
- export { blockResourceIdFromSourceAndLocalId, getConfluencePageAri, getLocalIdFromAri, getLocalIdFromResourceId, getPageARIFromResourceId, getPageIdAndTypeFromAri, resourceIdFromSourceAndLocalId } from './utils/ari';
14
+ export { getConfluencePageAri, getLocalIdFromAri, getPageARIFromResourceId, getPageIdAndTypeFromAri, resourceIdFromSourceAndLocalId } from './utils/ari';
14
15
  export { createSyncBlockNode, convertSyncBlockPMNodeToSyncBlockData, convertSyncBlockJSONNodeToSyncBlockNode } from './utils/utils';
15
16
  export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
@@ -0,0 +1,28 @@
1
+ /* eslint-disable require-unicode-regexp */
2
+ /**
3
+ * Generates a unique block ARI from a source ARI and a local ID.
4
+ * @param sourceId - the ARI of the document. E.G ari:cloud:confluence:cloudId:page/pageId
5
+ * @param localId - the localId of the block node. A randomly generated UUID
6
+ * @returns the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
7
+ */
8
+ export const blockResourceIdFromSourceAndLocalId = (sourceId, localId) => {
9
+ const match = sourceId.match(/ari:cloud:confluence:([^:]+):(page|blogpost)\/.*/);
10
+ if (!(match !== null && match !== void 0 && match[1])) {
11
+ throw new Error(`Invalid source ARI: ${sourceId}`);
12
+ }
13
+ const cloudId = match[1];
14
+ return `ari:cloud:blocks:${cloudId}:synced-block/${localId}`;
15
+ };
16
+
17
+ /**
18
+ * Extracts the local ID from a block ARI.
19
+ * @param ari - the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
20
+ * @returns the localId of the block node. A randomly generated UUID
21
+ */
22
+ export const getLocalIdFromResourceId = ari => {
23
+ const match = ari.match(/ari:cloud:blocks:[^:]+:synced-block\/([a-zA-Z0-9-]+)/);
24
+ if (match !== null && match !== void 0 && match[1]) {
25
+ return match[1];
26
+ }
27
+ throw new Error(`Invalid page ARI: ${ari}`);
28
+ };
@@ -1,8 +1,8 @@
1
1
  import { useMemo } from 'react';
2
2
  import { SyncBlockError } from '../../common/types';
3
- import { blockResourceIdFromSourceAndLocalId, getLocalIdFromResourceId } from '../../utils/ari';
4
3
  import { BlockError, createSyncedBlock, deleteSyncedBlock, getSyncedBlockContent, updateSyncedBlock } from '../../utils/blockService';
5
4
  import { stringifyError } from '../../utils/errorHandling';
5
+ import { blockResourceIdFromSourceAndLocalId, getLocalIdFromResourceId } from './ari';
6
6
  const mapBlockError = error => {
7
7
  switch (error.status) {
8
8
  case 403:
@@ -56,6 +56,18 @@ class BlockServiceADFFetchProvider {
56
56
  };
57
57
  }
58
58
  }
59
+ retrieveSourceInfoFetchData(resourceId, pageARI) {
60
+ let sourceLocalId;
61
+ try {
62
+ sourceLocalId = getLocalIdFromResourceId(resourceId);
63
+ } catch (error) {
64
+ // EDITOR-1921: log analytic here, safe to continue
65
+ }
66
+ return {
67
+ pageARI,
68
+ sourceLocalId
69
+ };
70
+ }
59
71
  }
60
72
 
61
73
  /**
@@ -1,7 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { useMemo } from 'react';
3
3
  import { SyncBlockError } from '../../common/types';
4
- import { getLocalIdFromAri, getPageIdAndTypeFromAri, resourceIdFromSourceAndLocalId } from '../../utils/ari';
4
+ import { getLocalIdFromAri, getPageARIFromResourceId, getPageIdAndTypeFromAri, resourceIdFromSourceAndLocalId } from '../../utils/ari';
5
5
  import { getContentProperty, createContentProperty, updateContentProperty, deleteContentProperty } from '../../utils/contentProperty';
6
6
  import { stringifyError } from '../../utils/errorHandling';
7
7
  import { isBlogPageType } from '../../utils/utils';
@@ -98,6 +98,19 @@ class ConfluenceADFFetchProvider {
98
98
  };
99
99
  }
100
100
  }
101
+ retrieveSourceInfoFetchData(resourceId) {
102
+ const pageARI = getPageARIFromResourceId(resourceId);
103
+ let sourceLocalId;
104
+ try {
105
+ sourceLocalId = getLocalIdFromAri(resourceId);
106
+ } catch (error) {
107
+ // EDITOR-1921: log analytic here, safe to continue
108
+ }
109
+ return {
110
+ pageARI,
111
+ sourceLocalId
112
+ };
113
+ }
101
114
  }
102
115
 
103
116
  /**
@@ -2,9 +2,10 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { useMemo } from 'react';
3
3
  import { SyncBlockError } from '../common/types';
4
4
  import { SyncBlockDataProvider } from '../providers/types';
5
- import { getLocalIdFromAri, getPageARIFromResourceId } from '../utils/ari';
6
5
  import { fetchSourceInfo } from '../utils/sourceInfo';
7
6
  export class SyncBlockProvider extends SyncBlockDataProvider {
7
+ // the source document ARI; that the source sync block is on.
8
+
8
9
  /**
9
10
  * Constructor for the SyncBlockProvider
10
11
  *
@@ -136,6 +137,9 @@ export class SyncBlockProvider extends SyncBlockDataProvider {
136
137
  * @returns The source info
137
138
  */
138
139
  retrieveSyncBlockSourceInfo(node) {
140
+ // with content API, this is the concatenation of the page ARI and the block's localId.
141
+ // with block service, this is the ARI of the block.
142
+ // this can be cleaned up from the specific providers and placed here after platform_synced_blocks_block_service_provider
139
143
  const {
140
144
  resourceId
141
145
  } = node.attrs;
@@ -143,15 +147,12 @@ export class SyncBlockProvider extends SyncBlockDataProvider {
143
147
  let sourceLocalId;
144
148
  if (resourceId && typeof resourceId === 'string') {
145
149
  try {
146
- pageARI = getPageARIFromResourceId(resourceId);
150
+ const fetchData = this.fetchProvider.retrieveSourceInfoFetchData(resourceId, this.sourceId);
151
+ pageARI = fetchData.pageARI;
152
+ sourceLocalId = fetchData.sourceLocalId;
147
153
  } catch (error) {
148
154
  return Promise.reject(error);
149
155
  }
150
- try {
151
- sourceLocalId = getLocalIdFromAri(resourceId);
152
- } catch (error) {
153
- // EDITOR-1921: log analytic here, safe to continue
154
- }
155
156
  }
156
157
  return pageARI ? fetchSourceInfo(pageARI, sourceLocalId) : Promise.resolve(undefined);
157
158
  }
@@ -1,6 +1,8 @@
1
1
  /* eslint-disable require-unicode-regexp */
2
2
 
3
3
  export const getConfluencePageAri = (pageId, cloudId, pageType = 'page') => `ari:cloud:confluence:${cloudId}:${pageType}/${pageId}`;
4
+
5
+ // For extracting from Page ARI and also the content property's version of resourceId
4
6
  export const getPageIdAndTypeFromAri = ari => {
5
7
  const match = ari.match(/ari:cloud:confluence:[^:]+:(page|blogpost)\/(\d+)/);
6
8
  if (match !== null && match !== void 0 && match[2]) {
@@ -27,35 +29,4 @@ export const getPageARIFromResourceId = resourceId => {
27
29
  };
28
30
  export const resourceIdFromSourceAndLocalId = (sourceId, localId) => {
29
31
  return sourceId + '/' + localId;
30
- };
31
-
32
- /**
33
- * For the following functions, they are used for the block service API provider.
34
- * The resourceId/blockResourceId always refers to the block ARI.
35
- */
36
-
37
- /**
38
- * @param sourceId - the ARI of the document. E.G ari:cloud:confluence:cloudId:page/pageId
39
- * @param localId - the localId of the block node. A randomly generated UUID
40
- * @returns the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
41
- */
42
- export const blockResourceIdFromSourceAndLocalId = (sourceId, localId) => {
43
- const match = sourceId.match(/ari:cloud:confluence:([^:]+):(page|blogpost)\/.*/);
44
- if (!(match !== null && match !== void 0 && match[1])) {
45
- throw new Error(`Invalid source ARI: ${sourceId}`);
46
- }
47
- const cloudId = match[1];
48
- return `ari:cloud:blocks:${cloudId}:synced-block/${localId}`;
49
- };
50
-
51
- /**
52
- * @param ari - the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
53
- * @returns the localId of the block node. A randomly generated UUID
54
- */
55
- export const getLocalIdFromResourceId = ari => {
56
- const match = ari.match(/ari:cloud:confluence:[^:]+:(page|blogpost)\/\d+\/([a-zA-Z0-9-]+)/);
57
- if (match !== null && match !== void 0 && match[2]) {
58
- return match[2];
59
- }
60
- throw new Error(`Invalid page ARI: ${ari}`);
61
32
  };
@@ -52,13 +52,13 @@ const getSourceInfo = async ari => {
52
52
  }
53
53
  return await response.json();
54
54
  };
55
- export const fetchSourceInfo = async (ari, localId) => {
55
+ export const fetchSourceInfo = async (pageAri, localId) => {
56
56
  try {
57
57
  var _response$data, _response$data$conten, _response$data$conten2, _contentData$space;
58
58
  const {
59
59
  type: pageType
60
- } = getPageIdAndTypeFromAri(ari);
61
- const response = await getSourceInfo(ari);
60
+ } = getPageIdAndTypeFromAri(pageAri);
61
+ const response = await getSourceInfo(pageAri);
62
62
  const contentData = (_response$data = response.data) === null || _response$data === void 0 ? void 0 : (_response$data$conten = _response$data.content) === null || _response$data$conten === void 0 ? void 0 : (_response$data$conten2 = _response$data$conten.nodes) === null || _response$data$conten2 === void 0 ? void 0 : _response$data$conten2[0];
63
63
  if (!contentData) {
64
64
  throw new Error(`Failed to get content data`);
package/dist/esm/index.js CHANGED
@@ -5,11 +5,12 @@ export { SyncBlockError } from './common/types';
5
5
  export { useFetchSyncBlockData } from './hooks/useFetchSyncBlockData';
6
6
  export { useFetchSyncBlockTitle } from './hooks/useFetchSyncBlockTitle';
7
7
  export { useHandleContentChanges } from './hooks/useHandleContentChanges';
8
+ export { blockResourceIdFromSourceAndLocalId, getLocalIdFromResourceId } from './providers/block-service/ari';
8
9
  export { useMemoizedBlockServiceAPIProviders } from './providers/block-service/blockServiceAPI';
9
10
  export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders } from './providers/confluence/confluenceContentAPI';
10
11
  export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider } from './providers/syncBlockProvider';
11
12
  export { ReferenceSyncBlockStoreManager } from './store-manager/referenceSyncBlockStoreManager';
12
13
  export { SyncBlockStoreManager } from './store-manager/syncBlockStoreManager';
13
- export { blockResourceIdFromSourceAndLocalId, getConfluencePageAri, getLocalIdFromAri, getLocalIdFromResourceId, getPageARIFromResourceId, getPageIdAndTypeFromAri, resourceIdFromSourceAndLocalId } from './utils/ari';
14
+ export { getConfluencePageAri, getLocalIdFromAri, getPageARIFromResourceId, getPageIdAndTypeFromAri, resourceIdFromSourceAndLocalId } from './utils/ari';
14
15
  export { createSyncBlockNode, convertSyncBlockPMNodeToSyncBlockData, convertSyncBlockJSONNodeToSyncBlockNode } from './utils/utils';
15
16
  export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
@@ -0,0 +1,28 @@
1
+ /* eslint-disable require-unicode-regexp */
2
+ /**
3
+ * Generates a unique block ARI from a source ARI and a local ID.
4
+ * @param sourceId - the ARI of the document. E.G ari:cloud:confluence:cloudId:page/pageId
5
+ * @param localId - the localId of the block node. A randomly generated UUID
6
+ * @returns the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
7
+ */
8
+ export var blockResourceIdFromSourceAndLocalId = function blockResourceIdFromSourceAndLocalId(sourceId, localId) {
9
+ var match = sourceId.match(/ari:cloud:confluence:([^:]+):(page|blogpost)\/.*/);
10
+ if (!(match !== null && match !== void 0 && match[1])) {
11
+ throw new Error("Invalid source ARI: ".concat(sourceId));
12
+ }
13
+ var cloudId = match[1];
14
+ return "ari:cloud:blocks:".concat(cloudId, ":synced-block/").concat(localId);
15
+ };
16
+
17
+ /**
18
+ * Extracts the local ID from a block ARI.
19
+ * @param ari - the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
20
+ * @returns the localId of the block node. A randomly generated UUID
21
+ */
22
+ export var getLocalIdFromResourceId = function getLocalIdFromResourceId(ari) {
23
+ var match = ari.match(/ari:cloud:blocks:[^:]+:synced-block\/([a-zA-Z0-9-]+)/);
24
+ if (match !== null && match !== void 0 && match[1]) {
25
+ return match[1];
26
+ }
27
+ throw new Error("Invalid page ARI: ".concat(ari));
28
+ };
@@ -4,9 +4,9 @@ import _createClass from "@babel/runtime/helpers/createClass";
4
4
  import _regeneratorRuntime from "@babel/runtime/regenerator";
5
5
  import { useMemo } from 'react';
6
6
  import { SyncBlockError } from '../../common/types';
7
- import { blockResourceIdFromSourceAndLocalId, getLocalIdFromResourceId } from '../../utils/ari';
8
7
  import { BlockError, createSyncedBlock, deleteSyncedBlock, getSyncedBlockContent, updateSyncedBlock } from '../../utils/blockService';
9
8
  import { stringifyError } from '../../utils/errorHandling';
9
+ import { blockResourceIdFromSourceAndLocalId, getLocalIdFromResourceId } from './ari';
10
10
  var mapBlockError = function mapBlockError(error) {
11
11
  switch (error.status) {
12
12
  case 403:
@@ -89,6 +89,20 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
89
89
  }
90
90
  return fetchData;
91
91
  }()
92
+ }, {
93
+ key: "retrieveSourceInfoFetchData",
94
+ value: function retrieveSourceInfoFetchData(resourceId, pageARI) {
95
+ var sourceLocalId;
96
+ try {
97
+ sourceLocalId = getLocalIdFromResourceId(resourceId);
98
+ } catch (error) {
99
+ // EDITOR-1921: log analytic here, safe to continue
100
+ }
101
+ return {
102
+ pageARI: pageARI,
103
+ sourceLocalId: sourceLocalId
104
+ };
105
+ }
92
106
  }]);
93
107
  }();
94
108
  /**
@@ -6,7 +6,7 @@ import _typeof from "@babel/runtime/helpers/typeof";
6
6
  import _regeneratorRuntime from "@babel/runtime/regenerator";
7
7
  import { useMemo } from 'react';
8
8
  import { SyncBlockError } from '../../common/types';
9
- import { getLocalIdFromAri, getPageIdAndTypeFromAri, resourceIdFromSourceAndLocalId } from '../../utils/ari';
9
+ import { getLocalIdFromAri, getPageARIFromResourceId, getPageIdAndTypeFromAri, resourceIdFromSourceAndLocalId } from '../../utils/ari';
10
10
  import { getContentProperty, createContentProperty, updateContentProperty, deleteContentProperty } from '../../utils/contentProperty';
11
11
  import { stringifyError } from '../../utils/errorHandling';
12
12
  import { isBlogPageType } from '../../utils/utils';
@@ -128,6 +128,21 @@ var ConfluenceADFFetchProvider = /*#__PURE__*/function () {
128
128
  }
129
129
  return fetchData;
130
130
  }()
131
+ }, {
132
+ key: "retrieveSourceInfoFetchData",
133
+ value: function retrieveSourceInfoFetchData(resourceId) {
134
+ var pageARI = getPageARIFromResourceId(resourceId);
135
+ var sourceLocalId;
136
+ try {
137
+ sourceLocalId = getLocalIdFromAri(resourceId);
138
+ } catch (error) {
139
+ // EDITOR-1921: log analytic here, safe to continue
140
+ }
141
+ return {
142
+ pageARI: pageARI,
143
+ sourceLocalId: sourceLocalId
144
+ };
145
+ }
131
146
  }]);
132
147
  }();
133
148
  /**
@@ -12,9 +12,10 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
12
12
  import { useMemo } from 'react';
13
13
  import { SyncBlockError } from '../common/types';
14
14
  import { SyncBlockDataProvider } from '../providers/types';
15
- import { getLocalIdFromAri, getPageARIFromResourceId } from '../utils/ari';
16
15
  import { fetchSourceInfo } from '../utils/sourceInfo';
17
16
  export var SyncBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
17
+ // the source document ARI; that the source sync block is on.
18
+
18
19
  /**
19
20
  * Constructor for the SyncBlockProvider
20
21
  *
@@ -209,20 +210,20 @@ export var SyncBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
209
210
  }, {
210
211
  key: "retrieveSyncBlockSourceInfo",
211
212
  value: function retrieveSyncBlockSourceInfo(node) {
213
+ // with content API, this is the concatenation of the page ARI and the block's localId.
214
+ // with block service, this is the ARI of the block.
215
+ // this can be cleaned up from the specific providers and placed here after platform_synced_blocks_block_service_provider
212
216
  var resourceId = node.attrs.resourceId;
213
217
  var pageARI;
214
218
  var sourceLocalId;
215
219
  if (resourceId && typeof resourceId === 'string') {
216
220
  try {
217
- pageARI = getPageARIFromResourceId(resourceId);
221
+ var fetchData = this.fetchProvider.retrieveSourceInfoFetchData(resourceId, this.sourceId);
222
+ pageARI = fetchData.pageARI;
223
+ sourceLocalId = fetchData.sourceLocalId;
218
224
  } catch (error) {
219
225
  return Promise.reject(error);
220
226
  }
221
- try {
222
- sourceLocalId = getLocalIdFromAri(resourceId);
223
- } catch (error) {
224
- // EDITOR-1921: log analytic here, safe to continue
225
- }
226
227
  }
227
228
  return pageARI ? fetchSourceInfo(pageARI, sourceLocalId) : Promise.resolve(undefined);
228
229
  }
@@ -4,6 +4,8 @@ export var getConfluencePageAri = function getConfluencePageAri(pageId, cloudId)
4
4
  var pageType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'page';
5
5
  return "ari:cloud:confluence:".concat(cloudId, ":").concat(pageType, "/").concat(pageId);
6
6
  };
7
+
8
+ // For extracting from Page ARI and also the content property's version of resourceId
7
9
  export var getPageIdAndTypeFromAri = function getPageIdAndTypeFromAri(ari) {
8
10
  var match = ari.match(/ari:cloud:confluence:[^:]+:(page|blogpost)\/(\d+)/);
9
11
  if (match !== null && match !== void 0 && match[2]) {
@@ -30,35 +32,4 @@ export var getPageARIFromResourceId = function getPageARIFromResourceId(resource
30
32
  };
31
33
  export var resourceIdFromSourceAndLocalId = function resourceIdFromSourceAndLocalId(sourceId, localId) {
32
34
  return sourceId + '/' + localId;
33
- };
34
-
35
- /**
36
- * For the following functions, they are used for the block service API provider.
37
- * The resourceId/blockResourceId always refers to the block ARI.
38
- */
39
-
40
- /**
41
- * @param sourceId - the ARI of the document. E.G ari:cloud:confluence:cloudId:page/pageId
42
- * @param localId - the localId of the block node. A randomly generated UUID
43
- * @returns the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
44
- */
45
- export var blockResourceIdFromSourceAndLocalId = function blockResourceIdFromSourceAndLocalId(sourceId, localId) {
46
- var match = sourceId.match(/ari:cloud:confluence:([^:]+):(page|blogpost)\/.*/);
47
- if (!(match !== null && match !== void 0 && match[1])) {
48
- throw new Error("Invalid source ARI: ".concat(sourceId));
49
- }
50
- var cloudId = match[1];
51
- return "ari:cloud:blocks:".concat(cloudId, ":synced-block/").concat(localId);
52
- };
53
-
54
- /**
55
- * @param ari - the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
56
- * @returns the localId of the block node. A randomly generated UUID
57
- */
58
- export var getLocalIdFromResourceId = function getLocalIdFromResourceId(ari) {
59
- var match = ari.match(/ari:cloud:confluence:[^:]+:(page|blogpost)\/\d+\/([a-zA-Z0-9-]+)/);
60
- if (match !== null && match !== void 0 && match[2]) {
61
- return match[2];
62
- }
63
- throw new Error("Invalid page ARI: ".concat(ari));
64
35
  };
@@ -64,15 +64,15 @@ var getSourceInfo = /*#__PURE__*/function () {
64
64
  };
65
65
  }();
66
66
  export var fetchSourceInfo = /*#__PURE__*/function () {
67
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(ari, localId) {
67
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(pageAri, localId) {
68
68
  var _response$data, _contentData$space, _getPageIdAndTypeFrom, pageType, response, contentData, title, url, _ref3, base;
69
69
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
70
70
  while (1) switch (_context2.prev = _context2.next) {
71
71
  case 0:
72
72
  _context2.prev = 0;
73
- _getPageIdAndTypeFrom = getPageIdAndTypeFromAri(ari), pageType = _getPageIdAndTypeFrom.type;
73
+ _getPageIdAndTypeFrom = getPageIdAndTypeFromAri(pageAri), pageType = _getPageIdAndTypeFrom.type;
74
74
  _context2.next = 4;
75
- return getSourceInfo(ari);
75
+ return getSourceInfo(pageAri);
76
76
  case 4:
77
77
  response = _context2.sent;
78
78
  contentData = (_response$data = response.data) === null || _response$data === void 0 || (_response$data = _response$data.content) === null || _response$data === void 0 || (_response$data = _response$data.nodes) === null || _response$data === void 0 ? void 0 : _response$data[0];
@@ -4,12 +4,13 @@ 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 { blockResourceIdFromSourceAndLocalId, getLocalIdFromResourceId } from './providers/block-service/ari';
7
8
  export { useMemoizedBlockServiceAPIProviders } from './providers/block-service/blockServiceAPI';
8
9
  export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders, } from './providers/confluence/confluenceContentAPI';
9
10
  export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider, } from './providers/syncBlockProvider';
10
11
  export type { ADFFetchProvider, ADFWriteProvider, SyncBlockDataProvider, SyncBlockInstance, } from './providers/types';
11
12
  export { ReferenceSyncBlockStoreManager } from './store-manager/referenceSyncBlockStoreManager';
12
13
  export { SyncBlockStoreManager } from './store-manager/syncBlockStoreManager';
13
- export { blockResourceIdFromSourceAndLocalId, getConfluencePageAri, getLocalIdFromAri, getLocalIdFromResourceId, getPageARIFromResourceId, getPageIdAndTypeFromAri, resourceIdFromSourceAndLocalId, } from './utils/ari';
14
+ export { getConfluencePageAri, getLocalIdFromAri, getPageARIFromResourceId, getPageIdAndTypeFromAri, resourceIdFromSourceAndLocalId, } from './utils/ari';
14
15
  export { createSyncBlockNode, convertSyncBlockPMNodeToSyncBlockData, convertSyncBlockJSONNodeToSyncBlockNode, } from './utils/utils';
15
16
  export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Generates a unique block ARI from a source ARI and a local ID.
3
+ * @param sourceId - the ARI of the document. E.G ari:cloud:confluence:cloudId:page/pageId
4
+ * @param localId - the localId of the block node. A randomly generated UUID
5
+ * @returns the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
6
+ */
7
+ export declare const blockResourceIdFromSourceAndLocalId: (sourceId: string, localId: string) => string;
8
+ /**
9
+ * Extracts the local ID from a block ARI.
10
+ * @param ari - the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
11
+ * @returns the localId of the block node. A randomly generated UUID
12
+ */
13
+ export declare const getLocalIdFromResourceId: (ari: string) => string;
@@ -1,10 +1,11 @@
1
- import { type SyncBlockData } from '../../common/types';
2
- import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SyncBlockInstance, WriteSyncBlockResult } from '../types';
1
+ import { type ResourceId, type SyncBlockData } from '../../common/types';
2
+ import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SourceInfoFetchData, SyncBlockInstance, WriteSyncBlockResult } from '../types';
3
3
  /**
4
4
  * ADFFetchProvider implementation that fetches synced block data from Block Service API
5
5
  */
6
6
  declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
7
7
  fetchData(resourceId: string): Promise<SyncBlockInstance>;
8
+ retrieveSourceInfoFetchData(resourceId: ResourceId, pageARI: string): SourceInfoFetchData;
8
9
  }
9
10
  /**
10
11
  * ADFWriteProvider implementation that writes synced block data to Block Service API
@@ -1,5 +1,5 @@
1
- import { type SyncBlockData } from '../../common/types';
2
- import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SyncBlockInstance, WriteSyncBlockResult } from '../types';
1
+ import { type ResourceId, type SyncBlockData } from '../../common/types';
2
+ import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SourceInfoFetchData, SyncBlockInstance, WriteSyncBlockResult } from '../types';
3
3
  /**
4
4
  * Configuration for Content API providers
5
5
  */
@@ -14,6 +14,7 @@ declare class ConfluenceADFFetchProvider implements ADFFetchProvider {
14
14
  private config;
15
15
  constructor(config: ContentAPIConfig);
16
16
  fetchData(resourceId: string): Promise<SyncBlockInstance>;
17
+ retrieveSourceInfoFetchData(resourceId: ResourceId): SourceInfoFetchData;
17
18
  }
18
19
  /**
19
20
  * ADFWriteProvider implementation that writes synced block data to Confluence Content API
@@ -25,8 +25,13 @@ export type WriteSyncBlockResult = {
25
25
  error?: string;
26
26
  resourceId?: string;
27
27
  };
28
+ export type SourceInfoFetchData = {
29
+ pageARI: string;
30
+ sourceLocalId?: string;
31
+ };
28
32
  export interface ADFFetchProvider {
29
33
  fetchData: (resourceId: ResourceId) => Promise<SyncBlockInstance>;
34
+ retrieveSourceInfoFetchData: (resourceId: ResourceId, pageAri: string) => SourceInfoFetchData;
30
35
  }
31
36
  export interface ADFWriteProvider {
32
37
  deleteData: (resourceId: string) => Promise<DeleteSyncBlockResult>;
@@ -7,18 +7,3 @@ export declare const getPageIdAndTypeFromAri: (ari: string) => {
7
7
  export declare const getLocalIdFromAri: (ari: string) => string;
8
8
  export declare const getPageARIFromResourceId: (resourceId: string) => string;
9
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;
@@ -1,2 +1,2 @@
1
1
  import type { SyncBlockSourceInfo } from '../providers/types';
2
- export declare const fetchSourceInfo: (ari: string, localId?: string) => Promise<SyncBlockSourceInfo | undefined>;
2
+ export declare const fetchSourceInfo: (pageAri: string, localId?: string) => Promise<SyncBlockSourceInfo | undefined>;
@@ -4,12 +4,13 @@ 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 { blockResourceIdFromSourceAndLocalId, getLocalIdFromResourceId } from './providers/block-service/ari';
7
8
  export { useMemoizedBlockServiceAPIProviders } from './providers/block-service/blockServiceAPI';
8
9
  export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders, } from './providers/confluence/confluenceContentAPI';
9
10
  export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider, } from './providers/syncBlockProvider';
10
11
  export type { ADFFetchProvider, ADFWriteProvider, SyncBlockDataProvider, SyncBlockInstance, } from './providers/types';
11
12
  export { ReferenceSyncBlockStoreManager } from './store-manager/referenceSyncBlockStoreManager';
12
13
  export { SyncBlockStoreManager } from './store-manager/syncBlockStoreManager';
13
- export { blockResourceIdFromSourceAndLocalId, getConfluencePageAri, getLocalIdFromAri, getLocalIdFromResourceId, getPageARIFromResourceId, getPageIdAndTypeFromAri, resourceIdFromSourceAndLocalId, } from './utils/ari';
14
+ export { getConfluencePageAri, getLocalIdFromAri, getPageARIFromResourceId, getPageIdAndTypeFromAri, resourceIdFromSourceAndLocalId, } from './utils/ari';
14
15
  export { createSyncBlockNode, convertSyncBlockPMNodeToSyncBlockData, convertSyncBlockJSONNodeToSyncBlockNode, } from './utils/utils';
15
16
  export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Generates a unique block ARI from a source ARI and a local ID.
3
+ * @param sourceId - the ARI of the document. E.G ari:cloud:confluence:cloudId:page/pageId
4
+ * @param localId - the localId of the block node. A randomly generated UUID
5
+ * @returns the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
6
+ */
7
+ export declare const blockResourceIdFromSourceAndLocalId: (sourceId: string, localId: string) => string;
8
+ /**
9
+ * Extracts the local ID from a block ARI.
10
+ * @param ari - the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
11
+ * @returns the localId of the block node. A randomly generated UUID
12
+ */
13
+ export declare const getLocalIdFromResourceId: (ari: string) => string;
@@ -1,10 +1,11 @@
1
- import { type SyncBlockData } from '../../common/types';
2
- import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SyncBlockInstance, WriteSyncBlockResult } from '../types';
1
+ import { type ResourceId, type SyncBlockData } from '../../common/types';
2
+ import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SourceInfoFetchData, SyncBlockInstance, WriteSyncBlockResult } from '../types';
3
3
  /**
4
4
  * ADFFetchProvider implementation that fetches synced block data from Block Service API
5
5
  */
6
6
  declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
7
7
  fetchData(resourceId: string): Promise<SyncBlockInstance>;
8
+ retrieveSourceInfoFetchData(resourceId: ResourceId, pageARI: string): SourceInfoFetchData;
8
9
  }
9
10
  /**
10
11
  * ADFWriteProvider implementation that writes synced block data to Block Service API
@@ -1,5 +1,5 @@
1
- import { type SyncBlockData } from '../../common/types';
2
- import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SyncBlockInstance, WriteSyncBlockResult } from '../types';
1
+ import { type ResourceId, type SyncBlockData } from '../../common/types';
2
+ import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SourceInfoFetchData, SyncBlockInstance, WriteSyncBlockResult } from '../types';
3
3
  /**
4
4
  * Configuration for Content API providers
5
5
  */
@@ -14,6 +14,7 @@ declare class ConfluenceADFFetchProvider implements ADFFetchProvider {
14
14
  private config;
15
15
  constructor(config: ContentAPIConfig);
16
16
  fetchData(resourceId: string): Promise<SyncBlockInstance>;
17
+ retrieveSourceInfoFetchData(resourceId: ResourceId): SourceInfoFetchData;
17
18
  }
18
19
  /**
19
20
  * ADFWriteProvider implementation that writes synced block data to Confluence Content API
@@ -25,8 +25,13 @@ export type WriteSyncBlockResult = {
25
25
  error?: string;
26
26
  resourceId?: string;
27
27
  };
28
+ export type SourceInfoFetchData = {
29
+ pageARI: string;
30
+ sourceLocalId?: string;
31
+ };
28
32
  export interface ADFFetchProvider {
29
33
  fetchData: (resourceId: ResourceId) => Promise<SyncBlockInstance>;
34
+ retrieveSourceInfoFetchData: (resourceId: ResourceId, pageAri: string) => SourceInfoFetchData;
30
35
  }
31
36
  export interface ADFWriteProvider {
32
37
  deleteData: (resourceId: string) => Promise<DeleteSyncBlockResult>;
@@ -7,18 +7,3 @@ export declare const getPageIdAndTypeFromAri: (ari: string) => {
7
7
  export declare const getLocalIdFromAri: (ari: string) => string;
8
8
  export declare const getPageARIFromResourceId: (resourceId: string) => string;
9
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;
@@ -1,2 +1,2 @@
1
1
  import type { SyncBlockSourceInfo } from '../providers/types';
2
- export declare const fetchSourceInfo: (ari: string, localId?: string) => Promise<SyncBlockSourceInfo | undefined>;
2
+ export declare const fetchSourceInfo: (pageAri: string, localId?: string) => Promise<SyncBlockSourceInfo | undefined>;
package/package.json CHANGED
@@ -24,13 +24,12 @@
24
24
  ],
25
25
  "atlaskit:src": "src/index.ts",
26
26
  "dependencies": {
27
- "@atlaskit/adf-schema": "^51.3.2",
27
+ "@atlaskit/adf-schema": "^51.4.0",
28
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",
34
33
  "@atlaskit/primitives": "^16.1.0",
35
34
  "@atlaskit/tokens": "^8.0.0",
36
35
  "@babel/runtime": "^7.0.0",
@@ -38,7 +37,7 @@
38
37
  "uuid": "^3.1.0"
39
38
  },
40
39
  "peerDependencies": {
41
- "@atlaskit/editor-common": "^110.30.0",
40
+ "@atlaskit/editor-common": "^110.32.0",
42
41
  "react": "^18.2.0"
43
42
  },
44
43
  "devDependencies": {
@@ -84,16 +83,11 @@
84
83
  }
85
84
  },
86
85
  "name": "@atlaskit/editor-synced-block-provider",
87
- "version": "2.9.1",
86
+ "version": "2.10.1",
88
87
  "description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
89
88
  "author": "Atlassian Pty Ltd",
90
89
  "license": "Apache-2.0",
91
90
  "publishConfig": {
92
91
  "registry": "https://registry.npmjs.org/"
93
- },
94
- "platform-feature-flags": {
95
- "platform_editor_synced_block_provider_use_block_service": {
96
- "type": "boolean"
97
- }
98
92
  }
99
93
  }