@atlaskit/editor-synced-block-provider 2.16.0 → 2.16.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/editor-synced-block-provider
2
2
 
3
+ ## 2.16.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`98568bfc82648`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/98568bfc82648) -
8
+ Export SyncedBlockRendererDataProviders type
9
+ - Updated dependencies
10
+
11
+ ## 2.16.1
12
+
13
+ ### Patch Changes
14
+
15
+ - [`5f9c5b4ae25c7`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5f9c5b4ae25c7) -
16
+ EDITOR-3594 Add Jira ARI utility functions to synced block provider
17
+
3
18
  ## 2.16.0
4
19
 
5
20
  ### Minor Changes
@@ -23,7 +23,7 @@ var generateBlockAri = exports.generateBlockAri = function generateBlockAri(sour
23
23
  };
24
24
 
25
25
  /**
26
- *
26
+ * Generates the block ARI from the reference synced block ARI and the resource ID
27
27
  * @param sourceAri - the ARI of the document. E.G ari:cloud:confluence:cloudId:page/pageId
28
28
  * @param resourceId - the resource ID of the reference synced block. E.G confluence-page/pageId/sourceResourceId
29
29
  * @returns the block ARI. E.G ari:cloud:blocks:<cloudId>:synced-block/<product>/<pageId>/<resourceId>
@@ -3,15 +3,30 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.resourceIdFromConfluencePageSourceIdAndLocalId = exports.getPageIdAndTypeFromConfluencePageAri = exports.getPageARIFromContentPropertyResourceId = exports.getLocalIdFromConfluencePageAri = exports.getConfluencePageAri = void 0;
6
+ exports.resourceIdFromConfluencePageSourceIdAndLocalId = exports.getPageIdAndTypeFromConfluencePageAri = exports.getPageAriFromContentPropertyResourceId = exports.getLocalIdFromContentPropertyResourceId = exports.getConfluencePageAri = void 0;
7
7
  /* eslint-disable require-unicode-regexp */
8
8
 
9
+ /**
10
+ * The type of the Confluence page
11
+ */
12
+
13
+ /**
14
+ * Generates the Confluence page ARI
15
+ * @param pageId - the ID of the page
16
+ * @param cloudId - the cloud ID
17
+ * @param pageType - the type of the page
18
+ * @returns the Confluence page ARI
19
+ */
9
20
  var getConfluencePageAri = exports.getConfluencePageAri = function getConfluencePageAri(pageId, cloudId) {
10
21
  var pageType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'page';
11
22
  return "ari:cloud:confluence:".concat(cloudId, ":").concat(pageType, "/").concat(pageId);
12
23
  };
13
24
 
14
- // For extracting from Page ARI and also the content property's version of resourceId
25
+ /**
26
+ * Extracts the page ID and type from the Confluence page ARI
27
+ * @param ari - the Confluence page ARI
28
+ * @returns the page ID and type
29
+ */
15
30
  var getPageIdAndTypeFromConfluencePageAri = exports.getPageIdAndTypeFromConfluencePageAri = function getPageIdAndTypeFromConfluencePageAri(ari) {
16
31
  var match = ari.match(/ari:cloud:confluence:[^:]+:(page|blogpost)\/(\d+)/);
17
32
  if (match !== null && match !== void 0 && match[2]) {
@@ -22,20 +37,39 @@ var getPageIdAndTypeFromConfluencePageAri = exports.getPageIdAndTypeFromConfluen
22
37
  }
23
38
  throw new Error("Invalid page ARI: ".concat(ari));
24
39
  };
