@atlaskit/editor-synced-block-provider 3.5.4 → 3.6.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 +20 -0
- package/dist/cjs/clients/confluence/fetchMediaToken.js +109 -0
- package/dist/cjs/clients/confluence/sourceInfo.js +77 -3
- package/dist/cjs/common/consts.js +7 -0
- package/dist/cjs/hooks/useFetchSyncBlockData.js +10 -2
- package/dist/cjs/index.js +14 -0
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +218 -48
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +117 -34
- package/dist/cjs/utils/parseResourceId.js +38 -0
- package/dist/es2019/clients/confluence/fetchMediaToken.js +68 -0
- package/dist/es2019/clients/confluence/sourceInfo.js +34 -1
- package/dist/es2019/common/consts.js +1 -0
- package/dist/es2019/hooks/useFetchSyncBlockData.js +10 -1
- package/dist/es2019/index.js +2 -0
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +200 -24
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +85 -15
- package/dist/es2019/utils/parseResourceId.js +25 -0
- package/dist/esm/clients/confluence/fetchMediaToken.js +102 -0
- package/dist/esm/clients/confluence/sourceInfo.js +76 -2
- package/dist/esm/common/consts.js +1 -0
- package/dist/esm/hooks/useFetchSyncBlockData.js +10 -2
- package/dist/esm/index.js +2 -0
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +218 -48
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +117 -34
- package/dist/esm/utils/parseResourceId.js +31 -0
- package/dist/types/clients/confluence/fetchMediaToken.d.ts +11 -0
- package/dist/types/clients/confluence/sourceInfo.d.ts +2 -0
- package/dist/types/common/consts.d.ts +1 -0
- package/dist/types/common/types.d.ts +2 -1
- package/dist/types/hooks/useFetchSyncBlockData.d.ts +6 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/providers/types.d.ts +3 -2
- package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +8 -0
- package/dist/types/store-manager/sourceSyncBlockStoreManager.d.ts +4 -0
- package/dist/types/utils/parseResourceId.d.ts +6 -0
- package/dist/types-ts4.5/clients/confluence/fetchMediaToken.d.ts +11 -0
- package/dist/types-ts4.5/clients/confluence/sourceInfo.d.ts +2 -0
- package/dist/types-ts4.5/common/consts.d.ts +4 -0
- package/dist/types-ts4.5/common/types.d.ts +2 -1
- package/dist/types-ts4.5/hooks/useFetchSyncBlockData.d.ts +6 -1
- package/dist/types-ts4.5/index.d.ts +2 -0
- package/dist/types-ts4.5/providers/types.d.ts +3 -2
- package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +8 -0
- package/dist/types-ts4.5/store-manager/sourceSyncBlockStoreManager.d.ts +4 -0
- package/dist/types-ts4.5/utils/parseResourceId.d.ts +6 -0
- package/package.json +2 -2
|
@@ -13,8 +13,10 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
|
|
|
13
13
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
14
|
var _monitoring = require("@atlaskit/editor-common/monitoring");
|
|
15
15
|
var _providerFactory = require("@atlaskit/editor-common/provider-factory");
|
|
16
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
17
|
var _types = require("../common/types");
|
|
17
18
|
var _errorHandling = require("../utils/errorHandling");
|
|
19
|
+
var _parseResourceId = require("../utils/parseResourceId");
|
|
18
20
|
var _resolveSyncBlockInstance = require("../utils/resolveSyncBlockInstance");
|
|
19
21
|
var _utils = require("../utils/utils");
|
|
20
22
|
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; }
|
|
@@ -54,6 +56,16 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
54
56
|
value: function setFireAnalyticsEvent(fireAnalyticsEvent) {
|
|
55
57
|
this.fireAnalyticsEvent = fireAnalyticsEvent;
|
|
56
58
|
}
|
|
59
|
+
}, {
|
|
60
|
+
key: "setExperiences",
|
|
61
|
+
value: function setExperiences(fetchExperience, fetchSourceInfoExperience, saveExperience) {
|
|
62
|
+
// don't reset experiences after they have already been set
|
|
63
|
+
if (!this.fetchExperience || !this.fetchSourceInfoExperience || !this.saveExperience) {
|
|
64
|
+
this.fetchExperience = fetchExperience;
|
|
65
|
+
this.fetchSourceInfoExperience = fetchSourceInfoExperience;
|
|
66
|
+
this.saveExperience = saveExperience;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
57
69
|
}, {
|
|
58
70
|
key: "generateResourceIdForReference",
|
|
59
71
|
value: function generateResourceIdForReference(sourceId) {
|
|
@@ -83,7 +95,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
83
95
|
key: "refreshSubscriptions",
|
|
84
96
|
value: (function () {
|
|
85
97
|
var _refreshSubscriptions = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
86
|
-
var syncBlocks, _iterator, _step, _loop, _this$fireAnalyticsEv;
|
|
98
|
+
var syncBlocks, _iterator, _step, _loop, _this$fetchExperience, _this$fireAnalyticsEv;
|
|
87
99
|
return _regenerator.default.wrap(function _callee$(_context2) {
|
|
88
100
|
while (1) switch (_context2.prev = _context2.next) {
|
|
89
101
|
case 0:
|
|
@@ -146,7 +158,13 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
146
158
|
(0, _monitoring.logException)(_context2.t2, {
|
|
147
159
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
148
160
|
});
|
|
149
|
-
|
|
161
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
162
|
+
(_this$fetchExperience = this.fetchExperience) === null || _this$fetchExperience === void 0 || _this$fetchExperience.failure({
|
|
163
|
+
reason: _context2.t2.message
|
|
164
|
+
});
|
|
165
|
+
} else {
|
|
166
|
+
(_this$fireAnalyticsEv = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv === void 0 || _this$fireAnalyticsEv.call(this, (0, _errorHandling.fetchErrorPayload)(_context2.t2.message));
|
|
167
|
+
}
|
|
150
168
|
case 29:
|
|
151
169
|
_context2.prev = 29;
|
|
152
170
|
this.isRefreshingSubscriptions = false;
|
|
@@ -169,6 +187,11 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
169
187
|
try {
|
|
170
188
|
var _existingSyncBlock$da, _existingSyncBlock$da2;
|
|
171
189
|
if (!resourceId || !this.dataProvider) {
|
|
190
|
+
// make sure experience has been started before throwing error
|
|
191
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
192
|
+
var _this$fetchSourceInfo;
|
|
193
|
+
(_this$fetchSourceInfo = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo === void 0 || _this$fetchSourceInfo.start({});
|
|
194
|
+
}
|
|
172
195
|
throw new Error('Data provider or resourceId not set');
|
|
173
196
|
}
|
|
174
197
|
if (this.syncBlockSourceInfoRequests.get(resourceId)) {
|
|
@@ -176,6 +199,10 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
176
199
|
}
|
|
177
200
|
var existingSyncBlock = this.getFromCache(resourceId);
|
|
178
201
|
if (!existingSyncBlock) {
|
|
202
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
203
|
+
var _this$fetchSourceInfo2;
|
|
204
|
+
(_this$fetchSourceInfo2 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo2 === void 0 || _this$fetchSourceInfo2.start({});
|
|
205
|
+
}
|
|
179
206
|
throw new Error('No existing sync block to fetch source info for');
|
|
180
207
|
}
|
|
181
208
|
|
|
@@ -183,36 +210,80 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
183
210
|
if ((_existingSyncBlock$da = existingSyncBlock.data) !== null && _existingSyncBlock$da !== void 0 && _existingSyncBlock$da.sourceURL && (_existingSyncBlock$da2 = existingSyncBlock.data) !== null && _existingSyncBlock$da2 !== void 0 && _existingSyncBlock$da2.sourceTitle) {
|
|
184
211
|
return;
|
|
185
212
|
}
|
|
213
|
+
|
|
214
|
+
// only start experience if there is data to fetch
|
|
215
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
216
|
+
var _this$fetchSourceInfo3;
|
|
217
|
+
(_this$fetchSourceInfo3 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo3 === void 0 || _this$fetchSourceInfo3.start({});
|
|
218
|
+
}
|
|
186
219
|
var _ref = existingSyncBlock.data || {},
|
|
187
220
|
sourceAri = _ref.sourceAri,
|
|
188
221
|
product = _ref.product,
|
|
189
222
|
blockInstanceId = _ref.blockInstanceId;
|
|
190
223
|
if (!sourceAri || !product || !blockInstanceId) {
|
|
191
|
-
|
|
192
|
-
|
|
224
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
225
|
+
var _this$fetchSourceInfo4;
|
|
226
|
+
(_this$fetchSourceInfo4 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo4 === void 0 || _this$fetchSourceInfo4.failure({
|
|
227
|
+
reason: 'SourceAri, product or blockInstanceId missing'
|
|
228
|
+
});
|
|
229
|
+
} else {
|
|
230
|
+
var _this$fireAnalyticsEv2;
|
|
231
|
+
(_this$fireAnalyticsEv2 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 || _this$fireAnalyticsEv2.call(this, (0, _errorHandling.getSourceInfoErrorPayload)('SourceAri, product or blockInstanceId missing'));
|
|
232
|
+
}
|
|
193
233
|
return;
|
|
194
234
|
}
|
|
195
235
|
this.syncBlockSourceInfoRequests.set(resourceId, true);
|
|
196
236
|
this.dataProvider.fetchSyncBlockSourceInfo(blockInstanceId, sourceAri, product, this.fireAnalyticsEvent).then(function (sourceInfo) {
|
|
197
237
|
if (!sourceInfo) {
|
|
238
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
239
|
+
var _this$fetchSourceInfo5;
|
|
240
|
+
(_this$fetchSourceInfo5 = _this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo5 === void 0 || _this$fetchSourceInfo5.failure({
|
|
241
|
+
reason: 'No source info returned'
|
|
242
|
+
});
|
|
243
|
+
}
|
|
198
244
|
return;
|
|
199
245
|
}
|
|
200
246
|
_this.updateCacheWithSourceInfo(resourceId, sourceInfo);
|
|
201
247
|
if (sourceInfo.title) {
|
|
202
248
|
_this.updateSourceTitleSubscriptions(resourceId, sourceInfo.title);
|
|
203
249
|
}
|
|
250
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
251
|
+
if (sourceInfo.title && sourceInfo.url) {
|
|
252
|
+
var _this$fetchSourceInfo6;
|
|
253
|
+
(_this$fetchSourceInfo6 = _this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo6 === void 0 || _this$fetchSourceInfo6.success();
|
|
254
|
+
} else {
|
|
255
|
+
var _this$fetchSourceInfo7;
|
|
256
|
+
(_this$fetchSourceInfo7 = _this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo7 === void 0 || _this$fetchSourceInfo7.failure({
|
|
257
|
+
reason: 'Missing title or url'
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}
|
|
204
261
|
}).catch(function (error) {
|
|
205
|
-
|
|
206
|
-
|
|
262
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
263
|
+
var _this$fetchSourceInfo8;
|
|
264
|
+
(_this$fetchSourceInfo8 = _this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo8 === void 0 || _this$fetchSourceInfo8.failure({
|
|
265
|
+
reason: error.message
|
|
266
|
+
});
|
|
267
|
+
} else {
|
|
268
|
+
var _this$fireAnalyticsEv3;
|
|
269
|
+
(_this$fireAnalyticsEv3 = _this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(_this, (0, _errorHandling.getSourceInfoErrorPayload)(error.message));
|
|
270
|
+
}
|
|
207
271
|
}).finally(function () {
|
|
208
272
|
_this.syncBlockSourceInfoRequests.delete(resourceId);
|
|
209
273
|
});
|
|
210
274
|
} catch (error) {
|
|
211
|
-
var _this$fireAnalyticsEv4;
|
|
212
275
|
(0, _monitoring.logException)(error, {
|
|
213
276
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
214
277
|
});
|
|
215
|
-
|
|
278
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
279
|
+
var _this$fetchSourceInfo9;
|
|
280
|
+
(_this$fetchSourceInfo9 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo9 === void 0 || _this$fetchSourceInfo9.failure({
|
|
281
|
+
reason: error.message
|
|
282
|
+
});
|
|
283
|
+
} else {
|
|
284
|
+
var _this$fireAnalyticsEv4;
|
|
285
|
+
(_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(this, (0, _errorHandling.getSourceInfoErrorPayload)(error.message));
|
|
286
|
+
}
|
|
216
287
|
}
|
|
217
288
|
}
|
|
218
289
|
|
|
@@ -226,7 +297,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
226
297
|
value: (function () {
|
|
227
298
|
var _fetchSyncBlocksData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(syncBlockNodes) {
|
|
228
299
|
var _this2 = this;
|
|
229
|
-
var nodesToFetch, data, resolvedData;
|
|
300
|
+
var nodesToFetch, _this$fetchExperience2, data, resolvedData, successfulFetched, failedFetch, _this$fetchExperience3, _this$fetchExperience4;
|
|
230
301
|
return _regenerator.default.wrap(function _callee2$(_context3) {
|
|
231
302
|
while (1) switch (_context3.prev = _context3.next) {
|
|
232
303
|
case 0:
|
|
@@ -236,12 +307,6 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
236
307
|
}
|
|
237
308
|
return _context3.abrupt("return");
|
|
238
309
|
case 2:
|
|
239
|
-
if (this.dataProvider) {
|
|
240
|
-
_context3.next = 4;
|
|
241
|
-
break;
|
|
242
|
-
}
|
|
243
|
-
throw new Error('Data provider not set');
|
|
244
|
-
case 4:
|
|
245
310
|
// Don't fetch for not_found error since the source is already deleted
|
|
246
311
|
nodesToFetch = [];
|
|
247
312
|
syncBlockNodes.forEach(function (node) {
|
|
@@ -255,27 +320,45 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
255
320
|
nodesToFetch.push(node);
|
|
256
321
|
});
|
|
257
322
|
if (!(nodesToFetch.length === 0)) {
|
|
258
|
-
_context3.next =
|
|
323
|
+
_context3.next = 6;
|
|
259
324
|
break;
|
|
260
325
|
}
|
|
261
326
|
return _context3.abrupt("return");
|
|
262
|
-
case
|
|
327
|
+
case 6:
|
|
328
|
+
// only start fetch experience if there is data to fetch
|
|
329
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
330
|
+
(_this$fetchExperience2 = this.fetchExperience) === null || _this$fetchExperience2 === void 0 || _this$fetchExperience2.start({});
|
|
331
|
+
}
|
|
332
|
+
if (this.dataProvider) {
|
|
333
|
+
_context3.next = 9;
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
throw new Error('Data provider not set');
|
|
337
|
+
case 9:
|
|
263
338
|
nodesToFetch.forEach(function (node) {
|
|
264
339
|
_this2.syncBlockFetchDataRequests.set(node.attrs.resourceId, true);
|
|
265
340
|
});
|
|
266
|
-
_context3.next =
|
|
341
|
+
_context3.next = 12;
|
|
267
342
|
return this.dataProvider.fetchNodesData(nodesToFetch).finally(function () {
|
|
268
343
|
nodesToFetch.forEach(function (node) {
|
|
269
344
|
_this2.syncBlockFetchDataRequests.delete(node.attrs.resourceId);
|
|
270
345
|
});
|
|
271
346
|
});
|
|
272
|
-
case
|
|
347
|
+
case 12:
|
|
273
348
|
data = _context3.sent;
|
|
274
349
|
resolvedData = [];
|
|
350
|
+
successfulFetched = [];
|
|
351
|
+
failedFetch = [];
|
|
275
352
|
data.forEach(function (syncBlockInstance) {
|
|
276
353
|
if (!syncBlockInstance.resourceId) {
|
|
277
|
-
|
|
278
|
-
|
|
354
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
355
|
+
failedFetch.push({
|
|
356
|
+
reason: syncBlockInstance.error || 'Returned sync block instance does not have resource id'
|
|
357
|
+
});
|
|
358
|
+
} else {
|
|
359
|
+
var _this2$fireAnalyticsE;
|
|
360
|
+
(_this2$fireAnalyticsE = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE === void 0 || _this2$fireAnalyticsE.call(_this2, (0, _errorHandling.fetchErrorPayload)(syncBlockInstance.error || 'Returned sync block instance does not have resource id'));
|
|
361
|
+
}
|
|
279
362
|
return;
|
|
280
363
|
}
|
|
281
364
|
var existingSyncBlock = _this2.getFromCache(syncBlockInstance.resourceId);
|
|
@@ -283,13 +366,39 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
283
366
|
_this2.updateCache(resolvedSyncBlockInstance);
|
|
284
367
|
resolvedData.push(resolvedSyncBlockInstance);
|
|
285
368
|
if (syncBlockInstance.error) {
|
|
286
|
-
|
|
287
|
-
|
|
369
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
370
|
+
failedFetch.push({
|
|
371
|
+
reason: syncBlockInstance.error,
|
|
372
|
+
resourceId: syncBlockInstance.resourceId
|
|
373
|
+
});
|
|
374
|
+
} else {
|
|
375
|
+
var _this2$fireAnalyticsE2;
|
|
376
|
+
(_this2$fireAnalyticsE2 = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE2 === void 0 || _this2$fireAnalyticsE2.call(_this2, (0, _errorHandling.fetchErrorPayload)(syncBlockInstance.error));
|
|
377
|
+
}
|
|
288
378
|
return;
|
|
289
379
|
}
|
|
380
|
+
successfulFetched.push(syncBlockInstance.resourceId);
|
|
290
381
|
_this2.fetchSyncBlockSourceInfo(resolvedSyncBlockInstance.resourceId);
|
|
291
382
|
});
|
|
292
|
-
|
|
383
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
384
|
+
if (data.every(function (syncBlockInstance) {
|
|
385
|
+
return syncBlockInstance.resourceId && !syncBlockInstance.error;
|
|
386
|
+
})) {
|
|
387
|
+
(_this$fetchExperience3 = this.fetchExperience) === null || _this$fetchExperience3 === void 0 || _this$fetchExperience3.success({
|
|
388
|
+
metadata: {
|
|
389
|
+
successfulFetched: successfulFetched
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
} else {
|
|
393
|
+
(_this$fetchExperience4 = this.fetchExperience) === null || _this$fetchExperience4 === void 0 || _this$fetchExperience4.failure({
|
|
394
|
+
metadata: {
|
|
395
|
+
successfulFetched: successfulFetched,
|
|
396
|
+
failedFetch: failedFetch
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
case 18:
|
|
293
402
|
case "end":
|
|
294
403
|
return _context3.stop();
|
|
295
404
|
}
|
|
@@ -378,11 +487,18 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
378
487
|
callback(cachedData);
|
|
379
488
|
} else {
|
|
380
489
|
this.fetchSyncBlocksData([syncBlockNode]).catch(function (error) {
|
|
381
|
-
var _this3$fireAnalyticsE;
|
|
382
490
|
(0, _monitoring.logException)(error, {
|
|
383
491
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
384
492
|
});
|
|
385
|
-
|
|
493
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
494
|
+
var _this3$fetchExperienc;
|
|
495
|
+
(_this3$fetchExperienc = _this3.fetchExperience) === null || _this3$fetchExperienc === void 0 || _this3$fetchExperienc.failure({
|
|
496
|
+
reason: error.message
|
|
497
|
+
});
|
|
498
|
+
} else {
|
|
499
|
+
var _this3$fireAnalyticsE;
|
|
500
|
+
(_this3$fireAnalyticsE = _this3.fireAnalyticsEvent) === null || _this3$fireAnalyticsE === void 0 || _this3$fireAnalyticsE.call(_this3, (0, _errorHandling.fetchErrorPayload)(error.message));
|
|
501
|
+
}
|
|
386
502
|
});
|
|
387
503
|
}
|
|
388
504
|
return function () {
|
|
@@ -534,6 +650,43 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
534
650
|
}
|
|
535
651
|
return providerFactory;
|
|
536
652
|
}
|
|
653
|
+
}, {
|
|
654
|
+
key: "getSSRProviders",
|
|
655
|
+
value: function getSSRProviders(resourceId) {
|
|
656
|
+
if (!(0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
657
|
+
return null;
|
|
658
|
+
}
|
|
659
|
+
if (!this.dataProvider) {
|
|
660
|
+
return null;
|
|
661
|
+
}
|
|
662
|
+
var _this$dataProvider$ge2 = this.dataProvider.getSyncedBlockRendererProviderOptions(),
|
|
663
|
+
providerCreator = _this$dataProvider$ge2.providerCreator;
|
|
664
|
+
if (!(providerCreator !== null && providerCreator !== void 0 && providerCreator.createSSRMediaProvider)) {
|
|
665
|
+
return null;
|
|
666
|
+
}
|
|
667
|
+
var parsedResourceId = (0, _parseResourceId.parseResourceId)(resourceId);
|
|
668
|
+
if (!parsedResourceId) {
|
|
669
|
+
return null;
|
|
670
|
+
}
|
|
671
|
+
var contentId = parsedResourceId.contentId,
|
|
672
|
+
contentProduct = parsedResourceId.product;
|
|
673
|
+
try {
|
|
674
|
+
var mediaProvider = providerCreator.createSSRMediaProvider({
|
|
675
|
+
contentId: contentId,
|
|
676
|
+
contentProduct: contentProduct
|
|
677
|
+
});
|
|
678
|
+
if (mediaProvider) {
|
|
679
|
+
return {
|
|
680
|
+
media: mediaProvider
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
} catch (error) {
|
|
684
|
+
(0, _monitoring.logException)(error, {
|
|
685
|
+
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
return null;
|
|
689
|
+
}
|
|
537
690
|
}, {
|
|
538
691
|
key: "retrieveDynamicProviders",
|
|
539
692
|
value: function retrieveDynamicProviders(resourceId, providerFactory, providerCreator) {
|
|
@@ -591,7 +744,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
591
744
|
key: "flush",
|
|
592
745
|
value: (function () {
|
|
593
746
|
var _flush = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
594
|
-
var success, blocks, updateResult, _this$fireAnalyticsEv9, _this$fireAnalyticsEv0;
|
|
747
|
+
var success, blocks, _this$saveExperience, updateResult, _this$saveExperience2, _this$fireAnalyticsEv9, _this$saveExperience3, _this$fireAnalyticsEv0, _this$saveExperience4;
|
|
595
748
|
return _regenerator.default.wrap(function _callee3$(_context4) {
|
|
596
749
|
while (1) switch (_context4.prev = _context4.next) {
|
|
597
750
|
case 0:
|
|
@@ -603,12 +756,6 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
603
756
|
case 2:
|
|
604
757
|
success = true;
|
|
605
758
|
_context4.prev = 3;
|
|
606
|
-
if (this.dataProvider) {
|
|
607
|
-
_context4.next = 6;
|
|
608
|
-
break;
|
|
609
|
-
}
|
|
610
|
-
throw new Error('Data provider not set');
|
|
611
|
-
case 6:
|
|
612
759
|
blocks = []; // Collect all reference synced blocks on the current document
|
|
613
760
|
Array.from(this.subscriptions.entries()).forEach(function (_ref2) {
|
|
614
761
|
var _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
|
|
@@ -622,50 +769,73 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
622
769
|
});
|
|
623
770
|
});
|
|
624
771
|
if (!(blocks.length === 0)) {
|
|
625
|
-
_context4.next =
|
|
772
|
+
_context4.next = 9;
|
|
626
773
|
break;
|
|
627
774
|
}
|
|
628
775
|
this.isCacheDirty = false;
|
|
629
776
|
return _context4.abrupt("return", true);
|
|
630
|
-
case
|
|
777
|
+
case 9:
|
|
778
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
779
|
+
(_this$saveExperience = this.saveExperience) === null || _this$saveExperience === void 0 || _this$saveExperience.start();
|
|
780
|
+
}
|
|
781
|
+
if (this.dataProvider) {
|
|
782
|
+
_context4.next = 12;
|
|
783
|
+
break;
|
|
784
|
+
}
|
|
785
|
+
throw new Error('Data provider not set');
|
|
786
|
+
case 12:
|
|
631
787
|
// reset isCacheDirty early to prevent race condition
|
|
632
788
|
// There is a race condition where if a user makes changes (create/delete) to a reference sync block
|
|
633
789
|
// on a live page and the reference sync block is being saved while the user
|
|
634
790
|
// is still making changes, the new changes might not be saved if they all happen
|
|
635
791
|
// exactly at a time when the updateReferenceData is being executed asynchronously.
|
|
636
792
|
this.isCacheDirty = false;
|
|
637
|
-
_context4.next =
|
|
793
|
+
_context4.next = 15;
|
|
638
794
|
return this.dataProvider.updateReferenceData(blocks);
|
|
639
|
-
case
|
|
795
|
+
case 15:
|
|
640
796
|
updateResult = _context4.sent;
|
|
641
797
|
if (!updateResult.success) {
|
|
642
798
|
success = false;
|
|
643
|
-
|
|
799
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
800
|
+
(_this$saveExperience2 = this.saveExperience) === null || _this$saveExperience2 === void 0 || _this$saveExperience2.failure({
|
|
801
|
+
reason: updateResult.error || 'Failed to update reference synced blocks on the document'
|
|
802
|
+
});
|
|
803
|
+
} else {
|
|
804
|
+
(_this$fireAnalyticsEv9 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv9 === void 0 || _this$fireAnalyticsEv9.call(this, (0, _errorHandling.updateReferenceErrorPayload)(updateResult.error || 'Failed to update reference synced blocks on the document'));
|
|
805
|
+
}
|
|
644
806
|
}
|
|
645
|
-
_context4.next =
|
|
807
|
+
_context4.next = 24;
|
|
646
808
|
break;
|
|
647
|
-
case
|
|
648
|
-
_context4.prev =
|
|
809
|
+
case 19:
|
|
810
|
+
_context4.prev = 19;
|
|
649
811
|
_context4.t0 = _context4["catch"](3);
|
|
650
812
|
success = false;
|
|
651
813
|
(0, _monitoring.logException)(_context4.t0, {
|
|
652
814
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
653
815
|
});
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
816
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
817
|
+
(_this$saveExperience3 = this.saveExperience) === null || _this$saveExperience3 === void 0 || _this$saveExperience3.failure({
|
|
818
|
+
reason: _context4.t0.message
|
|
819
|
+
});
|
|
820
|
+
} else {
|
|
821
|
+
(_this$fireAnalyticsEv0 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv0 === void 0 || _this$fireAnalyticsEv0.call(this, (0, _errorHandling.updateReferenceErrorPayload)(_context4.t0.message));
|
|
822
|
+
}
|
|
823
|
+
case 24:
|
|
824
|
+
_context4.prev = 24;
|
|
657
825
|
if (!success) {
|
|
658
826
|
// set isCacheDirty back to true for cases where it failed to update the reference synced blocks on the BE
|
|
659
827
|
this.isCacheDirty = true;
|
|
828
|
+
} else if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
829
|
+
(_this$saveExperience4 = this.saveExperience) === null || _this$saveExperience4 === void 0 || _this$saveExperience4.success();
|
|
660
830
|
}
|
|
661
|
-
return _context4.finish(
|
|
662
|
-
case 26:
|
|
663
|
-
return _context4.abrupt("return", success);
|
|
831
|
+
return _context4.finish(24);
|
|
664
832
|
case 27:
|
|
833
|
+
return _context4.abrupt("return", success);
|
|
834
|
+
case 28:
|
|
665
835
|
case "end":
|
|
666
836
|
return _context4.stop();
|
|
667
837
|
}
|
|
668
|
-
}, _callee3, this, [[3,
|
|
838
|
+
}, _callee3, this, [[3, 19, 24, 27]]);
|
|
669
839
|
}));
|
|
670
840
|
function flush() {
|
|
671
841
|
return _flush.apply(this, arguments);
|