@atlaskit/editor-synced-block-provider 0.6.1 → 0.8.0

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,23 @@
1
1
  # @atlaskit/editor-synced-block-provider
2
2
 
3
+ ## 0.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`5167552fe1a93`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5167552fe1a93) -
8
+ [EDITOR-2339] Bump @atlaskit/adf-schema to 51.3.0
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies
13
+
14
+ ## 0.7.0
15
+
16
+ ### Minor Changes
17
+
18
+ - [`4140dc02feebd`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4140dc02feebd) -
19
+ Add support for blogpost pages in content property provider
20
+
3
21
  ## 0.6.1
4
22
 
5
23
  ### Patch Changes
@@ -12,7 +12,8 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
12
12
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
13
  var _react = require("react");
14
14
  var _ari = require("../utils/ari");
15
- var _contentProperty = require("../utils/contentProperty");
15
+ var _contentProperty4 = require("../utils/contentProperty");
16
+ var _utils = require("../utils/utils");
16
17
  /**
17
18
  * Configuration for Content API providers
18
19
  */
@@ -22,17 +23,19 @@ var getContentPropertyKey = function getContentPropertyKey(contentPropertyKey, l
22
23
  };
23
24
  var parseSyncedBlockContentPropertyValue = function parseSyncedBlockContentPropertyValue(value) {
24
25
  try {
25
- if (typeof value === 'string') {
26
- return JSON.parse(value);
26
+ if (value !== '') {
27
+ var parsedValue = JSON.parse(value);
28
+ if (parsedValue.content) {
29
+ return parsedValue;
30
+ }
27
31
  }
28
- return value;
29
32
  } catch (error) {
30
33
  // eslint-disable-next-line no-console
31
34
  console.error('Failed to parse synced block content:', error);
32
- return {
33
- content: undefined
34
- };
35
35
  }
36
+ return {
37
+ content: undefined
38
+ };
36
39
  };
37
40
 
38
41
  /**
@@ -47,30 +50,43 @@ var ConfluenceADFFetchProvider = /*#__PURE__*/function () {
47
50
  key: "fetchData",
48
51
  value: function () {
49
52
  var _fetchData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(resourceId) {
50
- var _contentProperty$data;
51
- var pageId, localId, key, options, contentProperty, value, syncedBlockData;
53
+ var _getPageIdAndTypeFrom, pageId, pageType, localId, key, options, value, _contentProperty$data, contentProperty, _contentProperty$data2, _contentProperty, syncedBlockData;
52
54
  return _regenerator.default.wrap(function _callee$(_context) {
53
55
  while (1) switch (_context.prev = _context.next) {
54
56
  case 0:
55
- pageId = (0, _ari.getPageIdFromAri)(resourceId);
57
+ _getPageIdAndTypeFrom = (0, _ari.getPageIdAndTypeFromAri)(resourceId), pageId = _getPageIdAndTypeFrom.id, pageType = _getPageIdAndTypeFrom.type;
56
58
  localId = (0, _ari.getLocalIdFromAri)(resourceId);
57
59
  key = getContentPropertyKey(this.config.contentPropertyKey, localId);
58
60
  options = {
59
61
  pageId: pageId,
60
62
  key: key,
61
- cloudId: this.config.cloudId
63
+ cloudId: this.config.cloudId,
64
+ pageType: pageType
62
65
  };
63
- _context.next = 6;
64
- return (0, _contentProperty.getContentProperty)(options);
65
- case 6:
66
+ if (!(0, _utils.isBlogPageType)(pageType)) {
67
+ _context.next = 11;
68
+ break;
69
+ }
70
+ _context.next = 7;
71
+ return (0, _contentProperty4.getContentProperty)(options);
72
+ case 7:
66
73
  contentProperty = _context.sent;
67
- value = (_contentProperty$data = contentProperty.data.confluence.page.properties) === null || _contentProperty$data === void 0 || (_contentProperty$data = _contentProperty$data[0]) === null || _contentProperty$data === void 0 ? void 0 : _contentProperty$data.value;
74
+ value = (_contentProperty$data = contentProperty.data.confluence.blogPost.properties) === null || _contentProperty$data === void 0 || (_contentProperty$data = _contentProperty$data[0]) === null || _contentProperty$data === void 0 ? void 0 : _contentProperty$data.value;
75
+ _context.next = 15;
76
+ break;
77
+ case 11:
78
+ _context.next = 13;
79
+ return (0, _contentProperty4.getContentProperty)(options);
80
+ case 13:
81
+ _contentProperty = _context.sent;
82
+ value = (_contentProperty$data2 = _contentProperty.data.confluence.page.properties) === null || _contentProperty$data2 === void 0 || (_contentProperty$data2 = _contentProperty$data2[0]) === null || _contentProperty$data2 === void 0 ? void 0 : _contentProperty$data2.value;
83
+ case 15:
68
84
  if (value) {
69
- _context.next = 10;
85
+ _context.next = 17;
70
86
  break;
71
87
  }
72
88
  throw new Error('Content property value does not exist');
73
- case 10:
89
+ case 17:
74
90
  // Parse the synced block content from the property value
75
91
  syncedBlockData = parseSyncedBlockContentPropertyValue(value);
76
92
  return _context.abrupt("return", {
@@ -78,7 +94,7 @@ var ConfluenceADFFetchProvider = /*#__PURE__*/function () {
78
94
  resourceId: resourceId,
79
95
  localId: localId
80
96
  });
81
- case 12:
97
+ case 19:
82
98
  case "end":
83
99
  return _context.stop();
84
100
  }
@@ -99,35 +115,55 @@ var ConfluenceADFWriteProvider = /*#__PURE__*/function () {
99
115
  var _this = this;
100
116
  (0, _classCallCheck2.default)(this, ConfluenceADFWriteProvider);
101
117
  (0, _defineProperty2.default)(this, "createNewContentProperty", /*#__PURE__*/function () {
102
- var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(pageId, key, value) {
103
- var _contentProperty$data2;
104
- var contentProperty;
118
+ var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(pageId, key, value, pageType) {
119
+ var options, _contentProperty$data3, contentProperty, _contentProperty2$dat, _contentProperty2;
105
120
  return _regenerator.default.wrap(function _callee2$(_context2) {
106
121
  while (1) switch (_context2.prev = _context2.next) {
107
122
  case 0:
108
- _context2.next = 2;
109
- return (0, _contentProperty.createContentProperty)({
123
+ options = {
110
124
  pageId: pageId,
111
125
  key: key,
112
126
  value: value,
113
- cloudId: _this.config.cloudId
114
- });
115
- case 2:
127
+ cloudId: _this.config.cloudId,
128
+ pageType: pageType
129
+ };
130
+ if (!(0, _utils.isBlogPageType)(pageType)) {
131
+ _context2.next = 12;
132
+ break;
133
+ }
134
+ _context2.next = 4;
135
+ return (0, _contentProperty4.createContentProperty)(options);
136
+ case 4:
116
137
  contentProperty = _context2.sent;
117
- if (!(((_contentProperty$data2 = contentProperty.data.confluence.createPageProperty.pageProperty) === null || _contentProperty$data2 === void 0 ? void 0 : _contentProperty$data2.key) === key)) {
118
- _context2.next = 7;
138
+ if (!(((_contentProperty$data3 = contentProperty.data.confluence.createBlogPostProperty.blogPostProperty) === null || _contentProperty$data3 === void 0 ? void 0 : _contentProperty$data3.key) === key)) {
139
+ _context2.next = 9;
119
140
  break;
120
141
  }
121
142
  return _context2.abrupt("return", key);
122
- case 7:
123
- throw new Error('Failed to create content property');
124
- case 8:
143
+ case 9:
144
+ throw new Error('Failed to create blog post content property');
145
+ case 10:
146
+ _context2.next = 20;
147
+ break;
148
+ case 12:
149
+ _context2.next = 14;
150
+ return (0, _contentProperty4.createContentProperty)(options);
151
+ case 14:
152
+ _contentProperty2 = _context2.sent;
153
+ if (!(((_contentProperty2$dat = _contentProperty2.data.confluence.createPageProperty.pageProperty) === null || _contentProperty2$dat === void 0 ? void 0 : _contentProperty2$dat.key) === key)) {
154
+ _context2.next = 19;
155
+ break;
156
+ }
157
+ return _context2.abrupt("return", key);
158
+ case 19:
159
+ throw new Error('Failed to create page content property');
160
+ case 20:
125
161
  case "end":
126
162
  return _context2.stop();
127
163
  }
128
164
  }, _callee2);
129
165
  }));
130
- return function (_x2, _x3, _x4) {
166
+ return function (_x2, _x3, _x4, _x5) {
131
167
  return _ref.apply(this, arguments);
132
168
  };
133
169
  }());
@@ -137,11 +173,11 @@ var ConfluenceADFWriteProvider = /*#__PURE__*/function () {
137
173
  key: "writeData",
138
174
  value: function () {
139
175
  var _writeData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(data) {
140
- var pageId, syncedBlockValue, _contentProperty$data3, localId, key, contentProperty, _key;
176
+ var _getPageIdAndTypeFrom2, pageId, pageType, syncedBlockValue, localId, key, options, _contentProperty$data4, contentProperty, _contentProperty3$dat, _contentProperty3, _key;
141
177
  return _regenerator.default.wrap(function _callee3$(_context3) {
142
178
  while (1) switch (_context3.prev = _context3.next) {
143
179
  case 0:
144
- pageId = (0, _ari.getPageIdFromAri)(data.resourceId);
180
+ _getPageIdAndTypeFrom2 = (0, _ari.getPageIdAndTypeFromAri)(data.resourceId), pageId = _getPageIdAndTypeFrom2.id, pageType = _getPageIdAndTypeFrom2.type;
145
181
  if (!(data.sourceDocumentAri && data.resourceId !== (0, _ari.resourceIdFromSourceAndLocalId)(data.sourceDocumentAri, data.localId))) {
146
182
  _context3.next = 3;
147
183
  break;
@@ -152,48 +188,75 @@ var ConfluenceADFWriteProvider = /*#__PURE__*/function () {
152
188
  content: data.content
153
189
  });
154
190
  if (!data.resourceId) {
155
- _context3.next = 21;
191
+ _context3.next = 37;
156
192
  break;
157
193
  }
158
194
  // Update existing content property
159
195
  localId = (0, _ari.getLocalIdFromAri)(data.resourceId);
160
196
  key = getContentPropertyKey(this.config.contentPropertyKey, localId);
161
- _context3.next = 9;
162
- return (0, _contentProperty.updateContentProperty)({
197
+ options = {
163
198
  pageId: pageId,
164
199
  key: key,
165
200
  value: syncedBlockValue,
166
- cloudId: this.config.cloudId
167
- });
168
- case 9:
201
+ cloudId: this.config.cloudId,
202
+ pageType: pageType
203
+ };
204
+ if (!(0, _utils.isBlogPageType)(pageType)) {
205
+ _context3.next = 23;
206
+ break;
207
+ }
208
+ _context3.next = 11;
209
+ return (0, _contentProperty4.updateContentProperty)(options);
210
+ case 11:
169
211
  contentProperty = _context3.sent;
170
- if (!(((_contentProperty$data3 = contentProperty.data.confluence.updateValuePageProperty.pageProperty) === null || _contentProperty$data3 === void 0 ? void 0 : _contentProperty$data3.key) === key)) {
171
- _context3.next = 14;
212
+ if (!(((_contentProperty$data4 = contentProperty.data.confluence.updateValueBlogPostProperty.blogPostProperty) === null || _contentProperty$data4 === void 0 ? void 0 : _contentProperty$data4.key) === key)) {
213
+ _context3.next = 16;
172
214
  break;
173
215
  }
174
216
  return _context3.abrupt("return", key);
175
- case 14:
176
- if (!(contentProperty.data.confluence.updateValuePageProperty.pageProperty === null)) {
177
- _context3.next = 18;
217
+ case 16:
218
+ if (!(contentProperty.data.confluence.updateValueBlogPostProperty.blogPostProperty === null)) {
219
+ _context3.next = 20;
178
220
  break;
179
221
  }
180
- return _context3.abrupt("return", this.createNewContentProperty(pageId, key, syncedBlockValue));
181
- case 18:
222
+ return _context3.abrupt("return", this.createNewContentProperty(pageId, key, syncedBlockValue, pageType));
223
+ case 20:
224
+ throw new Error('Failed to update blog post content property');
225
+ case 21:
226
+ _context3.next = 35;
227
+ break;
228
+ case 23:
229
+ _context3.next = 25;
230
+ return (0, _contentProperty4.updateContentProperty)(options);
231
+ case 25:
232
+ _contentProperty3 = _context3.sent;
233
+ if (!(((_contentProperty3$dat = _contentProperty3.data.confluence.updateValuePageProperty.pageProperty) === null || _contentProperty3$dat === void 0 ? void 0 : _contentProperty3$dat.key) === key)) {
234
+ _context3.next = 30;
235
+ break;
236
+ }
237
+ return _context3.abrupt("return", key);
238
+ case 30:
239
+ if (!(_contentProperty3.data.confluence.updateValuePageProperty.pageProperty === null)) {
240
+ _context3.next = 34;
241
+ break;
242
+ }
243
+ return _context3.abrupt("return", this.createNewContentProperty(pageId, key, syncedBlockValue, pageType));
244
+ case 34:
182
245
  throw new Error('Failed to update content property');
183
- case 19:
184
- _context3.next = 23;
246
+ case 35:
247
+ _context3.next = 39;
185
248
  break;
186
- case 21:
249
+ case 37:
187
250
  // Create new content property
188
251
  _key = getContentPropertyKey(this.config.contentPropertyKey, data.localId);
189
- return _context3.abrupt("return", this.createNewContentProperty(pageId, _key, syncedBlockValue));
190
- case 23:
252
+ return _context3.abrupt("return", this.createNewContentProperty(pageId, _key, syncedBlockValue, pageType));
253
+ case 39:
191
254
  case "end":
192
255
  return _context3.stop();
193
256
  }
194
257
  }, _callee3, this);
195
258
  }));
196
- function writeData(_x5) {
259
+ function writeData(_x6) {
197
260
  return _writeData.apply(this, arguments);
198
261
  }
199
262
  return writeData;
@@ -3,35 +3,32 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.resourceIdFromSourceAndLocalId = exports.getPageIdFromAri = exports.getPageARIFromResourceId = exports.getLocalIdFromAri = exports.getContentPropertyIdFromAri = exports.getContentPropertyAri = exports.getConfluencePageAri = void 0;
6
+ exports.resourceIdFromSourceAndLocalId = exports.getPageIdAndTypeFromAri = exports.getPageARIFromResourceId = exports.getLocalIdFromAri = exports.getContentPropertyIdFromAri = exports.getContentPropertyAri = exports.getConfluencePageAri = void 0;
7
+ /* eslint-disable require-unicode-regexp */
8
+
7
9
  var getConfluencePageAri = exports.getConfluencePageAri = function getConfluencePageAri(pageId, cloudId) {
8
- return "ari:cloud:confluence:".concat(cloudId, ":page/").concat(pageId);
10
+ var pageType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'page';
11
+ return "ari:cloud:confluence:".concat(cloudId, ":").concat(pageType, "/").concat(pageId);
9
12
  };
10
- var getPageIdFromAri = exports.getPageIdFromAri = function getPageIdFromAri(ari) {
11
- // eslint-disable-next-line require-unicode-regexp
12
- var match = ari.match(/ari:cloud:confluence:[^:]+:page\/(\d+)/);
13
- if (match !== null && match !== void 0 && match[1]) {
14
- return match[1];
13
+ var getPageIdAndTypeFromAri = exports.getPageIdAndTypeFromAri = function getPageIdAndTypeFromAri(ari) {
14
+ var match = ari.match(/ari:cloud:confluence:[^:]+:(page|blogpost)\/(\d+)/);
15
+ if (match !== null && match !== void 0 && match[2]) {
16
+ return {
17
+ type: match[1],
18
+ id: match[2]
19
+ };
15
20
  }
16
21
  throw new Error("Invalid page ARI: ".concat(ari));
17
22
  };
18
-
19
- /**
20
- *
21
- * @param ari ari:cloud:confluence:<cloudId>:page/<pageId>/<localId>
22
- * @returns
23
- */
24
23
  var getLocalIdFromAri = exports.getLocalIdFromAri = function getLocalIdFromAri(ari) {
25
- // eslint-disable-next-line require-unicode-regexp
26
- var match = ari.match(/ari:cloud:confluence:[^:]+:page\/\d+\/([a-zA-Z0-9-]+)/);
27
- if (match !== null && match !== void 0 && match[1]) {
28
- return match[1];
24
+ var match = ari.match(/ari:cloud:confluence:[^:]+:(page|blogpost)\/\d+\/([a-zA-Z0-9-]+)/);
25
+ if (match !== null && match !== void 0 && match[2]) {
26
+ return match[2];
29
27
  }
30
28
  throw new Error("Invalid page ARI: ".concat(ari));
31
29
  };
32
30
  var getPageARIFromResourceId = exports.getPageARIFromResourceId = function getPageARIFromResourceId(resourceId) {
33
- // eslint-disable-next-line require-unicode-regexp
34
- var match = resourceId.match(/(ari:cloud:confluence:[^:]+:page\/\d+)\/([a-zA-Z0-9-]+)$/);
31
+ var match = resourceId.match(/(ari:cloud:confluence:[^:]+:(page|blogpost)\/\d+)\/([a-zA-Z0-9-]+)$/);
35
32
  if (match !== null && match !== void 0 && match[1]) {
36
33
  return match[1];
37
34
  }
@@ -40,8 +37,15 @@ var getPageARIFromResourceId = exports.getPageARIFromResourceId = function getPa
40
37
  var getContentPropertyAri = exports.getContentPropertyAri = function getContentPropertyAri(contentPropertyId, cloudId) {
41
38
  return "ari:cloud:confluence:".concat(cloudId, ":content/").concat(contentPropertyId);
42
39
  };
40
+
41
+ /**
42
+ * DEPRECATED - Will be removed in the future
43
+ * @private
44
+ * @deprecated
45
+ * @param ari
46
+ * @returns
47
+ */
43
48
  var getContentPropertyIdFromAri = exports.getContentPropertyIdFromAri = function getContentPropertyIdFromAri(ari) {
44
- // eslint-disable-next-line require-unicode-regexp
45
49
  var match = ari.match(/ari:cloud:confluence:[^:]+:content\/([^/]+)/);
46
50
  if (match) {
47
51
  return match[1];
@@ -9,6 +9,7 @@ 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"));
11
11
  var _ari = require("./ari");
12
+ var _utils = require("./utils");
12
13
  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; }
13
14
  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; }
14
15
  var COMMON_HEADERS = {
@@ -28,7 +29,15 @@ var UPDATE_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_UPDATE';
28
29
  * @param key
29
30
  * @returns
30
31
  */
31
- var GET_QUERY = "query ".concat(GET_OPERATION_NAME, " ($id: ID!, $keys: [String]!) {\n\t\t\t\t\tconfluence {\n\t\t\t\t\t\tpage (id: $id) {\n\t\t\t\t\t\t\tproperties(keys: $keys) {\n\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}");
32
+ var GET_PAGE_QUERY = "query ".concat(GET_OPERATION_NAME, " ($id: ID!, $keys: [String]!) {\n\t\t\t\t\tconfluence {\n\t\t\t\t\t\tpage (id: $id) {\n\t\t\t\t\t\t\tproperties(keys: $keys) {\n\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}");
33
+
34
+ /**
35
+ * Query to get the blog page property by key
36
+ * @param documentARI
37
+ * @param key
38
+ * @returns
39
+ */
40
+ var GET_BLOG_QUERY = "query ".concat(GET_OPERATION_NAME, " ($id: ID!, $keys: [String]!) {\n\tconfluence {\n\t\tblogPost (id: $id) {\n\t\t\tproperties(keys: $keys) {\n\t\t\t\tkey,\n\t\t\t\tvalue\n\t\t\t}\n\t\t}\n\t}\n}");
32
41
 
33
42
  /**
34
43
  * Query to create a page property with key and value
@@ -37,7 +46,16 @@ var GET_QUERY = "query ".concat(GET_OPERATION_NAME, " ($id: ID!, $keys: [String]
37
46
  * @param value
38
47
  * @returns
39
48
  */
40
- var CREATE_QUERY = "mutation ".concat(CREATE_OPERATION_NAME, " ($input: ConfluenceCreatePagePropertyInput!){\n\t\t\t\t\t\tconfluence {\n\t\t\t\t\t\t\tcreatePageProperty(input: $input) {\n\t\t\t\t\t\t\t\tpageProperty {\n\t\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}");
49
+ var CREATE_PAGE_QUERY = "mutation ".concat(CREATE_OPERATION_NAME, " ($input: ConfluenceCreatePagePropertyInput!){\n\t\t\t\t\t\tconfluence {\n\t\t\t\t\t\t\tcreatePageProperty(input: $input) {\n\t\t\t\t\t\t\t\tpageProperty {\n\t\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}");
50
+
51
+ /**
52
+ * Query to create a blog page property with key and value
53
+ * @param documentARI
54
+ * @param key
55
+ * @param value
56
+ * @returns
57
+ */
58
+ var CREATE_BLOG_QUERY = "mutation ".concat(CREATE_OPERATION_NAME, " ($input: ConfluenceCreateBlogPostPropertyInput!){\n\tconfluence {\n\t\tcreateBlogPostProperty(input: $input) {\n\t\t\tblogPostProperty {\n\t\t\t\tkey,\n\t\t\t\tvalue\n\t\t\t}\n\t\t}\n\t}\n}");
41
59
 
42
60
  /**
43
61
  * Query to update a page property with key and value without bumping the version
@@ -46,42 +64,51 @@ var CREATE_QUERY = "mutation ".concat(CREATE_OPERATION_NAME, " ($input: Confluen
46
64
  * @param value
47
65
  * @returns
48
66
  */
49
- var UPDATE_QUERY = "mutation ".concat(UPDATE_OPERATION_NAME, " ($input: ConfluenceUpdateValuePagePropertyInput!) {\n\t\t\t\t\t\tconfluence {\n\t\t\t\t\t\t\tupdateValuePageProperty(input: $input) {\n\t\t\t\t\t\t\t\tpageProperty {\n\t\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}");
67
+ var UPDATE_PAGE_QUERY = "mutation ".concat(UPDATE_OPERATION_NAME, " ($input: ConfluenceUpdateValuePagePropertyInput!) {\n\t\t\t\t\t\tconfluence {\n\t\t\t\t\t\t\tupdateValuePageProperty(input: $input) {\n\t\t\t\t\t\t\t\tpageProperty {\n\t\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}");
68
+
69
+ /**
70
+ * Query to update a blog page property with key and value without bumping the version
71
+ * @param documentARI
72
+ * @param key
73
+ * @param value
74
+ * @returns
75
+ */
76
+ var UPDATE_BLOG_QUERY = "mutation ".concat(UPDATE_OPERATION_NAME, " ($input: ConfluenceUpdateValueBlogPostPropertyInput!) {\n\tconfluence {\n\t\tupdateValueBlogPostProperty(input: $input) {\n\t\t\tblogPostProperty {\n\t\t\t\tkey,\n\t\t\t\tvalue\n\t\t\t}\n\t\t}\n\t}\n}");
50
77
  var getContentProperty = exports.getContentProperty = /*#__PURE__*/function () {
51
78
  var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref) {
52
- var pageId, key, cloudId, documentARI, bodyData, response, contentProperty;
79
+ var pageId, key, cloudId, pageType, documentARI, isBlog, bodyData, response;
53
80
  return _regenerator.default.wrap(function _callee$(_context) {
54
81
  while (1) switch (_context.prev = _context.next) {
55
82
  case 0:
56
- pageId = _ref.pageId, key = _ref.key, cloudId = _ref.cloudId;
57
- documentARI = (0, _ari.getConfluencePageAri)(pageId, cloudId);
83
+ pageId = _ref.pageId, key = _ref.key, cloudId = _ref.cloudId, pageType = _ref.pageType;
84
+ documentARI = (0, _ari.getConfluencePageAri)(pageId, cloudId, pageType);
85
+ isBlog = (0, _utils.isBlogPageType)(pageType);
58
86
  bodyData = {
59
- query: GET_QUERY,
87
+ query: isBlog ? GET_BLOG_QUERY : GET_PAGE_QUERY,
60
88
  operationName: GET_OPERATION_NAME,
61
89
  variables: {
62
90
  id: documentARI,
63
91
  keys: [key]
64
92
  }
65
93
  };
66
- _context.next = 5;
94
+ _context.next = 6;
67
95
  return fetch(GRAPHQL_ENDPOINT, {
68
96
  method: 'POST',
69
97
  headers: _objectSpread(_objectSpread({}, COMMON_HEADERS), AGG_HEADERS),
70
98
  body: JSON.stringify(bodyData)
71
99
  });
72
- case 5:
100
+ case 6:
73
101
  response = _context.sent;
74
102
  if (response.ok) {
75
- _context.next = 8;
103
+ _context.next = 9;
76
104
  break;
77
105
  }
78
106
  throw new Error("Failed to get content property: ".concat(response.statusText));
79
- case 8:
80
- _context.next = 10;
107
+ case 9:
108
+ _context.next = 11;
81
109
  return response.json();
82
- case 10:
83
- contentProperty = _context.sent;
84
- return _context.abrupt("return", contentProperty);
110
+ case 11:
111
+ return _context.abrupt("return", _context.sent);
85
112
  case 12:
86
113
  case "end":
87
114
  return _context.stop();
@@ -94,44 +121,53 @@ var getContentProperty = exports.getContentProperty = /*#__PURE__*/function () {
94
121
  }();
95
122
  var updateContentProperty = exports.updateContentProperty = /*#__PURE__*/function () {
96
123
  var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(_ref3) {
97
- var pageId, key, value, cloudId, documentARI, bodyData, response, contentProperty;
124
+ var pageId, key, value, cloudId, pageType, documentARI, isBlog, useSameVersion, input, bodyData, response;
98
125
  return _regenerator.default.wrap(function _callee2$(_context2) {
99
126
  while (1) switch (_context2.prev = _context2.next) {
100
127
  case 0:
101
- pageId = _ref3.pageId, key = _ref3.key, value = _ref3.value, cloudId = _ref3.cloudId;
102
- documentARI = (0, _ari.getConfluencePageAri)(pageId, cloudId);
128
+ pageId = _ref3.pageId, key = _ref3.key, value = _ref3.value, cloudId = _ref3.cloudId, pageType = _ref3.pageType;
129
+ documentARI = (0, _ari.getConfluencePageAri)(pageId, cloudId, pageType);
130
+ isBlog = (0, _utils.isBlogPageType)(pageType);
131
+ useSameVersion = {
132
+ useSameVersion: true
133
+ };
134
+ input = _objectSpread(_objectSpread({}, isBlog ? {
135
+ blogPostId: documentARI
136
+ } : {
137
+ pageId: documentARI
138
+ }), {}, {
139
+ key: key,
140
+ value: value
141
+ }); // Blog content properties don't support the useSameVersion flag at the moment
142
+ if (!isBlog) {
143
+ input = _objectSpread(_objectSpread({}, input), useSameVersion);
144
+ }
103
145
  bodyData = {
104
- query: UPDATE_QUERY,
146
+ query: isBlog ? UPDATE_BLOG_QUERY : UPDATE_PAGE_QUERY,
105
147
  operationName: UPDATE_OPERATION_NAME,
106
148
  variables: {
107
- input: {
108
- pageId: documentARI,
109
- key: key,
110
- value: value,
111
- useSameVersion: true
112
- }
149
+ input: input
113
150
  }
114
151
  };
115
- _context2.next = 5;
152
+ _context2.next = 9;
116
153
  return fetch(GRAPHQL_ENDPOINT, {
117
154
  method: 'POST',
118
155
  headers: _objectSpread(_objectSpread({}, COMMON_HEADERS), AGG_HEADERS),
119
156
  body: JSON.stringify(bodyData)
120
157
  });
121
- case 5:
158
+ case 9:
122
159
  response = _context2.sent;
123
160
  if (response.ok) {
124
- _context2.next = 8;
161
+ _context2.next = 12;
125
162
  break;
126
163
  }
127
164
  throw new Error("Failed to update content property: ".concat(response.statusText));
128
- case 8:
129
- _context2.next = 10;
130
- return response.json();
131
- case 10:
132
- contentProperty = _context2.sent;
133
- return _context2.abrupt("return", contentProperty);
134
165
  case 12:
166
+ _context2.next = 14;
167
+ return response.json();
168
+ case 14:
169
+ return _context2.abrupt("return", _context2.sent);
170
+ case 15:
135
171
  case "end":
136
172
  return _context2.stop();
137
173
  }
@@ -143,43 +179,46 @@ var updateContentProperty = exports.updateContentProperty = /*#__PURE__*/functio
143
179
  }();
144
180
  var createContentProperty = exports.createContentProperty = /*#__PURE__*/function () {
145
181
  var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(_ref5) {
146
- var pageId, key, value, cloudId, documentARI, escapedValue, bodyData, response, contentProperty;
182
+ var pageId, key, value, cloudId, pageType, documentARI, isBlog, escapedValue, bodyData, response;
147
183
  return _regenerator.default.wrap(function _callee3$(_context3) {
148
184
  while (1) switch (_context3.prev = _context3.next) {
149
185
  case 0:
150
- pageId = _ref5.pageId, key = _ref5.key, value = _ref5.value, cloudId = _ref5.cloudId;
151
- documentARI = (0, _ari.getConfluencePageAri)(pageId, cloudId); // eslint-disable-next-line require-unicode-regexp
186
+ pageId = _ref5.pageId, key = _ref5.key, value = _ref5.value, cloudId = _ref5.cloudId, pageType = _ref5.pageType;
187
+ documentARI = (0, _ari.getConfluencePageAri)(pageId, cloudId, pageType);
188
+ isBlog = (0, _utils.isBlogPageType)(pageType); // eslint-disable-next-line require-unicode-regexp
152
189
  escapedValue = value.replace(/"/g, '\\"');
153
190
  bodyData = {
154
- query: CREATE_QUERY,
191
+ query: isBlog ? CREATE_BLOG_QUERY : CREATE_PAGE_QUERY,
155
192
  operationName: CREATE_OPERATION_NAME,
156
193
  variables: {
157
- input: {
158
- pageId: documentARI,
194
+ input: _objectSpread(_objectSpread({}, isBlog ? {
195
+ blogPostId: documentARI
196
+ } : {
197
+ pageId: documentARI
198
+ }), {}, {
159
199
  key: key,
160
200
  value: escapedValue
161
- }
201
+ })
162
202
  }
163
203
  };
164
- _context3.next = 6;
204
+ _context3.next = 7;
165
205
  return fetch(GRAPHQL_ENDPOINT, {
166
206
  method: 'POST',
167
207
  headers: _objectSpread(_objectSpread({}, COMMON_HEADERS), AGG_HEADERS),
168
208
  body: JSON.stringify(bodyData)
169
209
  });
170
- case 6:
210
+ case 7:
171
211
  response = _context3.sent;
172
212
  if (response.ok) {
173
- _context3.next = 9;
213
+ _context3.next = 10;
174
214
  break;
175
215
  }
176
216
  throw new Error("Failed to create content property: ".concat(response.statusText));
177
- case 9:
178
- _context3.next = 11;
217
+ case 10:
218
+ _context3.next = 12;
179
219
  return response.json();
180
- case 11:
181
- contentProperty = _context3.sent;
182
- return _context3.abrupt("return", contentProperty);
220
+ case 12:
221
+ return _context3.abrupt("return", _context3.sent);
183
222
  case 13:
184
223
  case "end":
185
224
  return _context3.stop();
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.convertSyncBlockPMNodeToSyncBlockData = void 0;
6
+ exports.isBlogPageType = exports.convertSyncBlockPMNodeToSyncBlockData = void 0;
7
7
  var _editorJsonTransformer = require("@atlaskit/editor-json-transformer");
8
8
  var convertSyncBlockPMNodeToSyncBlockData = exports.convertSyncBlockPMNodeToSyncBlockData = function convertSyncBlockPMNodeToSyncBlockData(node) {
9
9
  var includeContent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
@@ -19,4 +19,7 @@ var convertSyncBlockPMNodeToSyncBlockData = exports.convertSyncBlockPMNodeToSync
19
19
  },
20
20
  content: includeContent ? node.content.content.map(toJSON) : undefined
21
21
  };
22
+ };
23
+ var isBlogPageType = exports.isBlogPageType = function isBlogPageType(pageType) {
24
+ return pageType === 'blogpost';
22
25
  };