@atlaskit/editor-synced-block-provider 2.10.2 → 2.10.3

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 (79) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/cjs/{providers → clients}/block-service/ari.js +2 -2
  3. package/dist/cjs/{utils → clients/confluence}/ari.js +5 -5
  4. package/dist/cjs/{utils → clients/confluence}/sourceInfo.js +7 -7
  5. package/dist/cjs/clients/confluence/utils.js +9 -0
  6. package/dist/cjs/hooks/useFetchSyncBlockData.js +5 -6
  7. package/dist/cjs/hooks/useFetchSyncBlockTitle.js +1 -1
  8. package/dist/cjs/hooks/useHandleContentChanges.js +1 -1
  9. package/dist/cjs/index.js +27 -14
  10. package/dist/cjs/providers/block-service/blockServiceAPI.js +4 -4
  11. package/dist/cjs/providers/confluence/confluenceContentAPI.js +12 -12
  12. package/dist/cjs/providers/syncBlockProvider.js +14 -9
  13. package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +35 -9
  14. package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +52 -10
  15. package/dist/cjs/store-manager/syncBlockStoreManager.js +14 -158
  16. package/dist/cjs/utils/utils.js +8 -4
  17. package/dist/es2019/{providers → clients}/block-service/ari.js +1 -1
  18. package/dist/es2019/{utils → clients/confluence}/ari.js +4 -4
  19. package/dist/es2019/{utils → clients/confluence}/sourceInfo.js +5 -5
  20. package/dist/es2019/clients/confluence/utils.js +3 -0
  21. package/dist/es2019/hooks/useFetchSyncBlockData.js +5 -6
  22. package/dist/es2019/hooks/useFetchSyncBlockTitle.js +1 -1
  23. package/dist/es2019/hooks/useHandleContentChanges.js +1 -1
  24. package/dist/es2019/index.js +14 -4
  25. package/dist/es2019/providers/block-service/blockServiceAPI.js +4 -4
  26. package/dist/es2019/providers/confluence/confluenceContentAPI.js +12 -12
  27. package/dist/es2019/providers/syncBlockProvider.js +14 -9
  28. package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +24 -0
  29. package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +39 -1
  30. package/dist/es2019/store-manager/syncBlockStoreManager.js +12 -119
  31. package/dist/es2019/utils/utils.js +3 -3
  32. package/dist/esm/{providers → clients}/block-service/ari.js +1 -1
  33. package/dist/esm/{utils → clients/confluence}/ari.js +4 -4
  34. package/dist/esm/{utils → clients/confluence}/sourceInfo.js +7 -7
  35. package/dist/esm/clients/confluence/utils.js +3 -0
  36. package/dist/esm/hooks/useFetchSyncBlockData.js +5 -6
  37. package/dist/esm/hooks/useFetchSyncBlockTitle.js +1 -1
  38. package/dist/esm/hooks/useHandleContentChanges.js +1 -1
  39. package/dist/esm/index.js +14 -4
  40. package/dist/esm/providers/block-service/blockServiceAPI.js +4 -4
  41. package/dist/esm/providers/confluence/confluenceContentAPI.js +12 -12
  42. package/dist/esm/providers/syncBlockProvider.js +14 -9
  43. package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +36 -9
  44. package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +52 -10
  45. package/dist/esm/store-manager/syncBlockStoreManager.js +14 -159
  46. package/dist/esm/utils/utils.js +7 -3
  47. package/dist/types/{providers → clients}/block-service/ari.d.ts +1 -1
  48. package/dist/types/{utils → clients/block-service}/blockService.d.ts +1 -1
  49. package/dist/types/clients/confluence/ari.d.ts +9 -0
  50. package/dist/types/{utils → clients/confluence}/contentProperty.d.ts +1 -1
  51. package/dist/types/clients/confluence/sourceInfo.d.ts +2 -0
  52. package/dist/types/clients/confluence/utils.d.ts +2 -0
  53. package/dist/types/index.d.ts +4 -3
  54. package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +5 -0
  55. package/dist/types/store-manager/sourceSyncBlockStoreManager.d.ts +17 -1
  56. package/dist/types/store-manager/syncBlockStoreManager.d.ts +4 -59
  57. package/dist/types/utils/utils.d.ts +1 -2
  58. package/dist/types-ts4.5/{providers → clients}/block-service/ari.d.ts +1 -1
  59. package/dist/types-ts4.5/{utils → clients/block-service}/blockService.d.ts +1 -1
  60. package/dist/types-ts4.5/clients/confluence/ari.d.ts +9 -0
  61. package/dist/types-ts4.5/{utils → clients/confluence}/contentProperty.d.ts +1 -1
  62. package/dist/types-ts4.5/clients/confluence/sourceInfo.d.ts +2 -0
  63. package/dist/types-ts4.5/clients/confluence/utils.d.ts +2 -0
  64. package/dist/types-ts4.5/index.d.ts +4 -3
  65. package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +5 -0
  66. package/dist/types-ts4.5/store-manager/sourceSyncBlockStoreManager.d.ts +17 -1
  67. package/dist/types-ts4.5/store-manager/syncBlockStoreManager.d.ts +4 -59
  68. package/dist/types-ts4.5/utils/utils.d.ts +1 -2
  69. package/package.json +2 -2
  70. package/dist/types/utils/ari.d.ts +0 -9
  71. package/dist/types/utils/sourceInfo.d.ts +0 -2
  72. package/dist/types-ts4.5/utils/ari.d.ts +0 -9
  73. package/dist/types-ts4.5/utils/sourceInfo.d.ts +0 -2
  74. /package/dist/cjs/{utils → clients/block-service}/blockService.js +0 -0
  75. /package/dist/cjs/{utils → clients/confluence}/contentProperty.js +0 -0
  76. /package/dist/es2019/{utils → clients/block-service}/blockService.js +0 -0
  77. /package/dist/es2019/{utils → clients/confluence}/contentProperty.js +0 -0
  78. /package/dist/esm/{utils → clients/block-service}/blockService.js +0 -0
  79. /package/dist/esm/{utils → clients/confluence}/contentProperty.js +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @atlaskit/editor-synced-block-provider
