@atlaskit/editor-synced-block-provider 2.15.6 → 2.16.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 (35) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/clients/block-service/ari.js +1 -1
  3. package/dist/cjs/clients/block-service/blockService.js +33 -25
  4. package/dist/cjs/clients/confluence/ari.js +41 -7
  5. package/dist/cjs/clients/jira/ari.js +30 -0
  6. package/dist/cjs/index.js +17 -4
  7. package/dist/cjs/providers/block-service/blockServiceAPI.js +35 -30
  8. package/dist/cjs/providers/confluence/confluenceContentAPI.js +4 -4
  9. package/dist/es2019/clients/block-service/ari.js +1 -1
  10. package/dist/es2019/clients/block-service/blockService.js +22 -12
  11. package/dist/es2019/clients/confluence/ari.js +40 -8
  12. package/dist/es2019/clients/jira/ari.js +22 -0
  13. package/dist/es2019/index.js +2 -1
  14. package/dist/es2019/providers/block-service/blockServiceAPI.js +12 -7
  15. package/dist/es2019/providers/confluence/confluenceContentAPI.js +5 -5
  16. package/dist/esm/clients/block-service/ari.js +1 -1
  17. package/dist/esm/clients/block-service/blockService.js +33 -25
  18. package/dist/esm/clients/confluence/ari.js +40 -6
  19. package/dist/esm/clients/jira/ari.js +24 -0
  20. package/dist/esm/index.js +2 -1
  21. package/dist/esm/providers/block-service/blockServiceAPI.js +35 -30
  22. package/dist/esm/providers/confluence/confluenceContentAPI.js +5 -5
  23. package/dist/types/clients/block-service/ari.d.ts +1 -1
  24. package/dist/types/clients/block-service/blockService.d.ts +4 -2
  25. package/dist/types/clients/confluence/ari.d.ts +33 -2
  26. package/dist/types/clients/jira/ari.d.ts +13 -0
  27. package/dist/types/index.d.ts +2 -1
  28. package/dist/types/providers/block-service/blockServiceAPI.d.ts +3 -2
  29. package/dist/types-ts4.5/clients/block-service/ari.d.ts +1 -1
  30. package/dist/types-ts4.5/clients/block-service/blockService.d.ts +4 -2
  31. package/dist/types-ts4.5/clients/confluence/ari.d.ts +33 -2
  32. package/dist/types-ts4.5/clients/jira/ari.d.ts +13 -0
  33. package/dist/types-ts4.5/index.d.ts +2 -1
  34. package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +3 -2
  35. package/package.json +2 -2
