@atlaskit/editor-synced-block-provider 2.8.0 → 2.9.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 +7 -0
- package/dist/cjs/index.js +30 -0
- package/dist/cjs/providers/block-service/blockServiceAPI.js +14 -8
- package/dist/cjs/providers/confluence/confluenceContentAPI.js +5 -0
- package/dist/cjs/providers/syncBlockProvider.js +5 -0
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +2 -5
- package/dist/cjs/utils/ari.js +32 -4
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/providers/block-service/blockServiceAPI.js +12 -8
- package/dist/es2019/providers/confluence/confluenceContentAPI.js +4 -1
- package/dist/es2019/providers/syncBlockProvider.js +3 -0
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +2 -5
- package/dist/es2019/utils/ari.js +31 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/providers/block-service/blockServiceAPI.js +15 -9
- package/dist/esm/providers/confluence/confluenceContentAPI.js +6 -1
- package/dist/esm/providers/syncBlockProvider.js +5 -0
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +2 -5
- package/dist/esm/utils/ari.js +31 -3
- package/dist/types/index.d.ts +1 -1
- package/dist/types/providers/block-service/blockServiceAPI.d.ts +1 -0
- package/dist/types/providers/confluence/confluenceContentAPI.d.ts +1 -0
- package/dist/types/providers/syncBlockProvider.d.ts +1 -0
- package/dist/types/providers/types.d.ts +8 -0
- package/dist/types/utils/ari.d.ts +15 -1
- package/dist/types/utils/blockService.d.ts +1 -1
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +1 -0
- package/dist/types-ts4.5/providers/confluence/confluenceContentAPI.d.ts +1 -0
- package/dist/types-ts4.5/providers/syncBlockProvider.d.ts +1 -0
- package/dist/types-ts4.5/providers/types.d.ts +8 -0
- package/dist/types-ts4.5/utils/ari.d.ts +15 -1
- package/dist/types-ts4.5/utils/blockService.d.ts +1 -1
- package/package.json +7 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/editor-synced-block-provider
|
|
2
2
|
|
|
3
|
+
## 2.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`e0dc40edfc665`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e0dc40edfc665) -
|
|
8
|
+
Update the resource ID generation for blockAri format
|
|
9
|
+
|
|
3
10
|
## 2.8.0
|
|
4
11
|
|
|
5
12
|
### Minor Changes
|
package/dist/cjs/index.js
CHANGED
|
@@ -27,6 +27,12 @@ Object.defineProperty(exports, "SyncedBlockProvider", {
|
|
|
27
27
|
return _syncBlockProvider.SyncBlockProvider;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
+
Object.defineProperty(exports, "blockResourceIdFromSourceAndLocalId", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function get() {
|
|
33
|
+
return _ari.blockResourceIdFromSourceAndLocalId;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
30
36
|
Object.defineProperty(exports, "convertSyncBlockJSONNodeToSyncBlockNode", {
|
|
31
37
|
enumerable: true,
|
|
32
38
|
get: function get() {
|
|
@@ -57,6 +63,24 @@ Object.defineProperty(exports, "getConfluencePageAri", {
|
|
|
57
63
|
return _ari.getConfluencePageAri;
|
|
58
64
|
}
|
|
59
65
|
});
|
|
66
|
+
Object.defineProperty(exports, "getLocalIdFromAri", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function get() {
|
|
69
|
+
return _ari.getLocalIdFromAri;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(exports, "getLocalIdFromResourceId", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function get() {
|
|
75
|
+
return _ari.getLocalIdFromResourceId;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(exports, "getPageARIFromResourceId", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function get() {
|
|
81
|
+
return _ari.getPageARIFromResourceId;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
60
84
|
Object.defineProperty(exports, "getPageIdAndTypeFromAri", {
|
|
61
85
|
enumerable: true,
|
|
62
86
|
get: function get() {
|
|
@@ -75,6 +99,12 @@ Object.defineProperty(exports, "resolveSyncBlockInstance", {
|
|
|
75
99
|
return _resolveSyncBlockInstance.resolveSyncBlockInstance;
|
|
76
100
|
}
|
|
77
101
|
});
|
|
102
|
+
Object.defineProperty(exports, "resourceIdFromSourceAndLocalId", {
|
|
103
|
+
enumerable: true,
|
|
104
|
+
get: function get() {
|
|
105
|
+
return _ari.resourceIdFromSourceAndLocalId;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
78
108
|
Object.defineProperty(exports, "useFetchSyncBlockData", {
|
|
79
109
|
enumerable: true,
|
|
80
110
|
get: function get() {
|
|
@@ -34,21 +34,22 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
34
34
|
return (0, _createClass2.default)(BlockServiceADFFetchProvider, [{
|
|
35
35
|
key: "fetchData",
|
|
36
36
|
value: // resourceId is the ARI of the block. E.G ari:cloud:blocks:site-123:synced-block/uuid-456
|
|
37
|
+
// in the content API provider, this was the concatenation of the source document's ARI and the local ID. E.G ari:cloud:confluence:site-123:page/pageId/uuid-456
|
|
37
38
|
function () {
|
|
38
39
|
var _fetchData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(resourceId) {
|
|
39
|
-
var localId,
|
|
40
|
+
var localId, blockContentResponse, value, syncedBlockData;
|
|
40
41
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
41
42
|
while (1) switch (_context.prev = _context.next) {
|
|
42
43
|
case 0:
|
|
43
|
-
localId = (0, _ari.
|
|
44
|
+
localId = (0, _ari.getLocalIdFromResourceId)(resourceId);
|
|
44
45
|
_context.prev = 1;
|
|
45
46
|
_context.next = 4;
|
|
46
47
|
return (0, _blockService.getSyncedBlockContent)({
|
|
47
48
|
blockAri: resourceId
|
|
48
49
|
});
|
|
49
50
|
case 4:
|
|
50
|
-
|
|
51
|
-
value =
|
|
51
|
+
blockContentResponse = _context.sent;
|
|
52
|
+
value = blockContentResponse.content;
|
|
52
53
|
if (value) {
|
|
53
54
|
_context.next = 8;
|
|
54
55
|
break;
|
|
@@ -58,7 +59,7 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
58
59
|
resourceId: resourceId
|
|
59
60
|
});
|
|
60
61
|
case 8:
|
|
61
|
-
// Parse the synced block content from the
|
|
62
|
+
// Parse the synced block content from the response's content
|
|
62
63
|
syncedBlockData = JSON.parse(value);
|
|
63
64
|
return _context.abrupt("return", {
|
|
64
65
|
data: {
|
|
@@ -106,7 +107,7 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
106
107
|
}
|
|
107
108
|
return (0, _createClass2.default)(BlockServiceADFWriteProvider, [{
|
|
108
109
|
key: "writeData",
|
|
109
|
-
value: // it will first try to update and if it can't (404) then it will try to create
|
|
110
|
+
value: // it will first try to update and if it can't (404) then it will try to create
|
|
110
111
|
function () {
|
|
111
112
|
var _writeData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(data) {
|
|
112
113
|
var resourceId;
|
|
@@ -137,7 +138,7 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
137
138
|
}
|
|
138
139
|
_context2.next = 13;
|
|
139
140
|
return (0, _blockService.createSyncedBlock)({
|
|
140
|
-
blockAri:
|
|
141
|
+
blockAri: resourceId,
|
|
141
142
|
blockInstanceId: data.blockInstanceId,
|
|
142
143
|
sourceAri: resourceId,
|
|
143
144
|
product: 'confluence-page',
|
|
@@ -166,7 +167,7 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
166
167
|
return _writeData.apply(this, arguments);
|
|
167
168
|
}
|
|
168
169
|
return writeData;
|
|
169
|
-
}() // soft deletes the source synced block
|
|
170
|
+
}() // soft deletes the source synced block
|
|
170
171
|
}, {
|
|
171
172
|
key: "deleteData",
|
|
172
173
|
value: function () {
|
|
@@ -214,6 +215,11 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
214
215
|
}
|
|
215
216
|
return deleteData;
|
|
216
217
|
}()
|
|
218
|
+
}, {
|
|
219
|
+
key: "generateResourceId",
|
|
220
|
+
value: function generateResourceId(sourceId, localId) {
|
|
221
|
+
return (0, _ari.blockResourceIdFromSourceAndLocalId)(sourceId, localId);
|
|
222
|
+
}
|
|
217
223
|
}]);
|
|
218
224
|
}();
|
|
219
225
|
/**
|
|
@@ -343,6 +343,11 @@ var ConfluenceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
343
343
|
}
|
|
344
344
|
return deleteData;
|
|
345
345
|
}()
|
|
346
|
+
}, {
|
|
347
|
+
key: "generateResourceId",
|
|
348
|
+
value: function generateResourceId(sourceId, localId) {
|
|
349
|
+
return (0, _ari.resourceIdFromSourceAndLocalId)(sourceId, localId);
|
|
350
|
+
}
|
|
346
351
|
}]);
|
|
347
352
|
}();
|
|
348
353
|
/**
|
|
@@ -177,6 +177,11 @@ var SyncBlockProvider = exports.SyncBlockProvider = /*#__PURE__*/function (_Sync
|
|
|
177
177
|
}
|
|
178
178
|
return pageARI ? (0, _sourceInfo.fetchSourceInfo)(pageARI, sourceLocalId) : Promise.resolve(undefined);
|
|
179
179
|
}
|
|
180
|
+
}, {
|
|
181
|
+
key: "generateResourceId",
|
|
182
|
+
value: function generateResourceId(sourceId, localId) {
|
|
183
|
+
return this.writeProvider.generateResourceId(sourceId, localId);
|
|
184
|
+
}
|
|
180
185
|
}]);
|
|
181
186
|
}(_types2.SyncBlockDataProvider);
|
|
182
187
|
var useMemoizedSyncedBlockProvider = exports.useMemoizedSyncedBlockProvider = function useMemoizedSyncedBlockProvider(fetchProvider, writeProvider, sourceId) {
|
|
@@ -12,7 +12,6 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
|
|
|
12
12
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
13
|
var _uuid = _interopRequireDefault(require("uuid"));
|
|
14
14
|
var _rebaseTransaction2 = require("../common/rebase-transaction");
|
|
15
|
-
var _ari = require("../utils/ari");
|
|
16
15
|
var _utils = require("../utils/utils");
|
|
17
16
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
18
17
|
var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
@@ -165,12 +164,10 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
165
164
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
166
165
|
var localId = (0, _uuid.default)();
|
|
167
166
|
var sourceId = (_this$dataProvider = this.dataProvider) === null || _this$dataProvider === void 0 ? void 0 : _this$dataProvider.getSourceId();
|
|
168
|
-
if (!sourceId) {
|
|
167
|
+
if (!this.dataProvider || !sourceId) {
|
|
169
168
|
throw new Error('Provider of sync block plugin is not set');
|
|
170
169
|
}
|
|
171
|
-
|
|
172
|
-
// This should be generated by the data provider implementation as it differs between data providers
|
|
173
|
-
var resourceId = (0, _ari.resourceIdFromSourceAndLocalId)(sourceId, localId);
|
|
170
|
+
var resourceId = this.dataProvider.generateResourceId(sourceId, localId);
|
|
174
171
|
return {
|
|
175
172
|
resourceId: resourceId,
|
|
176
173
|
localId: localId
|
package/dist/cjs/utils/ari.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.resourceIdFromSourceAndLocalId = exports.getPageIdAndTypeFromAri = exports.getPageARIFromResourceId = exports.
|
|
6
|
+
exports.resourceIdFromSourceAndLocalId = exports.getPageIdAndTypeFromAri = exports.getPageARIFromResourceId = exports.getLocalIdFromResourceId = exports.getLocalIdFromAri = exports.getConfluencePageAri = exports.blockResourceIdFromSourceAndLocalId = void 0;
|
|
7
7
|
/* eslint-disable require-unicode-regexp */
|
|
8
8
|
|
|
9
9
|
var getConfluencePageAri = exports.getConfluencePageAri = function getConfluencePageAri(pageId, cloudId) {
|
|
@@ -34,9 +34,37 @@ var getPageARIFromResourceId = exports.getPageARIFromResourceId = function getPa
|
|
|
34
34
|
}
|
|
35
35
|
throw new Error("Invalid resourceId: ".concat(resourceId));
|
|
36
36
|
};
|
|
37
|
-
var getContentPropertyAri = exports.getContentPropertyAri = function getContentPropertyAri(contentPropertyId, cloudId) {
|
|
38
|
-
return "ari:cloud:confluence:".concat(cloudId, ":content/").concat(contentPropertyId);
|
|
39
|
-
};
|
|
40
37
|
var resourceIdFromSourceAndLocalId = exports.resourceIdFromSourceAndLocalId = function resourceIdFromSourceAndLocalId(sourceId, localId) {
|
|
41
38
|
return sourceId + '/' + localId;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* For the following functions, they are used for the block service API provider.
|
|
43
|
+
* The resourceId/blockResourceId always refers to the block ARI.
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @param sourceId - the ARI of the document. E.G ari:cloud:confluence:cloudId:page/pageId
|
|
48
|
+
* @param localId - the localId of the block node. A randomly generated UUID
|
|
49
|
+
* @returns the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
|
|
50
|
+
*/
|
|
51
|
+
var blockResourceIdFromSourceAndLocalId = exports.blockResourceIdFromSourceAndLocalId = function blockResourceIdFromSourceAndLocalId(sourceId, localId) {
|
|
52
|
+
var match = sourceId.match(/ari:cloud:confluence:([^:]+):(page|blogpost)\/.*/);
|
|
53
|
+
if (!(match !== null && match !== void 0 && match[1])) {
|
|
54
|
+
throw new Error("Invalid source ARI: ".concat(sourceId));
|
|
55
|
+
}
|
|
56
|
+
var cloudId = match[1];
|
|
57
|
+
return "ari:cloud:blocks:".concat(cloudId, ":synced-block/").concat(localId);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @param ari - the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
|
|
62
|
+
* @returns the localId of the block node. A randomly generated UUID
|
|
63
|
+
*/
|
|
64
|
+
var getLocalIdFromResourceId = exports.getLocalIdFromResourceId = function getLocalIdFromResourceId(ari) {
|
|
65
|
+
var match = ari.match(/ari:cloud:confluence:[^:]+:(page|blogpost)\/\d+\/([a-zA-Z0-9-]+)/);
|
|
66
|
+
if (match !== null && match !== void 0 && match[2]) {
|
|
67
|
+
return match[2];
|
|
68
|
+
}
|
|
69
|
+
throw new Error("Invalid page ARI: ".concat(ari));
|
|
42
70
|
};
|
package/dist/es2019/index.js
CHANGED
|
@@ -10,6 +10,6 @@ export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders
|
|
|
10
10
|
export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider } from './providers/syncBlockProvider';
|
|
11
11
|
export { ReferenceSyncBlockStoreManager } from './store-manager/referenceSyncBlockStoreManager';
|
|
12
12
|
export { SyncBlockStoreManager } from './store-manager/syncBlockStoreManager';
|
|
13
|
-
export { getConfluencePageAri, getPageIdAndTypeFromAri } from './utils/ari';
|
|
13
|
+
export { blockResourceIdFromSourceAndLocalId, getConfluencePageAri, getLocalIdFromAri, getLocalIdFromResourceId, getPageARIFromResourceId, getPageIdAndTypeFromAri, resourceIdFromSourceAndLocalId } from './utils/ari';
|
|
14
14
|
export { createSyncBlockNode, convertSyncBlockPMNodeToSyncBlockData, convertSyncBlockJSONNodeToSyncBlockNode } from './utils/utils';
|
|
15
15
|
export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { SyncBlockError } from '../../common/types';
|
|
3
|
-
import {
|
|
3
|
+
import { blockResourceIdFromSourceAndLocalId, getLocalIdFromResourceId } from '../../utils/ari';
|
|
4
4
|
import { BlockError, createSyncedBlock, deleteSyncedBlock, getSyncedBlockContent, updateSyncedBlock } from '../../utils/blockService';
|
|
5
5
|
import { stringifyError } from '../../utils/errorHandling';
|
|
6
6
|
const mapBlockError = error => {
|
|
@@ -18,13 +18,14 @@ const mapBlockError = error => {
|
|
|
18
18
|
*/
|
|
19
19
|
class BlockServiceADFFetchProvider {
|
|
20
20
|
// resourceId is the ARI of the block. E.G ari:cloud:blocks:site-123:synced-block/uuid-456
|
|
21
|
+
// in the content API provider, this was the concatenation of the source document's ARI and the local ID. E.G ari:cloud:confluence:site-123:page/pageId/uuid-456
|
|
21
22
|
async fetchData(resourceId) {
|
|
22
|
-
const localId =
|
|
23
|
+
const localId = getLocalIdFromResourceId(resourceId);
|
|
23
24
|
try {
|
|
24
|
-
const
|
|
25
|
+
const blockContentResponse = await getSyncedBlockContent({
|
|
25
26
|
blockAri: resourceId
|
|
26
27
|
});
|
|
27
|
-
const value =
|
|
28
|
+
const value = blockContentResponse.content;
|
|
28
29
|
if (!value) {
|
|
29
30
|
return {
|
|
30
31
|
error: SyncBlockError.NotFound,
|
|
@@ -32,7 +33,7 @@ class BlockServiceADFFetchProvider {
|
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
// Parse the synced block content from the
|
|
36
|
+
// Parse the synced block content from the response's content
|
|
36
37
|
const syncedBlockData = JSON.parse(value);
|
|
37
38
|
return {
|
|
38
39
|
data: {
|
|
@@ -61,7 +62,7 @@ class BlockServiceADFFetchProvider {
|
|
|
61
62
|
* ADFWriteProvider implementation that writes synced block data to Block Service API
|
|
62
63
|
*/
|
|
63
64
|
class BlockServiceADFWriteProvider {
|
|
64
|
-
// it will first try to update and if it can't (404) then it will try to create
|
|
65
|
+
// it will first try to update and if it can't (404) then it will try to create
|
|
65
66
|
async writeData(data) {
|
|
66
67
|
const {
|
|
67
68
|
resourceId
|
|
@@ -80,7 +81,7 @@ class BlockServiceADFWriteProvider {
|
|
|
80
81
|
if (error.status === 404) {
|
|
81
82
|
// Create the block
|
|
82
83
|
await createSyncedBlock({
|
|
83
|
-
blockAri:
|
|
84
|
+
blockAri: resourceId,
|
|
84
85
|
blockInstanceId: data.blockInstanceId,
|
|
85
86
|
sourceAri: resourceId,
|
|
86
87
|
product: 'confluence-page',
|
|
@@ -100,7 +101,7 @@ class BlockServiceADFWriteProvider {
|
|
|
100
101
|
}
|
|
101
102
|
}
|
|
102
103
|
|
|
103
|
-
// soft deletes the source synced block
|
|
104
|
+
// soft deletes the source synced block
|
|
104
105
|
async deleteData(resourceId) {
|
|
105
106
|
try {
|
|
106
107
|
await deleteSyncedBlock({
|
|
@@ -126,6 +127,9 @@ class BlockServiceADFWriteProvider {
|
|
|
126
127
|
};
|
|
127
128
|
}
|
|
128
129
|
}
|
|
130
|
+
generateResourceId(sourceId, localId) {
|
|
131
|
+
return blockResourceIdFromSourceAndLocalId(sourceId, localId);
|
|
132
|
+
}
|
|
129
133
|
}
|
|
130
134
|
|
|
131
135
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { SyncBlockError } from '../../common/types';
|
|
4
|
-
import { getLocalIdFromAri, getPageIdAndTypeFromAri } from '../../utils/ari';
|
|
4
|
+
import { getLocalIdFromAri, getPageIdAndTypeFromAri, resourceIdFromSourceAndLocalId } from '../../utils/ari';
|
|
5
5
|
import { getContentProperty, createContentProperty, updateContentProperty, deleteContentProperty } from '../../utils/contentProperty';
|
|
6
6
|
import { stringifyError } from '../../utils/errorHandling';
|
|
7
7
|
import { isBlogPageType } from '../../utils/utils';
|
|
@@ -227,6 +227,9 @@ class ConfluenceADFWriteProvider {
|
|
|
227
227
|
error: deleteResult.errors.join()
|
|
228
228
|
};
|
|
229
229
|
}
|
|
230
|
+
generateResourceId(sourceId, localId) {
|
|
231
|
+
return resourceIdFromSourceAndLocalId(sourceId, localId);
|
|
232
|
+
}
|
|
230
233
|
}
|
|
231
234
|
|
|
232
235
|
/**
|
|
@@ -99,6 +99,9 @@ export class SyncBlockProvider extends SyncBlockDataProvider {
|
|
|
99
99
|
}
|
|
100
100
|
return pageARI ? fetchSourceInfo(pageARI, sourceLocalId) : Promise.resolve(undefined);
|
|
101
101
|
}
|
|
102
|
+
generateResourceId(sourceId, localId) {
|
|
103
|
+
return this.writeProvider.generateResourceId(sourceId, localId);
|
|
104
|
+
}
|
|
102
105
|
}
|
|
103
106
|
export const useMemoizedSyncedBlockProvider = (fetchProvider, writeProvider, sourceId) => {
|
|
104
107
|
return useMemo(() => {
|
|
@@ -2,7 +2,6 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
3
3
|
import uuid from 'uuid';
|
|
4
4
|
import { rebaseTransaction } from '../common/rebase-transaction';
|
|
5
|
-
import { resourceIdFromSourceAndLocalId } from '../utils/ari';
|
|
6
5
|
import { convertSyncBlockPMNodeToSyncBlockData, createBodiedSyncBlockNode } from '../utils/utils';
|
|
7
6
|
export class SourceSyncBlockStoreManager {
|
|
8
7
|
constructor(dataProvider) {
|
|
@@ -106,12 +105,10 @@ export class SourceSyncBlockStoreManager {
|
|
|
106
105
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
107
106
|
const localId = uuid();
|
|
108
107
|
const sourceId = (_this$dataProvider = this.dataProvider) === null || _this$dataProvider === void 0 ? void 0 : _this$dataProvider.getSourceId();
|
|
109
|
-
if (!sourceId) {
|
|
108
|
+
if (!this.dataProvider || !sourceId) {
|
|
110
109
|
throw new Error('Provider of sync block plugin is not set');
|
|
111
110
|
}
|
|
112
|
-
|
|
113
|
-
// This should be generated by the data provider implementation as it differs between data providers
|
|
114
|
-
const resourceId = resourceIdFromSourceAndLocalId(sourceId, localId);
|
|
111
|
+
const resourceId = this.dataProvider.generateResourceId(sourceId, localId);
|
|
115
112
|
return {
|
|
116
113
|
resourceId,
|
|
117
114
|
localId
|
package/dist/es2019/utils/ari.js
CHANGED
|
@@ -25,7 +25,37 @@ export const getPageARIFromResourceId = resourceId => {
|
|
|
25
25
|
}
|
|
26
26
|
throw new Error(`Invalid resourceId: ${resourceId}`);
|
|
27
27
|
};
|
|
28
|
-
export const getContentPropertyAri = (contentPropertyId, cloudId) => `ari:cloud:confluence:${cloudId}:content/${contentPropertyId}`;
|
|
29
28
|
export const resourceIdFromSourceAndLocalId = (sourceId, localId) => {
|
|
30
29
|
return sourceId + '/' + localId;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* For the following functions, they are used for the block service API provider.
|
|
34
|
+
* The resourceId/blockResourceId always refers to the block ARI.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @param sourceId - the ARI of the document. E.G ari:cloud:confluence:cloudId:page/pageId
|
|
39
|
+
* @param localId - the localId of the block node. A randomly generated UUID
|
|
40
|
+
* @returns the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
|
|
41
|
+
*/
|
|
42
|
+
export const blockResourceIdFromSourceAndLocalId = (sourceId, localId) => {
|
|
43
|
+
const match = sourceId.match(/ari:cloud:confluence:([^:]+):(page|blogpost)\/.*/);
|
|
44
|
+
if (!(match !== null && match !== void 0 && match[1])) {
|
|
45
|
+
throw new Error(`Invalid source ARI: ${sourceId}`);
|
|
46
|
+
}
|
|
47
|
+
const cloudId = match[1];
|
|
48
|
+
return `ari:cloud:blocks:${cloudId}:synced-block/${localId}`;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @param ari - the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
|
|
53
|
+
* @returns the localId of the block node. A randomly generated UUID
|
|
54
|
+
*/
|
|
55
|
+
export const getLocalIdFromResourceId = ari => {
|
|
56
|
+
const match = ari.match(/ari:cloud:confluence:[^:]+:(page|blogpost)\/\d+\/([a-zA-Z0-9-]+)/);
|
|
57
|
+
if (match !== null && match !== void 0 && match[2]) {
|
|
58
|
+
return match[2];
|
|
59
|
+
}
|
|
60
|
+
throw new Error(`Invalid page ARI: ${ari}`);
|
|
31
61
|
};
|
package/dist/esm/index.js
CHANGED
|
@@ -10,6 +10,6 @@ export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders
|
|
|
10
10
|
export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider } from './providers/syncBlockProvider';
|
|
11
11
|
export { ReferenceSyncBlockStoreManager } from './store-manager/referenceSyncBlockStoreManager';
|
|
12
12
|
export { SyncBlockStoreManager } from './store-manager/syncBlockStoreManager';
|
|
13
|
-
export { getConfluencePageAri, getPageIdAndTypeFromAri } from './utils/ari';
|
|
13
|
+
export { blockResourceIdFromSourceAndLocalId, getConfluencePageAri, getLocalIdFromAri, getLocalIdFromResourceId, getPageARIFromResourceId, getPageIdAndTypeFromAri, resourceIdFromSourceAndLocalId } from './utils/ari';
|
|
14
14
|
export { createSyncBlockNode, convertSyncBlockPMNodeToSyncBlockData, convertSyncBlockJSONNodeToSyncBlockNode } from './utils/utils';
|
|
15
15
|
export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
|
|
@@ -4,7 +4,7 @@ import _createClass from "@babel/runtime/helpers/createClass";
|
|
|
4
4
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
5
|
import { useMemo } from 'react';
|
|
6
6
|
import { SyncBlockError } from '../../common/types';
|
|
7
|
-
import {
|
|
7
|
+
import { blockResourceIdFromSourceAndLocalId, getLocalIdFromResourceId } from '../../utils/ari';
|
|
8
8
|
import { BlockError, createSyncedBlock, deleteSyncedBlock, getSyncedBlockContent, updateSyncedBlock } from '../../utils/blockService';
|
|
9
9
|
import { stringifyError } from '../../utils/errorHandling';
|
|
10
10
|
var mapBlockError = function mapBlockError(error) {
|
|
@@ -27,21 +27,22 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
27
27
|
return _createClass(BlockServiceADFFetchProvider, [{
|
|
28
28
|
key: "fetchData",
|
|
29
29
|
value: // resourceId is the ARI of the block. E.G ari:cloud:blocks:site-123:synced-block/uuid-456
|
|
30
|
+
// in the content API provider, this was the concatenation of the source document's ARI and the local ID. E.G ari:cloud:confluence:site-123:page/pageId/uuid-456
|
|
30
31
|
function () {
|
|
31
32
|
var _fetchData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(resourceId) {
|
|
32
|
-
var localId,
|
|
33
|
+
var localId, blockContentResponse, value, syncedBlockData;
|
|
33
34
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
34
35
|
while (1) switch (_context.prev = _context.next) {
|
|
35
36
|
case 0:
|
|
36
|
-
localId =
|
|
37
|
+
localId = getLocalIdFromResourceId(resourceId);
|
|
37
38
|
_context.prev = 1;
|
|
38
39
|
_context.next = 4;
|
|
39
40
|
return getSyncedBlockContent({
|
|
40
41
|
blockAri: resourceId
|
|
41
42
|
});
|
|
42
43
|
case 4:
|
|
43
|
-
|
|
44
|
-
value =
|
|
44
|
+
blockContentResponse = _context.sent;
|
|
45
|
+
value = blockContentResponse.content;
|
|
45
46
|
if (value) {
|
|
46
47
|
_context.next = 8;
|
|
47
48
|
break;
|
|
@@ -51,7 +52,7 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
51
52
|
resourceId: resourceId
|
|
52
53
|
});
|
|
53
54
|
case 8:
|
|
54
|
-
// Parse the synced block content from the
|
|
55
|
+
// Parse the synced block content from the response's content
|
|
55
56
|
syncedBlockData = JSON.parse(value);
|
|
56
57
|
return _context.abrupt("return", {
|
|
57
58
|
data: {
|
|
@@ -99,7 +100,7 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
99
100
|
}
|
|
100
101
|
return _createClass(BlockServiceADFWriteProvider, [{
|
|
101
102
|
key: "writeData",
|
|
102
|
-
value: // it will first try to update and if it can't (404) then it will try to create
|
|
103
|
+
value: // it will first try to update and if it can't (404) then it will try to create
|
|
103
104
|
function () {
|
|
104
105
|
var _writeData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(data) {
|
|
105
106
|
var resourceId;
|
|
@@ -130,7 +131,7 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
130
131
|
}
|
|
131
132
|
_context2.next = 13;
|
|
132
133
|
return createSyncedBlock({
|
|
133
|
-
blockAri:
|
|
134
|
+
blockAri: resourceId,
|
|
134
135
|
blockInstanceId: data.blockInstanceId,
|
|
135
136
|
sourceAri: resourceId,
|
|
136
137
|
product: 'confluence-page',
|
|
@@ -159,7 +160,7 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
159
160
|
return _writeData.apply(this, arguments);
|
|
160
161
|
}
|
|
161
162
|
return writeData;
|
|
162
|
-
}() // soft deletes the source synced block
|
|
163
|
+
}() // soft deletes the source synced block
|
|
163
164
|
}, {
|
|
164
165
|
key: "deleteData",
|
|
165
166
|
value: function () {
|
|
@@ -207,6 +208,11 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
207
208
|
}
|
|
208
209
|
return deleteData;
|
|
209
210
|
}()
|
|
211
|
+
}, {
|
|
212
|
+
key: "generateResourceId",
|
|
213
|
+
value: function generateResourceId(sourceId, localId) {
|
|
214
|
+
return blockResourceIdFromSourceAndLocalId(sourceId, localId);
|
|
215
|
+
}
|
|
210
216
|
}]);
|
|
211
217
|
}();
|
|
212
218
|
/**
|
|
@@ -6,7 +6,7 @@ import _typeof from "@babel/runtime/helpers/typeof";
|
|
|
6
6
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
7
7
|
import { useMemo } from 'react';
|
|
8
8
|
import { SyncBlockError } from '../../common/types';
|
|
9
|
-
import { getLocalIdFromAri, getPageIdAndTypeFromAri } from '../../utils/ari';
|
|
9
|
+
import { getLocalIdFromAri, getPageIdAndTypeFromAri, resourceIdFromSourceAndLocalId } from '../../utils/ari';
|
|
10
10
|
import { getContentProperty, createContentProperty, updateContentProperty, deleteContentProperty } from '../../utils/contentProperty';
|
|
11
11
|
import { stringifyError } from '../../utils/errorHandling';
|
|
12
12
|
import { isBlogPageType } from '../../utils/utils';
|
|
@@ -337,6 +337,11 @@ var ConfluenceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
337
337
|
}
|
|
338
338
|
return deleteData;
|
|
339
339
|
}()
|
|
340
|
+
}, {
|
|
341
|
+
key: "generateResourceId",
|
|
342
|
+
value: function generateResourceId(sourceId, localId) {
|
|
343
|
+
return resourceIdFromSourceAndLocalId(sourceId, localId);
|
|
344
|
+
}
|
|
340
345
|
}]);
|
|
341
346
|
}();
|
|
342
347
|
/**
|
|
@@ -170,6 +170,11 @@ export var SyncBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
|
|
|
170
170
|
}
|
|
171
171
|
return pageARI ? fetchSourceInfo(pageARI, sourceLocalId) : Promise.resolve(undefined);
|
|
172
172
|
}
|
|
173
|
+
}, {
|
|
174
|
+
key: "generateResourceId",
|
|
175
|
+
value: function generateResourceId(sourceId, localId) {
|
|
176
|
+
return this.writeProvider.generateResourceId(sourceId, localId);
|
|
177
|
+
}
|
|
173
178
|
}]);
|
|
174
179
|
}(SyncBlockDataProvider);
|
|
175
180
|
export var useMemoizedSyncedBlockProvider = function useMemoizedSyncedBlockProvider(fetchProvider, writeProvider, sourceId) {
|
|
@@ -6,7 +6,6 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
6
6
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
7
7
|
import uuid from 'uuid';
|
|
8
8
|
import { rebaseTransaction as _rebaseTransaction } from '../common/rebase-transaction';
|
|
9
|
-
import { resourceIdFromSourceAndLocalId } from '../utils/ari';
|
|
10
9
|
import { convertSyncBlockPMNodeToSyncBlockData, createBodiedSyncBlockNode as _createBodiedSyncBlockNode } from '../utils/utils';
|
|
11
10
|
export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
12
11
|
function SourceSyncBlockStoreManager(dataProvider) {
|
|
@@ -158,12 +157,10 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
158
157
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
159
158
|
var localId = uuid();
|
|
160
159
|
var sourceId = (_this$dataProvider = this.dataProvider) === null || _this$dataProvider === void 0 ? void 0 : _this$dataProvider.getSourceId();
|
|
161
|
-
if (!sourceId) {
|
|
160
|
+
if (!this.dataProvider || !sourceId) {
|
|
162
161
|
throw new Error('Provider of sync block plugin is not set');
|
|
163
162
|
}
|
|
164
|
-
|
|
165
|
-
// This should be generated by the data provider implementation as it differs between data providers
|
|
166
|
-
var resourceId = resourceIdFromSourceAndLocalId(sourceId, localId);
|
|
163
|
+
var resourceId = this.dataProvider.generateResourceId(sourceId, localId);
|
|
167
164
|
return {
|
|
168
165
|
resourceId: resourceId,
|
|
169
166
|
localId: localId
|
package/dist/esm/utils/ari.js
CHANGED
|
@@ -28,9 +28,37 @@ export var getPageARIFromResourceId = function getPageARIFromResourceId(resource
|
|
|
28
28
|
}
|
|
29
29
|
throw new Error("Invalid resourceId: ".concat(resourceId));
|
|
30
30
|
};
|
|
31
|
-
export var getContentPropertyAri = function getContentPropertyAri(contentPropertyId, cloudId) {
|
|
32
|
-
return "ari:cloud:confluence:".concat(cloudId, ":content/").concat(contentPropertyId);
|
|
33
|
-
};
|
|
34
31
|
export var resourceIdFromSourceAndLocalId = function resourceIdFromSourceAndLocalId(sourceId, localId) {
|
|
35
32
|
return sourceId + '/' + localId;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* For the following functions, they are used for the block service API provider.
|
|
37
|
+
* The resourceId/blockResourceId always refers to the block ARI.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @param sourceId - the ARI of the document. E.G ari:cloud:confluence:cloudId:page/pageId
|
|
42
|
+
* @param localId - the localId of the block node. A randomly generated UUID
|
|
43
|
+
* @returns the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
|
|
44
|
+
*/
|
|
45
|
+
export var blockResourceIdFromSourceAndLocalId = function blockResourceIdFromSourceAndLocalId(sourceId, localId) {
|
|
46
|
+
var match = sourceId.match(/ari:cloud:confluence:([^:]+):(page|blogpost)\/.*/);
|
|
47
|
+
if (!(match !== null && match !== void 0 && match[1])) {
|
|
48
|
+
throw new Error("Invalid source ARI: ".concat(sourceId));
|
|
49
|
+
}
|
|
50
|
+
var cloudId = match[1];
|
|
51
|
+
return "ari:cloud:blocks:".concat(cloudId, ":synced-block/").concat(localId);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @param ari - the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
|
|
56
|
+
* @returns the localId of the block node. A randomly generated UUID
|
|
57
|
+
*/
|
|
58
|
+
export var getLocalIdFromResourceId = function getLocalIdFromResourceId(ari) {
|
|
59
|
+
var match = ari.match(/ari:cloud:confluence:[^:]+:(page|blogpost)\/\d+\/([a-zA-Z0-9-]+)/);
|
|
60
|
+
if (match !== null && match !== void 0 && match[2]) {
|
|
61
|
+
return match[2];
|
|
62
|
+
}
|
|
63
|
+
throw new Error("Invalid page ARI: ".concat(ari));
|
|
36
64
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -10,6 +10,6 @@ export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvide
|
|
|
10
10
|
export type { ADFFetchProvider, ADFWriteProvider, SyncBlockDataProvider, SyncBlockInstance, } from './providers/types';
|
|
11
11
|
export { ReferenceSyncBlockStoreManager } from './store-manager/referenceSyncBlockStoreManager';
|
|
12
12
|
export { SyncBlockStoreManager } from './store-manager/syncBlockStoreManager';
|
|
13
|
-
export { getConfluencePageAri, getPageIdAndTypeFromAri } from './utils/ari';
|
|
13
|
+
export { blockResourceIdFromSourceAndLocalId, getConfluencePageAri, getLocalIdFromAri, getLocalIdFromResourceId, getPageARIFromResourceId, getPageIdAndTypeFromAri, resourceIdFromSourceAndLocalId, } from './utils/ari';
|
|
14
14
|
export { createSyncBlockNode, convertSyncBlockPMNodeToSyncBlockData, convertSyncBlockJSONNodeToSyncBlockNode, } from './utils/utils';
|
|
15
15
|
export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
|
|
@@ -12,6 +12,7 @@ declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
|
|
|
12
12
|
declare class BlockServiceADFWriteProvider implements ADFWriteProvider {
|
|
13
13
|
writeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
14
14
|
deleteData(resourceId: string): Promise<DeleteSyncBlockResult>;
|
|
15
|
+
generateResourceId(sourceId: string, localId: string): string;
|
|
15
16
|
}
|
|
16
17
|
export declare const useMemoizedBlockServiceAPIProviders: () => {
|
|
17
18
|
fetchProvider: BlockServiceADFFetchProvider;
|
|
@@ -24,6 +24,7 @@ declare class ConfluenceADFWriteProvider implements ADFWriteProvider {
|
|
|
24
24
|
private createNewContentProperty;
|
|
25
25
|
writeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
26
26
|
deleteData(resourceId: string): Promise<DeleteSyncBlockResult>;
|
|
27
|
+
generateResourceId(sourceId: string, localId: string): string;
|
|
27
28
|
}
|
|
28
29
|
/**
|
|
29
30
|
* Convenience function to create providers with default content property key
|
|
@@ -22,5 +22,6 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
|
22
22
|
deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
|
|
23
23
|
getSourceId(): string;
|
|
24
24
|
retrieveSyncBlockSourceInfo(node: SyncBlockNode): Promise<SyncBlockSourceInfo | undefined>;
|
|
25
|
+
generateResourceId(sourceId: string, localId: string): string;
|
|
25
26
|
}
|
|
26
27
|
export declare const useMemoizedSyncedBlockProvider: (fetchProvider: ADFFetchProvider, writeProvider: ADFWriteProvider, sourceId: string) => SyncBlockProvider;
|
|
@@ -28,6 +28,7 @@ export interface ADFFetchProvider {
|
|
|
28
28
|
}
|
|
29
29
|
export interface ADFWriteProvider {
|
|
30
30
|
deleteData: (resourceId: string) => Promise<DeleteSyncBlockResult>;
|
|
31
|
+
generateResourceId: (sourceId: string, localId: string) => ResourceId;
|
|
31
32
|
writeData: (data: SyncBlockData) => Promise<WriteSyncBlockResult>;
|
|
32
33
|
}
|
|
33
34
|
export declare abstract class SyncBlockDataProvider extends NodeDataProvider<SyncBlockNode, SyncBlockInstance> {
|
|
@@ -35,6 +36,13 @@ export declare abstract class SyncBlockDataProvider extends NodeDataProvider<Syn
|
|
|
35
36
|
abstract deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
|
|
36
37
|
abstract getSourceId(): ResourceId;
|
|
37
38
|
abstract retrieveSyncBlockSourceInfo(node: SyncBlockNode): Promise<SyncBlockSourceInfo | undefined>;
|
|
39
|
+
/**
|
|
40
|
+
* Generates a resource ID from a source ID and local ID.
|
|
41
|
+
* @param sourceId - The source document ID (e.g., page ARI)
|
|
42
|
+
* @param localId - The local block ID (usually a UUID)
|
|
43
|
+
* @returns The generated resource ID
|
|
44
|
+
*/
|
|
45
|
+
abstract generateResourceId(sourceId: ResourceId, localId: string): ResourceId;
|
|
38
46
|
}
|
|
39
47
|
export type SubscriptionCallback = (data: SyncBlockInstance) => void;
|
|
40
48
|
export type TitleSubscriptionCallback = (title: string) => void;
|
|
@@ -6,5 +6,19 @@ export declare const getPageIdAndTypeFromAri: (ari: string) => {
|
|
|
6
6
|
};
|
|
7
7
|
export declare const getLocalIdFromAri: (ari: string) => string;
|
|
8
8
|
export declare const getPageARIFromResourceId: (resourceId: string) => string;
|
|
9
|
-
export declare const getContentPropertyAri: (contentPropertyId: string, cloudId: string) => string;
|
|
10
9
|
export declare const resourceIdFromSourceAndLocalId: (sourceId: string, localId: string) => string;
|
|
10
|
+
/**
|
|
11
|
+
* For the following functions, they are used for the block service API provider.
|
|
12
|
+
* The resourceId/blockResourceId always refers to the block ARI.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* @param sourceId - the ARI of the document. E.G ari:cloud:confluence:cloudId:page/pageId
|
|
16
|
+
* @param localId - the localId of the block node. A randomly generated UUID
|
|
17
|
+
* @returns the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
|
|
18
|
+
*/
|
|
19
|
+
export declare const blockResourceIdFromSourceAndLocalId: (sourceId: string, localId: string) => string;
|
|
20
|
+
/**
|
|
21
|
+
* @param ari - the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
|
|
22
|
+
* @returns the localId of the block node. A randomly generated UUID
|
|
23
|
+
*/
|
|
24
|
+
export declare const getLocalIdFromResourceId: (ari: string) => string;
|
|
@@ -34,6 +34,6 @@ export declare class BlockError extends Error {
|
|
|
34
34
|
constructor(status: number);
|
|
35
35
|
}
|
|
36
36
|
export declare const getSyncedBlockContent: ({ blockAri, }: GetSyncedBlockContentRequest) => Promise<BlockContentResponse>;
|
|
37
|
-
export declare const deleteSyncedBlock: ({ blockAri
|
|
37
|
+
export declare const deleteSyncedBlock: ({ blockAri }: DeleteSyncedBlockRequest) => Promise<void>;
|
|
38
38
|
export declare const updateSyncedBlock: ({ blockAri, content, }: UpdateSyncedBlockRequest) => Promise<void>;
|
|
39
39
|
export declare const createSyncedBlock: ({ blockAri, blockInstanceId, sourceAri, product, content, }: CreateSyncedBlockRequest) => Promise<BlockContentResponse>;
|
|
@@ -10,6 +10,6 @@ export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvide
|
|
|
10
10
|
export type { ADFFetchProvider, ADFWriteProvider, SyncBlockDataProvider, SyncBlockInstance, } from './providers/types';
|
|
11
11
|
export { ReferenceSyncBlockStoreManager } from './store-manager/referenceSyncBlockStoreManager';
|
|
12
12
|
export { SyncBlockStoreManager } from './store-manager/syncBlockStoreManager';
|
|
13
|
-
export { getConfluencePageAri, getPageIdAndTypeFromAri } from './utils/ari';
|
|
13
|
+
export { blockResourceIdFromSourceAndLocalId, getConfluencePageAri, getLocalIdFromAri, getLocalIdFromResourceId, getPageARIFromResourceId, getPageIdAndTypeFromAri, resourceIdFromSourceAndLocalId, } from './utils/ari';
|
|
14
14
|
export { createSyncBlockNode, convertSyncBlockPMNodeToSyncBlockData, convertSyncBlockJSONNodeToSyncBlockNode, } from './utils/utils';
|
|
15
15
|
export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
|
|
@@ -12,6 +12,7 @@ declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
|
|
|
12
12
|
declare class BlockServiceADFWriteProvider implements ADFWriteProvider {
|
|
13
13
|
writeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
14
14
|
deleteData(resourceId: string): Promise<DeleteSyncBlockResult>;
|
|
15
|
+
generateResourceId(sourceId: string, localId: string): string;
|
|
15
16
|
}
|
|
16
17
|
export declare const useMemoizedBlockServiceAPIProviders: () => {
|
|
17
18
|
fetchProvider: BlockServiceADFFetchProvider;
|
|
@@ -24,6 +24,7 @@ declare class ConfluenceADFWriteProvider implements ADFWriteProvider {
|
|
|
24
24
|
private createNewContentProperty;
|
|
25
25
|
writeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
26
26
|
deleteData(resourceId: string): Promise<DeleteSyncBlockResult>;
|
|
27
|
+
generateResourceId(sourceId: string, localId: string): string;
|
|
27
28
|
}
|
|
28
29
|
/**
|
|
29
30
|
* Convenience function to create providers with default content property key
|
|
@@ -22,5 +22,6 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
|
22
22
|
deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
|
|
23
23
|
getSourceId(): string;
|
|
24
24
|
retrieveSyncBlockSourceInfo(node: SyncBlockNode): Promise<SyncBlockSourceInfo | undefined>;
|
|
25
|
+
generateResourceId(sourceId: string, localId: string): string;
|
|
25
26
|
}
|
|
26
27
|
export declare const useMemoizedSyncedBlockProvider: (fetchProvider: ADFFetchProvider, writeProvider: ADFWriteProvider, sourceId: string) => SyncBlockProvider;
|
|
@@ -28,6 +28,7 @@ export interface ADFFetchProvider {
|
|
|
28
28
|
}
|
|
29
29
|
export interface ADFWriteProvider {
|
|
30
30
|
deleteData: (resourceId: string) => Promise<DeleteSyncBlockResult>;
|
|
31
|
+
generateResourceId: (sourceId: string, localId: string) => ResourceId;
|
|
31
32
|
writeData: (data: SyncBlockData) => Promise<WriteSyncBlockResult>;
|
|
32
33
|
}
|
|
33
34
|
export declare abstract class SyncBlockDataProvider extends NodeDataProvider<SyncBlockNode, SyncBlockInstance> {
|
|
@@ -35,6 +36,13 @@ export declare abstract class SyncBlockDataProvider extends NodeDataProvider<Syn
|
|
|
35
36
|
abstract deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
|
|
36
37
|
abstract getSourceId(): ResourceId;
|
|
37
38
|
abstract retrieveSyncBlockSourceInfo(node: SyncBlockNode): Promise<SyncBlockSourceInfo | undefined>;
|
|
39
|
+
/**
|
|
40
|
+
* Generates a resource ID from a source ID and local ID.
|
|
41
|
+
* @param sourceId - The source document ID (e.g., page ARI)
|
|
42
|
+
* @param localId - The local block ID (usually a UUID)
|
|
43
|
+
* @returns The generated resource ID
|
|
44
|
+
*/
|
|
45
|
+
abstract generateResourceId(sourceId: ResourceId, localId: string): ResourceId;
|
|
38
46
|
}
|
|
39
47
|
export type SubscriptionCallback = (data: SyncBlockInstance) => void;
|
|
40
48
|
export type TitleSubscriptionCallback = (title: string) => void;
|
|
@@ -6,5 +6,19 @@ export declare const getPageIdAndTypeFromAri: (ari: string) => {
|
|
|
6
6
|
};
|
|
7
7
|
export declare const getLocalIdFromAri: (ari: string) => string;
|
|
8
8
|
export declare const getPageARIFromResourceId: (resourceId: string) => string;
|
|
9
|
-
export declare const getContentPropertyAri: (contentPropertyId: string, cloudId: string) => string;
|
|
10
9
|
export declare const resourceIdFromSourceAndLocalId: (sourceId: string, localId: string) => string;
|
|
10
|
+
/**
|
|
11
|
+
* For the following functions, they are used for the block service API provider.
|
|
12
|
+
* The resourceId/blockResourceId always refers to the block ARI.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* @param sourceId - the ARI of the document. E.G ari:cloud:confluence:cloudId:page/pageId
|
|
16
|
+
* @param localId - the localId of the block node. A randomly generated UUID
|
|
17
|
+
* @returns the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
|
|
18
|
+
*/
|
|
19
|
+
export declare const blockResourceIdFromSourceAndLocalId: (sourceId: string, localId: string) => string;
|
|
20
|
+
/**
|
|
21
|
+
* @param ari - the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
|
|
22
|
+
* @returns the localId of the block node. A randomly generated UUID
|
|
23
|
+
*/
|
|
24
|
+
export declare const getLocalIdFromResourceId: (ari: string) => string;
|
|
@@ -34,6 +34,6 @@ export declare class BlockError extends Error {
|
|
|
34
34
|
constructor(status: number);
|
|
35
35
|
}
|
|
36
36
|
export declare const getSyncedBlockContent: ({ blockAri, }: GetSyncedBlockContentRequest) => Promise<BlockContentResponse>;
|
|
37
|
-
export declare const deleteSyncedBlock: ({ blockAri
|
|
37
|
+
export declare const deleteSyncedBlock: ({ blockAri }: DeleteSyncedBlockRequest) => Promise<void>;
|
|
38
38
|
export declare const updateSyncedBlock: ({ blockAri, content, }: UpdateSyncedBlockRequest) => Promise<void>;
|
|
39
39
|
export declare const createSyncedBlock: ({ blockAri, blockInstanceId, sourceAri, product, content, }: CreateSyncedBlockRequest) => Promise<BlockContentResponse>;
|
package/package.json
CHANGED
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"@atlaskit/editor-json-transformer": "^8.31.0",
|
|
31
31
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
32
32
|
"@atlaskit/node-data-provider": "^7.5.0",
|
|
33
|
+
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
33
34
|
"@atlaskit/primitives": "^16.1.0",
|
|
34
35
|
"@atlaskit/tokens": "^8.0.0",
|
|
35
36
|
"@babel/runtime": "^7.0.0",
|
|
@@ -82,11 +83,16 @@
|
|
|
82
83
|
}
|
|
83
84
|
},
|
|
84
85
|
"name": "@atlaskit/editor-synced-block-provider",
|
|
85
|
-
"version": "2.
|
|
86
|
+
"version": "2.9.0",
|
|
86
87
|
"description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
|
|
87
88
|
"author": "Atlassian Pty Ltd",
|
|
88
89
|
"license": "Apache-2.0",
|
|
89
90
|
"publishConfig": {
|
|
90
91
|
"registry": "https://registry.npmjs.org/"
|
|
92
|
+
},
|
|
93
|
+
"platform-feature-flags": {
|
|
94
|
+
"platform_editor_synced_block_provider_use_block_service": {
|
|
95
|
+
"type": "boolean"
|
|
96
|
+
}
|
|
91
97
|
}
|
|
92
98
|
}
|