2
2
 
3
+ ## 2.10.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`964b980644f9d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/964b980644f9d) -
8
+ EDITOR-3348 Refactor Synced Block Store Manager
9
+ - [`caa54ec7bac4c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/caa54ec7bac4c) -
10
+ EDITOR-3312 Refactor and restructure synced block provider
11
+
3
12
  ## 2.10.2
4
13
 
5
14
  ### Patch Changes
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getLocalIdFromResourceId = exports.blockResourceIdFromSourceAndLocalId = void 0;
6
+ exports.getLocalIdFromBlockResourceId = exports.blockResourceIdFromSourceAndLocalId = void 0;
7
7
  /* eslint-disable require-unicode-regexp */
8
8
  /**
9
9
  * Generates a unique block ARI from a source ARI and a local ID.
@@ -25,7 +25,7 @@ var blockResourceIdFromSourceAndLocalId = exports.blockResourceIdFromSourceAndLo
25
25
  * @param ari - the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
26
26
  * @returns the localId of the block node. A randomly generated UUID
27
27
  */
28
- var getLocalIdFromResourceId = exports.getLocalIdFromResourceId = function getLocalIdFromResourceId(ari) {
28
+ var getLocalIdFromBlockResourceId = exports.getLocalIdFromBlockResourceId = function getLocalIdFromBlockResourceId(ari) {
29
29
  var match = ari.match(/ari:cloud:blocks:[^:]+:synced-block\/([a-zA-Z0-9-]+)/);
30
30
  if (match !== null && match !== void 0 && match[1]) {
31
31
  return match[1];
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.resourceIdFromSourceAndLocalId = exports.getPageIdAndTypeFromAri = exports.getPageARIFromResourceId = exports.getLocalIdFromAri = exports.getConfluencePageAri = void 0;
6
+ exports.resourceIdFromConfluencePageSourceIdAndLocalId = exports.getPageIdAndTypeFromConfluencePageAri = exports.getPageARIFromContentPropertyResourceId = exports.getLocalIdFromConfluencePageAri = exports.getConfluencePageAri = void 0;
7
7
  /* eslint-disable require-unicode-regexp */
8
8
 
9
9
  var getConfluencePageAri = exports.getConfluencePageAri = function getConfluencePageAri(pageId, cloudId) {
@@ -12,7 +12,7 @@ var getConfluencePageAri = exports.getConfluencePageAri = function getConfluence
12
12
  };
13
13
 
14
14
  // For extracting from Page ARI and also the content property's version of resourceId
15
- var getPageIdAndTypeFromAri = exports.getPageIdAndTypeFromAri = function getPageIdAndTypeFromAri(ari) {
15
+ var getPageIdAndTypeFromConfluencePageAri = exports.getPageIdAndTypeFromConfluencePageAri = function getPageIdAndTypeFromConfluencePageAri(ari) {
16
16
  var match = ari.match(/ari:cloud:confluence:[^:]+:(page|blogpost)\/(\d+)/);
17
17
  if (match !== null && match !== void 0 && match[2]) {
18
18
  return {
@@ -22,20 +22,20 @@ var getPageIdAndTypeFromAri = exports.getPageIdAndTypeFromAri = function getPage
22
22
  }
23
23
  throw new Error("Invalid page ARI: ".concat(ari));
24
24
  };
25
- var getLocalIdFromAri = exports.getLocalIdFromAri = function getLocalIdFromAri(ari) {
25
+ var getLocalIdFromConfluencePageAri = exports.getLocalIdFromConfluencePageAri = function getLocalIdFromConfluencePageAri(ari) {
26
26
  var match = ari.match(/ari:cloud:confluence:[^:]+:(page|blogpost)\/\d+\/([a-zA-Z0-9-]+)/);
27
27
  if (match !== null && match !== void 0 && match[2]) {
28
28
  return match[2];
29
29
  }
30
30
  throw new Error("Invalid page ARI: ".concat(ari));
31
31
  };
32
- var getPageARIFromResourceId = exports.getPageARIFromResourceId = function getPageARIFromResourceId(resourceId) {
32
+ var getPageARIFromContentPropertyResourceId = exports.getPageARIFromContentPropertyResourceId = function getPageARIFromContentPropertyResourceId(resourceId) {
33
33
  var match = resourceId.match(/(ari:cloud:confluence:[^:]+:(page|blogpost)\/\d+)\/([a-zA-Z0-9-]+)$/);
34
34
  if (match !== null && match !== void 0 && match[1]) {
35
35
  return match[1];
36
36
  }
37
37
  throw new Error("Invalid resourceId: ".concat(resourceId));
38
38
  };
39
- var resourceIdFromSourceAndLocalId = exports.resourceIdFromSourceAndLocalId = function resourceIdFromSourceAndLocalId(sourceId, localId) {
39
+ var resourceIdFromConfluencePageSourceIdAndLocalId = exports.resourceIdFromConfluencePageSourceIdAndLocalId = function resourceIdFromConfluencePageSourceIdAndLocalId(sourceId, localId) {
40
40
  return sourceId + '/' + localId;
41
41
  };
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.fetchSourceInfo = void 0;
7
+ exports.fetchConfluenceSourceInfo = void 0;
8
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
10
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
@@ -27,7 +27,7 @@ var GET_SOURCE_INFO_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_GET_SOURCE_INFO';
27
27
  * @returns subType live if livePage, subType null if classic page
28
28
  */
29
29
  var GET_SOURCE_INFO_QUERY = "query ".concat(GET_SOURCE_INFO_OPERATION_NAME, " ($id: ID!) {\n\tcontent (id: $id) {\n\t\tnodes {\n\t\t\tid\n\t\t\tlinks {\n\t\t\t\tbase\n\t\t\t}\n\t\t\tspace {\n\t\t\t\tkey\n\t\t\t}\n\t\t\tsubType\n\t\t\ttitle\n\t\t}\n\t}\n}");
30
- var getSourceInfo = /*#__PURE__*/function () {
30
+ var getConfluenceSourceInfo = /*#__PURE__*/function () {
31
31
  var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(ari) {
32
32
  var bodyData, response;
33
33
  return _regenerator.default.wrap(function _callee$(_context) {
@@ -64,20 +64,20 @@ var getSourceInfo = /*#__PURE__*/function () {
64
64
  }
65
65
  }, _callee);
66
66
  }));
67
- return function getSourceInfo(_x) {
67
+ return function getConfluenceSourceInfo(_x) {
68
68
  return _ref.apply(this, arguments);
69
69
  };
70
70
  }();
71
- var fetchSourceInfo = exports.fetchSourceInfo = /*#__PURE__*/function () {
71
+ var fetchConfluenceSourceInfo = exports.fetchConfluenceSourceInfo = /*#__PURE__*/function () {
72
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)(pageAri), pageType = _getPageIdAndTypeFrom.type;
78
+ _getPageIdAndTypeFrom = (0, _ari.getPageIdAndTypeFromConfluencePageAri)(pageAri), pageType = _getPageIdAndTypeFrom.type;
79
79
  _context2.next = 4;
80
- return getSourceInfo(pageAri);
80
+ return getConfluenceSourceInfo(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];
@@ -113,7 +113,7 @@ var fetchSourceInfo = exports.fetchSourceInfo = /*#__PURE__*/function () {
113
113
  }
114
114
  }, _callee2, null, [[0, 15]]);
115
115
  }));
116
- return function fetchSourceInfo(_x2, _x3) {
116
+ return function fetchConfluenceSourceInfo(_x2, _x3) {
117
117
  return _ref2.apply(this, arguments);
118
118
  };
119
119
  }();
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isBlogPageType = void 0;
7
+ var isBlogPageType = exports.isBlogPageType = function isBlogPageType(pageType) {
8
+ return pageType === 'blogpost';
9
+ };
@@ -20,7 +20,6 @@ var useFetchSyncBlockData = exports.useFetchSyncBlockData = function useFetchSyn
20
20
  _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
21
21
  isLoading = _useState4[0],
22
22
  setIsLoading = _useState4[1];
23
- var referenceSyncBlockStoreManager = manager.getReferenceSyncBlockStoreManager();
24
23
  var reloadData = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
25
24
  var syncBlockNode;
26
25
  return _regenerator.default.wrap(function _callee$(_context) {
@@ -42,7 +41,7 @@ var useFetchSyncBlockData = exports.useFetchSyncBlockData = function useFetchSyn
42
41
  setIsLoading(true);
43
42
  _context.prev = 6;
44
43
  _context.next = 9;
45
- return referenceSyncBlockStoreManager.fetchSyncBlocksData([syncBlockNode]);
44
+ return manager.referenceManager.fetchSyncBlocksData([syncBlockNode]);
46
45
  case 9:
47
46
  _context.next = 14;
48
47
  break;
@@ -61,19 +60,19 @@ var useFetchSyncBlockData = exports.useFetchSyncBlockData = function useFetchSyn
61
60
  return _context.stop();
62
61
  }
63
62
  }, _callee, null, [[6, 11]]);
64
- })), [isLoading, localId, referenceSyncBlockStoreManager, resourceId]);
63
+ })), [isLoading, localId, manager.referenceManager, resourceId]);
65
64
  (0, _react.useEffect)(function () {
66
- var unsubscribe = referenceSyncBlockStoreManager.subscribeToSyncBlock(resourceId || '', localId || '', function (data) {
65
+ var unsubscribe = manager.referenceManager.subscribeToSyncBlock(resourceId || '', localId || '', function (data) {
67
66
  setSyncBlockInstance(data);
68
67
  setIsLoading(false);
69
68
  });
70
69
  return function () {
71
70
  unsubscribe();
72
71
  };
73
- }, [localId, referenceSyncBlockStoreManager, resourceId]);
72
+ }, [localId, manager.referenceManager, resourceId]);
74
73
  return {
75
74
  isLoading: isLoading,
76
- providerFactory: referenceSyncBlockStoreManager.getProviderFactory(resourceId || ''),
75
+ providerFactory: manager.referenceManager.getProviderFactory(resourceId || ''),
77
76
  reloadData: reloadData,
78
77
  syncBlockInstance: syncBlockInstance
79
78
  };
@@ -13,7 +13,7 @@ var useFetchSyncBlockTitle = exports.useFetchSyncBlockTitle = function useFetchS
13
13
  sourceTitle = _useState2[0],
14
14
  setSourceTitle = _useState2[1];
15
15
  (0, _react.useEffect)(function () {
16
- var unsubscribe = manager.subscribeToSyncBlockSourceTitle(syncBlockNode, function (title) {
16
+ var unsubscribe = manager.referenceManager.subscribeToSourceTitle(syncBlockNode, function (title) {
17
17
  setSourceTitle(title);
18
18
  });
19
19
  return function () {
@@ -8,7 +8,7 @@ var _react = require("react");
8
8
  var useHandleContentChanges = exports.useHandleContentChanges = function useHandleContentChanges(manager, syncBlockNode) {
9
9
  (0, _react.useEffect)(function () {
10
10
  try {
11
- manager.updateSyncBlockData(syncBlockNode);
11
+ manager.sourceManager.updateSyncBlockData(syncBlockNode);
12
12
  } catch (_unused) {
13
13
  //TODO: EDITOR-1921 - add error analytics
14
14
  }
package/dist/cjs/index.js CHANGED
@@ -33,6 +33,12 @@ Object.defineProperty(exports, "blockResourceIdFromSourceAndLocalId", {
33
33
  return _ari.blockResourceIdFromSourceAndLocalId;
34
34
  }
35
35
  });
36
+ Object.defineProperty(exports, "convertPMNodesToSyncBlockNodes", {
37
+ enumerable: true,
38
+ get: function get() {
39
+ return _utils.convertPMNodesToSyncBlockNodes;
40
+ }
41
+ });
36
42
  Object.defineProperty(exports, "convertSyncBlockJSONNodeToSyncBlockNode", {
37
43
  enumerable: true,
38
44
  get: function get() {
@@ -57,34 +63,40 @@ Object.defineProperty(exports, "createSyncBlockNode", {
57
63
  return _utils.createSyncBlockNode;
58
64
  }
59
65
  });
66
+ Object.defineProperty(exports, "fetchConfluenceSourceInfo", {
67
+ enumerable: true,
68
+ get: function get() {
69
+ return _sourceInfo.fetchConfluenceSourceInfo;
70
+ }
71
+ });
60
72
  Object.defineProperty(exports, "getConfluencePageAri", {
61
73
  enumerable: true,
62
74
  get: function get() {
63
75
  return _ari2.getConfluencePageAri;
64
76
  }
65
77
  });
66
- Object.defineProperty(exports, "getLocalIdFromAri", {
78
+ Object.defineProperty(exports, "getLocalIdFromBlockResourceId", {
67
79
  enumerable: true,
68
80
  get: function get() {
69
- return _ari2.getLocalIdFromAri;
81
+ return _ari.getLocalIdFromBlockResourceId;
70
82
  }
71
83
  });
72
- Object.defineProperty(exports, "getLocalIdFromResourceId", {
84
+ Object.defineProperty(exports, "getLocalIdFromConfluencePageAri", {
73
85
  enumerable: true,
74
86
  get: function get() {
75
- return _ari.getLocalIdFromResourceId;
87
+ return _ari2.getLocalIdFromConfluencePageAri;
76
88
  }
77
89
  });
78
- Object.defineProperty(exports, "getPageARIFromResourceId", {
90
+ Object.defineProperty(exports, "getPageARIFromContentPropertyResourceId", {
79
91
  enumerable: true,
80
92
  get: function get() {
81
- return _ari2.getPageARIFromResourceId;
93
+ return _ari2.getPageARIFromContentPropertyResourceId;
82
94
  }
83
95
  });
84
- Object.defineProperty(exports, "getPageIdAndTypeFromAri", {
96
+ Object.defineProperty(exports, "getPageIdAndTypeFromConfluencePageAri", {
85
97
  enumerable: true,
86
98
  get: function get() {
87
- return _ari2.getPageIdAndTypeFromAri;
99
+ return _ari2.getPageIdAndTypeFromConfluencePageAri;
88
100
  }
89
101
  });
90
102
  Object.defineProperty(exports, "rebaseTransaction", {
@@ -99,10 +111,10 @@ Object.defineProperty(exports, "resolveSyncBlockInstance", {
99
111
  return _resolveSyncBlockInstance.resolveSyncBlockInstance;
100
112
  }
101
113
  });
102
- Object.defineProperty(exports, "resourceIdFromSourceAndLocalId", {
114
+ Object.defineProperty(exports, "resourceIdFromConfluencePageSourceIdAndLocalId", {
103
115
  enumerable: true,
104
116
  get: function get() {
105
- return _ari2.resourceIdFromSourceAndLocalId;
117
+ return _ari2.resourceIdFromConfluencePageSourceIdAndLocalId;
106
118
  }
107
119
  });
108
120
  Object.defineProperty(exports, "useFetchSyncBlockData", {
@@ -146,12 +158,13 @@ var _types = require("./common/types");
146
158
  var _useFetchSyncBlockData = require("./hooks/useFetchSyncBlockData");
147
159
  var _useFetchSyncBlockTitle = require("./hooks/useFetchSyncBlockTitle");
148
160
  var _useHandleContentChanges = require("./hooks/useHandleContentChanges");
149
- var _ari = require("./providers/block-service/ari");
161
+ var _ari = require("./clients/block-service/ari");
162
+ var _ari2 = require("./clients/confluence/ari");
150
163
  var _blockServiceAPI = require("./providers/block-service/blockServiceAPI");
151
164
  var _confluenceContentAPI = require("./providers/confluence/confluenceContentAPI");
165
+ var _sourceInfo = require("./clients/confluence/sourceInfo");
152
166
  var _syncBlockProvider = require("./providers/syncBlockProvider");
153
167
  var _referenceSyncBlockStoreManager = require("./store-manager/referenceSyncBlockStoreManager");
154
168
  var _syncBlockStoreManager = require("./store-manager/syncBlockStoreManager");
155
- var _ari2 = require("./utils/ari");
156
- var _utils = require("./utils/utils");
157
- var _resolveSyncBlockInstance = require("./utils/resolveSyncBlockInstance");
169
+ var _resolveSyncBlockInstance = require("./utils/resolveSyncBlockInstance");
170
+ var _utils = require("./utils/utils");
@@ -10,10 +10,10 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
10
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
11
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
12
  var _react = require("react");
13
+ var _ari = require("../../clients/block-service/ari");
14
+ var _blockService = require("../../clients/block-service/blockService");
13
15
  var _types = require("../../common/types");
14
- var _blockService = require("../../utils/blockService");
15
16
  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:
@@ -41,7 +41,7 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
41
41
  return _regenerator.default.wrap(function _callee$(_context) {
42
42
  while (1) switch (_context.prev = _context.next) {
43
43
  case 0:
44
- localId = (0, _ari.getLocalIdFromResourceId)(resourceId);
44
+ localId = (0, _ari.getLocalIdFromBlockResourceId)(resourceId);
45
45
  _context.prev = 1;
46
46
  _context.next = 4;
47
47
  return (0, _blockService.getSyncedBlockContent)({
@@ -101,7 +101,7 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
101
101
  value: function retrieveSourceInfoFetchData(resourceId, pageARI) {
102
102
  var sourceLocalId;
103
103
  try {
104
- sourceLocalId = (0, _ari.getLocalIdFromResourceId)(resourceId);
104
+ sourceLocalId = (0, _ari.getLocalIdFromBlockResourceId)(resourceId);
105
105
  } catch (error) {
106
106
  // EDITOR-1921: log analytic here, safe to continue
107
107
  }
@@ -12,11 +12,11 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
12
12
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
13
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
14
14
  var _react = require("react");
15
+ var _ari = require("../../clients/confluence/ari");
16
+ var _contentProperty3 = require("../../clients/confluence/contentProperty");
17
+ var _utils = require("../../clients/confluence/utils");
15
18
  var _types = require("../../common/types");
16
- var _ari = require("../../utils/ari");
17
- var _contentProperty3 = require("../../utils/contentProperty");
18
19
  var _errorHandling = require("../../utils/errorHandling");
19
- var _utils = require("../../utils/utils");
20
20
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
21
21
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
22
22
  /**
@@ -69,8 +69,8 @@ var ConfluenceADFFetchProvider = /*#__PURE__*/function () {
69
69
  return _regenerator.default.wrap(function _callee$(_context) {
70
70
  while (1) switch (_context.prev = _context.next) {
71
71
  case 0:
72
- _getPageIdAndTypeFrom = (0, _ari.getPageIdAndTypeFromAri)(resourceId), pageId = _getPageIdAndTypeFrom.id, pageType = _getPageIdAndTypeFrom.type;
73
- localId = (0, _ari.getLocalIdFromAri)(resourceId);
72
+ _getPageIdAndTypeFrom = (0, _ari.getPageIdAndTypeFromConfluencePageAri)(resourceId), pageId = _getPageIdAndTypeFrom.id, pageType = _getPageIdAndTypeFrom.type;
73
+ localId = (0, _ari.getLocalIdFromConfluencePageAri)(resourceId);
74
74
  _context.prev = 2;
75
75
  key = getContentPropertyKey(this.config.contentPropertyKey, localId);
76
76
  options = {
@@ -139,10 +139,10 @@ var ConfluenceADFFetchProvider = /*#__PURE__*/function () {
139
139
  }, {
140
140
  key: "retrieveSourceInfoFetchData",
141
141
  value: function retrieveSourceInfoFetchData(resourceId) {
142
- var pageARI = (0, _ari.getPageARIFromResourceId)(resourceId);
142
+ var pageARI = (0, _ari.getPageARIFromContentPropertyResourceId)(resourceId);
143
143
  var sourceLocalId;
144
144
  try {
145
- sourceLocalId = (0, _ari.getLocalIdFromAri)(resourceId);
145
+ sourceLocalId = (0, _ari.getLocalIdFromConfluencePageAri)(resourceId);
146
146
  } catch (error) {
147
147
  // EDITOR-1921: log analytic here, safe to continue
148
148
  }
@@ -225,7 +225,7 @@ var ConfluenceADFWriteProvider = /*#__PURE__*/function () {
225
225
  case 0:
226
226
  resourceId = data.resourceId;
227
227
  _context3.prev = 1;
228
- match = (0, _ari.getPageIdAndTypeFromAri)(data.resourceId);
228
+ match = (0, _ari.getPageIdAndTypeFromConfluencePageAri)(data.resourceId);
229
229
  _context3.next = 8;
230
230
  break;
231
231
  case 5:
@@ -238,7 +238,7 @@ var ConfluenceADFWriteProvider = /*#__PURE__*/function () {
238
238
  _match = match, pageId = _match.id, pageType = _match.type;
239
239
  _context3.prev = 9;
240
240
  // Update existing content property
241
- localId = (0, _ari.getLocalIdFromAri)(resourceId);
241
+ localId = (0, _ari.getLocalIdFromConfluencePageAri)(resourceId);
242
242
  key = getContentPropertyKey(this.config.contentPropertyKey, localId);
243
243
  sourceAri = (0, _ari.getConfluencePageAri)(pageId, this.config.cloudId, pageType);
244
244
  syncBlockDataWithSourceDocumentAri = _objectSpread(_objectSpread({}, data), {}, {
@@ -311,7 +311,7 @@ var ConfluenceADFWriteProvider = /*#__PURE__*/function () {
311
311
  while (1) switch (_context4.prev = _context4.next) {
312
312
  case 0:
313
313
  _context4.prev = 0;
314
- match = (0, _ari.getPageIdAndTypeFromAri)(resourceId);
314
+ match = (0, _ari.getPageIdAndTypeFromConfluencePageAri)(resourceId);
315
315
  _context4.next = 7;
316
316
  break;
317
317
  case 4:
@@ -325,7 +325,7 @@ var ConfluenceADFWriteProvider = /*#__PURE__*/function () {
325
325
  case 7:
326
326
  _match2 = match, pageId = _match2.id, pageType = _match2.type;
327
327
  _context4.prev = 8;
328
- localId = (0, _ari.getLocalIdFromAri)(resourceId);
328
+ localId = (0, _ari.getLocalIdFromConfluencePageAri)(resourceId);
329
329
  key = getContentPropertyKey(this.config.contentPropertyKey, localId);
330
330
  options = {
331
331
  pageId: pageId,
@@ -368,7 +368,7 @@ var ConfluenceADFWriteProvider = /*#__PURE__*/function () {
368
368
  }, {
369
369
  key: "generateResourceId",
370
370
  value: function generateResourceId(sourceId, localId) {
371
- return (0, _ari.resourceIdFromSourceAndLocalId)(sourceId, localId);
371
+ return (0, _ari.resourceIdFromConfluencePageSourceIdAndLocalId)(sourceId, localId);
372
372
  }
373
373
  }]);
374
374
  }();
@@ -15,10 +15,10 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
15
15
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
16
16
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
17
  var _react = require("react");
18
+ var _ari = require("../clients/confluence/ari");
19
+ var _sourceInfo = require("../clients/confluence/sourceInfo");
18
20
  var _types = require("../common/types");
19
21
  var _types2 = require("../providers/types");
20
- var _ari = require("../utils/ari");
21
- var _sourceInfo = require("../utils/sourceInfo");
22
22
  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
23
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
24
24
  var SyncBlockProvider = exports.SyncBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
@@ -233,7 +233,10 @@ var SyncBlockProvider = exports.SyncBlockProvider = /*#__PURE__*/function (_Sync
233
233
  return Promise.reject(error);
234
234
  }
235
235
  }
236
- return pageARI ? (0, _sourceInfo.fetchSourceInfo)(pageARI, sourceLocalId) : Promise.resolve(undefined);
236
+
237
+ // TODO: EDITOR-3312 - based on the source sync block product,
238
+ // execute fetchConfluenceSourceInfo or fetchJiraItemSourceInfo or similar...
239
+ return pageARI ? (0, _sourceInfo.fetchConfluenceSourceInfo)(pageARI, sourceLocalId) : Promise.resolve(undefined);
237
240
  }
238
241
  }, {
239
242
  key: "generateResourceId",
@@ -268,16 +271,18 @@ var SyncBlockProvider = exports.SyncBlockProvider = /*#__PURE__*/function (_Sync
268
271
  }
269
272
  var _syncBlockInstance$da = syncBlockInstance.data,
270
273
  sourceAri = _syncBlockInstance$da.sourceAri,
271
- resourceId = _syncBlockInstance$da.resourceId,
272
- contentProduct = _syncBlockInstance$da.product;
274
+ product = _syncBlockInstance$da.product;
275
+ if (!sourceAri || !product) {
276
+ return undefined;
277
+ }
273
278
 
274
- // Temp solution to get the pageId from resource since the sourceDocumentAri is not available for older sync blocks
275
- var pageARI = sourceAri || resourceId;
276
- var _getPageIdAndTypeFrom = (0, _ari.getPageIdAndTypeFromAri)(pageARI),
279
+ // TODO: EDITOR-3312 - based on the source sync block product,
280
+ // execute getPageIdAndTypeFromConfluencePageAri or getJiraItemIdAndTypeFromJiraItemAri or similar...
281
+ var _getPageIdAndTypeFrom = (0, _ari.getPageIdAndTypeFromConfluencePageAri)(sourceAri),
277
282
  contentId = _getPageIdAndTypeFrom.id;
278
283
  return {
279
284
  contentId: contentId,
280
- contentProduct: contentProduct || 'confluence-page'
285
+ contentProduct: product
281
286
  };
282
287
  }
283
288
  }]);
@@ -20,6 +20,11 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
20
20
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
21
21
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
22
22
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
23
+ // A store manager responsible for the lifecycle and state management of reference sync blocks in an editor instance.
24
+ // Designed to manage local in-memory state and synchronize with an external data provider.
25
+ // Supports fetch, cache, and subscription for sync block data.
26
+ // Handles fetching source URL and title for sync blocks.
27
+ // Can be used in both editor and renderer contexts.
23
28
  var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
24
29
  function ReferenceSyncBlockStoreManager(dataProvider) {
25
30
  (0, _classCallCheck2.default)(this, ReferenceSyncBlockStoreManager);
@@ -123,6 +128,8 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
123
128
  return;
124
129
  }
125
130
 
131
+ // TODO: EDITOR-3312 - retrieve the source info based on the source sync block product
132
+
126
133
  // if the sync block is a reference block, we need to fetch the URL to the source
127
134
  // we could optimise this further by checking if the sync block is on the same page as the source
128
135
  if (!this.syncBlockURLRequests.get(resourceId)) {
@@ -144,21 +151,33 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
144
151
  });
145
152
  }
146
153
  }
154
+
155
+ /**
156
+ * Fetch sync block data for a given array of sync block nodes.
157
+ * @param syncBlockNodes - The array of sync block nodes to fetch data for
158
+ * @returns The fetched sync block data results
159
+ */
147
160
  }, {
148
161
  key: "fetchSyncBlocksData",
149
- value: function () {
162
+ value: (function () {
150
163
  var _fetchSyncBlocksData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(syncBlockNodes) {
151
164
  var _this2 = this;
152
165
  var nodesToFetch, blocksWithNotFoundError, data, resolvedData;
153
166
  return _regenerator.default.wrap(function _callee2$(_context3) {
154
167
  while (1) switch (_context3.prev = _context3.next) {
155
168
  case 0:
156
- if (this.dataProvider) {
169
+ if (!(syncBlockNodes.length === 0)) {
157
170
  _context3.next = 2;
158
171
  break;
159
172
  }
160
- throw new Error('Data provider not set');
173
+ return _context3.abrupt("return", Promise.resolve([]));
161
174
  case 2:
175
+ if (this.dataProvider) {
176
+ _context3.next = 4;
177
+ break;
178
+ }
179
+ throw new Error('Data provider not set');
180
+ case 4:
162
181
  // Don't fetch for not_found error since the source is already deleted
163
182
  nodesToFetch = [], blocksWithNotFoundError = [];
164
183
  syncBlockNodes.forEach(function (node) {
@@ -169,16 +188,16 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
169
188
  nodesToFetch.push(node);
170
189
  }
171
190
  });
172
- _context3.next = 6;
191
+ _context3.next = 8;
173
192
  return this.dataProvider.fetchNodesData(nodesToFetch);
174
- case 6:
193
+ case 8:
175
194
  data = _context3.sent;
176
195
  if (data) {
177
- _context3.next = 9;
196
+ _context3.next = 11;
178
197
  break;
179
198
  }
180
199
  throw new Error('Failed to fetch sync block node data');
181
- case 9:
200
+ case 11:
182
201
  resolvedData = [];
183
202
  data.forEach(function (syncBlockInstance) {
184
203
  var _resolvedSyncBlockIns, _resolvedSyncBlockIns2;
@@ -201,7 +220,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
201
220
  }
202
221
  });
203
222
  return _context3.abrupt("return", [].concat(resolvedData, blocksWithNotFoundError));
204
- case 12:
223
+ case 14:
205
224
  case "end":
206
225
  return _context3.stop();
207
226
  }
@@ -211,7 +230,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
211
230
  return _fetchSyncBlocksData.apply(this, arguments);
212
231
  }
213
232
  return fetchSyncBlocksData;
214
- }()
233
+ }())
215
234
  }, {
216
235
  key: "updateCache",
217
236
  value: function updateCache(syncBlock) {
@@ -407,10 +426,17 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
407
426
  }, {
408
427
  key: "destroy",
409
428
  value: function destroy() {
429
+ this.dataProvider = undefined;
410
430
  this.syncBlockCache.clear();
411
431
  this.subscriptions.clear();
432
+ this.titleSubscriptions.clear();
412
433
  this.syncBlockURLRequests.clear();
413
434
  this.providerFactories.clear();
435
+ this.isRefreshingSubscriptions = false;
436
+ this.providerFactories.forEach(function (providerFactory) {
437
+ providerFactory.destroy();
438
+ });
439
+ this.providerFactories.clear();
414
440
  }
415
441
  }]);
416
442
  }();