25
- var getLocalIdFromConfluencePageAri = exports.getLocalIdFromConfluencePageAri = function getLocalIdFromConfluencePageAri(ari) {
26
- var match = ari.match(/ari:cloud:confluence:[^:]+:(page|blogpost)\/\d+\/([a-zA-Z0-9-]+)/);
40
+
41
+ /**
42
+ * Extracts the local ID from the Confluence page content property resource ID
43
+ * @param resourceId - the Confluence page content property resource ID
44
+ * @returns the local ID
45
+ */
46
+ var getLocalIdFromContentPropertyResourceId = exports.getLocalIdFromContentPropertyResourceId = function getLocalIdFromContentPropertyResourceId(resourceId) {
47
+ var match = resourceId.match(/ari:cloud:confluence:[^:]+:(page|blogpost)\/\d+\/([a-zA-Z0-9-]+)/);
27
48
  if (match !== null && match !== void 0 && match[2]) {
28
49
  return match[2];
29
50
  }
30
- throw new Error("Invalid page ARI: ".concat(ari));
51
+ throw new Error("Invalid resourceId: ".concat(resourceId));
31
52
  };
32
- var getPageARIFromContentPropertyResourceId = exports.getPageARIFromContentPropertyResourceId = function getPageARIFromContentPropertyResourceId(resourceId) {
53
+
54
+ /**
55
+ * Extracts the Confluence page ARI from the Confluence content property resource ID
56
+ * @param resourceId - the Confluence content property resource ID
57
+ * @returns the Confluence page ARI
58
+ */
59
+ var getPageAriFromContentPropertyResourceId = exports.getPageAriFromContentPropertyResourceId = function getPageAriFromContentPropertyResourceId(resourceId) {
33
60
  var match = resourceId.match(/(ari:cloud:confluence:[^:]+:(page|blogpost)\/\d+)\/([a-zA-Z0-9-]+)$/);
34
61
  if (match !== null && match !== void 0 && match[1]) {
35
62
  return match[1];
36
63
  }
37
64
  throw new Error("Invalid resourceId: ".concat(resourceId));
38
65
  };
66
+
67
+ /**
68
+ * Generates the Confluence page content property resource ID from the source ID and local ID
69
+ * @param sourceId - the source ID
70
+ * @param localId - the local ID
71
+ * @returns the Confluence page content property resource ID
72
+ */
39
73
  var resourceIdFromConfluencePageSourceIdAndLocalId = exports.resourceIdFromConfluencePageSourceIdAndLocalId = function resourceIdFromConfluencePageSourceIdAndLocalId(sourceId, localId) {
40
- return sourceId + '/' + localId;
74
+ return "".concat(sourceId, "/").concat(localId);
41
75
  };
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getJiraWorkItemIdFromAri = exports.getJiraWorkItemAri = void 0;
7
+ /* eslint-disable require-unicode-regexp */
8
+
9
+ /**
10
+ * Generates the Jira work item ARI
11
+ * @param workItemId - the ID of the work item
12
+ * @param cloudId - the cloud ID
13
+ * @returns the Jira work item ARI
14
+ */
15
+ var getJiraWorkItemAri = exports.getJiraWorkItemAri = function getJiraWorkItemAri(workItemId, cloudId) {
16
+ return "ari:cloud:jira:".concat(cloudId, ":issue/").concat(workItemId);
17
+ };
18
+
19
+ /**
20
+ * Extracts the Jira work item ID from the Jira work item ARI
21
+ * @param ari - the Jira work item ARI
22
+ * @returns the Jira work item ID
23
+ */
24
+ var getJiraWorkItemIdFromAri = exports.getJiraWorkItemIdFromAri = function getJiraWorkItemIdFromAri(ari) {
25
+ var match = ari.match(/ari:cloud:jira:([^:]+):issue\/(\d+)/);
26
+ if (match !== null && match !== void 0 && match[2]) {
27
+ return match[2];
28
+ }
29
+ throw new Error("Invalid Jira work item ARI: ".concat(ari));
30
+ };
package/dist/cjs/index.js CHANGED
@@ -93,22 +93,34 @@ Object.defineProperty(exports, "getContentIdAndProductFromResourceId", {
93
93
  return _utils.getContentIdAndProductFromResourceId;
94
94
  }
95
95
  });
96
+ Object.defineProperty(exports, "getJiraWorkItemAri", {
97
+ enumerable: true,
98
+ get: function get() {
99
+ return _ari3.getJiraWorkItemAri;
100
+ }
101
+ });
102
+ Object.defineProperty(exports, "getJiraWorkItemIdFromAri", {
103
+ enumerable: true,
104
+ get: function get() {
105
+ return _ari3.getJiraWorkItemIdFromAri;
106
+ }
107
+ });
96
108
  Object.defineProperty(exports, "getLocalIdFromBlockResourceId", {
97
109
  enumerable: true,
98
110
  get: function get() {
99
111
  return _ari.getLocalIdFromBlockResourceId;
100
112
  }
101
113
  });
102
- Object.defineProperty(exports, "getLocalIdFromConfluencePageAri", {
114
+ Object.defineProperty(exports, "getLocalIdFromContentPropertyResourceId", {
103
115
  enumerable: true,
104
116
  get: function get() {
105
- return _ari2.getLocalIdFromConfluencePageAri;
117
+ return _ari2.getLocalIdFromContentPropertyResourceId;
106
118
  }
107
119
  });
108
- Object.defineProperty(exports, "getPageARIFromContentPropertyResourceId", {
120
+ Object.defineProperty(exports, "getPageAriFromContentPropertyResourceId", {
109
121
  enumerable: true,
110
122
  get: function get() {
111
- return _ari2.getPageARIFromContentPropertyResourceId;
123
+ return _ari2.getPageAriFromContentPropertyResourceId;
112
124
  }
113
125
  });
114
126
  Object.defineProperty(exports, "getPageIdAndTypeFromConfluencePageAri", {
@@ -184,6 +196,7 @@ var _useFetchSyncBlockTitle = require("./hooks/useFetchSyncBlockTitle");
184
196
  var _useHandleContentChanges = require("./hooks/useHandleContentChanges");
185
197
  var _ari = require("./clients/block-service/ari");
186
198
  var _ari2 = require("./clients/confluence/ari");
199
+ var _ari3 = require("./clients/jira/ari");
187
200
  var _blockServiceAPI = require("./providers/block-service/blockServiceAPI");
188
201
  var _confluenceContentAPI = require("./providers/confluence/confluenceContentAPI");
189
202
  var _sourceInfo = require("./clients/confluence/sourceInfo");
@@ -70,7 +70,7 @@ var ConfluenceADFFetchProvider = /*#__PURE__*/function () {
70
70
  while (1) switch (_context.prev = _context.next) {
71
71
  case 0:
72
72
  _getPageIdAndTypeFrom = (0, _ari.getPageIdAndTypeFromConfluencePageAri)(resourceId), pageId = _getPageIdAndTypeFrom.id, pageType = _getPageIdAndTypeFrom.type;
73
- localId = (0, _ari.getLocalIdFromConfluencePageAri)(resourceId);
73
+ localId = (0, _ari.getLocalIdFromContentPropertyResourceId)(resourceId);
74
74
  _context.prev = 2;
75
75
  key = getContentPropertyKey(this.config.contentPropertyKey, localId);
76
76
  options = {
@@ -234,7 +234,7 @@ var ConfluenceADFWriteProvider = /*#__PURE__*/function () {
234
234
  _match = match, pageId = _match.id, pageType = _match.type;
235
235
  _context3.prev = 9;
236
236
  // Update existing content property
237
- localId = (0, _ari.getLocalIdFromConfluencePageAri)(resourceId);
237
+ localId = (0, _ari.getLocalIdFromContentPropertyResourceId)(resourceId);
238
238
  key = getContentPropertyKey(this.config.contentPropertyKey, localId);
239
239
  sourceAri = (0, _ari.getConfluencePageAri)(pageId, this.config.cloudId, pageType);
240
240
  syncBlockDataWithSourceDocumentAri = _objectSpread(_objectSpread({}, syncBlockData), {}, {
@@ -306,7 +306,7 @@ var ConfluenceADFWriteProvider = /*#__PURE__*/function () {
306
306
  case 8:
307
307
  _match2 = match, pageId = _match2.id, pageType = _match2.type;
308
308
  _context4.prev = 9;
309
- localId = (0, _ari.getLocalIdFromConfluencePageAri)(resourceId);
309
+ localId = (0, _ari.getLocalIdFromContentPropertyResourceId)(resourceId);
310
310
  key = getContentPropertyKey(this.config.contentPropertyKey, localId);
311
311
  sourceAri = (0, _ari.getConfluencePageAri)(pageId, this.config.cloudId, pageType);
312
312
  syncBlockDataWithSourceDocumentAri = _objectSpread(_objectSpread({}, syncBlockData), {}, {
@@ -359,7 +359,7 @@ var ConfluenceADFWriteProvider = /*#__PURE__*/function () {
359
359
  case 7:
360
360
  _match3 = match, pageId = _match3.id, pageType = _match3.type;
361
361
  _context5.prev = 8;
362
- localId = (0, _ari.getLocalIdFromConfluencePageAri)(resourceId);
362
+ localId = (0, _ari.getLocalIdFromContentPropertyResourceId)(resourceId);
363
363
  key = getContentPropertyKey(this.config.contentPropertyKey, localId);
364
364
  options = {
365
365
  pageId: pageId,
@@ -17,7 +17,7 @@ export const generateBlockAri = (sourceAri, resourceId, product) => {
17
17
  };
18
18
 
19
19
  /**
20
- *
20
+ * Generates the block ARI from the reference synced block ARI and the resource ID
21
21
  * @param sourceAri - the ARI of the document. E.G ari:cloud:confluence:cloudId:page/pageId
22
22
  * @param resourceId - the resource ID of the reference synced block. E.G confluence-page/pageId/sourceResourceId
23
23
  * @returns the block ARI. E.G ari:cloud:blocks:<cloudId>:synced-block/<product>/<pageId>/<resourceId>
@@ -1,8 +1,23 @@
1
1
  /* eslint-disable require-unicode-regexp */
2
2
 
3
+ /**
4
+ * The type of the Confluence page
5
+ */
6
+
7
+ /**
8
+ * Generates the Confluence page ARI
9
+ * @param pageId - the ID of the page
10
+ * @param cloudId - the cloud ID
11
+ * @param pageType - the type of the page
12
+ * @returns the Confluence page ARI
13
+ */
3
14
  export const getConfluencePageAri = (pageId, cloudId, pageType = 'page') => `ari:cloud:confluence:${cloudId}:${pageType}/${pageId}`;
4
15
 
5
- // For extracting from Page ARI and also the content property's version of resourceId
16
+ /**
17
+ * Extracts the page ID and type from the Confluence page ARI
18
+ * @param ari - the Confluence page ARI
19
+ * @returns the page ID and type
20
+ */
6
21
  export const getPageIdAndTypeFromConfluencePageAri = ari => {
7
22
  const match = ari.match(/ari:cloud:confluence:[^:]+:(page|blogpost)\/(\d+)/);
8
23
  if (match !== null && match !== void 0 && match[2]) {
@@ -13,20 +28,37 @@ export const getPageIdAndTypeFromConfluencePageAri = ari => {
13
28
  }
14
29
  throw new Error(`Invalid page ARI: ${ari}`);
15
30
  };
16
- export const getLocalIdFromConfluencePageAri = ari => {
17
- const match = ari.match(/ari:cloud:confluence:[^:]+:(page|blogpost)\/\d+\/([a-zA-Z0-9-]+)/);
31
+
32
+ /**
33
+ * Extracts the local ID from the Confluence page content property resource ID
34
+ * @param resourceId - the Confluence page content property resource ID
35
+ * @returns the local ID
36
+ */
37
+ export const getLocalIdFromContentPropertyResourceId = resourceId => {
38
+ const match = resourceId.match(/ari:cloud:confluence:[^:]+:(page|blogpost)\/\d+\/([a-zA-Z0-9-]+)/);
18
39
  if (match !== null && match !== void 0 && match[2]) {
19
40
  return match[2];
20
41
  }
21
- throw new Error(`Invalid page ARI: ${ari}`);
42
+ throw new Error(`Invalid resourceId: ${resourceId}`);
22
43
  };
23
- export const getPageARIFromContentPropertyResourceId = resourceId => {
44
+
45
+ /**
46
+ * Extracts the Confluence page ARI from the Confluence content property resource ID
47
+ * @param resourceId - the Confluence content property resource ID
48
+ * @returns the Confluence page ARI
49
+ */
50
+ export const getPageAriFromContentPropertyResourceId = resourceId => {
24
51
  const match = resourceId.match(/(ari:cloud:confluence:[^:]+:(page|blogpost)\/\d+)\/([a-zA-Z0-9-]+)$/);
25
52
  if (match !== null && match !== void 0 && match[1]) {
26
53
  return match[1];
27
54
  }
28
55
  throw new Error(`Invalid resourceId: ${resourceId}`);
29
56
  };
30
- export const resourceIdFromConfluencePageSourceIdAndLocalId = (sourceId, localId) => {
31
- return sourceId + '/' + localId;
32
- };
57
+
58
+ /**
59
+ * Generates the Confluence page content property resource ID from the source ID and local ID
60
+ * @param sourceId - the source ID
61
+ * @param localId - the local ID
62
+ * @returns the Confluence page content property resource ID
63
+ */
64
+ export const resourceIdFromConfluencePageSourceIdAndLocalId = (sourceId, localId) => `${sourceId}/${localId}`;
@@ -0,0 +1,22 @@
1
+ /* eslint-disable require-unicode-regexp */
2
+
3
+ /**
4
+ * Generates the Jira work item ARI
5
+ * @param workItemId - the ID of the work item
6
+ * @param cloudId - the cloud ID
7
+ * @returns the Jira work item ARI
8
+ */
9
+ export const getJiraWorkItemAri = (workItemId, cloudId) => `ari:cloud:jira:${cloudId}:issue/${workItemId}`;
10
+
11
+ /**
12
+ * Extracts the Jira work item ID from the Jira work item ARI
13
+ * @param ari - the Jira work item ARI
14
+ * @returns the Jira work item ID
15
+ */
16
+ export const getJiraWorkItemIdFromAri = ari => {
17
+ const match = ari.match(/ari:cloud:jira:([^:]+):issue\/(\d+)/);
18
+ if (match !== null && match !== void 0 && match[2]) {
19
+ return match[2];
20
+ }
21
+ throw new Error(`Invalid Jira work item ARI: ${ari}`);
22
+ };
@@ -10,7 +10,8 @@ export { useHandleContentChanges } from './hooks/useHandleContentChanges';
10
10
 
11
11
  // clients
12
12
  export { generateBlockAri, generateBlockAriFromReference, getLocalIdFromBlockResourceId } from './clients/block-service/ari';
13
- export { getConfluencePageAri, getLocalIdFromConfluencePageAri, getPageARIFromContentPropertyResourceId, getPageIdAndTypeFromConfluencePageAri, resourceIdFromConfluencePageSourceIdAndLocalId } from './clients/confluence/ari';
13
+ export { getConfluencePageAri, getLocalIdFromContentPropertyResourceId, getPageAriFromContentPropertyResourceId, getPageIdAndTypeFromConfluencePageAri, resourceIdFromConfluencePageSourceIdAndLocalId } from './clients/confluence/ari';
14
+ export { getJiraWorkItemAri, getJiraWorkItemIdFromAri } from './clients/jira/ari';
14
15
 
15
16
  // providers
16
17
  export { useMemoizedBlockServiceAPIProviders } from './providers/block-service/blockServiceAPI';
@@ -1,6 +1,6 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { useMemo } from 'react';
3
- import { getConfluencePageAri, getLocalIdFromConfluencePageAri, getPageIdAndTypeFromConfluencePageAri, resourceIdFromConfluencePageSourceIdAndLocalId } from '../../clients/confluence/ari';
3
+ import { getConfluencePageAri, getLocalIdFromContentPropertyResourceId, getPageIdAndTypeFromConfluencePageAri, resourceIdFromConfluencePageSourceIdAndLocalId } from '../../clients/confluence/ari';
4
4
  import { getContentProperty, createContentProperty, updateContentProperty, deleteContentProperty } from '../../clients/confluence/contentProperty';
5
5
  import { isBlogPageType } from '../../clients/confluence/utils';
6
6
  import { SyncBlockError } from '../../common/types';
@@ -52,7 +52,7 @@ class ConfluenceADFFetchProvider {
52
52
  id: pageId,
53
53
  type: pageType
54
54
  } = getPageIdAndTypeFromConfluencePageAri(resourceId);
55
- const localId = getLocalIdFromConfluencePageAri(resourceId);
55
+ const localId = getLocalIdFromContentPropertyResourceId(resourceId);
56
56
  try {
57
57
  const key = getContentPropertyKey(this.config.contentPropertyKey, localId);
58
58
  const options = {
@@ -162,7 +162,7 @@ class ConfluenceADFWriteProvider {
162
162
  } = match;
163
163
  try {
164
164
  // Update existing content property
165
- const localId = getLocalIdFromConfluencePageAri(resourceId);
165
+ const localId = getLocalIdFromContentPropertyResourceId(resourceId);
166
166
  const key = getContentPropertyKey(this.config.contentPropertyKey, localId);
167
167
  const sourceAri = getConfluencePageAri(pageId, this.config.cloudId, pageType);
168
168
  const syncBlockDataWithSourceDocumentAri = {
@@ -211,7 +211,7 @@ class ConfluenceADFWriteProvider {
211
211
  type: pageType
212
212
  } = match;
213
213
  try {
214
- const localId = getLocalIdFromConfluencePageAri(resourceId);
214
+ const localId = getLocalIdFromContentPropertyResourceId(resourceId);
215
215
  const key = getContentPropertyKey(this.config.contentPropertyKey, localId);
216
216
  const sourceAri = getConfluencePageAri(pageId, this.config.cloudId, pageType);
217
217
  const syncBlockDataWithSourceDocumentAri = {
@@ -245,7 +245,7 @@ class ConfluenceADFWriteProvider {
245
245
  type: pageType
246
246
  } = match;
247
247
  try {
248
- const localId = getLocalIdFromConfluencePageAri(resourceId);
248
+ const localId = getLocalIdFromContentPropertyResourceId(resourceId);
249
249
  const key = getContentPropertyKey(this.config.contentPropertyKey, localId);
250
250
  const options = {
251
251
  pageId,
@@ -17,7 +17,7 @@ export var generateBlockAri = function generateBlockAri(sourceAri, resourceId, p
17
17
  };
18
18
 
19
19
  /**
20
- *
20
+ * Generates the block ARI from the reference synced block ARI and the resource ID
21
21
  * @param sourceAri - the ARI of the document. E.G ari:cloud:confluence:cloudId:page/pageId
22
22
  * @param resourceId - the resource ID of the reference synced block. E.G confluence-page/pageId/sourceResourceId
23
23
  * @returns the block ARI. E.G ari:cloud:blocks:<cloudId>:synced-block/<product>/<pageId>/<resourceId>
@@ -1,11 +1,26 @@
1
1
  /* eslint-disable require-unicode-regexp */
2
2
 
3
+ /**
4
+ * The type of the Confluence page
5
+ */
6
+
7
+ /**
8
+ * Generates the Confluence page ARI
9
+ * @param pageId - the ID of the page
10
+ * @param cloudId - the cloud ID
11
+ * @param pageType - the type of the page
12
+ * @returns the Confluence page ARI
13
+ */
3
14
  export var getConfluencePageAri = function getConfluencePageAri(pageId, cloudId) {
4
15
  var pageType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'page';
5
16
  return "ari:cloud:confluence:".concat(cloudId, ":").concat(pageType, "/").concat(pageId);
6
17
  };
7
18
 
8
- // For extracting from Page ARI and also the content property's version of resourceId
19
+ /**
20
+ * Extracts the page ID and type from the Confluence page ARI
21
+ * @param ari - the Confluence page ARI
22
+ * @returns the page ID and type
23
+ */
9
24
  export var getPageIdAndTypeFromConfluencePageAri = function getPageIdAndTypeFromConfluencePageAri(ari) {
10
25
  var match = ari.match(/ari:cloud:confluence:[^:]+:(page|blogpost)\/(\d+)/);
11
26
  if (match !== null && match !== void 0 && match[2]) {
@@ -16,20 +31,39 @@ export var getPageIdAndTypeFromConfluencePageAri = function getPageIdAndTypeFrom
16
31
  }
17
32
  throw new Error("Invalid page ARI: ".concat(ari));
18
33
  };
19
- export var getLocalIdFromConfluencePageAri = function getLocalIdFromConfluencePageAri(ari) {
20
- var match = ari.match(/ari:cloud:confluence:[^:]+:(page|blogpost)\/\d+\/([a-zA-Z0-9-]+)/);
34
+
35
+ /**
36
+ * Extracts the local ID from the Confluence page content property resource ID
37
+ * @param resourceId - the Confluence page content property resource ID
38
+ * @returns the local ID
39
+ */
40
+ export var getLocalIdFromContentPropertyResourceId = function getLocalIdFromContentPropertyResourceId(resourceId) {
41
+ var match = resourceId.match(/ari:cloud:confluence:[^:]+:(page|blogpost)\/\d+\/([a-zA-Z0-9-]+)/);
21
42
  if (match !== null && match !== void 0 && match[2]) {
22
43
  return match[2];
23
44
  }
24
- throw new Error("Invalid page ARI: ".concat(ari));
45
+ throw new Error("Invalid resourceId: ".concat(resourceId));
25
46
  };
26
- export var getPageARIFromContentPropertyResourceId = function getPageARIFromContentPropertyResourceId(resourceId) {
47
+
48
+ /**
49
+ * Extracts the Confluence page ARI from the Confluence content property resource ID
50
+ * @param resourceId - the Confluence content property resource ID
51
+ * @returns the Confluence page ARI
52
+ */
53
+ export var getPageAriFromContentPropertyResourceId = function getPageAriFromContentPropertyResourceId(resourceId) {
27
54
  var match = resourceId.match(/(ari:cloud:confluence:[^:]+:(page|blogpost)\/\d+)\/([a-zA-Z0-9-]+)$/);
28
55
  if (match !== null && match !== void 0 && match[1]) {
29
56
  return match[1];
30
57
  }
31
58
  throw new Error("Invalid resourceId: ".concat(resourceId));
32
59
  };
60
+
61
+ /**
62
+ * Generates the Confluence page content property resource ID from the source ID and local ID
63
+ * @param sourceId - the source ID
64
+ * @param localId - the local ID
65
+ * @returns the Confluence page content property resource ID
66
+ */
33
67
  export var resourceIdFromConfluencePageSourceIdAndLocalId = function resourceIdFromConfluencePageSourceIdAndLocalId(sourceId, localId) {
34
- return sourceId + '/' + localId;
68
+ return "".concat(sourceId, "/").concat(localId);
35
69
  };
@@ -0,0 +1,24 @@
1
+ /* eslint-disable require-unicode-regexp */
2
+
3
+ /**
4
+ * Generates the Jira work item ARI
5
+ * @param workItemId - the ID of the work item
6
+ * @param cloudId - the cloud ID
7
+ * @returns the Jira work item ARI
8
+ */
9
+ export var getJiraWorkItemAri = function getJiraWorkItemAri(workItemId, cloudId) {
10
+ return "ari:cloud:jira:".concat(cloudId, ":issue/").concat(workItemId);
11
+ };
12
+
13
+ /**
14
+ * Extracts the Jira work item ID from the Jira work item ARI
15
+ * @param ari - the Jira work item ARI
16
+ * @returns the Jira work item ID
17
+ */
18
+ export var getJiraWorkItemIdFromAri = function getJiraWorkItemIdFromAri(ari) {
19
+ var match = ari.match(/ari:cloud:jira:([^:]+):issue\/(\d+)/);
20
+ if (match !== null && match !== void 0 && match[2]) {
21
+ return match[2];
22
+ }
23
+ throw new Error("Invalid Jira work item ARI: ".concat(ari));
24
+ };
package/dist/esm/index.js CHANGED
@@ -10,7 +10,8 @@ export { useHandleContentChanges } from './hooks/useHandleContentChanges';
10
10
 
11
11
  // clients
12
12
  export { generateBlockAri, generateBlockAriFromReference, getLocalIdFromBlockResourceId } from './clients/block-service/ari';
13
- export { getConfluencePageAri, getLocalIdFromConfluencePageAri, getPageARIFromContentPropertyResourceId, getPageIdAndTypeFromConfluencePageAri, resourceIdFromConfluencePageSourceIdAndLocalId } from './clients/confluence/ari';
13
+ export { getConfluencePageAri, getLocalIdFromContentPropertyResourceId, getPageAriFromContentPropertyResourceId, getPageIdAndTypeFromConfluencePageAri, resourceIdFromConfluencePageSourceIdAndLocalId } from './clients/confluence/ari';
14
+ export { getJiraWorkItemAri, getJiraWorkItemIdFromAri } from './clients/jira/ari';
14
15
 
15
16
  // providers
16
17
  export { useMemoizedBlockServiceAPIProviders } from './providers/block-service/blockServiceAPI';
@@ -7,7 +7,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
7
7
  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) { _defineProperty(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; }
8
8
  import _regeneratorRuntime from "@babel/runtime/regenerator";
9
9
  import { useMemo } from 'react';
10
- import { getConfluencePageAri, getLocalIdFromConfluencePageAri, getPageIdAndTypeFromConfluencePageAri, resourceIdFromConfluencePageSourceIdAndLocalId } from '../../clients/confluence/ari';
10
+ import { getConfluencePageAri, getLocalIdFromContentPropertyResourceId, getPageIdAndTypeFromConfluencePageAri, resourceIdFromConfluencePageSourceIdAndLocalId } from '../../clients/confluence/ari';
11
11
  import { getContentProperty, createContentProperty, updateContentProperty, deleteContentProperty } from '../../clients/confluence/contentProperty';
12
12
  import { isBlogPageType } from '../../clients/confluence/utils';
13
13
  import { SyncBlockError } from '../../common/types';
@@ -64,7 +64,7 @@ var ConfluenceADFFetchProvider = /*#__PURE__*/function () {
64
64
  while (1) switch (_context.prev = _context.next) {
65
65
  case 0:
66
66
  _getPageIdAndTypeFrom = getPageIdAndTypeFromConfluencePageAri(resourceId), pageId = _getPageIdAndTypeFrom.id, pageType = _getPageIdAndTypeFrom.type;
67
- localId = getLocalIdFromConfluencePageAri(resourceId);
67
+ localId = getLocalIdFromContentPropertyResourceId(resourceId);
68
68
  _context.prev = 2;
69
69
  key = getContentPropertyKey(this.config.contentPropertyKey, localId);
70
70
  options = {
@@ -228,7 +228,7 @@ var ConfluenceADFWriteProvider = /*#__PURE__*/function () {
228
228
  _match = match, pageId = _match.id, pageType = _match.type;
229
229
  _context3.prev = 9;
230
230
  // Update existing content property
231
- localId = getLocalIdFromConfluencePageAri(resourceId);
231
+ localId = getLocalIdFromContentPropertyResourceId(resourceId);
232
232
  key = getContentPropertyKey(this.config.contentPropertyKey, localId);
233
233
  sourceAri = getConfluencePageAri(pageId, this.config.cloudId, pageType);
234
234
  syncBlockDataWithSourceDocumentAri = _objectSpread(_objectSpread({}, syncBlockData), {}, {
@@ -300,7 +300,7 @@ var ConfluenceADFWriteProvider = /*#__PURE__*/function () {
300
300
  case 8:
301
301
  _match2 = match, pageId = _match2.id, pageType = _match2.type;
302
302
  _context4.prev = 9;
303
- localId = getLocalIdFromConfluencePageAri(resourceId);
303
+ localId = getLocalIdFromContentPropertyResourceId(resourceId);
304
304
  key = getContentPropertyKey(this.config.contentPropertyKey, localId);
305
305
  sourceAri = getConfluencePageAri(pageId, this.config.cloudId, pageType);
306
306
  syncBlockDataWithSourceDocumentAri = _objectSpread(_objectSpread({}, syncBlockData), {}, {
@@ -353,7 +353,7 @@ var ConfluenceADFWriteProvider = /*#__PURE__*/function () {
353
353
  case 7:
354
354
  _match3 = match, pageId = _match3.id, pageType = _match3.type;
355
355
  _context5.prev = 8;
356
- localId = getLocalIdFromConfluencePageAri(resourceId);
356
+ localId = getLocalIdFromContentPropertyResourceId(resourceId);
357
357
  key = getContentPropertyKey(this.config.contentPropertyKey, localId);
358
358
  options = {
359
359
  pageId: pageId,
@@ -7,7 +7,7 @@ import { type SyncBlockProduct } from '../../common/types';
7
7
  */
8
8
  export declare const generateBlockAri: (sourceAri: string, resourceId: string, product: SyncBlockProduct) => string;
9
9
  /**
10
- *
10
+ * Generates the block ARI from the reference synced block ARI and the resource ID
11
11
  * @param sourceAri - the ARI of the document. E.G ari:cloud:confluence:cloudId:page/pageId
12
12
  * @param resourceId - the resource ID of the reference synced block. E.G confluence-page/pageId/sourceResourceId
13
13
  * @returns the block ARI. E.G ari:cloud:blocks:<cloudId>:synced-block/<product>/<pageId>/<resourceId>
@@ -1,9 +1,40 @@
1
+ /**
2
+ * The type of the Confluence page
3
+ */
1
4
  export type PAGE_TYPE = 'page' | 'blogpost';
5
+ /**
6
+ * Generates the Confluence page ARI
7
+ * @param pageId - the ID of the page
8
+ * @param cloudId - the cloud ID
9
+ * @param pageType - the type of the page
10
+ * @returns the Confluence page ARI
11
+ */
2
12
  export declare const getConfluencePageAri: (pageId: string, cloudId: string, pageType?: PAGE_TYPE) => string;
13
+ /**
14
+ * Extracts the page ID and type from the Confluence page ARI
15
+ * @param ari - the Confluence page ARI
16
+ * @returns the page ID and type
17
+ */
3
18
  export declare const getPageIdAndTypeFromConfluencePageAri: (ari: string) => {
4
19
  id: string;
5
20
  type: PAGE_TYPE;
6
21
  };
7
- export declare const getLocalIdFromConfluencePageAri: (ari: string) => string;
8
- export declare const getPageARIFromContentPropertyResourceId: (resourceId: string) => string;
22
+ /**
23
+ * Extracts the local ID from the Confluence page content property resource ID
24
+ * @param resourceId - the Confluence page content property resource ID
25
+ * @returns the local ID
26
+ */
27
+ export declare const getLocalIdFromContentPropertyResourceId: (resourceId: string) => string;
28
+ /**
29
+ * Extracts the Confluence page ARI from the Confluence content property resource ID
30
+ * @param resourceId - the Confluence content property resource ID
31
+ * @returns the Confluence page ARI
32
+ */
33
+ export declare const getPageAriFromContentPropertyResourceId: (resourceId: string) => string;
34
+ /**
35
+ * Generates the Confluence page content property resource ID from the source ID and local ID
36
+ * @param sourceId - the source ID
37
+ * @param localId - the local ID
38
+ * @returns the Confluence page content property resource ID
39
+ */
9
40
  export declare const resourceIdFromConfluencePageSourceIdAndLocalId: (sourceId: string, localId: string) => string;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Generates the Jira work item ARI
3
+ * @param workItemId - the ID of the work item
4
+ * @param cloudId - the cloud ID
5
+ * @returns the Jira work item ARI
6
+ */
7
+ export declare const getJiraWorkItemAri: (workItemId: string, cloudId: string) => string;
8
+ /**
9
+ * Extracts the Jira work item ID from the Jira work item ARI
10
+ * @param ari - the Jira work item ARI
11
+ * @returns the Jira work item ID
12
+ */
13
+ export declare const getJiraWorkItemIdFromAri: (ari: string) => string;
@@ -5,12 +5,13 @@ export { useFetchSyncBlockData, type UseFetchSyncBlockDataResult, } from './hook
5
5
  export { useFetchSyncBlockTitle } from './hooks/useFetchSyncBlockTitle';
6
6
  export { useHandleContentChanges } from './hooks/useHandleContentChanges';
7
7
  export { generateBlockAri, generateBlockAriFromReference, getLocalIdFromBlockResourceId, } from './clients/block-service/ari';
8
- export { getConfluencePageAri, getLocalIdFromConfluencePageAri, getPageARIFromContentPropertyResourceId, getPageIdAndTypeFromConfluencePageAri, resourceIdFromConfluencePageSourceIdAndLocalId, } from './clients/confluence/ari';
8
+ export { getConfluencePageAri, getLocalIdFromContentPropertyResourceId, getPageAriFromContentPropertyResourceId, getPageIdAndTypeFromConfluencePageAri, resourceIdFromConfluencePageSourceIdAndLocalId, } from './clients/confluence/ari';
9
+ export { getJiraWorkItemAri, getJiraWorkItemIdFromAri } from './clients/jira/ari';
9
10
  export { useMemoizedBlockServiceAPIProviders } from './providers/block-service/blockServiceAPI';
10
11
  export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders, } from './providers/confluence/confluenceContentAPI';
11
12
  export { fetchConfluencePageInfo } from './clients/confluence/sourceInfo';
12
13
  export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider, } from './providers/syncBlockProvider';
13
- export type { ADFFetchProvider, ADFWriteProvider, SyncBlockDataProvider, SyncBlockInstance, MediaEmojiProviderOptions, SyncedBlockRendererProviderOptions, SyncBlockRendererProviderCreator, } from './providers/types';
14
+ export type { ADFFetchProvider, ADFWriteProvider, SyncBlockDataProvider, SyncBlockInstance, MediaEmojiProviderOptions, SyncedBlockRendererProviderOptions, SyncBlockRendererProviderCreator, SyncedBlockRendererDataProviders, } from './providers/types';
14
15
  export { type ReferenceSyncBlockStoreManager } from './store-manager/referenceSyncBlockStoreManager';
15
16
  export { SyncBlockStoreManager, useMemoizedSyncBlockStoreManager, } from './store-manager/syncBlockStoreManager';
16
17
  export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
@@ -7,7 +7,7 @@ import { type SyncBlockProduct } from '../../common/types';
7
7
  */
8
8
  export declare const generateBlockAri: (sourceAri: string, resourceId: string, product: SyncBlockProduct) => string;
9
9
  /**
10
- *
10
+ * Generates the block ARI from the reference synced block ARI and the resource ID
11
11
  * @param sourceAri - the ARI of the document. E.G ari:cloud:confluence:cloudId:page/pageId
12
12
  * @param resourceId - the resource ID of the reference synced block. E.G confluence-page/pageId/sourceResourceId
13
13
  * @returns the block ARI. E.G ari:cloud:blocks:<cloudId>:synced-block/<product>/<pageId>/<resourceId>
@@ -1,9 +1,40 @@
1
+ /**
2
+ * The type of the Confluence page
3
+ */
1
4
  export type PAGE_TYPE = 'page' | 'blogpost';
5
+ /**
6
+ * Generates the Confluence page ARI
7
+ * @param pageId - the ID of the page
8
+ * @param cloudId - the cloud ID
9
+ * @param pageType - the type of the page
10
+ * @returns the Confluence page ARI
11
+ */
2
12
  export declare const getConfluencePageAri: (pageId: string, cloudId: string, pageType?: PAGE_TYPE) => string;
13
+ /**
14
+ * Extracts the page ID and type from the Confluence page ARI
15
+ * @param ari - the Confluence page ARI
16
+ * @returns the page ID and type
17
+ */
3
18
  export declare const getPageIdAndTypeFromConfluencePageAri: (ari: string) => {
4
19
  id: string;
5
20
  type: PAGE_TYPE;
6
21
  };
7
- export declare const getLocalIdFromConfluencePageAri: (ari: string) => string;
8
- export declare const getPageARIFromContentPropertyResourceId: (resourceId: string) => string;
22
+ /**
23
+ * Extracts the local ID from the Confluence page content property resource ID
24
+ * @param resourceId - the Confluence page content property resource ID
25
+ * @returns the local ID
26
+ */
27
+ export declare const getLocalIdFromContentPropertyResourceId: (resourceId: string) => string;
28
+ /**
29
+ * Extracts the Confluence page ARI from the Confluence content property resource ID
30
+ * @param resourceId - the Confluence content property resource ID
31
+ * @returns the Confluence page ARI
32
+ */
33
+ export declare const getPageAriFromContentPropertyResourceId: (resourceId: string) => string;
34
+ /**
35
+ * Generates the Confluence page content property resource ID from the source ID and local ID
36
+ * @param sourceId - the source ID
37
+ * @param localId - the local ID
38
+ * @returns the Confluence page content property resource ID
39
+ */
9
40
  export declare const resourceIdFromConfluencePageSourceIdAndLocalId: (sourceId: string, localId: string) => string;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Generates the Jira work item ARI
3
+ * @param workItemId - the ID of the work item
4
+ * @param cloudId - the cloud ID
5
+ * @returns the Jira work item ARI
6
+ */
7
+ export declare const getJiraWorkItemAri: (workItemId: string, cloudId: string) => string;
8
+ /**
9
+ * Extracts the Jira work item ID from the Jira work item ARI
10
+ * @param ari - the Jira work item ARI
11
+ * @returns the Jira work item ID
12
+ */
13
+ export declare const getJiraWorkItemIdFromAri: (ari: string) => string;
@@ -5,12 +5,13 @@ export { useFetchSyncBlockData, type UseFetchSyncBlockDataResult, } from './hook
5
5
  export { useFetchSyncBlockTitle } from './hooks/useFetchSyncBlockTitle';
6
6
  export { useHandleContentChanges } from './hooks/useHandleContentChanges';
7
7
  export { generateBlockAri, generateBlockAriFromReference, getLocalIdFromBlockResourceId, } from './clients/block-service/ari';
8
- export { getConfluencePageAri, getLocalIdFromConfluencePageAri, getPageARIFromContentPropertyResourceId, getPageIdAndTypeFromConfluencePageAri, resourceIdFromConfluencePageSourceIdAndLocalId, } from './clients/confluence/ari';
8
+ export { getConfluencePageAri, getLocalIdFromContentPropertyResourceId, getPageAriFromContentPropertyResourceId, getPageIdAndTypeFromConfluencePageAri, resourceIdFromConfluencePageSourceIdAndLocalId, } from './clients/confluence/ari';
9
+ export { getJiraWorkItemAri, getJiraWorkItemIdFromAri } from './clients/jira/ari';
9
10
  export { useMemoizedBlockServiceAPIProviders } from './providers/block-service/blockServiceAPI';
10
11
  export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders, } from './providers/confluence/confluenceContentAPI';
11
12
  export { fetchConfluencePageInfo } from './clients/confluence/sourceInfo';
12
13
  export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider, } from './providers/syncBlockProvider';
13
- export type { ADFFetchProvider, ADFWriteProvider, SyncBlockDataProvider, SyncBlockInstance, MediaEmojiProviderOptions, SyncedBlockRendererProviderOptions, SyncBlockRendererProviderCreator, } from './providers/types';
14
+ export type { ADFFetchProvider, ADFWriteProvider, SyncBlockDataProvider, SyncBlockInstance, MediaEmojiProviderOptions, SyncedBlockRendererProviderOptions, SyncBlockRendererProviderCreator, SyncedBlockRendererDataProviders, } from './providers/types';
14
15
  export { type ReferenceSyncBlockStoreManager } from './store-manager/referenceSyncBlockStoreManager';
15
16
  export { SyncBlockStoreManager, useMemoizedSyncBlockStoreManager, } from './store-manager/syncBlockStoreManager';
16
17
  export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
package/package.json CHANGED
@@ -33,7 +33,7 @@
33
33
  "uuid": "^3.1.0"
34
34
  },
35
35
  "peerDependencies": {
36
- "@atlaskit/editor-common": "^110.49.0",
36
+ "@atlaskit/editor-common": "^110.50.0",
37
37
  "react": "^18.2.0"
38
38
  },
39
39
  "devDependencies": {
@@ -76,7 +76,7 @@
76
76
  }
77
77
  },
78
78
  "name": "@atlaskit/editor-synced-block-provider",
79
- "version": "2.16.0",
79
+ "version": "2.16.2",
80
80
  "description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
81
81
  "author": "Atlassian Pty Ltd",
82
82
  "license": "Apache-2.0",