@atlaskit/editor-synced-block-provider 3.18.0 → 3.19.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,16 @@
|
|
|
1
1
|
# @atlaskit/editor-synced-block-provider
|
|
2
2
|
|
|
3
|
+
## 3.19.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`1e7ebf4e1bf2d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1e7ebf4e1bf2d) -
|
|
8
|
+
Use the GraphQL endpoint for update block
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
3
14
|
## 3.18.0
|
|
4
15
|
|
|
5
16
|
### Minor Changes
|
|
@@ -125,9 +125,18 @@ var COMMON_HEADERS = {
|
|
|
125
125
|
var BLOCK_SERVICE_API_URL = '/gateway/api/blocks/v1';
|
|
126
126
|
var GRAPHQL_ENDPOINT = '/gateway/api/graphql';
|
|
127
127
|
var GET_DOCUMENT_REFERENCE_BLOCKS_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_GET_DOCUMENT_REFERENCE_BLOCKS';
|
|
128
|
+
var UPDATE_BLOCK_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_UPDATE_BLOCK';
|
|
128
129
|
var buildGetDocumentReferenceBlocksQuery = function buildGetDocumentReferenceBlocksQuery(documentAri) {
|
|
129
130
|
return "query ".concat(GET_DOCUMENT_REFERENCE_BLOCKS_OPERATION_NAME, " {\n\tblockService_getDocumentReferenceBlocks(documentAri: \"").concat(documentAri, "\") {\n\t\tblocks {\n\t\t\tblockAri\n\t\t\tblockInstanceId\n\t\t\tcontent\n\t\t\tcontentUpdatedAt\n\t\t\tcreatedAt\n\t\t\tcreatedBy\n\t\t\tproduct\n\t\t\tsourceAri\n\t\t\tstatus\n\t\t\tversion\n\t\t}\n\t\terrors {\n\t\t\tblockAri\n\t\t\tcode\n\t\t\treason\n\t\t}\n\t}\n}");
|
|
130
131
|
};
|
|
132
|
+
var buildUpdateBlockMutation = function buildUpdateBlockMutation(blockAri, content, stepVersion) {
|
|
133
|
+
var inputParts = ["blockAri: ".concat(JSON.stringify(blockAri)), "content: ".concat(JSON.stringify(content))];
|
|
134
|
+
if (stepVersion !== undefined) {
|
|
135
|
+
inputParts.push("stepVersion: ".concat(stepVersion));
|
|
136
|
+
}
|
|
137
|
+
var inputArgs = inputParts.join(', ');
|
|
138
|
+
return "mutation ".concat(UPDATE_BLOCK_OPERATION_NAME, " {\n\tblockService_updateBlock(input: { ").concat(inputArgs, " }) {\n\t\t__typename\n\t}\n}");
|
|
139
|
+
};
|
|
131
140
|
var BlockError = exports.BlockError = /*#__PURE__*/function (_Error) {
|
|
132
141
|
function BlockError(status) {
|
|
133
142
|
var _this;
|
|
@@ -259,31 +268,67 @@ var deleteSyncedBlock = exports.deleteSyncedBlock = /*#__PURE__*/function () {
|
|
|
259
268
|
}();
|
|
260
269
|
var updateSyncedBlock = exports.updateSyncedBlock = /*#__PURE__*/function () {
|
|
261
270
|
var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(_ref8) {
|
|
262
|
-
var blockAri, content, stepVersion, requestBody, response;
|
|
271
|
+
var blockAri, content, stepVersion, bodyData, _response, result, requestBody, response;
|
|
263
272
|
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
264
273
|
while (1) switch (_context5.prev = _context5.next) {
|
|
265
274
|
case 0:
|
|
266
275
|
blockAri = _ref8.blockAri, content = _ref8.content, stepVersion = _ref8.stepVersion;
|
|
276
|
+
if (!(0, _platformFeatureFlags.fg)('platform_synced_block_patch_1')) {
|
|
277
|
+
_context5.next = 14;
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
280
|
+
bodyData = {
|
|
281
|
+
query: buildUpdateBlockMutation(blockAri, content, stepVersion),
|
|
282
|
+
operationName: UPDATE_BLOCK_OPERATION_NAME
|
|
283
|
+
};
|
|
284
|
+
_context5.next = 5;
|
|
285
|
+
return (0, _retry.fetchWithRetry)(GRAPHQL_ENDPOINT, {
|
|
286
|
+
method: 'POST',
|
|
287
|
+
headers: COMMON_HEADERS,
|
|
288
|
+
body: JSON.stringify(bodyData)
|
|
289
|
+
});
|
|
290
|
+
case 5:
|
|
291
|
+
_response = _context5.sent;
|
|
292
|
+
if (_response.ok) {
|
|
293
|
+
_context5.next = 8;
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
throw new BlockError(_response.status);
|
|
297
|
+
case 8:
|
|
298
|
+
_context5.next = 10;
|
|
299
|
+
return _response.json();
|
|
300
|
+
case 10:
|
|
301
|
+
result = _context5.sent;
|
|
302
|
+
if (!(result.errors && result.errors.length > 0)) {
|
|
303
|
+
_context5.next = 13;
|
|
304
|
+
break;
|
|
305
|
+
}
|
|
306
|
+
throw new Error(result.errors.map(function (e) {
|
|
307
|
+
return e.message;
|
|
308
|
+
}).join(', '));
|
|
309
|
+
case 13:
|
|
310
|
+
return _context5.abrupt("return");
|
|
311
|
+
case 14:
|
|
267
312
|
requestBody = {
|
|
268
313
|
content: content
|
|
269
314
|
};
|
|
270
315
|
if (stepVersion !== undefined) {
|
|
271
316
|
requestBody.stepVersion = stepVersion;
|
|
272
317
|
}
|
|
273
|
-
_context5.next =
|
|
318
|
+
_context5.next = 18;
|
|
274
319
|
return (0, _retry.fetchWithRetry)("".concat(BLOCK_SERVICE_API_URL, "/block/").concat(encodeURIComponent(blockAri)), {
|
|
275
320
|
method: 'PUT',
|
|
276
321
|
headers: COMMON_HEADERS,
|
|
277
322
|
body: JSON.stringify(requestBody)
|
|
278
323
|
});
|
|
279
|
-
case
|
|
324
|
+
case 18:
|
|
280
325
|
response = _context5.sent;
|
|
281
326
|
if (response.ok) {
|
|
282
|
-
_context5.next =
|
|
327
|
+
_context5.next = 21;
|
|
283
328
|
break;
|
|
284
329
|
}
|
|
285
330
|
throw new BlockError(response.status);
|
|
286
|
-
case
|
|
331
|
+
case 21:
|
|
287
332
|
case "end":
|
|
288
333
|
return _context5.stop();
|
|
289
334
|
}
|
|
@@ -74,6 +74,7 @@ const COMMON_HEADERS = {
|
|
|
74
74
|
const BLOCK_SERVICE_API_URL = '/gateway/api/blocks/v1';
|
|
75
75
|
const GRAPHQL_ENDPOINT = '/gateway/api/graphql';
|
|
76
76
|
const GET_DOCUMENT_REFERENCE_BLOCKS_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_GET_DOCUMENT_REFERENCE_BLOCKS';
|
|
77
|
+
const UPDATE_BLOCK_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_UPDATE_BLOCK';
|
|
77
78
|
const buildGetDocumentReferenceBlocksQuery = documentAri => `query ${GET_DOCUMENT_REFERENCE_BLOCKS_OPERATION_NAME} {
|
|
78
79
|
blockService_getDocumentReferenceBlocks(documentAri: "${documentAri}") {
|
|
79
80
|
blocks {
|
|
@@ -95,6 +96,18 @@ const buildGetDocumentReferenceBlocksQuery = documentAri => `query ${GET_DOCUMEN
|
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
}`;
|
|
99
|
+
const buildUpdateBlockMutation = (blockAri, content, stepVersion) => {
|
|
100
|
+
const inputParts = [`blockAri: ${JSON.stringify(blockAri)}`, `content: ${JSON.stringify(content)}`];
|
|
101
|
+
if (stepVersion !== undefined) {
|
|
102
|
+
inputParts.push(`stepVersion: ${stepVersion}`);
|
|
103
|
+
}
|
|
104
|
+
const inputArgs = inputParts.join(', ');
|
|
105
|
+
return `mutation ${UPDATE_BLOCK_OPERATION_NAME} {
|
|
106
|
+
blockService_updateBlock(input: { ${inputArgs} }) {
|
|
107
|
+
__typename
|
|
108
|
+
}
|
|
109
|
+
}`;
|
|
110
|
+
};
|
|
98
111
|
export class BlockError extends Error {
|
|
99
112
|
constructor(status) {
|
|
100
113
|
super(`Block error`);
|
|
@@ -162,6 +175,25 @@ export const updateSyncedBlock = async ({
|
|
|
162
175
|
content,
|
|
163
176
|
stepVersion
|
|
164
177
|
}) => {
|
|
178
|
+
if (fg('platform_synced_block_patch_1')) {
|
|
179
|
+
const bodyData = {
|
|
180
|
+
query: buildUpdateBlockMutation(blockAri, content, stepVersion),
|
|
181
|
+
operationName: UPDATE_BLOCK_OPERATION_NAME
|
|
182
|
+
};
|
|
183
|
+
const response = await fetchWithRetry(GRAPHQL_ENDPOINT, {
|
|
184
|
+
method: 'POST',
|
|
185
|
+
headers: COMMON_HEADERS,
|
|
186
|
+
body: JSON.stringify(bodyData)
|
|
187
|
+
});
|
|
188
|
+
if (!response.ok) {
|
|
189
|
+
throw new BlockError(response.status);
|
|
190
|
+
}
|
|
191
|
+
const result = await response.json();
|
|
192
|
+
if (result.errors && result.errors.length > 0) {
|
|
193
|
+
throw new Error(result.errors.map(e => e.message).join(', '));
|
|
194
|
+
}
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
165
197
|
const requestBody = {
|
|
166
198
|
content
|
|
167
199
|
};
|
|
@@ -118,9 +118,18 @@ var COMMON_HEADERS = {
|
|
|
118
118
|
var BLOCK_SERVICE_API_URL = '/gateway/api/blocks/v1';
|
|
119
119
|
var GRAPHQL_ENDPOINT = '/gateway/api/graphql';
|
|
120
120
|
var GET_DOCUMENT_REFERENCE_BLOCKS_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_GET_DOCUMENT_REFERENCE_BLOCKS';
|
|
121
|
+
var UPDATE_BLOCK_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_UPDATE_BLOCK';
|
|
121
122
|
var buildGetDocumentReferenceBlocksQuery = function buildGetDocumentReferenceBlocksQuery(documentAri) {
|
|
122
123
|
return "query ".concat(GET_DOCUMENT_REFERENCE_BLOCKS_OPERATION_NAME, " {\n\tblockService_getDocumentReferenceBlocks(documentAri: \"").concat(documentAri, "\") {\n\t\tblocks {\n\t\t\tblockAri\n\t\t\tblockInstanceId\n\t\t\tcontent\n\t\t\tcontentUpdatedAt\n\t\t\tcreatedAt\n\t\t\tcreatedBy\n\t\t\tproduct\n\t\t\tsourceAri\n\t\t\tstatus\n\t\t\tversion\n\t\t}\n\t\terrors {\n\t\t\tblockAri\n\t\t\tcode\n\t\t\treason\n\t\t}\n\t}\n}");
|
|
123
124
|
};
|
|
125
|
+
var buildUpdateBlockMutation = function buildUpdateBlockMutation(blockAri, content, stepVersion) {
|
|
126
|
+
var inputParts = ["blockAri: ".concat(JSON.stringify(blockAri)), "content: ".concat(JSON.stringify(content))];
|
|
127
|
+
if (stepVersion !== undefined) {
|
|
128
|
+
inputParts.push("stepVersion: ".concat(stepVersion));
|
|
129
|
+
}
|
|
130
|
+
var inputArgs = inputParts.join(', ');
|
|
131
|
+
return "mutation ".concat(UPDATE_BLOCK_OPERATION_NAME, " {\n\tblockService_updateBlock(input: { ").concat(inputArgs, " }) {\n\t\t__typename\n\t}\n}");
|
|
132
|
+
};
|
|
124
133
|
export var BlockError = /*#__PURE__*/function (_Error) {
|
|
125
134
|
function BlockError(status) {
|
|
126
135
|
var _this;
|
|
@@ -252,31 +261,67 @@ export var deleteSyncedBlock = /*#__PURE__*/function () {
|
|
|
252
261
|
}();
|
|
253
262
|
export var updateSyncedBlock = /*#__PURE__*/function () {
|
|
254
263
|
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref8) {
|
|
255
|
-
var blockAri, content, stepVersion, requestBody, response;
|
|
264
|
+
var blockAri, content, stepVersion, bodyData, _response, result, requestBody, response;
|
|
256
265
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
257
266
|
while (1) switch (_context5.prev = _context5.next) {
|
|
258
267
|
case 0:
|
|
259
268
|
blockAri = _ref8.blockAri, content = _ref8.content, stepVersion = _ref8.stepVersion;
|
|
269
|
+
if (!fg('platform_synced_block_patch_1')) {
|
|
270
|
+
_context5.next = 14;
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
bodyData = {
|
|
274
|
+
query: buildUpdateBlockMutation(blockAri, content, stepVersion),
|
|
275
|
+
operationName: UPDATE_BLOCK_OPERATION_NAME
|
|
276
|
+
};
|
|
277
|
+
_context5.next = 5;
|
|
278
|
+
return fetchWithRetry(GRAPHQL_ENDPOINT, {
|
|
279
|
+
method: 'POST',
|
|
280
|
+
headers: COMMON_HEADERS,
|
|
281
|
+
body: JSON.stringify(bodyData)
|
|
282
|
+
});
|
|
283
|
+
case 5:
|
|
284
|
+
_response = _context5.sent;
|
|
285
|
+
if (_response.ok) {
|
|
286
|
+
_context5.next = 8;
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
throw new BlockError(_response.status);
|
|
290
|
+
case 8:
|
|
291
|
+
_context5.next = 10;
|
|
292
|
+
return _response.json();
|
|
293
|
+
case 10:
|
|
294
|
+
result = _context5.sent;
|
|
295
|
+
if (!(result.errors && result.errors.length > 0)) {
|
|
296
|
+
_context5.next = 13;
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
throw new Error(result.errors.map(function (e) {
|
|
300
|
+
return e.message;
|
|
301
|
+
}).join(', '));
|
|
302
|
+
case 13:
|
|
303
|
+
return _context5.abrupt("return");
|
|
304
|
+
case 14:
|
|
260
305
|
requestBody = {
|
|
261
306
|
content: content
|
|
262
307
|
};
|
|
263
308
|
if (stepVersion !== undefined) {
|
|
264
309
|
requestBody.stepVersion = stepVersion;
|
|
265
310
|
}
|
|
266
|
-
_context5.next =
|
|
311
|
+
_context5.next = 18;
|
|
267
312
|
return fetchWithRetry("".concat(BLOCK_SERVICE_API_URL, "/block/").concat(encodeURIComponent(blockAri)), {
|
|
268
313
|
method: 'PUT',
|
|
269
314
|
headers: COMMON_HEADERS,
|
|
270
315
|
body: JSON.stringify(requestBody)
|
|
271
316
|
});
|
|
272
|
-
case
|
|
317
|
+
case 18:
|
|
273
318
|
response = _context5.sent;
|
|
274
319
|
if (response.ok) {
|
|
275
|
-
_context5.next =
|
|
320
|
+
_context5.next = 21;
|
|
276
321
|
break;
|
|
277
322
|
}
|
|
278
323
|
throw new BlockError(response.status);
|
|
279
|
-
case
|
|
324
|
+
case 21:
|
|
280
325
|
case "end":
|
|
281
326
|
return _context5.stop();
|
|
282
327
|
}
|
package/package.json
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@atlaskit/adf-utils": "^19.27.0",
|
|
28
28
|
"@atlaskit/editor-json-transformer": "^8.31.0",
|
|
29
|
-
"@atlaskit/editor-prosemirror": "^7.
|
|
29
|
+
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
30
30
|
"@atlaskit/node-data-provider": "^8.1.0",
|
|
31
31
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
32
32
|
"@babel/runtime": "^7.0.0",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
}
|
|
79
79
|
},
|
|
80
80
|
"name": "@atlaskit/editor-synced-block-provider",
|
|
81
|
-
"version": "3.
|
|
81
|
+
"version": "3.19.0",
|
|
82
82
|
"description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
|
|
83
83
|
"author": "Atlassian Pty Ltd",
|
|
84
84
|
"license": "Apache-2.0",
|
|
@@ -91,6 +91,9 @@
|
|
|
91
91
|
},
|
|
92
92
|
"platform_synced_block_patch1": {
|
|
93
93
|
"type": "boolean"
|
|
94
|
+
},
|
|
95
|
+
"platform_synced_block_patch_1": {
|
|
96
|
+
"type": "boolean"
|
|
94
97
|
}
|
|
95
98
|
}
|
|
96
99
|
}
|