@atlaskit/editor-synced-block-provider 3.26.0 → 3.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/cjs/clients/block-service/blockService.js +9 -14
- package/dist/cjs/clients/confluence/sourceInfo.js +3 -35
- package/dist/cjs/hooks/useFetchSyncBlockData.js +5 -11
- package/dist/cjs/providers/block-service/blockServiceAPI.js +1 -1
- package/dist/cjs/providers/syncBlockProvider.js +29 -72
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +75 -124
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +59 -93
- package/dist/cjs/store-manager/syncBlockStoreManager.js +2 -4
- package/dist/cjs/utils/errorHandling.js +2 -5
- package/dist/cjs/utils/resolveSyncBlockInstance.js +1 -3
- package/dist/cjs/utils/utils.js +5 -6
- package/dist/es2019/clients/block-service/blockService.js +5 -9
- package/dist/es2019/clients/confluence/sourceInfo.js +1 -4
- package/dist/es2019/hooks/useFetchSyncBlockData.js +6 -12
- package/dist/es2019/providers/block-service/blockServiceAPI.js +1 -1
- package/dist/es2019/providers/syncBlockProvider.js +21 -53
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +65 -114
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +60 -92
- package/dist/es2019/store-manager/syncBlockStoreManager.js +2 -4
- package/dist/es2019/utils/errorHandling.js +1 -4
- package/dist/es2019/utils/resolveSyncBlockInstance.js +2 -5
- package/dist/es2019/utils/utils.js +5 -6
- package/dist/esm/clients/block-service/blockService.js +9 -14
- package/dist/esm/clients/confluence/sourceInfo.js +2 -34
- package/dist/esm/hooks/useFetchSyncBlockData.js +5 -11
- package/dist/esm/providers/block-service/blockServiceAPI.js +1 -1
- package/dist/esm/providers/syncBlockProvider.js +29 -72
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +75 -124
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +59 -93
- package/dist/esm/store-manager/syncBlockStoreManager.js +2 -4
- package/dist/esm/utils/errorHandling.js +2 -5
- package/dist/esm/utils/resolveSyncBlockInstance.js +1 -3
- package/dist/esm/utils/utils.js +5 -6
- package/dist/types/clients/confluence/sourceInfo.d.ts +1 -2
- package/dist/types/hooks/useFetchSyncBlockData.d.ts +1 -1
- package/dist/types/providers/syncBlockProvider.d.ts +1 -1
- package/dist/types/providers/types.d.ts +2 -2
- package/dist/types/store-manager/sourceSyncBlockStoreManager.d.ts +1 -1
- package/dist/types-ts4.5/clients/confluence/sourceInfo.d.ts +1 -2
- package/dist/types-ts4.5/hooks/useFetchSyncBlockData.d.ts +1 -1
- package/dist/types-ts4.5/providers/syncBlockProvider.d.ts +1 -1
- package/dist/types-ts4.5/providers/types.d.ts +2 -2
- package/dist/types-ts4.5/store-manager/sourceSyncBlockStoreManager.d.ts +1 -1
- package/package.json +2 -5
|
@@ -6,7 +6,6 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
6
6
|
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; }
|
|
7
7
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
8
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
9
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
9
|
import { SyncBlockError } from '../common/types';
|
|
11
10
|
import { updateErrorPayload, createErrorPayload, deleteErrorPayload, updateCacheErrorPayload, getSourceInfoErrorPayload, updateSuccessPayload, createSuccessPayload, deleteSuccessPayload, fetchReferencesErrorPayload } from '../utils/errorHandling';
|
|
12
11
|
import { getCreateSourceExperience, getDeleteSourceExperience, getSaveSourceExperience, getFetchSourceInfoExperience } from '../utils/experienceTracking';
|
|
@@ -86,7 +85,7 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
86
85
|
value: (function () {
|
|
87
86
|
var _flush = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
88
87
|
var _this2 = this;
|
|
89
|
-
var bodiedSyncBlockNodes, bodiedSyncBlockData,
|
|
88
|
+
var _this$saveExperience, bodiedSyncBlockNodes, bodiedSyncBlockData, writeResults, _this$saveExperience2, _this$saveExperience3, _this$fireAnalyticsEv2;
|
|
90
89
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
91
90
|
while (1) switch (_context.prev = _context.next) {
|
|
92
91
|
case 0:
|
|
@@ -126,9 +125,7 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
126
125
|
}
|
|
127
126
|
throw new Error('Data provider not set');
|
|
128
127
|
case 8:
|
|
129
|
-
|
|
130
|
-
(_this$saveExperience = this.saveExperience) === null || _this$saveExperience === void 0 || _this$saveExperience.start({});
|
|
131
|
-
}
|
|
128
|
+
(_this$saveExperience = this.saveExperience) === null || _this$saveExperience === void 0 || _this$saveExperience.start({});
|
|
132
129
|
_context.next = 11;
|
|
133
130
|
return this.dataProvider.writeNodesData(bodiedSyncBlockNodes, bodiedSyncBlockData);
|
|
134
131
|
case 11:
|
|
@@ -145,23 +142,19 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
145
142
|
if (!writeResults.every(function (result) {
|
|
146
143
|
return result.resourceId && !result.error;
|
|
147
144
|
})) {
|
|
148
|
-
_context.next =
|
|
145
|
+
_context.next = 19;
|
|
149
146
|
break;
|
|
150
147
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
});
|
|
159
|
-
}
|
|
148
|
+
(_this$saveExperience2 = this.saveExperience) === null || _this$saveExperience2 === void 0 || _this$saveExperience2.success();
|
|
149
|
+
writeResults.forEach(function (result) {
|
|
150
|
+
if (result.resourceId && !result.error) {
|
|
151
|
+
var _this2$fireAnalyticsE;
|
|
152
|
+
(_this2$fireAnalyticsE = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE === void 0 || _this2$fireAnalyticsE.call(_this2, updateSuccessPayload(result.resourceId, false));
|
|
153
|
+
}
|
|
154
|
+
});
|
|
160
155
|
return _context.abrupt("return", true);
|
|
161
|
-
case
|
|
162
|
-
|
|
163
|
-
(_this$saveExperience3 = this.saveExperience) === null || _this$saveExperience3 === void 0 || _this$saveExperience3.failure();
|
|
164
|
-
}
|
|
156
|
+
case 19:
|
|
157
|
+
(_this$saveExperience3 = this.saveExperience) === null || _this$saveExperience3 === void 0 || _this$saveExperience3.failure();
|
|
165
158
|
writeResults.filter(function (result) {
|
|
166
159
|
return !result.resourceId || result.error;
|
|
167
160
|
}).forEach(function (result) {
|
|
@@ -169,22 +162,22 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
169
162
|
(_this2$fireAnalyticsE2 = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE2 === void 0 || _this2$fireAnalyticsE2.call(_this2, updateErrorPayload(result.error || 'Failed to write data', result.resourceId));
|
|
170
163
|
});
|
|
171
164
|
return _context.abrupt("return", false);
|
|
172
|
-
case
|
|
173
|
-
_context.next =
|
|
165
|
+
case 22:
|
|
166
|
+
_context.next = 29;
|
|
174
167
|
break;
|
|
175
|
-
case
|
|
176
|
-
_context.prev =
|
|
168
|
+
case 24:
|
|
169
|
+
_context.prev = 24;
|
|
177
170
|
_context.t0 = _context["catch"](0);
|
|
178
171
|
logException(_context.t0, {
|
|
179
172
|
location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
|
|
180
173
|
});
|
|
181
174
|
(_this$fireAnalyticsEv2 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 || _this$fireAnalyticsEv2.call(this, updateErrorPayload(_context.t0.message));
|
|
182
175
|
return _context.abrupt("return", false);
|
|
183
|
-
case
|
|
176
|
+
case 29:
|
|
184
177
|
case "end":
|
|
185
178
|
return _context.stop();
|
|
186
179
|
}
|
|
187
|
-
}, _callee, this, [[0,
|
|
180
|
+
}, _callee, this, [[0, 24]]);
|
|
188
181
|
}));
|
|
189
182
|
function flush() {
|
|
190
183
|
return _flush.apply(this, arguments);
|
|
@@ -214,12 +207,10 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
214
207
|
key: "commitPendingCreation",
|
|
215
208
|
value: function commitPendingCreation(success) {
|
|
216
209
|
if (success && this.creationCallback) {
|
|
210
|
+
var _this$fireAnalyticsEv3;
|
|
217
211
|
this.creationCallback();
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
(_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(this, createSuccessPayload(this.pendingResourceId || ''));
|
|
221
|
-
}
|
|
222
|
-
} else if (success && !this.creationCallback && fg('platform_synced_block_dogfooding')) {
|
|
212
|
+
(_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(this, createSuccessPayload(this.pendingResourceId || ''));
|
|
213
|
+
} else if (success && !this.creationCallback) {
|
|
223
214
|
var _this$fireAnalyticsEv4;
|
|
224
215
|
(_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(this, createErrorPayload('creation callback missing', this.pendingResourceId));
|
|
225
216
|
}
|
|
@@ -292,11 +283,9 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
292
283
|
}).then(function (result) {
|
|
293
284
|
var resourceId = result.resourceId;
|
|
294
285
|
if (resourceId) {
|
|
286
|
+
var _this4$createExperien;
|
|
295
287
|
_this4.commitPendingCreation(true);
|
|
296
|
-
|
|
297
|
-
var _this4$createExperien;
|
|
298
|
-
(_this4$createExperien = _this4.createExperience) === null || _this4$createExperien === void 0 || _this4$createExperien.success();
|
|
299
|
-
}
|
|
288
|
+
(_this4$createExperien = _this4.createExperience) === null || _this4$createExperien === void 0 || _this4$createExperien.success();
|
|
300
289
|
|
|
301
290
|
// Update the sync block data with the node data if it is provided
|
|
302
291
|
// to avoid any race conditions where the data could be missed during a render operation
|
|
@@ -304,28 +293,22 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
304
293
|
_this4.updateSyncBlockData(nodeData);
|
|
305
294
|
}
|
|
306
295
|
} else {
|
|
307
|
-
var _this4$fireAnalyticsE;
|
|
296
|
+
var _this4$createExperien2, _this4$fireAnalyticsE;
|
|
308
297
|
_this4.commitPendingCreation(false);
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
reason: result.error || 'Failed to create bodied sync block'
|
|
313
|
-
});
|
|
314
|
-
}
|
|
298
|
+
(_this4$createExperien2 = _this4.createExperience) === null || _this4$createExperien2 === void 0 || _this4$createExperien2.failure({
|
|
299
|
+
reason: result.error || 'Failed to create bodied sync block'
|
|
300
|
+
});
|
|
315
301
|
(_this4$fireAnalyticsE = _this4.fireAnalyticsEvent) === null || _this4$fireAnalyticsE === void 0 || _this4$fireAnalyticsE.call(_this4, createErrorPayload(result.error || 'Failed to create bodied sync block', resourceId));
|
|
316
302
|
}
|
|
317
303
|
}).catch(function (error) {
|
|
318
|
-
var _this4$fireAnalyticsE2;
|
|
304
|
+
var _this4$createExperien3, _this4$fireAnalyticsE2;
|
|
319
305
|
_this4.commitPendingCreation(false);
|
|
320
306
|
logException(error, {
|
|
321
307
|
location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
|
|
322
308
|
});
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
reason: error.message
|
|
327
|
-
});
|
|
328
|
-
}
|
|
309
|
+
(_this4$createExperien3 = _this4.createExperience) === null || _this4$createExperien3 === void 0 || _this4$createExperien3.failure({
|
|
310
|
+
reason: error.message
|
|
311
|
+
});
|
|
329
312
|
(_this4$fireAnalyticsE2 = _this4.fireAnalyticsEvent) === null || _this4$fireAnalyticsE2 === void 0 || _this4$fireAnalyticsE2.call(_this4, createErrorPayload(error.message, resourceId));
|
|
330
313
|
});
|
|
331
314
|
this.registerPendingCreation(resourceId);
|
|
@@ -359,9 +342,7 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
359
342
|
syncBlockIds.forEach(function (Ids) {
|
|
360
343
|
_this5.setPendingDeletion(Ids, true);
|
|
361
344
|
});
|
|
362
|
-
|
|
363
|
-
(_this$deleteExperienc = this.deleteExperience) === null || _this$deleteExperienc === void 0 || _this$deleteExperienc.start({});
|
|
364
|
-
}
|
|
345
|
+
(_this$deleteExperienc = this.deleteExperience) === null || _this$deleteExperienc === void 0 || _this$deleteExperienc.start({});
|
|
365
346
|
_context2.next = 7;
|
|
366
347
|
return this.dataProvider.deleteNodesData(syncBlockIds.map(function (attrs) {
|
|
367
348
|
return attrs.resourceId;
|
|
@@ -378,36 +359,25 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
378
359
|
return _this5.syncBlockCache.delete(Ids.resourceId);
|
|
379
360
|
};
|
|
380
361
|
this.clearPendingDeletion();
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
});
|
|
387
|
-
}
|
|
362
|
+
(_this$deleteExperienc2 = this.deleteExperience) === null || _this$deleteExperienc2 === void 0 || _this$deleteExperienc2.success();
|
|
363
|
+
results.forEach(function (result) {
|
|
364
|
+
var _this5$fireAnalyticsE;
|
|
365
|
+
(_this5$fireAnalyticsE = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE === void 0 || _this5$fireAnalyticsE.call(_this5, deleteSuccessPayload(result.resourceId));
|
|
366
|
+
});
|
|
388
367
|
} else {
|
|
389
368
|
callback = function callback(Ids) {
|
|
390
369
|
_this5.setPendingDeletion(Ids, false);
|
|
391
370
|
};
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
});
|
|
403
|
-
} else {
|
|
404
|
-
results.filter(function (result) {
|
|
405
|
-
return result.resourceId === undefined;
|
|
406
|
-
}).forEach(function (result) {
|
|
407
|
-
var _this5$fireAnalyticsE4;
|
|
408
|
-
(_this5$fireAnalyticsE4 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE4 === void 0 || _this5$fireAnalyticsE4.call(_this5, deleteErrorPayload(result.error || 'Failed to delete synced block'));
|
|
409
|
-
});
|
|
410
|
-
}
|
|
371
|
+
(_this$deleteExperienc3 = this.deleteExperience) === null || _this$deleteExperienc3 === void 0 || _this$deleteExperienc3.failure();
|
|
372
|
+
results.forEach(function (result) {
|
|
373
|
+
if (result.success) {
|
|
374
|
+
var _this5$fireAnalyticsE2;
|
|
375
|
+
(_this5$fireAnalyticsE2 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE2 === void 0 || _this5$fireAnalyticsE2.call(_this5, deleteSuccessPayload(result.resourceId));
|
|
376
|
+
} else {
|
|
377
|
+
var _this5$fireAnalyticsE3;
|
|
378
|
+
(_this5$fireAnalyticsE3 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE3 === void 0 || _this5$fireAnalyticsE3.call(_this5, deleteErrorPayload(result.error || 'Failed to delete synced block', result.resourceId));
|
|
379
|
+
}
|
|
380
|
+
});
|
|
411
381
|
}
|
|
412
382
|
syncBlockIds.forEach(callback);
|
|
413
383
|
return _context2.abrupt("return", isDeleteSuccessful);
|
|
@@ -415,9 +385,9 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
415
385
|
_context2.prev = 15;
|
|
416
386
|
_context2.t0 = _context2["catch"](0);
|
|
417
387
|
syncBlockIds.forEach(function (Ids) {
|
|
418
|
-
var _this5$
|
|
388
|
+
var _this5$fireAnalyticsE4;
|
|
419
389
|
_this5.setPendingDeletion(Ids, false);
|
|
420
|
-
(_this5$
|
|
390
|
+
(_this5$fireAnalyticsE4 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE4 === void 0 || _this5$fireAnalyticsE4.call(_this5, deleteErrorPayload(_context2.t0.message, Ids.resourceId));
|
|
421
391
|
});
|
|
422
392
|
logException(_context2.t0, {
|
|
423
393
|
location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
|
|
@@ -543,24 +513,20 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
543
513
|
value: function getSyncBlockSourceInfo(localId) {
|
|
544
514
|
var _this6 = this;
|
|
545
515
|
try {
|
|
516
|
+
var _this$fetchSourceInfo;
|
|
546
517
|
if (!this.dataProvider) {
|
|
547
518
|
throw new Error('Data provider not set');
|
|
548
519
|
}
|
|
549
|
-
|
|
550
|
-
var _this$fetchSourceInfo;
|
|
551
|
-
(_this$fetchSourceInfo = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo === void 0 || _this$fetchSourceInfo.start();
|
|
552
|
-
}
|
|
520
|
+
(_this$fetchSourceInfo = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo === void 0 || _this$fetchSourceInfo.start();
|
|
553
521
|
return this.dataProvider.fetchSyncBlockSourceInfo(localId, undefined, undefined, this.fireAnalyticsEvent).then(function (sourceInfo) {
|
|
554
|
-
if (
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
(_this6$fetchSourceInf2 = _this6.fetchSourceInfoExperience) === null || _this6$fetchSourceInf2 === void 0 || _this6$fetchSourceInf2.success();
|
|
563
|
-
}
|
|
522
|
+
if (!sourceInfo) {
|
|
523
|
+
var _this6$fetchSourceInf;
|
|
524
|
+
(_this6$fetchSourceInf = _this6.fetchSourceInfoExperience) === null || _this6$fetchSourceInf === void 0 || _this6$fetchSourceInf.failure({
|
|
525
|
+
reason: 'No source info returned'
|
|
526
|
+
});
|
|
527
|
+
} else {
|
|
528
|
+
var _this6$fetchSourceInf2;
|
|
529
|
+
(_this6$fetchSourceInf2 = _this6.fetchSourceInfoExperience) === null || _this6$fetchSourceInf2 === void 0 || _this6$fetchSourceInf2.success();
|
|
564
530
|
}
|
|
565
531
|
return sourceInfo;
|
|
566
532
|
});
|
|
@@ -164,10 +164,8 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
164
164
|
this.fireAnalyticsEvent = fireAnalyticsEvent;
|
|
165
165
|
this.referenceSyncBlockStoreManager.setFireAnalyticsEvent(fireAnalyticsEvent);
|
|
166
166
|
this.sourceSyncBlockStoreManager.setFireAnalyticsEvent(fireAnalyticsEvent);
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
this.fetchSourceInfoExperience = getFetchSourceInfoExperience(fireAnalyticsEvent);
|
|
170
|
-
}
|
|
167
|
+
this.fetchReferencesExperience = getFetchReferencesExperience(fireAnalyticsEvent);
|
|
168
|
+
this.fetchSourceInfoExperience = getFetchSourceInfoExperience(fireAnalyticsEvent);
|
|
171
169
|
}
|
|
172
170
|
}, {
|
|
173
171
|
key: "referenceManager",
|
|
@@ -2,7 +2,6 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
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; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
5
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
5
|
export var stringifyError = function stringifyError(error) {
|
|
7
6
|
try {
|
|
8
7
|
return JSON.stringify(error);
|
|
@@ -16,13 +15,11 @@ export var getErrorPayload = function getErrorPayload(actionSubjectId, error, re
|
|
|
16
15
|
actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
17
16
|
actionSubjectId: actionSubjectId,
|
|
18
17
|
eventType: EVENT_TYPE.OPERATIONAL,
|
|
19
|
-
attributes:
|
|
18
|
+
attributes: _objectSpread({
|
|
20
19
|
error: error
|
|
21
20
|
}, resourceId && {
|
|
22
21
|
resourceId: resourceId
|
|
23
|
-
})
|
|
24
|
-
error: error
|
|
25
|
-
}
|
|
22
|
+
})
|
|
26
23
|
};
|
|
27
24
|
};
|
|
28
25
|
export var fetchErrorPayload = function fetchErrorPayload(error, resourceId) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
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; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
4
|
import { SyncBlockError } from '../common/types';
|
|
6
5
|
/**
|
|
7
6
|
* Merges two SyncBlockInstance objects,
|
|
@@ -32,8 +31,7 @@ export var resolveSyncBlockInstance = function resolveSyncBlockInstance(oldResul
|
|
|
32
31
|
return _objectSpread(_objectSpread({}, newResult), {}, {
|
|
33
32
|
data: _objectSpread(_objectSpread({}, newResult.data), {}, {
|
|
34
33
|
sourceURL: ((_newResult$data = newResult.data) === null || _newResult$data === void 0 ? void 0 : _newResult$data.sourceURL) || ((_oldResult$data = oldResult.data) === null || _oldResult$data === void 0 ? void 0 : _oldResult$data.sourceURL) || undefined,
|
|
35
|
-
sourceTitle: ((_newResult$data2 = newResult.data) === null || _newResult$data2 === void 0 ? void 0 : _newResult$data2.sourceTitle) || ((_oldResult$data2 = oldResult.data) === null || _oldResult$data2 === void 0 ? void 0 : _oldResult$data2.sourceTitle) || undefined
|
|
36
|
-
}, fg('platform_synced_block_dogfooding') && {
|
|
34
|
+
sourceTitle: ((_newResult$data2 = newResult.data) === null || _newResult$data2 === void 0 ? void 0 : _newResult$data2.sourceTitle) || ((_oldResult$data2 = oldResult.data) === null || _oldResult$data2 === void 0 ? void 0 : _oldResult$data2.sourceTitle) || undefined,
|
|
37
35
|
sourceSubType: ((_newResult$data3 = newResult.data) === null || _newResult$data3 === void 0 ? void 0 : _newResult$data3.sourceSubType) || ((_oldResult$data3 = oldResult.data) === null || _oldResult$data3 === void 0 ? void 0 : _oldResult$data3.sourceSubType) || undefined,
|
|
38
36
|
onSameDocument: ((_newResult$data4 = newResult.data) === null || _newResult$data4 === void 0 ? void 0 : _newResult$data4.onSameDocument) || ((_oldResult$data4 = oldResult.data) === null || _oldResult$data4 === void 0 ? void 0 : _oldResult$data4.onSameDocument) || undefined
|
|
39
37
|
})
|
package/dist/esm/utils/utils.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/* eslint-disable require-unicode-regexp */
|
|
2
2
|
|
|
3
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
3
|
export var convertSyncBlockPMNodeToSyncBlockData = function convertSyncBlockPMNodeToSyncBlockData(node) {
|
|
5
4
|
return {
|
|
6
5
|
blockInstanceId: node.attrs.localId,
|
|
@@ -39,10 +38,10 @@ export var convertPMNodesToSyncBlockNodes = function convertPMNodesToSyncBlockNo
|
|
|
39
38
|
};
|
|
40
39
|
|
|
41
40
|
/*
|
|
42
|
-
* From a reference block resource id (the resourceId stored in the node attributes)
|
|
43
|
-
* e.g. confluence-page/5769323474/cdf6a1bc-b241-487a-93e9-e30bde363cbc
|
|
44
|
-
* Extracts the source page content id and source product
|
|
45
|
-
*/
|
|
41
|
+
* From a reference block resource id (the resourceId stored in the node attributes)
|
|
42
|
+
* e.g. confluence-page/5769323474/cdf6a1bc-b241-487a-93e9-e30bde363cbc
|
|
43
|
+
* Extracts the source page content id and source product
|
|
44
|
+
*/
|
|
46
45
|
export var getContentIdAndProductFromResourceId = function getContentIdAndProductFromResourceId(resourceId) {
|
|
47
46
|
var match = resourceId.match(/^(confluence-page|jira-work-item)\/([^/]+)/);
|
|
48
47
|
if (match !== null && match !== void 0 && match[2]) {
|
|
@@ -54,7 +53,7 @@ export var getContentIdAndProductFromResourceId = function getContentIdAndProduc
|
|
|
54
53
|
throw new Error("Invalid resourceId: ".concat(resourceId));
|
|
55
54
|
};
|
|
56
55
|
export var convertContentUpdatedAt = function convertContentUpdatedAt(contentUpdatedAt) {
|
|
57
|
-
if (typeof contentUpdatedAt === 'number'
|
|
56
|
+
if (typeof contentUpdatedAt === 'number') {
|
|
58
57
|
try {
|
|
59
58
|
return new Date(contentUpdatedAt).toISOString();
|
|
60
59
|
} catch (_unused) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import type { SyncBlockSourceInfo } from '../../providers/types';
|
|
3
3
|
export declare const fetchConfluencePageInfoOld: (pageAri: string, localId?: string, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void) => Promise<SyncBlockSourceInfo | undefined>;
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const fetchConfluencePageInfo: (pageAri: string, hasAccess: boolean, urlType: "view" | "edit", localId?: string, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void, isUnpublished?: boolean) => Promise<SyncBlockSourceInfo | undefined>;
|
|
4
|
+
export declare const fetchConfluencePageInfo: (pageAri: string, hasAccess: boolean, urlType: "view" | "edit", localId?: string, isUnpublished?: boolean) => Promise<SyncBlockSourceInfo | undefined>;
|
|
@@ -12,5 +12,5 @@ export interface UseFetchSyncBlockDataResult {
|
|
|
12
12
|
ssrProviders?: SSRProviders | null;
|
|
13
13
|
syncBlockInstance: SyncBlockInstance | null;
|
|
14
14
|
}
|
|
15
|
-
export declare const useFetchSyncBlockData: (manager: SyncBlockStoreManager, resourceId?: string, localId?: string,
|
|
15
|
+
export declare const useFetchSyncBlockData: (manager: SyncBlockStoreManager, resourceId?: string, localId?: string, _fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void) => UseFetchSyncBlockDataResult;
|
|
16
16
|
export {};
|
|
@@ -58,7 +58,7 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
|
58
58
|
*
|
|
59
59
|
* @returns Array of {resourceId?: string, error?: string}.
|
|
60
60
|
*/
|
|
61
|
-
deleteNodesData(resourceIds: ResourceId[], deletionReason: DeletionReason
|
|
61
|
+
deleteNodesData(resourceIds: ResourceId[], deletionReason: DeletionReason): Promise<Array<DeleteSyncBlockResult>>;
|
|
62
62
|
/**
|
|
63
63
|
* Fetch the source info from the source id
|
|
64
64
|
*
|
|
@@ -82,7 +82,7 @@ export interface ADFWriteProvider {
|
|
|
82
82
|
* @returns Object representing the result of the deletion. {resourceId: string, success: boolean, error?: string}.
|
|
83
83
|
* User should not be blocked by not_found error when deleting, so successful result should be returned for 404 error
|
|
84
84
|
*/
|
|
85
|
-
deleteData: (resourceId: ResourceId, deleteReason: string
|
|
85
|
+
deleteData: (resourceId: ResourceId, deleteReason: string) => Promise<DeleteSyncBlockResult>;
|
|
86
86
|
generateResourceIdForReference: (sourceId: ResourceId) => ResourceId;
|
|
87
87
|
parentAri?: string;
|
|
88
88
|
product: SyncBlockProduct;
|
|
@@ -111,7 +111,7 @@ export type SyncedBlockRendererProviderOptions = {
|
|
|
111
111
|
export declare abstract class SyncBlockDataProvider extends NodeDataProvider<SyncBlockNode, SyncBlockInstance> {
|
|
112
112
|
abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<WriteSyncBlockResult>>;
|
|
113
113
|
abstract createNodeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
114
|
-
abstract deleteNodesData(resourceIds: string[], deleteReason: DeletionReason
|
|
114
|
+
abstract deleteNodesData(resourceIds: string[], deleteReason: DeletionReason): Promise<Array<DeleteSyncBlockResult>>;
|
|
115
115
|
abstract fetchSyncBlockSourceInfo(localId?: BlockInstanceId, sourceAri?: string, sourceProduct?: SyncBlockProduct, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void, hasAccess?: boolean, urlType?: 'view' | 'edit', isUnpublished?: boolean): Promise<SyncBlockSourceInfo | undefined>;
|
|
116
116
|
abstract setProviderOptions(providerOptions: SyncedBlockRendererProviderOptions): void;
|
|
117
117
|
abstract getSyncedBlockRendererProviderOptions(): SyncedBlockRendererProviderOptions;
|
|
@@ -71,7 +71,7 @@ export declare class SourceSyncBlockStoreManager {
|
|
|
71
71
|
* @param onDeleteCompleted - The callback for after the deletion is saved to BE (whether successful or not)
|
|
72
72
|
* @param destroyCallback - The callback to clear any reference stored for deletion (regardless if deletion is completed or abort)
|
|
73
73
|
*/
|
|
74
|
-
deleteSyncBlocksWithConfirmation(syncBlockIds: SyncBlockAttrs[], deletionReason: DeletionReason
|
|
74
|
+
deleteSyncBlocksWithConfirmation(syncBlockIds: SyncBlockAttrs[], deletionReason: DeletionReason, onDelete: OnDelete, onDeleteCompleted: OnDeleteCompleted, destroyCallback: DestroyCallback): Promise<void>;
|
|
75
75
|
getSyncBlockSourceInfo(localId: BlockInstanceId): Promise<SyncBlockSourceInfo | undefined>;
|
|
76
76
|
fetchReferences(resourceId: string): Promise<ReferenceSyncBlockData>;
|
|
77
77
|
destroy(): void;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import type { SyncBlockSourceInfo } from '../../providers/types';
|
|
3
3
|
export declare const fetchConfluencePageInfoOld: (pageAri: string, localId?: string, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void) => Promise<SyncBlockSourceInfo | undefined>;
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const fetchConfluencePageInfo: (pageAri: string, hasAccess: boolean, urlType: "view" | "edit", localId?: string, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void, isUnpublished?: boolean) => Promise<SyncBlockSourceInfo | undefined>;
|
|
4
|
+
export declare const fetchConfluencePageInfo: (pageAri: string, hasAccess: boolean, urlType: "view" | "edit", localId?: string, isUnpublished?: boolean) => Promise<SyncBlockSourceInfo | undefined>;
|
|
@@ -12,5 +12,5 @@ export interface UseFetchSyncBlockDataResult {
|
|
|
12
12
|
ssrProviders?: SSRProviders | null;
|
|
13
13
|
syncBlockInstance: SyncBlockInstance | null;
|
|
14
14
|
}
|
|
15
|
-
export declare const useFetchSyncBlockData: (manager: SyncBlockStoreManager, resourceId?: string, localId?: string,
|
|
15
|
+
export declare const useFetchSyncBlockData: (manager: SyncBlockStoreManager, resourceId?: string, localId?: string, _fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void) => UseFetchSyncBlockDataResult;
|
|
16
16
|
export {};
|
|
@@ -58,7 +58,7 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
|
58
58
|
*
|
|
59
59
|
* @returns Array of {resourceId?: string, error?: string}.
|
|
60
60
|
*/
|
|
61
|
-
deleteNodesData(resourceIds: ResourceId[], deletionReason: DeletionReason
|
|
61
|
+
deleteNodesData(resourceIds: ResourceId[], deletionReason: DeletionReason): Promise<Array<DeleteSyncBlockResult>>;
|
|
62
62
|
/**
|
|
63
63
|
* Fetch the source info from the source id
|
|
64
64
|
*
|
|
@@ -82,7 +82,7 @@ export interface ADFWriteProvider {
|
|
|
82
82
|
* @returns Object representing the result of the deletion. {resourceId: string, success: boolean, error?: string}.
|
|
83
83
|
* User should not be blocked by not_found error when deleting, so successful result should be returned for 404 error
|
|
84
84
|
*/
|
|
85
|
-
deleteData: (resourceId: ResourceId, deleteReason: string
|
|
85
|
+
deleteData: (resourceId: ResourceId, deleteReason: string) => Promise<DeleteSyncBlockResult>;
|
|
86
86
|
generateResourceIdForReference: (sourceId: ResourceId) => ResourceId;
|
|
87
87
|
parentAri?: string;
|
|
88
88
|
product: SyncBlockProduct;
|
|
@@ -111,7 +111,7 @@ export type SyncedBlockRendererProviderOptions = {
|
|
|
111
111
|
export declare abstract class SyncBlockDataProvider extends NodeDataProvider<SyncBlockNode, SyncBlockInstance> {
|
|
112
112
|
abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<WriteSyncBlockResult>>;
|
|
113
113
|
abstract createNodeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
114
|
-
abstract deleteNodesData(resourceIds: string[], deleteReason: DeletionReason
|
|
114
|
+
abstract deleteNodesData(resourceIds: string[], deleteReason: DeletionReason): Promise<Array<DeleteSyncBlockResult>>;
|
|
115
115
|
abstract fetchSyncBlockSourceInfo(localId?: BlockInstanceId, sourceAri?: string, sourceProduct?: SyncBlockProduct, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void, hasAccess?: boolean, urlType?: 'view' | 'edit', isUnpublished?: boolean): Promise<SyncBlockSourceInfo | undefined>;
|
|
116
116
|
abstract setProviderOptions(providerOptions: SyncedBlockRendererProviderOptions): void;
|
|
117
117
|
abstract getSyncedBlockRendererProviderOptions(): SyncedBlockRendererProviderOptions;
|
|
@@ -71,7 +71,7 @@ export declare class SourceSyncBlockStoreManager {
|
|
|
71
71
|
* @param onDeleteCompleted - The callback for after the deletion is saved to BE (whether successful or not)
|
|
72
72
|
* @param destroyCallback - The callback to clear any reference stored for deletion (regardless if deletion is completed or abort)
|
|
73
73
|
*/
|
|
74
|
-
deleteSyncBlocksWithConfirmation(syncBlockIds: SyncBlockAttrs[], deletionReason: DeletionReason
|
|
74
|
+
deleteSyncBlocksWithConfirmation(syncBlockIds: SyncBlockAttrs[], deletionReason: DeletionReason, onDelete: OnDelete, onDeleteCompleted: OnDeleteCompleted, destroyCallback: DestroyCallback): Promise<void>;
|
|
75
75
|
getSyncBlockSourceInfo(localId: BlockInstanceId): Promise<SyncBlockSourceInfo | undefined>;
|
|
76
76
|
fetchReferences(resourceId: string): Promise<ReferenceSyncBlockData>;
|
|
77
77
|
destroy(): void;
|
package/package.json
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@atlaskit/adf-utils": "^19.27.0",
|
|
28
28
|
"@atlaskit/editor-json-transformer": "^8.31.0",
|
|
29
29
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
30
|
-
"@atlaskit/node-data-provider": "^8.
|
|
30
|
+
"@atlaskit/node-data-provider": "^8.3.0",
|
|
31
31
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
32
32
|
"@babel/runtime": "^7.0.0",
|
|
33
33
|
"@compiled/react": "^0.18.6",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
}
|
|
80
80
|
},
|
|
81
81
|
"name": "@atlaskit/editor-synced-block-provider",
|
|
82
|
-
"version": "3.26.
|
|
82
|
+
"version": "3.26.1",
|
|
83
83
|
"description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
|
|
84
84
|
"author": "Atlassian Pty Ltd",
|
|
85
85
|
"license": "Apache-2.0",
|
|
@@ -87,9 +87,6 @@
|
|
|
87
87
|
"registry": "https://registry.npmjs.org/"
|
|
88
88
|
},
|
|
89
89
|
"platform-feature-flags": {
|
|
90
|
-
"platform_synced_block_dogfooding": {
|
|
91
|
-
"type": "boolean"
|
|
92
|
-
},
|
|
93
90
|
"platform_synced_block_patch_1": {
|
|
94
91
|
"type": "boolean"
|
|
95
92
|
}
|