@atlaskit/editor-synced-block-provider 23.0.5 → 23.1.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 +24 -0
- package/dist/cjs/clients/jira/ari.js +2 -2
- package/dist/cjs/common/types.js +1 -0
- package/dist/cjs/providers/block-service/blockServiceAPI.js +32 -10
- package/dist/cjs/providers/syncBlockProvider.js +11 -5
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +41 -23
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +15 -7
- package/dist/cjs/utils/errorHandling.js +16 -10
- package/dist/cjs/utils/fieldAwareLocations.js +26 -1
- package/dist/es2019/clients/jira/ari.js +1 -1
- package/dist/es2019/common/types.js +2 -0
- package/dist/es2019/providers/block-service/blockServiceAPI.js +27 -7
- package/dist/es2019/providers/syncBlockProvider.js +9 -3
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +41 -24
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +15 -9
- package/dist/es2019/utils/errorHandling.js +14 -5
- package/dist/es2019/utils/fieldAwareLocations.js +27 -2
- package/dist/esm/clients/jira/ari.js +1 -1
- package/dist/esm/common/types.js +2 -0
- package/dist/esm/providers/block-service/blockServiceAPI.js +32 -10
- package/dist/esm/providers/syncBlockProvider.js +11 -5
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +41 -23
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +15 -7
- package/dist/esm/utils/errorHandling.js +16 -10
- package/dist/esm/utils/fieldAwareLocations.js +26 -1
- package/dist/types/clients/jira/ari.d.ts +1 -0
- package/dist/types/common/types.d.ts +2 -0
- package/dist/types/providers/block-service/blockServiceAPI.d.ts +9 -2
- package/dist/types/providers/syncBlockProvider.d.ts +1 -1
- package/dist/types/providers/types.d.ts +6 -1
- package/dist/types/store-manager/sourceSyncBlockStoreManager.d.ts +1 -0
- package/dist/types/utils/errorHandling.d.ts +9 -7
- package/dist/types/utils/fieldAwareLocations.d.ts +9 -1
- package/package.json +7 -2
|
@@ -5,6 +5,7 @@ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-e
|
|
|
5
5
|
import { isProviderNotReadyError, ProviderNotReadyError, SyncBlockError } from '../common/types';
|
|
6
6
|
import { buildErrorAttribution, buildFetchErrorAttribution, cacheDeletionForcedPayload, fetchErrorPayload, fetchSuccessPayload, getSourceInfoErrorPayload, sourceInfoOrphanedPayload, updateReferenceErrorPayload } from '../utils/errorHandling';
|
|
7
7
|
import { getFetchExperience, getFetchSourceInfoExperience, getSaveReferenceExperience } from '../utils/experienceTracking';
|
|
8
|
+
import { getSourceLocation } from '../utils/fieldAwareLocations';
|
|
8
9
|
import { resolveSyncBlockInstance } from '../utils/resolveSyncBlockInstance';
|
|
9
10
|
import { parseResourceId } from '../utils/resourceId';
|
|
10
11
|
import { createSyncBlockNode, getSourceProductFromResourceIdSafe, normalizeSyncBlockJSONContent } from '../utils/utils';
|
|
@@ -192,9 +193,8 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
192
193
|
return this.getFromSessionCache(resourceId);
|
|
193
194
|
}
|
|
194
195
|
getSameDocumentReferenceParts(resourceId) {
|
|
195
|
-
var _this$dataProvider$ca, _this$dataProvider3;
|
|
196
196
|
const parsed = parseResourceId(resourceId);
|
|
197
|
-
if (!parsed || !this.dataProvider ||
|
|
197
|
+
if (!parsed || !this.dataProvider || this.dataProvider.generateResourceIdForReference(parsed.uuid) !== resourceId) {
|
|
198
198
|
return undefined;
|
|
199
199
|
}
|
|
200
200
|
return parsed;
|
|
@@ -348,15 +348,25 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
348
348
|
(_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 ? void 0 : _this$fireAnalyticsEv3.call(this, getSourceInfoErrorPayload('SourceAri, product or blockInstanceId missing', resourceId, sourceProduct));
|
|
349
349
|
return Promise.resolve(undefined);
|
|
350
350
|
}
|
|
351
|
+
const sourceLocation = getSourceLocation(sourceAri);
|
|
352
|
+
// Undefined with `platform_editor_blocks_patch_13` off, so experience calls below keep
|
|
353
|
+
// exactly their previous arguments (no `metadata` key, `success()` without arguments).
|
|
354
|
+
const experienceMetadata = sourceLocation && {
|
|
355
|
+
sourceLocation
|
|
356
|
+
};
|
|
357
|
+
const withExperienceMetadata = options => experienceMetadata ? {
|
|
358
|
+
...options,
|
|
359
|
+
metadata: experienceMetadata
|
|
360
|
+
} : options;
|
|
351
361
|
(_this$fetchSourceInfo = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo === void 0 ? void 0 : _this$fetchSourceInfo.start({});
|
|
352
362
|
const sourceInfoPromise = this.dataProvider.fetchSyncBlockSourceInfo(blockInstanceId, sourceAri, product, true // hasAccess
|
|
353
363
|
).then(sourceInfo => {
|
|
354
364
|
if (!sourceInfo) {
|
|
355
365
|
var _this$fetchSourceInfo2, _this$fireAnalyticsEv4;
|
|
356
|
-
(_this$fetchSourceInfo2 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo2 === void 0 ? void 0 : _this$fetchSourceInfo2.failure({
|
|
366
|
+
(_this$fetchSourceInfo2 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo2 === void 0 ? void 0 : _this$fetchSourceInfo2.failure(withExperienceMetadata({
|
|
357
367
|
reason: 'No source info returned'
|
|
358
|
-
});
|
|
359
|
-
(_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 ? void 0 : _this$fireAnalyticsEv4.call(this, getSourceInfoErrorPayload('No source info returned', resourceId, sourceProduct));
|
|
368
|
+
}));
|
|
369
|
+
(_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 ? void 0 : _this$fireAnalyticsEv4.call(this, getSourceInfoErrorPayload('No source info returned', resourceId, sourceProduct, sourceLocation));
|
|
360
370
|
return undefined;
|
|
361
371
|
}
|
|
362
372
|
this.updateCacheWithSourceInfo(resourceId, sourceInfo);
|
|
@@ -364,22 +374,29 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
364
374
|
this._subscriptionManager.updateSourceTitleSubscriptions(resourceId, sourceInfo.title);
|
|
365
375
|
}
|
|
366
376
|
if (sourceInfo.title && sourceInfo.url) {
|
|
367
|
-
|
|
368
|
-
|
|
377
|
+
if (experienceMetadata) {
|
|
378
|
+
var _this$fetchSourceInfo3;
|
|
379
|
+
(_this$fetchSourceInfo3 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo3 === void 0 ? void 0 : _this$fetchSourceInfo3.success({
|
|
380
|
+
metadata: experienceMetadata
|
|
381
|
+
});
|
|
382
|
+
} else {
|
|
383
|
+
var _this$fetchSourceInfo4;
|
|
384
|
+
(_this$fetchSourceInfo4 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo4 === void 0 ? void 0 : _this$fetchSourceInfo4.success();
|
|
385
|
+
}
|
|
369
386
|
} else {
|
|
370
|
-
var _this$
|
|
371
|
-
(_this$
|
|
387
|
+
var _this$fetchSourceInfo5, _this$fireAnalyticsEv5;
|
|
388
|
+
(_this$fetchSourceInfo5 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo5 === void 0 ? void 0 : _this$fetchSourceInfo5.failure(withExperienceMetadata({
|
|
372
389
|
reason: 'Missing title or url'
|
|
373
|
-
});
|
|
374
|
-
(_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 ? void 0 : _this$fireAnalyticsEv5.call(this, getSourceInfoErrorPayload('Missing title or url', resourceId, sourceProduct));
|
|
390
|
+
}));
|
|
391
|
+
(_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 ? void 0 : _this$fireAnalyticsEv5.call(this, getSourceInfoErrorPayload('Missing title or url', resourceId, sourceProduct, sourceLocation));
|
|
375
392
|
}
|
|
376
393
|
return sourceInfo;
|
|
377
394
|
}).catch(error => {
|
|
378
|
-
var _this$
|
|
379
|
-
(_this$
|
|
395
|
+
var _this$fetchSourceInfo6, _this$fireAnalyticsEv6;
|
|
396
|
+
(_this$fetchSourceInfo6 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo6 === void 0 ? void 0 : _this$fetchSourceInfo6.failure(withExperienceMetadata({
|
|
380
397
|
reason: error.message
|
|
381
|
-
});
|
|
382
|
-
(_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 ? void 0 : _this$fireAnalyticsEv6.call(this, getSourceInfoErrorPayload(error.message, resourceId, sourceProduct));
|
|
398
|
+
}));
|
|
399
|
+
(_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 ? void 0 : _this$fireAnalyticsEv6.call(this, getSourceInfoErrorPayload(error.message, resourceId, sourceProduct, sourceLocation));
|
|
383
400
|
return undefined;
|
|
384
401
|
}).finally(() => {
|
|
385
402
|
this.syncBlockSourceInfoRequests.delete(resourceId);
|
|
@@ -631,8 +648,8 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
631
648
|
resourceId
|
|
632
649
|
} = sanitizedSyncBlock;
|
|
633
650
|
if (resourceId) {
|
|
634
|
-
var _this$
|
|
635
|
-
(_this$
|
|
651
|
+
var _this$dataProvider3;
|
|
652
|
+
(_this$dataProvider3 = this.dataProvider) === null || _this$dataProvider3 === void 0 ? void 0 : _this$dataProvider3.updateCache({
|
|
636
653
|
[resourceId]: sanitizedSyncBlock
|
|
637
654
|
}, {
|
|
638
655
|
strategy: 'merge',
|
|
@@ -643,13 +660,13 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
643
660
|
}
|
|
644
661
|
}
|
|
645
662
|
getFromCache(resourceId) {
|
|
646
|
-
var _this$
|
|
663
|
+
var _this$dataProvider4, _this$dataProvider4$g;
|
|
647
664
|
const syncBlockNode = createSyncBlockNode('', resourceId);
|
|
648
|
-
return (_this$
|
|
665
|
+
return (_this$dataProvider4 = this.dataProvider) === null || _this$dataProvider4 === void 0 ? void 0 : (_this$dataProvider4$g = _this$dataProvider4.getNodeDataFromCache(syncBlockNode)) === null || _this$dataProvider4$g === void 0 ? void 0 : _this$dataProvider4$g.data;
|
|
649
666
|
}
|
|
650
667
|
deleteFromCache(resourceId) {
|
|
651
|
-
var _this$
|
|
652
|
-
(_this$
|
|
668
|
+
var _this$dataProvider5;
|
|
669
|
+
(_this$dataProvider5 = this.dataProvider) === null || _this$dataProvider5 === void 0 ? void 0 : _this$dataProvider5.removeFromCache([resourceId]);
|
|
653
670
|
this._providerFactoryManager.deleteFactory(resourceId);
|
|
654
671
|
// Evict in-flight source-info promise and reset reschedule counter
|
|
655
672
|
// so a stale resolution can't silently merge into a re-fetched entry.
|
|
@@ -1036,7 +1053,7 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
1036
1053
|
return success;
|
|
1037
1054
|
}
|
|
1038
1055
|
destroy() {
|
|
1039
|
-
var _this$
|
|
1056
|
+
var _this$dataProvider6, _this$saveExperience5, _this$fetchExperience0, _this$fetchSourceInfo7;
|
|
1040
1057
|
// Mark destroyed first so in-flight timer callbacks can early-return.
|
|
1041
1058
|
this.isDestroyed = true;
|
|
1042
1059
|
|
|
@@ -1058,7 +1075,7 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
1058
1075
|
this._subscriptionManager.destroy();
|
|
1059
1076
|
this._providerFactoryManager.destroy();
|
|
1060
1077
|
this._batchFetcher.destroy();
|
|
1061
|
-
(_this$
|
|
1078
|
+
(_this$dataProvider6 = this.dataProvider) === null || _this$dataProvider6 === void 0 ? void 0 : _this$dataProvider6.resetCache();
|
|
1062
1079
|
this.dataProvider = undefined;
|
|
1063
1080
|
this.syncBlockFetchDataRequests.clear();
|
|
1064
1081
|
this.syncBlockSourceInfoRequests.clear();
|
|
@@ -1068,7 +1085,7 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
1068
1085
|
(_this$fetchExperience0 = this.fetchExperience) === null || _this$fetchExperience0 === void 0 ? void 0 : _this$fetchExperience0.abort({
|
|
1069
1086
|
reason: 'editorDestroyed'
|
|
1070
1087
|
});
|
|
1071
|
-
(_this$
|
|
1088
|
+
(_this$fetchSourceInfo7 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo7 === void 0 ? void 0 : _this$fetchSourceInfo7.abort({
|
|
1072
1089
|
reason: 'editorDestroyed'
|
|
1073
1090
|
});
|
|
1074
1091
|
this.fireAnalyticsEvent = undefined;
|
|
@@ -4,6 +4,7 @@ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-e
|
|
|
4
4
|
import { SyncBlockError } from '../common/types';
|
|
5
5
|
import { updateErrorPayload, createErrorPayload, deleteErrorPayload, updateCacheErrorPayload, getSourceInfoErrorPayload, updateSuccessPayload, createSuccessPayload, createSuccessOperationalPayload, addContentSuccessPayload, deleteSuccessPayload, fetchReferencesErrorPayload, buildErrorAttribution } from '../utils/errorHandling';
|
|
6
6
|
import { getCreateSourceExperience, getDeleteSourceExperience, getSaveSourceExperience, getFetchSourceInfoExperience } from '../utils/experienceTracking';
|
|
7
|
+
import { getSourceLocation } from '../utils/fieldAwareLocations';
|
|
7
8
|
import { convertSyncBlockPMNodeToSyncBlockData, getSourceProductFromResourceIdSafe } from '../utils/utils';
|
|
8
9
|
/** Maximum time (ms) flush() will wait for in-flight block creations before proceeding. */
|
|
9
10
|
const FLUSH_CREATION_AWAIT_TIMEOUT_MS = 1000;
|
|
@@ -406,16 +407,17 @@ export class SourceSyncBlockStoreManager {
|
|
|
406
407
|
}
|
|
407
408
|
} else {
|
|
408
409
|
var _this$fireAnalyticsEv5;
|
|
409
|
-
(_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 ? void 0 : _this$fireAnalyticsEv5.call(this, createErrorPayload('creation complete callback missing', resourceId, getSourceProductFromResourceIdSafe(resourceId)));
|
|
410
|
+
(_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 ? void 0 : _this$fireAnalyticsEv5.call(this, createErrorPayload('creation complete callback missing', resourceId, getSourceProductFromResourceIdSafe(resourceId), undefined, this.getSourceLocation()));
|
|
410
411
|
}
|
|
411
412
|
if (success) {
|
|
412
413
|
var _this$dataProvider$ge, _this$dataProvider, _this$fireAnalyticsEv6, _this$fireAnalyticsEv7, _this$syncBlockCache$2;
|
|
413
414
|
const sourceProduct = getSourceProductFromResourceIdSafe(resourceId);
|
|
415
|
+
const sourceLocation = this.getSourceLocation();
|
|
414
416
|
const documentInsertedResourceId = (_this$dataProvider$ge = (_this$dataProvider = this.dataProvider) === null || _this$dataProvider === void 0 ? void 0 : _this$dataProvider.generateResourceIdForReference(resourceId)) !== null && _this$dataProvider$ge !== void 0 ? _this$dataProvider$ge : resourceId;
|
|
415
|
-
(_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 ? void 0 : _this$fireAnalyticsEv6.call(this, createSuccessPayload(documentInsertedResourceId || '', sourceProduct));
|
|
417
|
+
(_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 ? void 0 : _this$fireAnalyticsEv6.call(this, createSuccessPayload(documentInsertedResourceId || '', sourceProduct, sourceLocation));
|
|
416
418
|
// Operational create-success event with the join key + creation-type
|
|
417
419
|
// signals (inputMethod / createdEmpty / nodeTypes) captured at the command layer.
|
|
418
|
-
(_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 ? void 0 : _this$fireAnalyticsEv7.call(this, createSuccessOperationalPayload(resourceId || '', (_this$syncBlockCache$2 = this.syncBlockCache.get(resourceId)) === null || _this$syncBlockCache$2 === void 0 ? void 0 : _this$syncBlockCache$2.blockInstanceId, sourceProduct, this.creationEnrichment.get(resourceId)));
|
|
420
|
+
(_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 ? void 0 : _this$fireAnalyticsEv7.call(this, createSuccessOperationalPayload(resourceId || '', (_this$syncBlockCache$2 = this.syncBlockCache.get(resourceId)) === null || _this$syncBlockCache$2 === void 0 ? void 0 : _this$syncBlockCache$2.blockInstanceId, sourceProduct, this.creationEnrichment.get(resourceId), sourceLocation));
|
|
419
421
|
} else {
|
|
420
422
|
var _this$fireAnalyticsEv8;
|
|
421
423
|
// Delete the node from cache if fail to create so it's not flushed to BE
|
|
@@ -425,7 +427,7 @@ export class SourceSyncBlockStoreManager {
|
|
|
425
427
|
// Creation failed, so there is no block to add content to — drop the
|
|
426
428
|
// first-content tracking entry so a later unrelated edit cannot fire it.
|
|
427
429
|
this.awaitingFirstContent.delete(resourceId || '');
|
|
428
|
-
(_this$fireAnalyticsEv8 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv8 === void 0 ? void 0 : _this$fireAnalyticsEv8.call(this, createErrorPayload('Fail to create bodied sync block', resourceId, getSourceProductFromResourceIdSafe(resourceId)));
|
|
430
|
+
(_this$fireAnalyticsEv8 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv8 === void 0 ? void 0 : _this$fireAnalyticsEv8.call(this, createErrorPayload('Fail to create bodied sync block', resourceId, getSourceProductFromResourceIdSafe(resourceId), undefined, this.getSourceLocation()));
|
|
429
431
|
}
|
|
430
432
|
// Enrichment is single-use — drop it once the create has resolved either way.
|
|
431
433
|
this.creationEnrichment.delete(resourceId || '');
|
|
@@ -538,7 +540,7 @@ export class SourceSyncBlockStoreManager {
|
|
|
538
540
|
(_this$createExperienc3 = this.createExperience) === null || _this$createExperienc3 === void 0 ? void 0 : _this$createExperienc3.failure({
|
|
539
541
|
reason: result.error || 'Failed to create bodied sync block'
|
|
540
542
|
});
|
|
541
|
-
(_this$fireAnalyticsEv0 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv0 === void 0 ? void 0 : _this$fireAnalyticsEv0.call(this, createErrorPayload(result.error || 'Failed to create bodied sync block', resourceId, getSourceProductFromResourceIdSafe(resourceId), buildErrorAttribution(result.error, result.statusCode)));
|
|
543
|
+
(_this$fireAnalyticsEv0 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv0 === void 0 ? void 0 : _this$fireAnalyticsEv0.call(this, createErrorPayload(result.error || 'Failed to create bodied sync block', resourceId, getSourceProductFromResourceIdSafe(resourceId), buildErrorAttribution(result.error, result.statusCode), this.getSourceLocation()));
|
|
542
544
|
}
|
|
543
545
|
}).catch(error => {
|
|
544
546
|
var _this$createExperienc4, _this$fireAnalyticsEv1;
|
|
@@ -549,7 +551,7 @@ export class SourceSyncBlockStoreManager {
|
|
|
549
551
|
(_this$createExperienc4 = this.createExperience) === null || _this$createExperienc4 === void 0 ? void 0 : _this$createExperienc4.failure({
|
|
550
552
|
reason: error.message
|
|
551
553
|
});
|
|
552
|
-
(_this$fireAnalyticsEv1 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv1 === void 0 ? void 0 : _this$fireAnalyticsEv1.call(this, createErrorPayload(error.message, resourceId, getSourceProductFromResourceIdSafe(resourceId)));
|
|
554
|
+
(_this$fireAnalyticsEv1 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv1 === void 0 ? void 0 : _this$fireAnalyticsEv1.call(this, createErrorPayload(error.message, resourceId, getSourceProductFromResourceIdSafe(resourceId), undefined, this.getSourceLocation()));
|
|
553
555
|
}).finally(() => {
|
|
554
556
|
this.pendingCreationPromises.delete(resourceId);
|
|
555
557
|
});
|
|
@@ -563,9 +565,13 @@ export class SourceSyncBlockStoreManager {
|
|
|
563
565
|
logException(error, {
|
|
564
566
|
location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
|
|
565
567
|
});
|
|
566
|
-
(_this$fireAnalyticsEv10 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv10 === void 0 ? void 0 : _this$fireAnalyticsEv10.call(this, createErrorPayload(error.message, resourceId, getSourceProductFromResourceIdSafe(resourceId)));
|
|
568
|
+
(_this$fireAnalyticsEv10 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv10 === void 0 ? void 0 : _this$fireAnalyticsEv10.call(this, createErrorPayload(error.message, resourceId, getSourceProductFromResourceIdSafe(resourceId), undefined, this.getSourceLocation()));
|
|
567
569
|
}
|
|
568
570
|
}
|
|
571
|
+
getSourceLocation() {
|
|
572
|
+
var _this$dataProvider2, _this$dataProvider2$g;
|
|
573
|
+
return getSourceLocation((_this$dataProvider2 = this.dataProvider) === null || _this$dataProvider2 === void 0 ? void 0 : (_this$dataProvider2$g = _this$dataProvider2.getParentAri) === null || _this$dataProvider2$g === void 0 ? void 0 : _this$dataProvider2$g.call(_this$dataProvider2));
|
|
574
|
+
}
|
|
569
575
|
/**
|
|
570
576
|
* Drop dedupe entries older than {@link DELETE_DEDUPE_WINDOW_MS} so
|
|
571
577
|
* `recentDeleteEmissions` stays bounded by the number of recent deletes.
|
|
@@ -709,8 +715,8 @@ export class SourceSyncBlockStoreManager {
|
|
|
709
715
|
// so we can update the correct cache entries.
|
|
710
716
|
const sourceToReferenceMap = new Map();
|
|
711
717
|
const syncBlockNodes = Array.from(this.syncBlockCache.entries()).map(([resourceId, data]) => {
|
|
712
|
-
var _this$dataProvider$ge2, _this$
|
|
713
|
-
const referenceResourceId = (_this$dataProvider$ge2 = (_this$
|
|
718
|
+
var _this$dataProvider$ge2, _this$dataProvider3;
|
|
719
|
+
const referenceResourceId = (_this$dataProvider$ge2 = (_this$dataProvider3 = this.dataProvider) === null || _this$dataProvider3 === void 0 ? void 0 : _this$dataProvider3.generateResourceIdForReference(resourceId)) !== null && _this$dataProvider$ge2 !== void 0 ? _this$dataProvider$ge2 : resourceId;
|
|
714
720
|
sourceToReferenceMap.set(referenceResourceId, resourceId);
|
|
715
721
|
return {
|
|
716
722
|
type: 'bodiedSyncBlock',
|
|
@@ -209,7 +209,7 @@ export const buildFetchErrorAttribution = (error, statusCode, deferred) => {
|
|
|
209
209
|
* buckets like `source_deleted` they never emit.
|
|
210
210
|
*/
|
|
211
211
|
|
|
212
|
-
export function getErrorPayload(actionSubjectId, error, resourceId, sourceProduct, attribution) {
|
|
212
|
+
export function getErrorPayload(actionSubjectId, error, resourceId, sourceProduct, attribution, sourceLocation) {
|
|
213
213
|
return {
|
|
214
214
|
action: ACTION.ERROR,
|
|
215
215
|
actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
@@ -223,6 +223,9 @@ export function getErrorPayload(actionSubjectId, error, resourceId, sourceProduc
|
|
|
223
223
|
...(sourceProduct && {
|
|
224
224
|
sourceProduct
|
|
225
225
|
}),
|
|
226
|
+
...(sourceLocation && {
|
|
227
|
+
sourceLocation
|
|
228
|
+
}),
|
|
226
229
|
...((attribution === null || attribution === void 0 ? void 0 : attribution.reason) && {
|
|
227
230
|
reason: attribution.reason
|
|
228
231
|
}),
|
|
@@ -249,10 +252,10 @@ export const fetchErrorPayload = (error, resourceId, sourceProduct, attribution)
|
|
|
249
252
|
// attribution it hits the fetch overload (wider `reason`); without it, the
|
|
250
253
|
// no-attribution overload. Both produce a fetch event regardless.
|
|
251
254
|
attribution ? getErrorPayload(ACTION_SUBJECT_ID.SYNCED_BLOCK_FETCH, error, resourceId, sourceProduct, attribution) : getErrorPayload(ACTION_SUBJECT_ID.SYNCED_BLOCK_FETCH, error, resourceId, sourceProduct);
|
|
252
|
-
export const getSourceInfoErrorPayload = (error, resourceId, sourceProduct) => getErrorPayload(ACTION_SUBJECT_ID.SYNCED_BLOCK_GET_SOURCE_INFO, error, resourceId, sourceProduct);
|
|
255
|
+
export const getSourceInfoErrorPayload = (error, resourceId, sourceProduct, sourceLocation) => getErrorPayload(ACTION_SUBJECT_ID.SYNCED_BLOCK_GET_SOURCE_INFO, error, resourceId, sourceProduct, undefined, sourceLocation);
|
|
253
256
|
export const updateErrorPayload = (error, resourceId, sourceProduct, attribution) => getErrorPayload(ACTION_SUBJECT_ID.SYNCED_BLOCK_UPDATE, error, resourceId, sourceProduct, attribution);
|
|
254
257
|
export const updateReferenceErrorPayload = (error, resourceId, sourceProduct, attribution) => getErrorPayload(ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_UPDATE, error, resourceId, sourceProduct, attribution);
|
|
255
|
-
export const createErrorPayload = (error, resourceId, sourceProduct, attribution) => getErrorPayload(ACTION_SUBJECT_ID.SYNCED_BLOCK_CREATE, error, resourceId, sourceProduct, attribution);
|
|
258
|
+
export const createErrorPayload = (error, resourceId, sourceProduct, attribution, sourceLocation) => getErrorPayload(ACTION_SUBJECT_ID.SYNCED_BLOCK_CREATE, error, resourceId, sourceProduct, attribution, sourceLocation);
|
|
256
259
|
export const deleteErrorPayload = (error, resourceId, sourceProduct, attribution) => getErrorPayload(ACTION_SUBJECT_ID.SYNCED_BLOCK_DELETE, error, resourceId, sourceProduct, attribution);
|
|
257
260
|
export const updateCacheErrorPayload = (error, resourceId, sourceProduct) => getErrorPayload(ACTION_SUBJECT_ID.SYNCED_BLOCK_UPDATE_CACHE, error, resourceId, sourceProduct);
|
|
258
261
|
/**
|
|
@@ -316,7 +319,7 @@ export const fetchSuccessPayload = (resourceId, blockInstanceId, sourceProduct)
|
|
|
316
319
|
})
|
|
317
320
|
}
|
|
318
321
|
});
|
|
319
|
-
export const createSuccessPayload = (resourceId, sourceProduct) => {
|
|
322
|
+
export const createSuccessPayload = (resourceId, sourceProduct, sourceLocation) => {
|
|
320
323
|
return {
|
|
321
324
|
action: ACTION.INSERTED,
|
|
322
325
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
@@ -326,6 +329,9 @@ export const createSuccessPayload = (resourceId, sourceProduct) => {
|
|
|
326
329
|
resourceId,
|
|
327
330
|
...(sourceProduct && {
|
|
328
331
|
sourceProduct
|
|
332
|
+
}),
|
|
333
|
+
...(sourceLocation && {
|
|
334
|
+
sourceLocation
|
|
329
335
|
})
|
|
330
336
|
}
|
|
331
337
|
};
|
|
@@ -343,7 +349,7 @@ export const createSuccessPayload = (resourceId, sourceProduct) => {
|
|
|
343
349
|
* Operational `syncedBlockCreate` success event with the `blockInstanceId` join key and,
|
|
344
350
|
* when available, the `inputMethod`, `createdEmpty`, and `nodeTypes` creation signals.
|
|
345
351
|
*/
|
|
346
|
-
export const createSuccessOperationalPayload = (resourceId, blockInstanceId, sourceProduct, enrichment) => {
|
|
352
|
+
export const createSuccessOperationalPayload = (resourceId, blockInstanceId, sourceProduct, enrichment, sourceLocation) => {
|
|
347
353
|
var _enrichment$nodeTypes;
|
|
348
354
|
return {
|
|
349
355
|
action: ACTION.INSERTED,
|
|
@@ -366,6 +372,9 @@ export const createSuccessOperationalPayload = (resourceId, blockInstanceId, sou
|
|
|
366
372
|
}),
|
|
367
373
|
...((enrichment === null || enrichment === void 0 ? void 0 : (_enrichment$nodeTypes = enrichment.nodeTypes) === null || _enrichment$nodeTypes === void 0 ? void 0 : _enrichment$nodeTypes.length) && {
|
|
368
374
|
nodeTypes: enrichment.nodeTypes
|
|
375
|
+
}),
|
|
376
|
+
...(sourceLocation && {
|
|
377
|
+
sourceLocation
|
|
369
378
|
})
|
|
370
379
|
}
|
|
371
380
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
2
|
-
import {
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
3
|
+
import { getLocationScope, getProductFromSourceAri } from '../clients/block-service/ari';
|
|
4
|
+
import { JIRA_DESCRIPTION_FIELD_ID, parseJiraFieldLocation } from '../clients/jira/ari';
|
|
3
5
|
/**
|
|
4
6
|
* The product check runs first so a Confluence-only document never reads the experiment.
|
|
5
7
|
*/
|
|
@@ -18,4 +20,27 @@ export const getFieldAwareLocationScope = ({
|
|
|
18
20
|
documentAri,
|
|
19
21
|
hostAri
|
|
20
22
|
})
|
|
21
|
-
} : undefined;
|
|
23
|
+
} : undefined;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Analytics `sourceLocation` for a source ARI: `undefined` for non-Jira sources and for the
|
|
27
|
+
* control cohort, so events outside the experiment keep their current shape.
|
|
28
|
+
*
|
|
29
|
+
* The `platform_editor_blocks_patch_13` gate runs first: with it off this returns `undefined`
|
|
30
|
+
* without the product check or the experiment read, so no new exposure is logged.
|
|
31
|
+
*/
|
|
32
|
+
export const getSourceLocation = sourceAri => {
|
|
33
|
+
if (!fg('platform_editor_blocks_patch_13')) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
if (!sourceAri || !isFieldAwareJiraLocation(getProductFromSourceAri(sourceAri))) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
const location = parseJiraFieldLocation({
|
|
40
|
+
ari: sourceAri
|
|
41
|
+
});
|
|
42
|
+
if (!location) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
return location.fieldId === JIRA_DESCRIPTION_FIELD_ID ? 'description' : 'custom-field';
|
|
46
|
+
};
|
|
@@ -63,7 +63,7 @@ export var getJiraIssueAriFromSourceAri = function getJiraIssueAriFromSourceAri(
|
|
|
63
63
|
}
|
|
64
64
|
return ari;
|
|
65
65
|
};
|
|
66
|
-
var JIRA_DESCRIPTION_FIELD_ID = 'description';
|
|
66
|
+
export var JIRA_DESCRIPTION_FIELD_ID = 'description';
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* One synced block location on a Jira work item, parsed once from its document ARI.
|
package/dist/esm/common/types.js
CHANGED
|
@@ -14,6 +14,8 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
14
14
|
* `same-parent-document` is another field of the host work item.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
/** Which Jira work item field holds a source block. */
|
|
18
|
+
|
|
17
19
|
export var SyncBlockError = /*#__PURE__*/function (SyncBlockError) {
|
|
18
20
|
SyncBlockError["Errored"] = "errored";
|
|
19
21
|
SyncBlockError["NotFound"] = "not_found";
|
|
@@ -600,15 +600,27 @@ export var writeDataBatch = /*#__PURE__*/function () {
|
|
|
600
600
|
var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
601
601
|
function BlockServiceADFFetchProvider(_ref5) {
|
|
602
602
|
var cloudId = _ref5.cloudId,
|
|
603
|
-
parentAri = _ref5.parentAri
|
|
603
|
+
parentAri = _ref5.parentAri,
|
|
604
|
+
parentId = _ref5.parentId,
|
|
605
|
+
product = _ref5.product;
|
|
604
606
|
_classCallCheck(this, BlockServiceADFFetchProvider);
|
|
605
607
|
this.cloudId = cloudId;
|
|
606
608
|
this.parentAri = parentAri;
|
|
609
|
+
this.parentId = parentId;
|
|
610
|
+
this.product = product;
|
|
607
611
|
}
|
|
608
|
-
|
|
609
|
-
// resourceId of the reference synced block.
|
|
610
|
-
// the ARI must be constructed to call the block service API
|
|
611
612
|
return _createClass(BlockServiceADFFetchProvider, [{
|
|
613
|
+
key: "generateResourceIdForReference",
|
|
614
|
+
value: function generateResourceIdForReference(sourceId) {
|
|
615
|
+
if (!this.product || !this.parentId) {
|
|
616
|
+
return sourceId;
|
|
617
|
+
}
|
|
618
|
+
return createResourceIdForReference(this.product, this.parentId, sourceId);
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
// resourceId of the reference synced block.
|
|
622
|
+
// the ARI must be constructed to call the block service API
|
|
623
|
+
}, {
|
|
612
624
|
key: "fetchData",
|
|
613
625
|
value: function () {
|
|
614
626
|
var _fetchData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(resourceId) {
|
|
@@ -1488,7 +1500,9 @@ var createBlockServiceAPIProviders = function createBlockServiceAPIProviders(_re
|
|
|
1488
1500
|
return {
|
|
1489
1501
|
fetchProvider: new BlockServiceADFFetchProvider({
|
|
1490
1502
|
cloudId: cloudId,
|
|
1491
|
-
parentAri: parentAri
|
|
1503
|
+
parentAri: parentAri,
|
|
1504
|
+
parentId: parentId,
|
|
1505
|
+
product: product
|
|
1492
1506
|
}),
|
|
1493
1507
|
writeProvider: new BlockServiceADFWriteProvider({
|
|
1494
1508
|
cloudId: cloudId,
|
|
@@ -1517,11 +1531,15 @@ export var useMemoizedBlockServiceAPIProviders = function useMemoizedBlockServic
|
|
|
1517
1531
|
};
|
|
1518
1532
|
var createBlockServiceFetchOnlyAPIProvider = function createBlockServiceFetchOnlyAPIProvider(_ref1) {
|
|
1519
1533
|
var cloudId = _ref1.cloudId,
|
|
1520
|
-
parentAri = _ref1.parentAri
|
|
1534
|
+
parentAri = _ref1.parentAri,
|
|
1535
|
+
parentId = _ref1.parentId,
|
|
1536
|
+
product = _ref1.product;
|
|
1521
1537
|
return {
|
|
1522
1538
|
fetchProvider: new BlockServiceADFFetchProvider({
|
|
1523
1539
|
cloudId: cloudId,
|
|
1524
|
-
parentAri: parentAri
|
|
1540
|
+
parentAri: parentAri,
|
|
1541
|
+
parentId: parentId,
|
|
1542
|
+
product: product
|
|
1525
1543
|
}),
|
|
1526
1544
|
writeProvider: undefined
|
|
1527
1545
|
};
|
|
@@ -1532,11 +1550,15 @@ var createBlockServiceFetchOnlyAPIProvider = function createBlockServiceFetchOnl
|
|
|
1532
1550
|
*/
|
|
1533
1551
|
export var useMemoizedBlockServiceFetchOnlyAPIProvider = function useMemoizedBlockServiceFetchOnlyAPIProvider(_ref10) {
|
|
1534
1552
|
var cloudId = _ref10.cloudId,
|
|
1535
|
-
parentAri = _ref10.parentAri
|
|
1553
|
+
parentAri = _ref10.parentAri,
|
|
1554
|
+
parentId = _ref10.parentId,
|
|
1555
|
+
product = _ref10.product;
|
|
1536
1556
|
return useMemo(function () {
|
|
1537
1557
|
return createBlockServiceFetchOnlyAPIProvider({
|
|
1538
1558
|
cloudId: cloudId,
|
|
1539
|
-
parentAri: parentAri
|
|
1559
|
+
parentAri: parentAri,
|
|
1560
|
+
parentId: parentId,
|
|
1561
|
+
product: product
|
|
1540
1562
|
});
|
|
1541
|
-
}, [cloudId, parentAri]);
|
|
1563
|
+
}, [cloudId, parentAri, parentId, product]);
|
|
1542
1564
|
};
|
|
@@ -12,6 +12,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
12
12
|
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
13
13
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
14
14
|
import { useMemo, useRef } from 'react';
|
|
15
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
15
16
|
import { getProductFromSourceAri } from '../clients/block-service/ari';
|
|
16
17
|
import { getPageIdAndTypeFromConfluencePageAri } from '../clients/confluence/ari';
|
|
17
18
|
import { fetchConfluencePageInfo } from '../clients/confluence/sourceInfo';
|
|
@@ -381,6 +382,12 @@ export var SyncedBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
|
|
|
381
382
|
}
|
|
382
383
|
return fetchSyncBlockSourceInfo;
|
|
383
384
|
}())
|
|
385
|
+
}, {
|
|
386
|
+
key: "getParentAri",
|
|
387
|
+
value: function getParentAri() {
|
|
388
|
+
var _this$writeProvider5;
|
|
389
|
+
return (_this$writeProvider5 = this.writeProvider) === null || _this$writeProvider5 === void 0 ? void 0 : _this$writeProvider5.parentAri;
|
|
390
|
+
}
|
|
384
391
|
}, {
|
|
385
392
|
key: "generateResourceId",
|
|
386
393
|
value: function generateResourceId() {
|
|
@@ -391,14 +398,13 @@ export var SyncedBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
|
|
|
391
398
|
resourceId: resourceId
|
|
392
399
|
};
|
|
393
400
|
}
|
|
394
|
-
}, {
|
|
395
|
-
key: "canGenerateResourceIdForReference",
|
|
396
|
-
value: function canGenerateResourceIdForReference() {
|
|
397
|
-
return this.writeProvider !== undefined;
|
|
398
|
-
}
|
|
399
401
|
}, {
|
|
400
402
|
key: "generateResourceIdForReference",
|
|
401
403
|
value: function generateResourceIdForReference(sourceId) {
|
|
404
|
+
if (isExperimentEnabled('platform_editor_blocks_patch_12')) {
|
|
405
|
+
var _this$fetchProvider$g, _this$fetchProvider$g2, _this$fetchProvider;
|
|
406
|
+
return (_this$fetchProvider$g = (_this$fetchProvider$g2 = (_this$fetchProvider = this.fetchProvider).generateResourceIdForReference) === null || _this$fetchProvider$g2 === void 0 ? void 0 : _this$fetchProvider$g2.call(_this$fetchProvider, sourceId)) !== null && _this$fetchProvider$g !== void 0 ? _this$fetchProvider$g : sourceId;
|
|
407
|
+
}
|
|
402
408
|
if (!this.writeProvider) {
|
|
403
409
|
throw new Error('Write provider not set');
|
|
404
410
|
}
|
|
@@ -16,6 +16,7 @@ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-e
|
|
|
16
16
|
import { isProviderNotReadyError, ProviderNotReadyError, SyncBlockError } from '../common/types';
|
|
17
17
|
import { buildErrorAttribution, buildFetchErrorAttribution, cacheDeletionForcedPayload, fetchErrorPayload, fetchSuccessPayload, getSourceInfoErrorPayload, sourceInfoOrphanedPayload, updateReferenceErrorPayload } from '../utils/errorHandling';
|
|
18
18
|
import { getFetchExperience, getFetchSourceInfoExperience, getSaveReferenceExperience } from '../utils/experienceTracking';
|
|
19
|
+
import { getSourceLocation } from '../utils/fieldAwareLocations';
|
|
19
20
|
import { resolveSyncBlockInstance } from '../utils/resolveSyncBlockInstance';
|
|
20
21
|
import { parseResourceId } from '../utils/resourceId';
|
|
21
22
|
import { createSyncBlockNode, getSourceProductFromResourceIdSafe, normalizeSyncBlockJSONContent } from '../utils/utils';
|
|
@@ -265,9 +266,8 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
265
266
|
}, {
|
|
266
267
|
key: "getSameDocumentReferenceParts",
|
|
267
268
|
value: function getSameDocumentReferenceParts(resourceId) {
|
|
268
|
-
var _this$dataProvider$ca, _this$dataProvider3;
|
|
269
269
|
var parsed = parseResourceId(resourceId);
|
|
270
|
-
if (!parsed || !this.dataProvider ||
|
|
270
|
+
if (!parsed || !this.dataProvider || this.dataProvider.generateResourceIdForReference(parsed.uuid) !== resourceId) {
|
|
271
271
|
return undefined;
|
|
272
272
|
}
|
|
273
273
|
return parsed;
|
|
@@ -433,15 +433,26 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
433
433
|
(_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(this, getSourceInfoErrorPayload('SourceAri, product or blockInstanceId missing', resourceId, sourceProduct));
|
|
434
434
|
return Promise.resolve(undefined);
|
|
435
435
|
}
|
|
436
|
+
var sourceLocation = getSourceLocation(sourceAri);
|
|
437
|
+
// Undefined with `platform_editor_blocks_patch_13` off, so experience calls below keep
|
|
438
|
+
// exactly their previous arguments (no `metadata` key, `success()` without arguments).
|
|
439
|
+
var experienceMetadata = sourceLocation && {
|
|
440
|
+
sourceLocation: sourceLocation
|
|
441
|
+
};
|
|
442
|
+
var withExperienceMetadata = function withExperienceMetadata(options) {
|
|
443
|
+
return experienceMetadata ? _objectSpread(_objectSpread({}, options), {}, {
|
|
444
|
+
metadata: experienceMetadata
|
|
445
|
+
}) : options;
|
|
446
|
+
};
|
|
436
447
|
(_this$fetchSourceInfo = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo === void 0 || _this$fetchSourceInfo.start({});
|
|
437
448
|
var sourceInfoPromise = this.dataProvider.fetchSyncBlockSourceInfo(blockInstanceId, sourceAri, product, true // hasAccess
|
|
438
449
|
).then(function (sourceInfo) {
|
|
439
450
|
if (!sourceInfo) {
|
|
440
451
|
var _this2$fetchSourceInf, _this2$fireAnalyticsE;
|
|
441
|
-
(_this2$fetchSourceInf = _this2.fetchSourceInfoExperience) === null || _this2$fetchSourceInf === void 0 || _this2$fetchSourceInf.failure({
|
|
452
|
+
(_this2$fetchSourceInf = _this2.fetchSourceInfoExperience) === null || _this2$fetchSourceInf === void 0 || _this2$fetchSourceInf.failure(withExperienceMetadata({
|
|
442
453
|
reason: 'No source info returned'
|
|
443
|
-
});
|
|
444
|
-
(_this2$fireAnalyticsE = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE === void 0 || _this2$fireAnalyticsE.call(_this2, getSourceInfoErrorPayload('No source info returned', resourceId, sourceProduct));
|
|
454
|
+
}));
|
|
455
|
+
(_this2$fireAnalyticsE = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE === void 0 || _this2$fireAnalyticsE.call(_this2, getSourceInfoErrorPayload('No source info returned', resourceId, sourceProduct, sourceLocation));
|
|
445
456
|
return undefined;
|
|
446
457
|
}
|
|
447
458
|
_this2.updateCacheWithSourceInfo(resourceId, sourceInfo);
|
|
@@ -449,22 +460,29 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
449
460
|
_this2._subscriptionManager.updateSourceTitleSubscriptions(resourceId, sourceInfo.title);
|
|
450
461
|
}
|
|
451
462
|
if (sourceInfo.title && sourceInfo.url) {
|
|
452
|
-
|
|
453
|
-
|
|
463
|
+
if (experienceMetadata) {
|
|
464
|
+
var _this2$fetchSourceInf2;
|
|
465
|
+
(_this2$fetchSourceInf2 = _this2.fetchSourceInfoExperience) === null || _this2$fetchSourceInf2 === void 0 || _this2$fetchSourceInf2.success({
|
|
466
|
+
metadata: experienceMetadata
|
|
467
|
+
});
|
|
468
|
+
} else {
|
|
469
|
+
var _this2$fetchSourceInf3;
|
|
470
|
+
(_this2$fetchSourceInf3 = _this2.fetchSourceInfoExperience) === null || _this2$fetchSourceInf3 === void 0 || _this2$fetchSourceInf3.success();
|
|
471
|
+
}
|
|
454
472
|
} else {
|
|
455
|
-
var _this2$
|
|
456
|
-
(_this2$
|
|
473
|
+
var _this2$fetchSourceInf4, _this2$fireAnalyticsE2;
|
|
474
|
+
(_this2$fetchSourceInf4 = _this2.fetchSourceInfoExperience) === null || _this2$fetchSourceInf4 === void 0 || _this2$fetchSourceInf4.failure(withExperienceMetadata({
|
|
457
475
|
reason: 'Missing title or url'
|
|
458
|
-
});
|
|
459
|
-
(_this2$fireAnalyticsE2 = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE2 === void 0 || _this2$fireAnalyticsE2.call(_this2, getSourceInfoErrorPayload('Missing title or url', resourceId, sourceProduct));
|
|
476
|
+
}));
|
|
477
|
+
(_this2$fireAnalyticsE2 = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE2 === void 0 || _this2$fireAnalyticsE2.call(_this2, getSourceInfoErrorPayload('Missing title or url', resourceId, sourceProduct, sourceLocation));
|
|
460
478
|
}
|
|
461
479
|
return sourceInfo;
|
|
462
480
|
}).catch(function (error) {
|
|
463
|
-
var _this2$
|
|
464
|
-
(_this2$
|
|
481
|
+
var _this2$fetchSourceInf5, _this2$fireAnalyticsE3;
|
|
482
|
+
(_this2$fetchSourceInf5 = _this2.fetchSourceInfoExperience) === null || _this2$fetchSourceInf5 === void 0 || _this2$fetchSourceInf5.failure(withExperienceMetadata({
|
|
465
483
|
reason: error.message
|
|
466
|
-
});
|
|
467
|
-
(_this2$fireAnalyticsE3 = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE3 === void 0 || _this2$fireAnalyticsE3.call(_this2, getSourceInfoErrorPayload(error.message, resourceId, sourceProduct));
|
|
484
|
+
}));
|
|
485
|
+
(_this2$fireAnalyticsE3 = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE3 === void 0 || _this2$fireAnalyticsE3.call(_this2, getSourceInfoErrorPayload(error.message, resourceId, sourceProduct, sourceLocation));
|
|
468
486
|
return undefined;
|
|
469
487
|
}).finally(function () {
|
|
470
488
|
_this2.syncBlockSourceInfoRequests.delete(resourceId);
|
|
@@ -761,8 +779,8 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
761
779
|
var sanitizedSyncBlock = this.normalizeReferenceData(syncBlock);
|
|
762
780
|
var resourceId = sanitizedSyncBlock.resourceId;
|
|
763
781
|
if (resourceId) {
|
|
764
|
-
var _this$
|
|
765
|
-
(_this$
|
|
782
|
+
var _this$dataProvider3;
|
|
783
|
+
(_this$dataProvider3 = this.dataProvider) === null || _this$dataProvider3 === void 0 || _this$dataProvider3.updateCache(_defineProperty({}, resourceId, sanitizedSyncBlock), {
|
|
766
784
|
strategy: 'merge',
|
|
767
785
|
source: 'network'
|
|
768
786
|
});
|
|
@@ -773,15 +791,15 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
773
791
|
}, {
|
|
774
792
|
key: "getFromCache",
|
|
775
793
|
value: function getFromCache(resourceId) {
|
|
776
|
-
var _this$
|
|
794
|
+
var _this$dataProvider4;
|
|
777
795
|
var syncBlockNode = createSyncBlockNode('', resourceId);
|
|
778
|
-
return (_this$
|
|
796
|
+
return (_this$dataProvider4 = this.dataProvider) === null || _this$dataProvider4 === void 0 || (_this$dataProvider4 = _this$dataProvider4.getNodeDataFromCache(syncBlockNode)) === null || _this$dataProvider4 === void 0 ? void 0 : _this$dataProvider4.data;
|
|
779
797
|
}
|
|
780
798
|
}, {
|
|
781
799
|
key: "deleteFromCache",
|
|
782
800
|
value: function deleteFromCache(resourceId) {
|
|
783
|
-
var _this$
|
|
784
|
-
(_this$
|
|
801
|
+
var _this$dataProvider5;
|
|
802
|
+
(_this$dataProvider5 = this.dataProvider) === null || _this$dataProvider5 === void 0 || _this$dataProvider5.removeFromCache([resourceId]);
|
|
785
803
|
this._providerFactoryManager.deleteFactory(resourceId);
|
|
786
804
|
// Evict in-flight source-info promise and reset reschedule counter
|
|
787
805
|
// so a stale resolution can't silently merge into a re-fetched entry.
|
|
@@ -1265,7 +1283,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
1265
1283
|
}, {
|
|
1266
1284
|
key: "destroy",
|
|
1267
1285
|
value: function destroy() {
|
|
1268
|
-
var _this$
|
|
1286
|
+
var _this$dataProvider6, _this$saveExperience5, _this$fetchExperience0, _this$fetchSourceInfo2;
|
|
1269
1287
|
// Mark destroyed first so in-flight timer callbacks can early-return.
|
|
1270
1288
|
this.isDestroyed = true;
|
|
1271
1289
|
|
|
@@ -1291,7 +1309,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
1291
1309
|
this._subscriptionManager.destroy();
|
|
1292
1310
|
this._providerFactoryManager.destroy();
|
|
1293
1311
|
this._batchFetcher.destroy();
|
|
1294
|
-
(_this$
|
|
1312
|
+
(_this$dataProvider6 = this.dataProvider) === null || _this$dataProvider6 === void 0 || _this$dataProvider6.resetCache();
|
|
1295
1313
|
this.dataProvider = undefined;
|
|
1296
1314
|
this.syncBlockFetchDataRequests.clear();
|
|
1297
1315
|
this.syncBlockSourceInfoRequests.clear();
|