@@ -134,10 +134,11 @@ class BlockServiceADFFetchProvider {
134
134
  * ADFWriteProvider implementation that writes synced block data to Block Service API
135
135
  */
136
136
  class BlockServiceADFWriteProvider {
137
- constructor(sourceAri, product, sourceDocumentId) {
137
+ constructor(sourceAri, product, sourceDocumentId, getVersion) {
138
138
  this.sourceAri = sourceAri;
139
139
  this.product = product;
140
140
  this.sourceDocumentId = sourceDocumentId;
141
+ this.getVersion = getVersion;
141
142
  }
142
143
 
143
144
  // it will first try to update and if it can't (404) then it will try to create
@@ -146,11 +147,13 @@ class BlockServiceADFWriteProvider {
146
147
  resourceId
147
148
  } = data;
148
149
  const blockAri = generateBlockAri(this.sourceAri, resourceId, this.product);
150
+ const stepVersion = this.getVersion ? this.getVersion() : undefined;
149
151
  try {
150
152
  // Try update existing block's content
151
153
  await updateSyncedBlock({
152
154
  blockAri,
153
- content: JSON.stringify(data.content)
155
+ content: JSON.stringify(data.content),
156
+ stepVersion
154
157
  });
155
158
  return {
156
159
  resourceId
@@ -173,13 +176,15 @@ class BlockServiceADFWriteProvider {
173
176
  resourceId
174
177
  } = data;
175
178
  const blockAri = generateBlockAri(this.sourceAri, resourceId, this.product);
179
+ const stepVersion = this.getVersion ? this.getVersion() : undefined;
176
180
  try {
177
181
  await createSyncedBlock({
178
182
  blockAri,
179
183
  blockInstanceId: data.blockInstanceId,
180
184
  sourceAri: this.sourceAri,
181
185
  product: this.product,
182
- content: JSON.stringify(data.content)
186
+ content: JSON.stringify(data.content),
187
+ stepVersion
183
188
  });
184
189
  return {
185
190
  resourceId
@@ -272,14 +277,14 @@ class BlockServiceADFWriteProvider {
272
277
  /**
273
278
  * Factory function to create both providers with shared configuration
274
279
  */
275
- const createBlockServiceAPIProviders = (sourceAri, product, sourceDocumentId) => {
280
+ const createBlockServiceAPIProviders = (sourceAri, product, sourceDocumentId, getVersion) => {
276
281
  const fetchProvider = new BlockServiceADFFetchProvider(sourceAri);
277
- const writeProvider = new BlockServiceADFWriteProvider(sourceAri, product, sourceDocumentId);
282
+ const writeProvider = new BlockServiceADFWriteProvider(sourceAri, product, sourceDocumentId, getVersion);
278
283
  return {
279
284
  fetchProvider,
280
285
  writeProvider
281
286
  };
282
287
  };
283
- export const useMemoizedBlockServiceAPIProviders = (sourceAri, product, sourceDocumentId) => {
284
- return useMemo(() => createBlockServiceAPIProviders(sourceAri, product, sourceDocumentId), [sourceAri, product, sourceDocumentId]);
288
+ export const useMemoizedBlockServiceAPIProviders = (sourceAri, product, sourceDocumentId, getVersion) => {
289
+ return useMemo(() => createBlockServiceAPIProviders(sourceAri, product, sourceDocumentId, getVersion), [sourceAri, product, sourceDocumentId, getVersion]);
285
290
  };
@@ -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>
@@ -170,27 +170,31 @@ export var deleteSyncedBlock = /*#__PURE__*/function () {
170
170
  }();
171
171
  export var updateSyncedBlock = /*#__PURE__*/function () {
172
172
  var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref6) {
173
- var blockAri, content, response;
173
+ var blockAri, content, stepVersion, requestBody, response;
174
174
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
175
175
  while (1) switch (_context4.prev = _context4.next) {
176
176
  case 0:
177
- blockAri = _ref6.blockAri, content = _ref6.content;
178
- _context4.next = 3;
177
+ blockAri = _ref6.blockAri, content = _ref6.content, stepVersion = _ref6.stepVersion;
178
+ requestBody = {
179
+ content: content
180
+ };
181
+ if (stepVersion !== undefined) {
182
+ requestBody.stepVersion = stepVersion;
183
+ }
184
+ _context4.next = 5;
179
185
  return fetchWithRetry("".concat(BLOCK_SERVICE_API_URL, "/block/").concat(encodeURIComponent(blockAri)), {
180
186
  method: 'PUT',
181
187
  headers: COMMON_HEADERS,
182
- body: JSON.stringify({
183
- content: content
184
- })
188
+ body: JSON.stringify(requestBody)
185
189
  });
186
- case 3:
190
+ case 5:
187
191
  response = _context4.sent;
188
192
  if (response.ok) {
189
- _context4.next = 6;
193
+ _context4.next = 8;
190
194
  break;
191
195
  }
192
196
  throw new BlockError(response.status);
193
- case 6:
197
+ case 8:
194
198
  case "end":
195
199
  return _context4.stop();
196
200
  }
@@ -202,36 +206,40 @@ export var updateSyncedBlock = /*#__PURE__*/function () {
202
206
  }();
203
207
  export var createSyncedBlock = /*#__PURE__*/function () {
204
208
  var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref8) {
205
- var blockAri, blockInstanceId, sourceAri, product, content, response;
209
+ var blockAri, blockInstanceId, sourceAri, product, content, stepVersion, requestBody, response;
206
210
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
207
211
  while (1) switch (_context5.prev = _context5.next) {
208
212
  case 0:
209
- blockAri = _ref8.blockAri, blockInstanceId = _ref8.blockInstanceId, sourceAri = _ref8.sourceAri, product = _ref8.product, content = _ref8.content;
210
- _context5.next = 3;
213
+ blockAri = _ref8.blockAri, blockInstanceId = _ref8.blockInstanceId, sourceAri = _ref8.sourceAri, product = _ref8.product, content = _ref8.content, stepVersion = _ref8.stepVersion;
214
+ requestBody = {
215
+ blockAri: blockAri,
216
+ blockInstanceId: blockInstanceId,
217
+ sourceAri: sourceAri,
218
+ product: product,
219
+ content: content
220
+ };
221
+ if (stepVersion !== undefined) {
222
+ requestBody.stepVersion = stepVersion;
223
+ }
224
+ _context5.next = 5;
211
225
  return fetchWithRetry("".concat(BLOCK_SERVICE_API_URL, "/block"), {
212
226
  method: 'POST',
213
227
  headers: COMMON_HEADERS,
214
- body: JSON.stringify({
215
- blockAri: blockAri,
216
- blockInstanceId: blockInstanceId,
217
- sourceAri: sourceAri,
218
- product: product,
219
- content: content
220
- })
228
+ body: JSON.stringify(requestBody)
221
229
  });
222
- case 3:
230
+ case 5:
223
231
  response = _context5.sent;
224
232
  if (response.ok) {
225
- _context5.next = 6;
233
+ _context5.next = 8;
226
234
  break;
227
235
  }
228
236
  throw new BlockError(response.status);
229
- case 6:
230
- _context5.next = 8;
231
- return response.json();
232
237
  case 8:
238
+ _context5.next = 10;
239
+ return response.json();
240
+ case 10:
233
241
  return _context5.abrupt("return", _context5.sent);
234
- case 9:
242
+ case 11:
235
243
  case "end":
236
244
  return _context5.stop();
237
245
  }
@@ -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';
@@ -188,11 +188,12 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
188
188
  * ADFWriteProvider implementation that writes synced block data to Block Service API
189
189
  */
190
190
  var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
191
- function BlockServiceADFWriteProvider(sourceAri, product, sourceDocumentId) {
191
+ function BlockServiceADFWriteProvider(sourceAri, product, sourceDocumentId, getVersion) {
192
192
  _classCallCheck(this, BlockServiceADFWriteProvider);
193
193
  this.sourceAri = sourceAri;
194
194
  this.product = product;
195
195
  this.sourceDocumentId = sourceDocumentId;
196
+ this.getVersion = getVersion;
196
197
  }
197
198
 
198
199
  // it will first try to update and if it can't (404) then it will try to create
@@ -200,43 +201,45 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
200
201
  key: "writeData",
201
202
  value: function () {
202
203
  var _writeData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(data) {
203
- var resourceId, blockAri;
204
+ var resourceId, blockAri, stepVersion;
204
205
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
205
206
  while (1) switch (_context3.prev = _context3.next) {
206
207
  case 0:
207
208
  resourceId = data.resourceId;
208
209
  blockAri = generateBlockAri(this.sourceAri, resourceId, this.product);
209
- _context3.prev = 2;
210
- _context3.next = 5;
210
+ stepVersion = this.getVersion ? this.getVersion() : undefined;
211
+ _context3.prev = 3;
212
+ _context3.next = 6;
211
213
  return updateSyncedBlock({
212
214
  blockAri: blockAri,
213
- content: JSON.stringify(data.content)
215
+ content: JSON.stringify(data.content),
216
+ stepVersion: stepVersion
214
217
  });
215
- case 5:
218
+ case 6:
216
219
  return _context3.abrupt("return", {
217
220
  resourceId: resourceId
218
221
  });
219
- case 8:
220
- _context3.prev = 8;
221
- _context3.t0 = _context3["catch"](2);
222
+ case 9:
223
+ _context3.prev = 9;
224
+ _context3.t0 = _context3["catch"](3);
222
225
  if (!(_context3.t0 instanceof BlockError)) {
223
- _context3.next = 12;
226
+ _context3.next = 13;
224
227
  break;
225
228
  }
226
229
  return _context3.abrupt("return", {
227
230
  error: mapBlockError(_context3.t0),
228
231
  resourceId: resourceId
229
232
  });
230
- case 12:
233
+ case 13:
231
234
  return _context3.abrupt("return", {
232
235
  error: stringifyError(_context3.t0),
233
236
  resourceId: resourceId
234
237
  });
235
- case 13:
238
+ case 14:
236
239
  case "end":
237
240
  return _context3.stop();
238
241
  }
239
- }, _callee3, this, [[2, 8]]);
242
+ }, _callee3, this, [[3, 9]]);
240
243
  }));
241
244
  function writeData(_x3) {
242
245
  return _writeData.apply(this, arguments);
@@ -247,46 +250,48 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
247
250
  key: "createData",
248
251
  value: function () {
249
252
  var _createData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(data) {
250
- var resourceId, blockAri;
253
+ var resourceId, blockAri, stepVersion;
251
254
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
252
255
  while (1) switch (_context4.prev = _context4.next) {
253
256
  case 0:
254
257
  resourceId = data.resourceId;
255
258
  blockAri = generateBlockAri(this.sourceAri, resourceId, this.product);
256
- _context4.prev = 2;
257
- _context4.next = 5;
259
+ stepVersion = this.getVersion ? this.getVersion() : undefined;
260
+ _context4.prev = 3;
261
+ _context4.next = 6;
258
262
  return createSyncedBlock({
259
263
  blockAri: blockAri,
260
264
  blockInstanceId: data.blockInstanceId,
261
265
  sourceAri: this.sourceAri,
262
266
  product: this.product,
263
- content: JSON.stringify(data.content)
267
+ content: JSON.stringify(data.content),
268
+ stepVersion: stepVersion
264
269
  });
265
- case 5:
270
+ case 6:
266
271
  return _context4.abrupt("return", {
267
272
  resourceId: resourceId
268
273
  });
269
- case 8:
270
- _context4.prev = 8;
271
- _context4.t0 = _context4["catch"](2);
274
+ case 9:
275
+ _context4.prev = 9;
276
+ _context4.t0 = _context4["catch"](3);
272
277
  if (!(_context4.t0 instanceof BlockError)) {
273
- _context4.next = 12;
278
+ _context4.next = 13;
274
279
  break;
275
280
  }
276
281
  return _context4.abrupt("return", {
277
282
  error: mapBlockError(_context4.t0),
278
283
  resourceId: resourceId
279
284
  });
280
- case 12:
285
+ case 13:
281
286
  return _context4.abrupt("return", {
282
287
  error: stringifyError(_context4.t0),
283
288
  resourceId: resourceId
284
289
  });
285
- case 13:
290
+ case 14:
286
291
  case "end":
287
292
  return _context4.stop();
288
293
  }
289
- }, _callee4, this, [[2, 8]]);
294
+ }, _callee4, this, [[3, 9]]);
290
295
  }));
291
296
  function createData(_x4) {
292
297
  return _createData.apply(this, arguments);
@@ -417,16 +422,16 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
417
422
  /**
418
423
  * Factory function to create both providers with shared configuration
419
424
  */
420
- var createBlockServiceAPIProviders = function createBlockServiceAPIProviders(sourceAri, product, sourceDocumentId) {
425
+ var createBlockServiceAPIProviders = function createBlockServiceAPIProviders(sourceAri, product, sourceDocumentId, getVersion) {
421
426
  var fetchProvider = new BlockServiceADFFetchProvider(sourceAri);
422
- var writeProvider = new BlockServiceADFWriteProvider(sourceAri, product, sourceDocumentId);
427
+ var writeProvider = new BlockServiceADFWriteProvider(sourceAri, product, sourceDocumentId, getVersion);
423
428
  return {
424
429
  fetchProvider: fetchProvider,
425
430
  writeProvider: writeProvider
426
431
  };
427
432
  };
428
- export var useMemoizedBlockServiceAPIProviders = function useMemoizedBlockServiceAPIProviders(sourceAri, product, sourceDocumentId) {
433
+ export var useMemoizedBlockServiceAPIProviders = function useMemoizedBlockServiceAPIProviders(sourceAri, product, sourceDocumentId, getVersion) {
429
434
  return useMemo(function () {
430
- return createBlockServiceAPIProviders(sourceAri, product, sourceDocumentId);
431
- }, [sourceAri, product, sourceDocumentId]);
435
+ return createBlockServiceAPIProviders(sourceAri, product, sourceDocumentId, getVersion);
436
+ }, [sourceAri, product, sourceDocumentId, getVersion]);
432
437
  };
@@ -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>
@@ -72,6 +72,7 @@ export type DeleteSyncedBlockRequest = {
72
72
  export type UpdateSyncedBlockRequest = {
73
73
  blockAri: string;
74
74
  content: string;
75
+ stepVersion?: number;
75
76
  };
76
77
  export type CreateSyncedBlockRequest = {
77
78
  blockAri: string;
@@ -79,6 +80,7 @@ export type CreateSyncedBlockRequest = {
79
80
  content: string;
80
81
  product: SyncBlockProduct;
81
82
  sourceAri: string;
83
+ stepVersion?: number;
82
84
  };
83
85
  type ReferenceSyncedBlockIDs = {
84
86
  blockAri: string;
@@ -95,7 +97,7 @@ export declare class BlockError extends Error {
95
97
  }
96
98
  export declare const getSyncedBlockContent: ({ blockAri, }: GetSyncedBlockContentRequest) => Promise<BlockContentResponse>;
97
99
  export declare const deleteSyncedBlock: ({ blockAri }: DeleteSyncedBlockRequest) => Promise<void>;
98
- export declare const updateSyncedBlock: ({ blockAri, content, }: UpdateSyncedBlockRequest) => Promise<void>;
99
- export declare const createSyncedBlock: ({ blockAri, blockInstanceId, sourceAri, product, content, }: CreateSyncedBlockRequest) => Promise<BlockContentResponse>;
100
+ export declare const updateSyncedBlock: ({ blockAri, content, stepVersion, }: UpdateSyncedBlockRequest) => Promise<void>;
101
+ export declare const createSyncedBlock: ({ blockAri, blockInstanceId, sourceAri, product, content, stepVersion, }: CreateSyncedBlockRequest) => Promise<BlockContentResponse>;
100
102
  export declare const updateReferenceSyncedBlockOnDocument: ({ documentAri, blocks, noContent, }: UpdateReferenceSyncedBlockOnDocumentRequest) => Promise<ReferenceSyncedBlockResponse | void>;
101
103
  export {};
@@ -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,7 +5,8 @@ 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';
@@ -15,8 +15,9 @@ declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
15
15
  declare class BlockServiceADFWriteProvider implements ADFWriteProvider {
16
16
  private sourceAri;
17
17
  private sourceDocumentId;
18
+ private getVersion?;
18
19
  product: SyncBlockProduct;
19
- constructor(sourceAri: string, product: SyncBlockProduct, sourceDocumentId: string);
20
+ constructor(sourceAri: string, product: SyncBlockProduct, sourceDocumentId: string, getVersion?: () => number | undefined);
20
21
  writeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
21
22
  createData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
22
23
  deleteData(resourceId: string): Promise<DeleteSyncBlockResult>;
@@ -24,7 +25,7 @@ declare class BlockServiceADFWriteProvider implements ADFWriteProvider {
24
25
  generateResourceId(): ResourceId;
25
26
  updateReferenceData(blocks: SyncBlockAttrs[], noContent?: boolean): Promise<UpdateReferenceSyncBlockResult>;
26
27
  }
27
- export declare const useMemoizedBlockServiceAPIProviders: (sourceAri: string, product: SyncBlockProduct, sourceDocumentId: string) => {
28
+ export declare const useMemoizedBlockServiceAPIProviders: (sourceAri: string, product: SyncBlockProduct, sourceDocumentId: string, getVersion?: () => number | undefined) => {
28
29
  fetchProvider: BlockServiceADFFetchProvider;
29
30
  writeProvider: BlockServiceADFWriteProvider;
30
31
  };