@atlaskit/editor-synced-block-provider 3.24.0 → 3.25.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.25.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`1ded312f31a41`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1ded312f31a41) -
|
|
8
|
+
Fetch references by blockAri uses GraphQL endpoint
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
3
14
|
## 3.24.0
|
|
4
15
|
|
|
5
16
|
### Minor Changes
|
|
@@ -130,6 +130,7 @@ var DELETE_BLOCK_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_DELETE_BLOCK';
|
|
|
130
130
|
var CREATE_BLOCK_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_CREATE_BLOCK';
|
|
131
131
|
var UPDATE_DOCUMENT_REFERENCES_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_UPDATE_DOCUMENT_REFERENCES';
|
|
132
132
|
var BATCH_RETRIEVE_BLOCKS_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_BATCH_RETRIEVE_BLOCKS';
|
|
133
|
+
var GET_BLOCK_REFERENCES_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_GET_REFERENCES';
|
|
133
134
|
var buildGetDocumentReferenceBlocksQuery = function buildGetDocumentReferenceBlocksQuery(documentAri) {
|
|
134
135
|
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}");
|
|
135
136
|
};
|
|
@@ -187,6 +188,9 @@ var buildBatchRetrieveBlocksQuery = function buildBatchRetrieveBlocksQuery(block
|
|
|
187
188
|
var inputArgs = "blockAris: [".concat(blockArisArray, "]");
|
|
188
189
|
return "query ".concat(BATCH_RETRIEVE_BLOCKS_OPERATION_NAME, " {\n\tblockService_batchRetrieveBlocks(input: { ").concat(inputArgs, " }) {\n\t\tsuccess {\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\tdeletionReason\n\t\t\tproduct\n\t\t\tsourceAri\n\t\t\tstatus\n\t\t\tversion\n\t\t}\n\t\terror {\n\t\t\tblockAri\n\t\t\tcode\n\t\t\treason\n\t\t}\n\t}\n}");
|
|
189
190
|
};
|
|
191
|
+
var buildGetBlockReferencesQuery = function buildGetBlockReferencesQuery(blockAri) {
|
|
192
|
+
return "query ".concat(GET_BLOCK_REFERENCES_OPERATION_NAME, " {\n\tblockService_getReferences(blockAri: ").concat(JSON.stringify(blockAri), ") {\n\t\treferences {\n\t\t\tblockAri\n\t\t\tblockInstanceId\n\t\t\tcreatedAt\n\t\t\tcreatedBy\n\t\t\tdocumentAri\n\t\t}\n\t\terrors {\n\t\t\tblockAri\n\t\t\tcode\n\t\t\treason\n\t\t}\n\t}\n}");
|
|
193
|
+
};
|
|
190
194
|
var BlockError = exports.BlockError = /*#__PURE__*/function (_Error) {
|
|
191
195
|
function BlockError(status) {
|
|
192
196
|
var _this;
|
|
@@ -665,29 +669,76 @@ var updateReferenceSyncedBlockOnDocument = exports.updateReferenceSyncedBlockOnD
|
|
|
665
669
|
}();
|
|
666
670
|
var getReferenceSyncedBlocksByBlockAri = exports.getReferenceSyncedBlocksByBlockAri = /*#__PURE__*/function () {
|
|
667
671
|
var _ref13 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(_ref12) {
|
|
668
|
-
var blockAri, response;
|
|
672
|
+
var blockAri, _result$data5, bodyData, _response6, result, graphqlResponse, response;
|
|
669
673
|
return _regenerator.default.wrap(function _callee8$(_context8) {
|
|
670
674
|
while (1) switch (_context8.prev = _context8.next) {
|
|
671
675
|
case 0:
|
|
672
676
|
blockAri = _ref12.blockAri;
|
|
673
|
-
|
|
677
|
+
if (!(0, _platformFeatureFlags.fg)('platform_synced_block_patch_1')) {
|
|
678
|
+
_context8.next = 17;
|
|
679
|
+
break;
|
|
680
|
+
}
|
|
681
|
+
bodyData = {
|
|
682
|
+
query: buildGetBlockReferencesQuery(blockAri),
|
|
683
|
+
operationName: GET_BLOCK_REFERENCES_OPERATION_NAME
|
|
684
|
+
};
|
|
685
|
+
_context8.next = 5;
|
|
686
|
+
return (0, _retry.fetchWithRetry)(GRAPHQL_ENDPOINT, {
|
|
687
|
+
method: 'POST',
|
|
688
|
+
headers: COMMON_HEADERS,
|
|
689
|
+
body: JSON.stringify(bodyData)
|
|
690
|
+
});
|
|
691
|
+
case 5:
|
|
692
|
+
_response6 = _context8.sent;
|
|
693
|
+
if (_response6.ok) {
|
|
694
|
+
_context8.next = 8;
|
|
695
|
+
break;
|
|
696
|
+
}
|
|
697
|
+
throw new BlockError(_response6.status);
|
|
698
|
+
case 8:
|
|
699
|
+
_context8.next = 10;
|
|
700
|
+
return _response6.json();
|
|
701
|
+
case 10:
|
|
702
|
+
result = _context8.sent;
|
|
703
|
+
if (!(result.errors && result.errors.length > 0)) {
|
|
704
|
+
_context8.next = 13;
|
|
705
|
+
break;
|
|
706
|
+
}
|
|
707
|
+
throw new Error(result.errors.map(function (e) {
|
|
708
|
+
return e.message;
|
|
709
|
+
}).join(', '));
|
|
710
|
+
case 13:
|
|
711
|
+
if ((_result$data5 = result.data) !== null && _result$data5 !== void 0 && _result$data5.blockService_getReferences) {
|
|
712
|
+
_context8.next = 15;
|
|
713
|
+
break;
|
|
714
|
+
}
|
|
715
|
+
throw new Error('No data returned from GraphQL query');
|
|
716
|
+
case 15:
|
|
717
|
+
graphqlResponse = result.data.blockService_getReferences;
|
|
718
|
+
return _context8.abrupt("return", {
|
|
719
|
+
blockAri: blockAri,
|
|
720
|
+
references: graphqlResponse.references || [],
|
|
721
|
+
errors: graphqlResponse.errors || []
|
|
722
|
+
});
|
|
723
|
+
case 17:
|
|
724
|
+
_context8.next = 19;
|
|
674
725
|
return (0, _retry.fetchWithRetry)("".concat(BLOCK_SERVICE_API_URL, "/reference/batch-retrieve/").concat(encodeURIComponent(blockAri)), {
|
|
675
726
|
method: 'GET',
|
|
676
727
|
headers: COMMON_HEADERS
|
|
677
728
|
});
|
|
678
|
-
case
|
|
729
|
+
case 19:
|
|
679
730
|
response = _context8.sent;
|
|
680
731
|
if (response.ok) {
|
|
681
|
-
_context8.next =
|
|
732
|
+
_context8.next = 22;
|
|
682
733
|
break;
|
|
683
734
|
}
|
|
684
735
|
throw new BlockError(response.status);
|
|
685
|
-
case
|
|
686
|
-
_context8.next =
|
|
736
|
+
case 22:
|
|
737
|
+
_context8.next = 24;
|
|
687
738
|
return response.json();
|
|
688
|
-
case
|
|
739
|
+
case 24:
|
|
689
740
|
return _context8.abrupt("return", _context8.sent);
|
|
690
|
-
case
|
|
741
|
+
case 25:
|
|
691
742
|
case "end":
|
|
692
743
|
return _context8.stop();
|
|
693
744
|
}
|
|
@@ -79,6 +79,7 @@ const DELETE_BLOCK_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_DELETE_BLOCK';
|
|
|
79
79
|
const CREATE_BLOCK_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_CREATE_BLOCK';
|
|
80
80
|
const UPDATE_DOCUMENT_REFERENCES_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_UPDATE_DOCUMENT_REFERENCES';
|
|
81
81
|
const BATCH_RETRIEVE_BLOCKS_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_BATCH_RETRIEVE_BLOCKS';
|
|
82
|
+
const GET_BLOCK_REFERENCES_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_GET_REFERENCES';
|
|
82
83
|
const buildGetDocumentReferenceBlocksQuery = documentAri => `query ${GET_DOCUMENT_REFERENCE_BLOCKS_OPERATION_NAME} {
|
|
83
84
|
blockService_getDocumentReferenceBlocks(documentAri: "${documentAri}") {
|
|
84
85
|
blocks {
|
|
@@ -213,6 +214,24 @@ const buildBatchRetrieveBlocksQuery = blockAris => {
|
|
|
213
214
|
}
|
|
214
215
|
}`;
|
|
215
216
|
};
|
|
217
|
+
const buildGetBlockReferencesQuery = blockAri => {
|
|
218
|
+
return `query ${GET_BLOCK_REFERENCES_OPERATION_NAME} {
|
|
219
|
+
blockService_getReferences(blockAri: ${JSON.stringify(blockAri)}) {
|
|
220
|
+
references {
|
|
221
|
+
blockAri
|
|
222
|
+
blockInstanceId
|
|
223
|
+
createdAt
|
|
224
|
+
createdBy
|
|
225
|
+
documentAri
|
|
226
|
+
}
|
|
227
|
+
errors {
|
|
228
|
+
blockAri
|
|
229
|
+
code
|
|
230
|
+
reason
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}`;
|
|
234
|
+
};
|
|
216
235
|
export class BlockError extends Error {
|
|
217
236
|
constructor(status) {
|
|
218
237
|
super(`Block error`);
|
|
@@ -475,6 +494,34 @@ export const updateReferenceSyncedBlockOnDocument = async ({
|
|
|
475
494
|
export const getReferenceSyncedBlocksByBlockAri = async ({
|
|
476
495
|
blockAri
|
|
477
496
|
}) => {
|
|
497
|
+
if (fg('platform_synced_block_patch_1')) {
|
|
498
|
+
var _result$data5;
|
|
499
|
+
const bodyData = {
|
|
500
|
+
query: buildGetBlockReferencesQuery(blockAri),
|
|
501
|
+
operationName: GET_BLOCK_REFERENCES_OPERATION_NAME
|
|
502
|
+
};
|
|
503
|
+
const response = await fetchWithRetry(GRAPHQL_ENDPOINT, {
|
|
504
|
+
method: 'POST',
|
|
505
|
+
headers: COMMON_HEADERS,
|
|
506
|
+
body: JSON.stringify(bodyData)
|
|
507
|
+
});
|
|
508
|
+
if (!response.ok) {
|
|
509
|
+
throw new BlockError(response.status);
|
|
510
|
+
}
|
|
511
|
+
const result = await response.json();
|
|
512
|
+
if (result.errors && result.errors.length > 0) {
|
|
513
|
+
throw new Error(result.errors.map(e => e.message).join(', '));
|
|
514
|
+
}
|
|
515
|
+
if (!((_result$data5 = result.data) !== null && _result$data5 !== void 0 && _result$data5.blockService_getReferences)) {
|
|
516
|
+
throw new Error('No data returned from GraphQL query');
|
|
517
|
+
}
|
|
518
|
+
const graphqlResponse = result.data.blockService_getReferences;
|
|
519
|
+
return {
|
|
520
|
+
blockAri,
|
|
521
|
+
references: graphqlResponse.references || [],
|
|
522
|
+
errors: graphqlResponse.errors || []
|
|
523
|
+
};
|
|
524
|
+
}
|
|
478
525
|
const response = await fetchWithRetry(`${BLOCK_SERVICE_API_URL}/reference/batch-retrieve/${encodeURIComponent(blockAri)}`, {
|
|
479
526
|
method: 'GET',
|
|
480
527
|
headers: COMMON_HEADERS
|
|
@@ -123,6 +123,7 @@ var DELETE_BLOCK_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_DELETE_BLOCK';
|
|
|
123
123
|
var CREATE_BLOCK_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_CREATE_BLOCK';
|
|
124
124
|
var UPDATE_DOCUMENT_REFERENCES_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_UPDATE_DOCUMENT_REFERENCES';
|
|
125
125
|
var BATCH_RETRIEVE_BLOCKS_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_BATCH_RETRIEVE_BLOCKS';
|
|
126
|
+
var GET_BLOCK_REFERENCES_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_GET_REFERENCES';
|
|
126
127
|
var buildGetDocumentReferenceBlocksQuery = function buildGetDocumentReferenceBlocksQuery(documentAri) {
|
|
127
128
|
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}");
|
|
128
129
|
};
|
|
@@ -180,6 +181,9 @@ var buildBatchRetrieveBlocksQuery = function buildBatchRetrieveBlocksQuery(block
|
|
|
180
181
|
var inputArgs = "blockAris: [".concat(blockArisArray, "]");
|
|
181
182
|
return "query ".concat(BATCH_RETRIEVE_BLOCKS_OPERATION_NAME, " {\n\tblockService_batchRetrieveBlocks(input: { ").concat(inputArgs, " }) {\n\t\tsuccess {\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\tdeletionReason\n\t\t\tproduct\n\t\t\tsourceAri\n\t\t\tstatus\n\t\t\tversion\n\t\t}\n\t\terror {\n\t\t\tblockAri\n\t\t\tcode\n\t\t\treason\n\t\t}\n\t}\n}");
|
|
182
183
|
};
|
|
184
|
+
var buildGetBlockReferencesQuery = function buildGetBlockReferencesQuery(blockAri) {
|
|
185
|
+
return "query ".concat(GET_BLOCK_REFERENCES_OPERATION_NAME, " {\n\tblockService_getReferences(blockAri: ").concat(JSON.stringify(blockAri), ") {\n\t\treferences {\n\t\t\tblockAri\n\t\t\tblockInstanceId\n\t\t\tcreatedAt\n\t\t\tcreatedBy\n\t\t\tdocumentAri\n\t\t}\n\t\terrors {\n\t\t\tblockAri\n\t\t\tcode\n\t\t\treason\n\t\t}\n\t}\n}");
|
|
186
|
+
};
|
|
183
187
|
export var BlockError = /*#__PURE__*/function (_Error) {
|
|
184
188
|
function BlockError(status) {
|
|
185
189
|
var _this;
|
|
@@ -658,29 +662,76 @@ export var updateReferenceSyncedBlockOnDocument = /*#__PURE__*/function () {
|
|
|
658
662
|
}();
|
|
659
663
|
export var getReferenceSyncedBlocksByBlockAri = /*#__PURE__*/function () {
|
|
660
664
|
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref12) {
|
|
661
|
-
var blockAri, response;
|
|
665
|
+
var blockAri, _result$data5, bodyData, _response6, result, graphqlResponse, response;
|
|
662
666
|
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
663
667
|
while (1) switch (_context8.prev = _context8.next) {
|
|
664
668
|
case 0:
|
|
665
669
|
blockAri = _ref12.blockAri;
|
|
666
|
-
|
|
670
|
+
if (!fg('platform_synced_block_patch_1')) {
|
|
671
|
+
_context8.next = 17;
|
|
672
|
+
break;
|
|
673
|
+
}
|
|
674
|
+
bodyData = {
|
|
675
|
+
query: buildGetBlockReferencesQuery(blockAri),
|
|
676
|
+
operationName: GET_BLOCK_REFERENCES_OPERATION_NAME
|
|
677
|
+
};
|
|
678
|
+
_context8.next = 5;
|
|
679
|
+
return fetchWithRetry(GRAPHQL_ENDPOINT, {
|
|
680
|
+
method: 'POST',
|
|
681
|
+
headers: COMMON_HEADERS,
|
|
682
|
+
body: JSON.stringify(bodyData)
|
|
683
|
+
});
|
|
684
|
+
case 5:
|
|
685
|
+
_response6 = _context8.sent;
|
|
686
|
+
if (_response6.ok) {
|
|
687
|
+
_context8.next = 8;
|
|
688
|
+
break;
|
|
689
|
+
}
|
|
690
|
+
throw new BlockError(_response6.status);
|
|
691
|
+
case 8:
|
|
692
|
+
_context8.next = 10;
|
|
693
|
+
return _response6.json();
|
|
694
|
+
case 10:
|
|
695
|
+
result = _context8.sent;
|
|
696
|
+
if (!(result.errors && result.errors.length > 0)) {
|
|
697
|
+
_context8.next = 13;
|
|
698
|
+
break;
|
|
699
|
+
}
|
|
700
|
+
throw new Error(result.errors.map(function (e) {
|
|
701
|
+
return e.message;
|
|
702
|
+
}).join(', '));
|
|
703
|
+
case 13:
|
|
704
|
+
if ((_result$data5 = result.data) !== null && _result$data5 !== void 0 && _result$data5.blockService_getReferences) {
|
|
705
|
+
_context8.next = 15;
|
|
706
|
+
break;
|
|
707
|
+
}
|
|
708
|
+
throw new Error('No data returned from GraphQL query');
|
|
709
|
+
case 15:
|
|
710
|
+
graphqlResponse = result.data.blockService_getReferences;
|
|
711
|
+
return _context8.abrupt("return", {
|
|
712
|
+
blockAri: blockAri,
|
|
713
|
+
references: graphqlResponse.references || [],
|
|
714
|
+
errors: graphqlResponse.errors || []
|
|
715
|
+
});
|
|
716
|
+
case 17:
|
|
717
|
+
_context8.next = 19;
|
|
667
718
|
return fetchWithRetry("".concat(BLOCK_SERVICE_API_URL, "/reference/batch-retrieve/").concat(encodeURIComponent(blockAri)), {
|
|
668
719
|
method: 'GET',
|
|
669
720
|
headers: COMMON_HEADERS
|
|
670
721
|
});
|
|
671
|
-
case
|
|
722
|
+
case 19:
|
|
672
723
|
response = _context8.sent;
|
|
673
724
|
if (response.ok) {
|
|
674
|
-
_context8.next =
|
|
725
|
+
_context8.next = 22;
|
|
675
726
|
break;
|
|
676
727
|
}
|
|
677
728
|
throw new BlockError(response.status);
|
|
678
|
-
case
|
|
679
|
-
_context8.next =
|
|
729
|
+
case 22:
|
|
730
|
+
_context8.next = 24;
|
|
680
731
|
return response.json();
|
|
681
|
-
case
|
|
732
|
+
case 24:
|
|
682
733
|
return _context8.abrupt("return", _context8.sent);
|
|
683
|
-
case
|
|
734
|
+
case 25:
|
|
684
735
|
case "end":
|
|
685
736
|
return _context8.stop();
|
|
686
737
|
}
|
package/package.json
CHANGED