@atlaskit/editor-synced-block-provider 6.6.2 → 6.6.4

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/clients/jira/sourceInfo.js +18 -40
  3. package/dist/cjs/entry-points/utils.js +0 -6
  4. package/dist/cjs/hooks/useFetchSyncBlockData.js +1 -1
  5. package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +4 -7
  6. package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +120 -39
  7. package/dist/cjs/store-manager/syncBlockBatchFetcher.js +1 -1
  8. package/dist/cjs/store-manager/syncBlockProviderFactoryManager.js +3 -3
  9. package/dist/cjs/store-manager/syncBlockStoreManager.js +1 -1
  10. package/dist/cjs/store-manager/syncBlockSubscriptionManager.js +3 -6
  11. package/dist/cjs/utils/utils.js +1 -13
  12. package/dist/es2019/clients/jira/sourceInfo.js +27 -48
  13. package/dist/es2019/entry-points/utils.js +1 -1
  14. package/dist/es2019/hooks/useFetchSyncBlockData.js +2 -2
  15. package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +5 -8
  16. package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +95 -16
  17. package/dist/es2019/store-manager/syncBlockBatchFetcher.js +2 -2
  18. package/dist/es2019/store-manager/syncBlockProviderFactoryManager.js +4 -4
  19. package/dist/es2019/store-manager/syncBlockStoreManager.js +2 -2
  20. package/dist/es2019/store-manager/syncBlockSubscriptionManager.js +4 -7
  21. package/dist/es2019/utils/utils.js +0 -10
  22. package/dist/esm/clients/jira/sourceInfo.js +19 -40
  23. package/dist/esm/entry-points/utils.js +1 -1
  24. package/dist/esm/hooks/useFetchSyncBlockData.js +2 -2
  25. package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +5 -8
  26. package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +122 -41
  27. package/dist/esm/store-manager/syncBlockBatchFetcher.js +2 -2
  28. package/dist/esm/store-manager/syncBlockProviderFactoryManager.js +4 -4
  29. package/dist/esm/store-manager/syncBlockStoreManager.js +2 -2
  30. package/dist/esm/store-manager/syncBlockSubscriptionManager.js +4 -7
  31. package/dist/esm/utils/utils.js +0 -12
  32. package/dist/types/entry-points/utils.d.ts +1 -1
  33. package/dist/types/store-manager/sourceSyncBlockStoreManager.d.ts +24 -0
  34. package/dist/types/utils/utils.d.ts +0 -1
  35. package/dist/types-ts4.5/entry-points/utils.d.ts +1 -1
  36. package/dist/types-ts4.5/store-manager/sourceSyncBlockStoreManager.d.ts +24 -0
  37. package/dist/types-ts4.5/utils/utils.d.ts +0 -1
  38. package/package.json +4 -4
@@ -9,7 +9,6 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
9
9
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
  var _monitoring = require("@atlaskit/editor-common/monitoring");
12
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
12
  var _errorHandling = require("../utils/errorHandling");
14
13
  var _resolveSyncBlockInstance = require("../utils/resolveSyncBlockInstance");
15
14
  var _utils = require("../utils/utils");
@@ -258,7 +257,7 @@ var SyncBlockSubscriptionManager = exports.SyncBlockSubscriptionManager = /*#__P
258
257
  (0, _monitoring.logException)(error, {
259
258
  location: 'editor-synced-block-provider/syncBlockSubscriptionManager/graphql-subscription'
260
259
  });
261
- (_this5$deps$getFireAn = _this5.deps.getFireAnalyticsEvent()) === null || _this5$deps$getFireAn === void 0 || _this5$deps$getFireAn((0, _errorHandling.fetchErrorPayload)(error.message, resourceId, (0, _utils.productAttrIfGateOn)(resourceId)));
260
+ (_this5$deps$getFireAn = _this5.deps.getFireAnalyticsEvent()) === null || _this5$deps$getFireAn === void 0 || _this5$deps$getFireAn((0, _errorHandling.fetchErrorPayload)(error.message, resourceId, (0, _utils.getSourceProductFromResourceIdSafe)(resourceId)));
262
261
  });
263
262
  if (unsubscribe) {
264
263
  this.graphqlSubscriptions.set(resourceId, unsubscribe);
@@ -350,15 +349,13 @@ var SyncBlockSubscriptionManager = exports.SyncBlockSubscriptionManager = /*#__P
350
349
  var localIds = callbacks ? Object.keys(callbacks) : [];
351
350
  localIds.forEach(function (localId) {
352
351
  var _this6$deps$getFireAn, _syncBlockInstance$da, _syncBlockInstance$da2;
353
- (_this6$deps$getFireAn = _this6.deps.getFireAnalyticsEvent()) === null || _this6$deps$getFireAn === void 0 || _this6$deps$getFireAn((0, _errorHandling.fetchSuccessPayload)(syncBlockInstance.resourceId, localId,
354
- // Prefer cached product when available; fall back to parsing the resourceId.
355
- (0, _platformFeatureFlags.fg)('platform_synced_block_patch_11') ? (_syncBlockInstance$da = (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.product) !== null && _syncBlockInstance$da !== void 0 ? _syncBlockInstance$da : (0, _utils.getSourceProductFromResourceIdSafe)(syncBlockInstance.resourceId) : undefined));
352
+ (_this6$deps$getFireAn = _this6.deps.getFireAnalyticsEvent()) === null || _this6$deps$getFireAn === void 0 || _this6$deps$getFireAn((0, _errorHandling.fetchSuccessPayload)(syncBlockInstance.resourceId, localId, (_syncBlockInstance$da = (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.product) !== null && _syncBlockInstance$da !== void 0 ? _syncBlockInstance$da : (0, _utils.getSourceProductFromResourceIdSafe)(syncBlockInstance.resourceId)));
356
353
  });
357
354
  this.deps.fetchSyncBlockSourceInfo(resolved.resourceId);
358
355
  } else {
359
356
  var _syncBlockInstance$er, _syncBlockInstance$er2, _this$deps$getFireAna, _syncBlockInstance$da3, _syncBlockInstance$da4;
360
357
  var errorMessage = ((_syncBlockInstance$er = syncBlockInstance.error) === null || _syncBlockInstance$er === void 0 ? void 0 : _syncBlockInstance$er.reason) || ((_syncBlockInstance$er2 = syncBlockInstance.error) === null || _syncBlockInstance$er2 === void 0 ? void 0 : _syncBlockInstance$er2.type);
361
- (_this$deps$getFireAna = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna === void 0 || _this$deps$getFireAna((0, _errorHandling.fetchErrorPayload)(errorMessage, syncBlockInstance.resourceId, (0, _platformFeatureFlags.fg)('platform_synced_block_patch_11') ? (_syncBlockInstance$da3 = (_syncBlockInstance$da4 = syncBlockInstance.data) === null || _syncBlockInstance$da4 === void 0 ? void 0 : _syncBlockInstance$da4.product) !== null && _syncBlockInstance$da3 !== void 0 ? _syncBlockInstance$da3 : (0, _utils.getSourceProductFromResourceIdSafe)(syncBlockInstance.resourceId) : undefined));
358
+ (_this$deps$getFireAna = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna === void 0 || _this$deps$getFireAna((0, _errorHandling.fetchErrorPayload)(errorMessage, syncBlockInstance.resourceId, (_syncBlockInstance$da3 = (_syncBlockInstance$da4 = syncBlockInstance.data) === null || _syncBlockInstance$da4 === void 0 ? void 0 : _syncBlockInstance$da4.product) !== null && _syncBlockInstance$da3 !== void 0 ? _syncBlockInstance$da3 : (0, _utils.getSourceProductFromResourceIdSafe)(syncBlockInstance.resourceId)));
362
359
  }
363
360
  }
364
361
  }]);
@@ -3,8 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.productAttrIfGateOn = exports.getSourceProductFromResourceIdSafe = exports.getContentIdAndProductFromResourceId = exports.createSyncBlockNode = exports.convertSyncBlockPMNodeToSyncBlockData = exports.convertSyncBlockJSONNodeToSyncBlockNode = exports.convertPMNodesToSyncBlockNodes = exports.convertPMNodeToSyncBlockNode = exports.convertContentUpdatedAt = void 0;
7
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
6
+ exports.getSourceProductFromResourceIdSafe = exports.getContentIdAndProductFromResourceId = exports.createSyncBlockNode = exports.convertSyncBlockPMNodeToSyncBlockData = exports.convertSyncBlockJSONNodeToSyncBlockNode = exports.convertPMNodesToSyncBlockNodes = exports.convertPMNodeToSyncBlockNode = exports.convertContentUpdatedAt = void 0;
8
7
  /* eslint-disable require-unicode-regexp */
9
8
 
10
9
  var convertSyncBlockPMNodeToSyncBlockData = exports.convertSyncBlockPMNodeToSyncBlockData = function convertSyncBlockPMNodeToSyncBlockData(node) {
@@ -75,17 +74,6 @@ var getSourceProductFromResourceIdSafe = exports.getSourceProductFromResourceIdS
75
74
  return undefined;
76
75
  }
77
76
  };
78
-
79
- /*
80
- * Convenience wrapper around `getSourceProductFromResourceIdSafe` that returns
81
- * `undefined` whenever the `platform_synced_block_patch_11` rollout flag is off.
82
- * Centralised so that the flag name lives in exactly one place — when the flag is
83
- * cleaned up, this function should be deleted in its entirety and call-sites should
84
- * fall back to calling `getSourceProductFromResourceIdSafe` directly.
85
- */
86
- var productAttrIfGateOn = exports.productAttrIfGateOn = function productAttrIfGateOn(resourceId) {
87
- return (0, _platformFeatureFlags.fg)('platform_synced_block_patch_11') ? getSourceProductFromResourceIdSafe(resourceId) : undefined;
88
- };
89
77
  var convertContentUpdatedAt = exports.convertContentUpdatedAt = function convertContentUpdatedAt(contentUpdatedAt) {
90
78
  if (typeof contentUpdatedAt === 'number') {
91
79
  try {
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable require-unicode-regexp */
2
- import { fg } from '@atlaskit/platform-feature-flags';
2
+
3
3
  import { fetchWithRetry } from '../../utils/retry';
4
4
  const COMMON_HEADERS = {
5
5
  'Content-Type': 'application/json',
@@ -15,23 +15,21 @@ const GET_SOURCE_INFO_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_GET_SOURCE_INFO';
15
15
  * @param id - the ID of the work item
16
16
  * @returns url of the work item
17
17
  */
18
- // `issueType` is requested unconditionally because GraphQL field selection cannot be
19
- // gated at the network layer without a separate operation; AGG ignores unknown
20
- // front-end gating. The runtime mapping into `SyncBlockSourceInfo.issueType` is gated
21
- // by `platform_synced_block_patch_11` below.
18
+ // `issueType` is requested alongside `summary` and `webUrl` so the
19
+ // SyncedLocationDropdown can render the correct ADS issue-type icon.
22
20
  const GET_SOURCE_INFO_QUERY = `query ${GET_SOURCE_INFO_OPERATION_NAME} ($id: ID!) {
23
21
  jira {
24
- issueById(id: $id) {
25
- id
26
- webUrl
27
- summary
28
- issueType {
29
- name
30
- avatar {
31
- xsmall
32
- }
33
- }
34
- }
22
+ issueById(id: $id) {
23
+ id
24
+ webUrl
25
+ summary
26
+ issueType {
27
+ name
28
+ avatar {
29
+ xsmall
30
+ }
31
+ }
32
+ }
35
33
  }}`;
36
34
  const getJiraWorkItemSourceInfo = async ari => {
37
35
  const bodyData = {
@@ -102,44 +100,25 @@ const resolveNoAccessWorkItemInfo = async ari => {
102
100
  */
103
101
  export const fetchJiraWorkItemInfo = async (workItemAri, hasAccess) => {
104
102
  if (hasAccess) {
105
- var _response$data, _response$data$jira, _contentData$webUrl, _contentData$summary;
103
+ var _response$data, _response$data$jira, _contentData$issueTyp, _contentData$issueTyp2, _contentData$issueTyp3;
106
104
  const response = await getJiraWorkItemSourceInfo(workItemAri);
107
105
  const contentData = (_response$data = response.data) === null || _response$data === void 0 ? void 0 : (_response$data$jira = _response$data.jira) === null || _response$data$jira === void 0 ? void 0 : _response$data$jira.issueById;
106
+ const webUrl = typeof (contentData === null || contentData === void 0 ? void 0 : contentData.webUrl) === 'string' ? contentData.webUrl : undefined;
107
+ const summary = typeof (contentData === null || contentData === void 0 ? void 0 : contentData.summary) === 'string' ? contentData.summary : undefined;
108
108
 
109
- // Defensive narrowing (gated by `platform_synced_block_patch_11`):
110
- // AGG may return `null` (not just omit the field) for `webUrl` / `summary` on
111
- // partially indexed issues. Without these guards, downstream consumers that
112
- // expect `string | undefined` would receive `null` and either crash or render
113
- // the literal string "null". The pre-gate path preserves the legacy behaviour
114
- // so this can be dialled off independently.
115
- if (fg('platform_synced_block_patch_11')) {
116
- var _rawIssueType$avatar;
117
- const webUrl = typeof (contentData === null || contentData === void 0 ? void 0 : contentData.webUrl) === 'string' ? contentData.webUrl : undefined;
118
- const summary = typeof (contentData === null || contentData === void 0 ? void 0 : contentData.summary) === 'string' ? contentData.summary : undefined;
119
-
120
- // Surface issue-type metadata so consumers can render the correct ADS issue-type
121
- // icon. Defensive narrowing mirrors the webUrl/summary treatment above: only
122
- // surfaced when `name` is a non-empty string; AGG values like `{ name: null }`
123
- // collapse back to `undefined`.
124
- const rawIssueType = contentData === null || contentData === void 0 ? void 0 : contentData.issueType;
125
- const issueTypeName = typeof (rawIssueType === null || rawIssueType === void 0 ? void 0 : rawIssueType.name) === 'string' && rawIssueType.name.length > 0 ? rawIssueType.name : undefined;
126
- const issueType = issueTypeName ? {
127
- name: issueTypeName,
128
- iconUrl: typeof (rawIssueType === null || rawIssueType === void 0 ? void 0 : (_rawIssueType$avatar = rawIssueType.avatar) === null || _rawIssueType$avatar === void 0 ? void 0 : _rawIssueType$avatar.xsmall) === 'string' ? rawIssueType.avatar.xsmall : undefined
129
- } : undefined;
130
- return Promise.resolve({
131
- url: webUrl,
132
- sourceAri: workItemAri,
133
- title: summary,
134
- issueType
135
- });
136
- }
137
- const webUrl = (_contentData$webUrl = contentData === null || contentData === void 0 ? void 0 : contentData.webUrl) !== null && _contentData$webUrl !== void 0 ? _contentData$webUrl : undefined;
138
- const summary = (_contentData$summary = contentData === null || contentData === void 0 ? void 0 : contentData.summary) !== null && _contentData$summary !== void 0 ? _contentData$summary : undefined;
109
+ // Surface issue-type metadata for the SyncedLocationDropdown's ADS icon.
110
+ // Defensive narrowing: only surface when `name` is a non-empty string;
111
+ // AGG values like `{ name: null }` collapse back to `undefined`.
112
+ const issueTypeName = contentData === null || contentData === void 0 ? void 0 : (_contentData$issueTyp = contentData.issueType) === null || _contentData$issueTyp === void 0 ? void 0 : _contentData$issueTyp.name;
113
+ const issueType = typeof issueTypeName === 'string' && issueTypeName.length > 0 ? {
114
+ name: issueTypeName,
115
+ iconUrl: typeof (contentData === null || contentData === void 0 ? void 0 : (_contentData$issueTyp2 = contentData.issueType) === null || _contentData$issueTyp2 === void 0 ? void 0 : (_contentData$issueTyp3 = _contentData$issueTyp2.avatar) === null || _contentData$issueTyp3 === void 0 ? void 0 : _contentData$issueTyp3.xsmall) === 'string' ? contentData.issueType.avatar.xsmall : undefined
116
+ } : undefined;
139
117
  return Promise.resolve({
140
118
  url: webUrl,
141
119
  sourceAri: workItemAri,
142
- title: summary
120
+ title: summary,
121
+ issueType
143
122
  });
144
123
  } else {
145
124
  return await resolveNoAccessWorkItemInfo(workItemAri);
@@ -1,2 +1,2 @@
1
1
  /* eslint-disable @atlaskit/editor/no-re-export */
2
- export { createSyncBlockNode, convertSyncBlockPMNodeToSyncBlockData, convertSyncBlockJSONNodeToSyncBlockNode, convertPMNodesToSyncBlockNodes, convertPMNodeToSyncBlockNode, convertContentUpdatedAt, getContentIdAndProductFromResourceId, getSourceProductFromResourceIdSafe, productAttrIfGateOn } from '../utils/utils';
2
+ export { createSyncBlockNode, convertSyncBlockPMNodeToSyncBlockData, convertSyncBlockJSONNodeToSyncBlockNode, convertPMNodesToSyncBlockNodes, convertPMNodeToSyncBlockNode, convertContentUpdatedAt, getContentIdAndProductFromResourceId, getSourceProductFromResourceIdSafe } from '../utils/utils';
@@ -3,7 +3,7 @@ import { isSSR } from '@atlaskit/editor-common/core-utils';
3
3
  import { logException } from '@atlaskit/editor-common/monitoring';
4
4
  import { SyncBlockError } from '../common/types';
5
5
  import { fetchErrorPayload } from '../utils/errorHandling';
6
- import { createSyncBlockNode, productAttrIfGateOn } from '../utils/utils';
6
+ import { createSyncBlockNode, getSourceProductFromResourceIdSafe } from '../utils/utils';
7
7
  export const useFetchSyncBlockData = (manager, resourceId, localId, fireAnalyticsEvent) => {
8
8
  // Initialize both states from a single cache lookup to avoid race conditions.
9
9
  // When a block is moved/remounted, the old component's cleanup may clear the cache
@@ -46,7 +46,7 @@ export const useFetchSyncBlockData = (manager, resourceId, localId, fireAnalytic
46
46
  logException(error, {
47
47
  location: 'editor-synced-block-provider/useFetchSyncBlockData'
48
48
  });
49
- fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 ? void 0 : fireAnalyticsEvent(fetchErrorPayload(error.message, resourceId, productAttrIfGateOn(resourceId)));
49
+ fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 ? void 0 : fireAnalyticsEvent(fetchErrorPayload(error.message, resourceId, getSourceProductFromResourceIdSafe(resourceId)));
50
50
 
51
51
  // Set error state if fetching fails
52
52
  setFetchState({
@@ -1,12 +1,11 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import isEqual from 'lodash/isEqual';
3
3
  import { logException } from '@atlaskit/editor-common/monitoring';
4
- import { fg } from '@atlaskit/platform-feature-flags';
5
4
  import { SyncBlockError } from '../common/types';
6
5
  import { fetchErrorPayload, fetchSuccessPayload, getSourceInfoErrorPayload, updateReferenceErrorPayload } from '../utils/errorHandling';
7
6
  import { getFetchExperience, getFetchSourceInfoExperience, getSaveReferenceExperience } from '../utils/experienceTracking';
8
7
  import { resolveSyncBlockInstance } from '../utils/resolveSyncBlockInstance';
9
- import { createSyncBlockNode, getSourceProductFromResourceIdSafe, productAttrIfGateOn } from '../utils/utils';
8
+ import { createSyncBlockNode, getSourceProductFromResourceIdSafe } from '../utils/utils';
10
9
  import { SyncBlockBatchFetcher } from './syncBlockBatchFetcher';
11
10
  import { syncBlockInMemorySessionCache } from './syncBlockInMemorySessionCache';
12
11
  import { SyncBlockProviderFactoryManager } from './syncBlockProviderFactoryManager';
@@ -237,7 +236,7 @@ export class ReferenceSyncBlockStoreManager {
237
236
  // Derive once per call so we don't re-parse on every analytics event below.
238
237
  // `product` from cached data is preferred when available; fall back to parsing
239
238
  // the resourceId.
240
- const sourceProduct = fg('platform_synced_block_patch_11') ? product !== null && product !== void 0 ? product : getSourceProductFromResourceIdSafe(resourceId) : undefined;
239
+ const sourceProduct = product !== null && product !== void 0 ? product : getSourceProductFromResourceIdSafe(resourceId);
241
240
  if (!sourceAri || !product || !blockInstanceId) {
242
241
  var _this$fireAnalyticsEv3;
243
242
  (_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 ? void 0 : _this$fireAnalyticsEv3.call(this, getSourceInfoErrorPayload('SourceAri, product or blockInstanceId missing', resourceId, sourceProduct));
@@ -286,7 +285,7 @@ export class ReferenceSyncBlockStoreManager {
286
285
  logException(error, {
287
286
  location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
288
287
  });
289
- (_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 ? void 0 : _this$fireAnalyticsEv7.call(this, getSourceInfoErrorPayload(error.message, resourceId, productAttrIfGateOn(resourceId)));
288
+ (_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 ? void 0 : _this$fireAnalyticsEv7.call(this, getSourceInfoErrorPayload(error.message, resourceId, getSourceProductFromResourceIdSafe(resourceId)));
290
289
  }
291
290
  return Promise.resolve(undefined);
292
291
  }
@@ -434,7 +433,7 @@ export class ReferenceSyncBlockStoreManager {
434
433
  }
435
434
  if (syncBlockInstance.error) {
436
435
  var _this$fireAnalyticsEv9, _syncBlockInstance$da, _syncBlockInstance$da2;
437
- (_this$fireAnalyticsEv9 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv9 === void 0 ? void 0 : _this$fireAnalyticsEv9.call(this, fetchErrorPayload(syncBlockInstance.error.reason || syncBlockInstance.error.type, syncBlockInstance.resourceId, fg('platform_synced_block_patch_11') ? (_syncBlockInstance$da = (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.product) !== null && _syncBlockInstance$da !== void 0 ? _syncBlockInstance$da : getSourceProductFromResourceIdSafe(syncBlockInstance.resourceId) : undefined));
436
+ (_this$fireAnalyticsEv9 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv9 === void 0 ? void 0 : _this$fireAnalyticsEv9.call(this, fetchErrorPayload(syncBlockInstance.error.reason || syncBlockInstance.error.type, syncBlockInstance.resourceId, (_syncBlockInstance$da = (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.product) !== null && _syncBlockInstance$da !== void 0 ? _syncBlockInstance$da : getSourceProductFromResourceIdSafe(syncBlockInstance.resourceId)));
438
437
  if (syncBlockInstance.error.type === SyncBlockError.NotFound || syncBlockInstance.error.type === SyncBlockError.Forbidden) {
439
438
  hasExpectedError = true;
440
439
  } else if (syncBlockInstance.error) {
@@ -446,9 +445,7 @@ export class ReferenceSyncBlockStoreManager {
446
445
  const localIds = callbacks ? Object.keys(callbacks) : [];
447
446
  localIds.forEach(localId => {
448
447
  var _this$fireAnalyticsEv0, _syncBlockInstance$da3, _syncBlockInstance$da4;
449
- (_this$fireAnalyticsEv0 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv0 === void 0 ? void 0 : _this$fireAnalyticsEv0.call(this, fetchSuccessPayload(syncBlockInstance.resourceId, localId,
450
- // Prefer cached product when available; fall back to parsing the resourceId.
451
- fg('platform_synced_block_patch_11') ? (_syncBlockInstance$da3 = (_syncBlockInstance$da4 = syncBlockInstance.data) === null || _syncBlockInstance$da4 === void 0 ? void 0 : _syncBlockInstance$da4.product) !== null && _syncBlockInstance$da3 !== void 0 ? _syncBlockInstance$da3 : getSourceProductFromResourceIdSafe(syncBlockInstance.resourceId) : undefined));
448
+ (_this$fireAnalyticsEv0 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv0 === void 0 ? void 0 : _this$fireAnalyticsEv0.call(this, fetchSuccessPayload(syncBlockInstance.resourceId, localId, (_syncBlockInstance$da3 = (_syncBlockInstance$da4 = syncBlockInstance.data) === null || _syncBlockInstance$da4 === void 0 ? void 0 : _syncBlockInstance$da4.product) !== null && _syncBlockInstance$da3 !== void 0 ? _syncBlockInstance$da3 : getSourceProductFromResourceIdSafe(syncBlockInstance.resourceId)));
452
449
  });
453
450
  this.fetchSyncBlockSourceInfo(resolvedSyncBlockInstance.resourceId);
454
451
  });
@@ -1,9 +1,13 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { logException } from '@atlaskit/editor-common/monitoring';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
  import { SyncBlockError } from '../common/types';
4
5
  import { updateErrorPayload, createErrorPayload, deleteErrorPayload, updateCacheErrorPayload, getSourceInfoErrorPayload, updateSuccessPayload, createSuccessPayload, deleteSuccessPayload, fetchReferencesErrorPayload } from '../utils/errorHandling';
5
6
  import { getCreateSourceExperience, getDeleteSourceExperience, getSaveSourceExperience, getFetchSourceInfoExperience } from '../utils/experienceTracking';
6
- import { convertSyncBlockPMNodeToSyncBlockData, productAttrIfGateOn } from '../utils/utils';
7
+ import { convertSyncBlockPMNodeToSyncBlockData, getSourceProductFromResourceIdSafe } from '../utils/utils';
8
+ /** Maximum time (ms) flush() will wait for in-flight block creations before proceeding. */
9
+ const FLUSH_CREATION_AWAIT_TIMEOUT_MS = 1000;
10
+
7
11
  // A store manager responsible for the lifecycle and state management of source sync blocks in an editor instance.
8
12
  // Designed to manage local in-memory state and synchronize with an external data provider.
9
13
  // Supports create, flush, and delete operations for source sync blocks.
@@ -12,6 +16,22 @@ import { convertSyncBlockPMNodeToSyncBlockData, productAttrIfGateOn } from '../u
12
16
  export class SourceSyncBlockStoreManager {
13
17
  constructor(dataProvider, viewMode, isLivePage) {
14
18
  _defineProperty(this, "hasReceivedContentChange", false);
19
+ /**
20
+ * Promises for in-flight block creations, keyed by resourceId.
21
+ * `flush()` awaits these so that blocks created from existing content are
22
+ * persisted even if no further edits trigger a subsequent flush.
23
+ * See EDITOR-7112.
24
+ */
25
+ _defineProperty(this, "pendingCreationPromises", new Map());
26
+ /**
27
+ * Set of resource IDs whose creation was still in-flight when a `flush()`
28
+ * timed out. Each completion (success or failure) is removed from this set;
29
+ * the first successful completion of any of these IDs triggers
30
+ * `postCreationFlushCallback` so the content is eventually persisted.
31
+ * Tracking IDs (not just a boolean) avoids dropping late completions when
32
+ * multiple blocks are created concurrently. See EDITOR-7112.
33
+ */
34
+ _defineProperty(this, "creationsTimedOutDuringFlush", new Set());
15
35
  _defineProperty(this, "setPendingDeletion", (Ids, value) => {
16
36
  if (this.viewMode === 'view') {
17
37
  return;
@@ -36,6 +56,16 @@ export class SourceSyncBlockStoreManager {
36
56
  registerFlushCompletionCallback(callback) {
37
57
  this.flushCompletionCallback = callback;
38
58
  }
59
+
60
+ /**
61
+ * Register a callback to be invoked when flush() timed out waiting for a
62
+ * pending block creation and that creation subsequently completes. The
63
+ * callback should trigger a deferred flush to persist the content that
64
+ * was skipped due to the timeout. See EDITOR-7112.
65
+ */
66
+ registerPostCreationFlushCallback(callback) {
67
+ this.postCreationFlushCallback = callback;
68
+ }
39
69
  setFireAnalyticsEvent(fireAnalyticsEvent) {
40
70
  this.fireAnalyticsEvent = fireAnalyticsEvent;
41
71
  this.createExperience = getCreateSourceExperience(fireAnalyticsEvent);
@@ -94,7 +124,7 @@ export class SourceSyncBlockStoreManager {
94
124
  });
95
125
  // We can derive the product from `syncBlockNode.attrs.resourceId` even though
96
126
  // the variable wasn't destructured (the destructuring step itself may have thrown).
97
- (_this$fireAnalyticsEv = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv === void 0 ? void 0 : _this$fireAnalyticsEv.call(this, updateCacheErrorPayload(error.message, syncBlockNode === null || syncBlockNode === void 0 ? void 0 : (_syncBlockNode$attrs = syncBlockNode.attrs) === null || _syncBlockNode$attrs === void 0 ? void 0 : _syncBlockNode$attrs.resourceId, productAttrIfGateOn(syncBlockNode === null || syncBlockNode === void 0 ? void 0 : (_syncBlockNode$attrs2 = syncBlockNode.attrs) === null || _syncBlockNode$attrs2 === void 0 ? void 0 : _syncBlockNode$attrs2.resourceId)));
127
+ (_this$fireAnalyticsEv = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv === void 0 ? void 0 : _this$fireAnalyticsEv.call(this, updateCacheErrorPayload(error.message, syncBlockNode === null || syncBlockNode === void 0 ? void 0 : (_syncBlockNode$attrs = syncBlockNode.attrs) === null || _syncBlockNode$attrs === void 0 ? void 0 : _syncBlockNode$attrs.resourceId, getSourceProductFromResourceIdSafe(syncBlockNode === null || syncBlockNode === void 0 ? void 0 : (_syncBlockNode$attrs2 = syncBlockNode.attrs) === null || _syncBlockNode$attrs2 === void 0 ? void 0 : _syncBlockNode$attrs2.resourceId)));
98
128
  return false;
99
129
  }
100
130
  }
@@ -110,6 +140,39 @@ export class SourceSyncBlockStoreManager {
110
140
  if (this.viewMode === 'view') {
111
141
  return true;
112
142
  }
143
+
144
+ // Wait (up to FLUSH_CREATION_AWAIT_TIMEOUT_MS) for any in-flight
145
+ // block creations to complete before iterating the cache. Without
146
+ // this, blocks created from existing content are skipped
147
+ // (isPendingCreation check below) and if no further edits are made,
148
+ // no subsequent flush is triggered — causing references to show an
149
+ // "unpublished" error.
150
+ // If the timeout expires, any block whose creation is still
151
+ // in-flight is recorded in `creationsTimedOutDuringFlush` so that
152
+ // `commitPendingCreation()` can trigger a follow-up flush once that
153
+ // specific creation completes.
154
+ // See EDITOR-7112.
155
+ if (this.pendingCreationPromises.size > 0 && fg('platform_synced_block_patch_12')) {
156
+ let timedOut = false;
157
+ let timeoutId;
158
+ const timeout = new Promise(resolve => {
159
+ timeoutId = setTimeout(() => {
160
+ timedOut = true;
161
+ resolve();
162
+ }, FLUSH_CREATION_AWAIT_TIMEOUT_MS);
163
+ });
164
+ await Promise.race([Promise.all(this.pendingCreationPromises.values()), timeout]);
165
+ if (timeoutId !== undefined) {
166
+ clearTimeout(timeoutId);
167
+ }
168
+ if (timedOut) {
169
+ // Record every still-in-flight creation so each late
170
+ // completion is tracked independently.
171
+ for (const resourceId of this.pendingCreationPromises.keys()) {
172
+ this.creationsTimedOutDuringFlush.add(resourceId);
173
+ }
174
+ }
175
+ }
113
176
  const bodiedSyncBlockNodes = [];
114
177
  const bodiedSyncBlockData = [];
115
178
  Array.from(this.syncBlockCache.values()).forEach(syncBlockData => {
@@ -167,7 +230,7 @@ export class SourceSyncBlockStoreManager {
167
230
  if (cachedData && result.status) {
168
231
  cachedData.status = result.status;
169
232
  }
170
- (_this$fireAnalyticsEv2 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 ? void 0 : _this$fireAnalyticsEv2.call(this, updateSuccessPayload(result.resourceId, false, productAttrIfGateOn(result.resourceId)));
233
+ (_this$fireAnalyticsEv2 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 ? void 0 : _this$fireAnalyticsEv2.call(this, updateSuccessPayload(result.resourceId, false, getSourceProductFromResourceIdSafe(result.resourceId)));
171
234
  }
172
235
  });
173
236
  return true;
@@ -176,7 +239,7 @@ export class SourceSyncBlockStoreManager {
176
239
  (_this$saveExperience3 = this.saveExperience) === null || _this$saveExperience3 === void 0 ? void 0 : _this$saveExperience3.failure();
177
240
  writeResults.filter(result => !result.resourceId || result.error).forEach(result => {
178
241
  var _this$fireAnalyticsEv3;
179
- (_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 ? void 0 : _this$fireAnalyticsEv3.call(this, updateErrorPayload(result.error || 'Failed to write data', result.resourceId, productAttrIfGateOn(result.resourceId)));
242
+ (_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 ? void 0 : _this$fireAnalyticsEv3.call(this, updateErrorPayload(result.error || 'Failed to write data', result.resourceId, getSourceProductFromResourceIdSafe(result.resourceId)));
180
243
  });
181
244
  return false;
182
245
  }
@@ -232,23 +295,33 @@ export class SourceSyncBlockStoreManager {
232
295
  if (onCompletion) {
233
296
  this.creationCompletionCallbacks.delete(resourceId);
234
297
  onCompletion(success);
298
+ // If a previous flush() timed out waiting for this specific
299
+ // creation, drop it from the tracking set regardless of outcome so
300
+ // it does not leak. See EDITOR-7112.
301
+ const wasTimedOut = this.creationsTimedOutDuringFlush.delete(resourceId);
235
302
  if (success) {
236
303
  // If creation is successful, set hasReceivedContentChange to true
237
304
  // to indicate that there are unsaved changes in the cache
238
305
  this.hasReceivedContentChange = true;
306
+ // If flush() timed out waiting for this creation, notify the
307
+ // plugin so it can trigger a deferred flush. See EDITOR-7112.
308
+ if (wasTimedOut) {
309
+ var _this$postCreationFlu;
310
+ (_this$postCreationFlu = this.postCreationFlushCallback) === null || _this$postCreationFlu === void 0 ? void 0 : _this$postCreationFlu.call(this);
311
+ }
239
312
  }
240
313
  } else {
241
314
  var _this$fireAnalyticsEv5;
242
- (_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 ? void 0 : _this$fireAnalyticsEv5.call(this, createErrorPayload('creation complete callback missing', resourceId, productAttrIfGateOn(resourceId)));
315
+ (_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 ? void 0 : _this$fireAnalyticsEv5.call(this, createErrorPayload('creation complete callback missing', resourceId, getSourceProductFromResourceIdSafe(resourceId)));
243
316
  }
244
317
  if (success) {
245
318
  var _this$fireAnalyticsEv6;
246
- (_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 ? void 0 : _this$fireAnalyticsEv6.call(this, createSuccessPayload(resourceId || '', productAttrIfGateOn(resourceId)));
319
+ (_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 ? void 0 : _this$fireAnalyticsEv6.call(this, createSuccessPayload(resourceId || '', getSourceProductFromResourceIdSafe(resourceId)));
247
320
  } else {
248
321
  var _this$fireAnalyticsEv7;
249
322
  // Delete the node from cache if fail to create so it's not flushed to BE
250
323
  this.syncBlockCache.delete(resourceId || '');
251
- (_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 ? void 0 : _this$fireAnalyticsEv7.call(this, createErrorPayload('Fail to create bodied sync block', resourceId, productAttrIfGateOn(resourceId)));
324
+ (_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 ? void 0 : _this$fireAnalyticsEv7.call(this, createErrorPayload('Fail to create bodied sync block', resourceId, getSourceProductFromResourceIdSafe(resourceId)));
252
325
  }
253
326
  }
254
327
  registerConfirmationCallback(callback) {
@@ -308,7 +381,7 @@ export class SourceSyncBlockStoreManager {
308
381
  }
309
382
  this.creationCompletionCallbacks.set(resourceId, onCompletion);
310
383
  (_this$createExperienc = this.createExperience) === null || _this$createExperienc === void 0 ? void 0 : _this$createExperienc.start({});
311
- this.dataProvider.createNodeData({
384
+ const creationPromise = this.dataProvider.createNodeData({
312
385
  content: [],
313
386
  blockInstanceId,
314
387
  resourceId
@@ -324,7 +397,7 @@ export class SourceSyncBlockStoreManager {
324
397
  (_this$createExperienc3 = this.createExperience) === null || _this$createExperienc3 === void 0 ? void 0 : _this$createExperienc3.failure({
325
398
  reason: result.error || 'Failed to create bodied sync block'
326
399
  });
327
- (_this$fireAnalyticsEv8 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv8 === void 0 ? void 0 : _this$fireAnalyticsEv8.call(this, createErrorPayload(result.error || 'Failed to create bodied sync block', resourceId, productAttrIfGateOn(resourceId)));
400
+ (_this$fireAnalyticsEv8 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv8 === void 0 ? void 0 : _this$fireAnalyticsEv8.call(this, createErrorPayload(result.error || 'Failed to create bodied sync block', resourceId, getSourceProductFromResourceIdSafe(resourceId)));
328
401
  }
329
402
  }).catch(error => {
330
403
  var _this$createExperienc4, _this$fireAnalyticsEv9;
@@ -335,8 +408,11 @@ export class SourceSyncBlockStoreManager {
335
408
  (_this$createExperienc4 = this.createExperience) === null || _this$createExperienc4 === void 0 ? void 0 : _this$createExperienc4.failure({
336
409
  reason: error.message
337
410
  });
338
- (_this$fireAnalyticsEv9 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv9 === void 0 ? void 0 : _this$fireAnalyticsEv9.call(this, createErrorPayload(error.message, resourceId, productAttrIfGateOn(resourceId)));
411
+ (_this$fireAnalyticsEv9 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv9 === void 0 ? void 0 : _this$fireAnalyticsEv9.call(this, createErrorPayload(error.message, resourceId, getSourceProductFromResourceIdSafe(resourceId)));
412
+ }).finally(() => {
413
+ this.pendingCreationPromises.delete(resourceId);
339
414
  });
415
+ this.pendingCreationPromises.set(resourceId, creationPromise);
340
416
  } catch (error) {
341
417
  var _this$fireAnalyticsEv0;
342
418
  if (this.isPendingCreation(resourceId)) {
@@ -345,7 +421,7 @@ export class SourceSyncBlockStoreManager {
345
421
  logException(error, {
346
422
  location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
347
423
  });
348
- (_this$fireAnalyticsEv0 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv0 === void 0 ? void 0 : _this$fireAnalyticsEv0.call(this, createErrorPayload(error.message, resourceId, productAttrIfGateOn(resourceId)));
424
+ (_this$fireAnalyticsEv0 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv0 === void 0 ? void 0 : _this$fireAnalyticsEv0.call(this, createErrorPayload(error.message, resourceId, getSourceProductFromResourceIdSafe(resourceId)));
349
425
  }
350
426
  }
351
427
  async delete(syncBlockIds, onDelete, onDeleteCompleted, reason) {
@@ -373,7 +449,7 @@ export class SourceSyncBlockStoreManager {
373
449
  (_this$deleteExperienc2 = this.deleteExperience) === null || _this$deleteExperienc2 === void 0 ? void 0 : _this$deleteExperienc2.success();
374
450
  results.forEach(result => {
375
451
  var _this$fireAnalyticsEv1;
376
- (_this$fireAnalyticsEv1 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv1 === void 0 ? void 0 : _this$fireAnalyticsEv1.call(this, deleteSuccessPayload(result.resourceId, productAttrIfGateOn(result.resourceId)));
452
+ (_this$fireAnalyticsEv1 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv1 === void 0 ? void 0 : _this$fireAnalyticsEv1.call(this, deleteSuccessPayload(result.resourceId, getSourceProductFromResourceIdSafe(result.resourceId)));
377
453
  });
378
454
  } else {
379
455
  var _this$deleteExperienc3;
@@ -384,10 +460,10 @@ export class SourceSyncBlockStoreManager {
384
460
  results.forEach(result => {
385
461
  if (result.success) {
386
462
  var _this$fireAnalyticsEv10;
387
- (_this$fireAnalyticsEv10 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv10 === void 0 ? void 0 : _this$fireAnalyticsEv10.call(this, deleteSuccessPayload(result.resourceId, productAttrIfGateOn(result.resourceId)));
463
+ (_this$fireAnalyticsEv10 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv10 === void 0 ? void 0 : _this$fireAnalyticsEv10.call(this, deleteSuccessPayload(result.resourceId, getSourceProductFromResourceIdSafe(result.resourceId)));
388
464
  } else {
389
465
  var _this$fireAnalyticsEv11;
390
- (_this$fireAnalyticsEv11 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv11 === void 0 ? void 0 : _this$fireAnalyticsEv11.call(this, deleteErrorPayload(result.error || 'Failed to delete synced block', result.resourceId, productAttrIfGateOn(result.resourceId)));
466
+ (_this$fireAnalyticsEv11 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv11 === void 0 ? void 0 : _this$fireAnalyticsEv11.call(this, deleteErrorPayload(result.error || 'Failed to delete synced block', result.resourceId, getSourceProductFromResourceIdSafe(result.resourceId)));
391
467
  }
392
468
  });
393
469
  }
@@ -397,7 +473,7 @@ export class SourceSyncBlockStoreManager {
397
473
  syncBlockIds.forEach(Ids => {
398
474
  var _this$fireAnalyticsEv12;
399
475
  this.setPendingDeletion(Ids, false);
400
- (_this$fireAnalyticsEv12 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv12 === void 0 ? void 0 : _this$fireAnalyticsEv12.call(this, deleteErrorPayload(error.message, Ids.resourceId, productAttrIfGateOn(Ids.resourceId)));
476
+ (_this$fireAnalyticsEv12 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv12 === void 0 ? void 0 : _this$fireAnalyticsEv12.call(this, deleteErrorPayload(error.message, Ids.resourceId, getSourceProductFromResourceIdSafe(Ids.resourceId)));
401
477
  });
402
478
  logException(error, {
403
479
  location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
@@ -572,7 +648,7 @@ export class SourceSyncBlockStoreManager {
572
648
  logException(error, {
573
649
  location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
574
650
  });
575
- (_this$fireAnalyticsEv14 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv14 === void 0 ? void 0 : _this$fireAnalyticsEv14.call(this, fetchReferencesErrorPayload(error.message, resourceId, productAttrIfGateOn(resourceId)));
651
+ (_this$fireAnalyticsEv14 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv14 === void 0 ? void 0 : _this$fireAnalyticsEv14.call(this, fetchReferencesErrorPayload(error.message, resourceId, getSourceProductFromResourceIdSafe(resourceId)));
576
652
  return Promise.resolve({
577
653
  error: SyncBlockError.Errored
578
654
  });
@@ -584,6 +660,9 @@ export class SourceSyncBlockStoreManager {
584
660
  this.confirmationCallback = undefined;
585
661
  this.creationCompletionCallbacks.clear();
586
662
  this.flushCompletionCallback = undefined;
663
+ this.postCreationFlushCallback = undefined;
664
+ this.pendingCreationPromises.clear();
665
+ this.creationsTimedOutDuringFlush.clear();
587
666
  this.dataProvider = undefined;
588
667
  (_this$saveExperience4 = this.saveExperience) === null || _this$saveExperience4 === void 0 ? void 0 : _this$saveExperience4.abort({
589
668
  reason: 'editorDestroyed'
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import rafSchedule from 'raf-schd';
3
3
  import { logException } from '@atlaskit/editor-common/monitoring';
4
4
  import { fetchErrorPayload } from '../utils/errorHandling';
5
- import { createSyncBlockNode, productAttrIfGateOn } from '../utils/utils';
5
+ import { createSyncBlockNode, getSourceProductFromResourceIdSafe } from '../utils/utils';
6
6
  /**
7
7
  * Handles debounced batch-fetching of sync block data via `raf-schd`.
8
8
  * Accumulates resource IDs and flushes them in a single fetch per
@@ -29,7 +29,7 @@ export class SyncBlockBatchFetcher {
29
29
  });
30
30
  resourceIds.forEach(resId => {
31
31
  var _this$deps$getFireAna;
32
- (_this$deps$getFireAna = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna === void 0 ? void 0 : _this$deps$getFireAna(fetchErrorPayload(error.message, resId, productAttrIfGateOn(resId)));
32
+ (_this$deps$getFireAna = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna === void 0 ? void 0 : _this$deps$getFireAna(fetchErrorPayload(error.message, resId, getSourceProductFromResourceIdSafe(resId)));
33
33
  });
34
34
  });
35
35
  });
@@ -3,7 +3,7 @@ import { logException } from '@atlaskit/editor-common/monitoring';
3
3
  import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
4
4
  import { fetchErrorPayload } from '../utils/errorHandling';
5
5
  import { parseResourceId } from '../utils/resourceId';
6
- import { productAttrIfGateOn } from '../utils/utils';
6
+ import { getSourceProductFromResourceIdSafe } from '../utils/utils';
7
7
  /**
8
8
  * Manages creation and caching of ProviderFactory instances used to
9
9
  * render synced block content (media, emoji, smart links, etc.).
@@ -21,7 +21,7 @@ export class SyncBlockProviderFactoryManager {
21
21
  logException(error, {
22
22
  location: 'editor-synced-block-provider/syncBlockProviderFactoryManager'
23
23
  });
24
- (_this$deps$getFireAna = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna === void 0 ? void 0 : _this$deps$getFireAna(fetchErrorPayload(error.message, resourceId, productAttrIfGateOn(resourceId)));
24
+ (_this$deps$getFireAna = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna === void 0 ? void 0 : _this$deps$getFireAna(fetchErrorPayload(error.message, resourceId, getSourceProductFromResourceIdSafe(resourceId)));
25
25
  return undefined;
26
26
  }
27
27
  const {
@@ -55,7 +55,7 @@ export class SyncBlockProviderFactoryManager {
55
55
  logException(error, {
56
56
  location: 'editor-synced-block-provider/syncBlockProviderFactoryManager'
57
57
  });
58
- (_this$deps$getFireAna2 = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna2 === void 0 ? void 0 : _this$deps$getFireAna2(fetchErrorPayload(error.message, resourceId, productAttrIfGateOn(resourceId)));
58
+ (_this$deps$getFireAna2 = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna2 === void 0 ? void 0 : _this$deps$getFireAna2(fetchErrorPayload(error.message, resourceId, getSourceProductFromResourceIdSafe(resourceId)));
59
59
  }
60
60
  }
61
61
  return providerFactory;
@@ -133,7 +133,7 @@ export class SyncBlockProviderFactoryManager {
133
133
  if (!syncBlock.data.sourceAri || !syncBlock.data.product) {
134
134
  var _this$deps$getFireAna3, _syncBlock$data$produ;
135
135
  (_this$deps$getFireAna3 = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna3 === void 0 ? void 0 : _this$deps$getFireAna3(fetchErrorPayload('Sync block source ari or product not found', resourceId, // Prefer cached product when available; fall back to parsing resourceId.
136
- (_syncBlock$data$produ = syncBlock.data.product) !== null && _syncBlock$data$produ !== void 0 ? _syncBlock$data$produ : productAttrIfGateOn(resourceId)));
136
+ (_syncBlock$data$produ = syncBlock.data.product) !== null && _syncBlock$data$produ !== void 0 ? _syncBlock$data$produ : getSourceProductFromResourceIdSafe(resourceId)));
137
137
  return;
138
138
  }
139
139
  const parentInfo = dataProvider.retrieveSyncBlockParentInfo(syncBlock.data.sourceAri, syncBlock.data.product);
@@ -4,7 +4,7 @@ import { getProductFromSourceAri } from '../clients/block-service/ari';
4
4
  import { SyncBlockError } from '../common/types';
5
5
  import { fetchReferencesErrorPayload } from '../utils/errorHandling';
6
6
  import { getFetchReferencesExperience, getFetchSourceInfoExperience } from '../utils/experienceTracking';
7
- import { productAttrIfGateOn } from '../utils/utils';
7
+ import { getSourceProductFromResourceIdSafe } from '../utils/utils';
8
8
  import { ReferenceSyncBlockStoreManager } from './referenceSyncBlockStoreManager';
9
9
  import { SourceSyncBlockStoreManager } from './sourceSyncBlockStoreManager';
10
10
 
@@ -84,7 +84,7 @@ export class SyncBlockStoreManager {
84
84
  logException(error, {
85
85
  location: 'editor-synced-block-provider/syncBlockStoreManager'
86
86
  });
87
- (_this$fireAnalyticsEv = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv === void 0 ? void 0 : _this$fireAnalyticsEv.call(this, fetchReferencesErrorPayload(error.message, resourceId, productAttrIfGateOn(resourceId)));
87
+ (_this$fireAnalyticsEv = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv === void 0 ? void 0 : _this$fireAnalyticsEv.call(this, fetchReferencesErrorPayload(error.message, resourceId, getSourceProductFromResourceIdSafe(resourceId)));
88
88
  return {
89
89
  error: SyncBlockError.Errored
90
90
  };
@@ -1,9 +1,8 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { logException } from '@atlaskit/editor-common/monitoring';
3
- import { fg } from '@atlaskit/platform-feature-flags';
4
3
  import { fetchErrorPayload, fetchSuccessPayload } from '../utils/errorHandling';
5
4
  import { resolveSyncBlockInstance } from '../utils/resolveSyncBlockInstance';
6
- import { getSourceProductFromResourceIdSafe, productAttrIfGateOn } from '../utils/utils';
5
+ import { getSourceProductFromResourceIdSafe } from '../utils/utils';
7
6
  /**
8
7
  * Manages the lifecycle of GraphQL WebSocket subscriptions for sync block
9
8
  * real-time updates, owns the subscriptions and titleSubscriptions maps,
@@ -221,7 +220,7 @@ export class SyncBlockSubscriptionManager {
221
220
  logException(error, {
222
221
  location: 'editor-synced-block-provider/syncBlockSubscriptionManager/graphql-subscription'
223
222
  });
224
- (_this$deps$getFireAna2 = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna2 === void 0 ? void 0 : _this$deps$getFireAna2(fetchErrorPayload(error.message, resourceId, productAttrIfGateOn(resourceId)));
223
+ (_this$deps$getFireAna2 = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna2 === void 0 ? void 0 : _this$deps$getFireAna2(fetchErrorPayload(error.message, resourceId, getSourceProductFromResourceIdSafe(resourceId)));
225
224
  });
226
225
  if (unsubscribe) {
227
226
  this.graphqlSubscriptions.set(resourceId, unsubscribe);
@@ -273,15 +272,13 @@ export class SyncBlockSubscriptionManager {
273
272
  const localIds = callbacks ? Object.keys(callbacks) : [];
274
273
  localIds.forEach(localId => {
275
274
  var _this$deps$getFireAna3, _syncBlockInstance$da, _syncBlockInstance$da2;
276
- (_this$deps$getFireAna3 = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna3 === void 0 ? void 0 : _this$deps$getFireAna3(fetchSuccessPayload(syncBlockInstance.resourceId, localId,
277
- // Prefer cached product when available; fall back to parsing the resourceId.
278
- fg('platform_synced_block_patch_11') ? (_syncBlockInstance$da = (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.product) !== null && _syncBlockInstance$da !== void 0 ? _syncBlockInstance$da : getSourceProductFromResourceIdSafe(syncBlockInstance.resourceId) : undefined));
275
+ (_this$deps$getFireAna3 = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna3 === void 0 ? void 0 : _this$deps$getFireAna3(fetchSuccessPayload(syncBlockInstance.resourceId, localId, (_syncBlockInstance$da = (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.product) !== null && _syncBlockInstance$da !== void 0 ? _syncBlockInstance$da : getSourceProductFromResourceIdSafe(syncBlockInstance.resourceId)));
279
276
  });
280
277
  this.deps.fetchSyncBlockSourceInfo(resolved.resourceId);
281
278
  } else {
282
279
  var _syncBlockInstance$er, _syncBlockInstance$er2, _this$deps$getFireAna4, _syncBlockInstance$da3, _syncBlockInstance$da4;
283
280
  const errorMessage = ((_syncBlockInstance$er = syncBlockInstance.error) === null || _syncBlockInstance$er === void 0 ? void 0 : _syncBlockInstance$er.reason) || ((_syncBlockInstance$er2 = syncBlockInstance.error) === null || _syncBlockInstance$er2 === void 0 ? void 0 : _syncBlockInstance$er2.type);
284
- (_this$deps$getFireAna4 = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna4 === void 0 ? void 0 : _this$deps$getFireAna4(fetchErrorPayload(errorMessage, syncBlockInstance.resourceId, fg('platform_synced_block_patch_11') ? (_syncBlockInstance$da3 = (_syncBlockInstance$da4 = syncBlockInstance.data) === null || _syncBlockInstance$da4 === void 0 ? void 0 : _syncBlockInstance$da4.product) !== null && _syncBlockInstance$da3 !== void 0 ? _syncBlockInstance$da3 : getSourceProductFromResourceIdSafe(syncBlockInstance.resourceId) : undefined));
281
+ (_this$deps$getFireAna4 = this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna4 === void 0 ? void 0 : _this$deps$getFireAna4(fetchErrorPayload(errorMessage, syncBlockInstance.resourceId, (_syncBlockInstance$da3 = (_syncBlockInstance$da4 = syncBlockInstance.data) === null || _syncBlockInstance$da4 === void 0 ? void 0 : _syncBlockInstance$da4.product) !== null && _syncBlockInstance$da3 !== void 0 ? _syncBlockInstance$da3 : getSourceProductFromResourceIdSafe(syncBlockInstance.resourceId)));
285
282
  }
286
283
  }
287
284
  }