@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
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable require-unicode-regexp */
2
2
 
3
- import { fg } from '@atlaskit/platform-feature-flags';
4
3
  export const convertSyncBlockPMNodeToSyncBlockData = node => {
5
4
  return {
6
5
  blockInstanceId: node.attrs.localId,
@@ -65,15 +64,6 @@ export const getSourceProductFromResourceIdSafe = resourceId => {
65
64
  return undefined;
66
65
  }
67
66
  };
68
-
69
- /*
70
- * Convenience wrapper around `getSourceProductFromResourceIdSafe` that returns
71
- * `undefined` whenever the `platform_synced_block_patch_11` rollout flag is off.
72
- * Centralised so that the flag name lives in exactly one place — when the flag is
73
- * cleaned up, this function should be deleted in its entirety and call-sites should
74
- * fall back to calling `getSourceProductFromResourceIdSafe` directly.
75
- */
76
- export const productAttrIfGateOn = resourceId => fg('platform_synced_block_patch_11') ? getSourceProductFromResourceIdSafe(resourceId) : undefined;
77
67
  export const convertContentUpdatedAt = contentUpdatedAt => {
78
68
  if (typeof contentUpdatedAt === 'number') {
79
69
  try {
@@ -4,7 +4,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
4
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
5
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
6
  /* eslint-disable require-unicode-regexp */
7
- import { fg } from '@atlaskit/platform-feature-flags';
7
+
8
8
  import { fetchWithRetry } from '../../utils/retry';
9
9
  var COMMON_HEADERS = {
10
10
  'Content-Type': 'application/json',
@@ -20,11 +20,9 @@ var GET_SOURCE_INFO_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_GET_SOURCE_INFO';
20
20
  * @param id - the ID of the work item
21
21
  * @returns url of the work item
22
22
  */
23
- // `issueType` is requested unconditionally because GraphQL field selection cannot be
24
- // gated at the network layer without a separate operation; AGG ignores unknown
25
- // front-end gating. The runtime mapping into `SyncBlockSourceInfo.issueType` is gated
26
- // by `platform_synced_block_patch_11` below.
27
- var GET_SOURCE_INFO_QUERY = "query ".concat(GET_SOURCE_INFO_OPERATION_NAME, " ($id: ID!) {\n jira {\n issueById(id: $id) {\n id\n webUrl\n summary\n issueType {\n name\n avatar {\n xsmall\n }\n }\n }\n }}");
23
+ // `issueType` is requested alongside `summary` and `webUrl` so the
24
+ // SyncedLocationDropdown can render the correct ADS issue-type icon.
25
+ var GET_SOURCE_INFO_QUERY = "query ".concat(GET_SOURCE_INFO_OPERATION_NAME, " ($id: ID!) {\n jira {\n\tissueById(id: $id) {\n\tid\n\twebUrl\n\tsummary\n\tissueType {\n\t\tname\n\t\tavatar {\n\t\txsmall\n\t\t}\n\t}\n\t}\n }}");
28
26
  var getJiraWorkItemSourceInfo = /*#__PURE__*/function () {
29
27
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(ari) {
30
28
  var bodyData, response;
@@ -135,59 +133,40 @@ var resolveNoAccessWorkItemInfo = /*#__PURE__*/function () {
135
133
  */
136
134
  export var fetchJiraWorkItemInfo = /*#__PURE__*/function () {
137
135
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(workItemAri, hasAccess) {
138
- var _response$data, _contentData$webUrl, _contentData$summary, response, contentData, _rawIssueType$avatar, _webUrl, _summary, rawIssueType, issueTypeName, issueType, webUrl, summary;
136
+ var _response$data, _contentData$issueTyp, _contentData$issueTyp2, response, contentData, webUrl, summary, issueTypeName, issueType;
139
137
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
140
138
  while (1) switch (_context3.prev = _context3.next) {
141
139
  case 0:
142
140
  if (!hasAccess) {
143
- _context3.next = 17;
141
+ _context3.next = 12;
144
142
  break;
145
143
  }
146
144
  _context3.next = 3;
147
145
  return getJiraWorkItemSourceInfo(workItemAri);
148
146
  case 3:
149
147
  response = _context3.sent;
150
- contentData = (_response$data = response.data) === null || _response$data === void 0 || (_response$data = _response$data.jira) === null || _response$data === void 0 ? void 0 : _response$data.issueById; // Defensive narrowing (gated by `platform_synced_block_patch_11`):
151
- // AGG may return `null` (not just omit the field) for `webUrl` / `summary` on
152
- // partially indexed issues. Without these guards, downstream consumers that
153
- // expect `string | undefined` would receive `null` and either crash or render
154
- // the literal string "null". The pre-gate path preserves the legacy behaviour
155
- // so this can be dialled off independently.
156
- if (!fg('platform_synced_block_patch_11')) {
157
- _context3.next = 12;
158
- break;
159
- }
160
- _webUrl = typeof (contentData === null || contentData === void 0 ? void 0 : contentData.webUrl) === 'string' ? contentData.webUrl : undefined;
161
- _summary = typeof (contentData === null || contentData === void 0 ? void 0 : contentData.summary) === 'string' ? contentData.summary : undefined; // Surface issue-type metadata so consumers can render the correct ADS issue-type
162
- // icon. Defensive narrowing mirrors the webUrl/summary treatment above: only
163
- // surfaced when `name` is a non-empty string; AGG values like `{ name: null }`
164
- // collapse back to `undefined`.
165
- rawIssueType = contentData === null || contentData === void 0 ? void 0 : contentData.issueType;
166
- issueTypeName = typeof (rawIssueType === null || rawIssueType === void 0 ? void 0 : rawIssueType.name) === 'string' && rawIssueType.name.length > 0 ? rawIssueType.name : undefined;
167
- issueType = issueTypeName ? {
148
+ contentData = (_response$data = response.data) === null || _response$data === void 0 || (_response$data = _response$data.jira) === null || _response$data === void 0 ? void 0 : _response$data.issueById;
149
+ webUrl = typeof (contentData === null || contentData === void 0 ? void 0 : contentData.webUrl) === 'string' ? contentData.webUrl : undefined;
150
+ summary = typeof (contentData === null || contentData === void 0 ? void 0 : contentData.summary) === 'string' ? contentData.summary : undefined; // Surface issue-type metadata for the SyncedLocationDropdown's ADS icon.
151
+ // Defensive narrowing: only surface when `name` is a non-empty string;
152
+ // AGG values like `{ name: null }` collapse back to `undefined`.
153
+ issueTypeName = contentData === null || contentData === void 0 || (_contentData$issueTyp = contentData.issueType) === null || _contentData$issueTyp === void 0 ? void 0 : _contentData$issueTyp.name;
154
+ issueType = typeof issueTypeName === 'string' && issueTypeName.length > 0 ? {
168
155
  name: issueTypeName,
169
- iconUrl: typeof (rawIssueType === null || rawIssueType === void 0 || (_rawIssueType$avatar = rawIssueType.avatar) === null || _rawIssueType$avatar === void 0 ? void 0 : _rawIssueType$avatar.xsmall) === 'string' ? rawIssueType.avatar.xsmall : undefined
156
+ iconUrl: typeof (contentData === null || contentData === void 0 || (_contentData$issueTyp2 = contentData.issueType) === null || _contentData$issueTyp2 === void 0 || (_contentData$issueTyp2 = _contentData$issueTyp2.avatar) === null || _contentData$issueTyp2 === void 0 ? void 0 : _contentData$issueTyp2.xsmall) === 'string' ? contentData.issueType.avatar.xsmall : undefined
170
157
  } : undefined;
171
158
  return _context3.abrupt("return", Promise.resolve({
172
- url: _webUrl,
159
+ url: webUrl,
173
160
  sourceAri: workItemAri,
174
- title: _summary,
161
+ title: summary,
175
162
  issueType: issueType
176
163
  }));
177
164
  case 12:
178
- webUrl = (_contentData$webUrl = contentData === null || contentData === void 0 ? void 0 : contentData.webUrl) !== null && _contentData$webUrl !== void 0 ? _contentData$webUrl : undefined;
179
- summary = (_contentData$summary = contentData === null || contentData === void 0 ? void 0 : contentData.summary) !== null && _contentData$summary !== void 0 ? _contentData$summary : undefined;
180
- return _context3.abrupt("return", Promise.resolve({
181
- url: webUrl,
182
- sourceAri: workItemAri,
183
- title: summary
184
- }));
185
- case 17:
186
- _context3.next = 19;
165
+ _context3.next = 14;
187
166
  return resolveNoAccessWorkItemInfo(workItemAri);
188
- case 19:
167
+ case 14:
189
168
  return _context3.abrupt("return", _context3.sent);
190
- case 20:
169
+ case 15:
191
170
  case "end":
192
171
  return _context3.stop();
193
172
  }
@@ -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';
@@ -9,7 +9,7 @@ import { isSSR } from '@atlaskit/editor-common/core-utils';
9
9
  import { logException } from '@atlaskit/editor-common/monitoring';
10
10
  import { SyncBlockError } from '../common/types';
11
11
  import { fetchErrorPayload } from '../utils/errorHandling';
12
- import { createSyncBlockNode, productAttrIfGateOn } from '../utils/utils';
12
+ import { createSyncBlockNode, getSourceProductFromResourceIdSafe } from '../utils/utils';
13
13
  export var useFetchSyncBlockData = function useFetchSyncBlockData(manager, resourceId, localId, fireAnalyticsEvent) {
14
14
  // Initialize both states from a single cache lookup to avoid race conditions.
15
15
  // When a block is moved/remounted, the old component's cleanup may clear the cache
@@ -71,7 +71,7 @@ export var useFetchSyncBlockData = function useFetchSyncBlockData(manager, resou
71
71
  logException(_context.t0, {
72
72
  location: 'editor-synced-block-provider/useFetchSyncBlockData'
73
73
  });
74
- fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent(fetchErrorPayload(_context.t0.message, resourceId, productAttrIfGateOn(resourceId)));
74
+ fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent(fetchErrorPayload(_context.t0.message, resourceId, getSourceProductFromResourceIdSafe(resourceId)));
75
75
 
76
76
  // Set error state if fetching fails
77
77
  setFetchState({
@@ -11,12 +11,11 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
11
11
  import _regeneratorRuntime from "@babel/runtime/regenerator";
12
12
  import isEqual from 'lodash/isEqual';
13
13
  import { logException } from '@atlaskit/editor-common/monitoring';
14
- import { fg } from '@atlaskit/platform-feature-flags';
15
14
  import { SyncBlockError } from '../common/types';
16
15
  import { fetchErrorPayload, fetchSuccessPayload, getSourceInfoErrorPayload, updateReferenceErrorPayload } from '../utils/errorHandling';
17
16
  import { getFetchExperience, getFetchSourceInfoExperience, getSaveReferenceExperience } from '../utils/experienceTracking';
18
17
  import { resolveSyncBlockInstance } from '../utils/resolveSyncBlockInstance';
19
- import { createSyncBlockNode, getSourceProductFromResourceIdSafe, productAttrIfGateOn } from '../utils/utils';
18
+ import { createSyncBlockNode, getSourceProductFromResourceIdSafe } from '../utils/utils';
20
19
  import { SyncBlockBatchFetcher } from './syncBlockBatchFetcher';
21
20
  import { syncBlockInMemorySessionCache } from './syncBlockInMemorySessionCache';
22
21
  import { SyncBlockProviderFactoryManager } from './syncBlockProviderFactoryManager';
@@ -311,7 +310,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
311
310
  // Derive once per call so we don't re-parse on every analytics event below.
312
311
  // `product` from cached data is preferred when available; fall back to parsing
313
312
  // the resourceId.
314
- var sourceProduct = fg('platform_synced_block_patch_11') ? product !== null && product !== void 0 ? product : getSourceProductFromResourceIdSafe(resourceId) : undefined;
313
+ var sourceProduct = product !== null && product !== void 0 ? product : getSourceProductFromResourceIdSafe(resourceId);
315
314
  if (!sourceAri || !product || !blockInstanceId) {
316
315
  var _this$fireAnalyticsEv3;
317
316
  (_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(this, getSourceInfoErrorPayload('SourceAri, product or blockInstanceId missing', resourceId, sourceProduct));
@@ -360,7 +359,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
360
359
  logException(error, {
361
360
  location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
362
361
  });
363
- (_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(this, getSourceInfoErrorPayload(error.message, resourceId, productAttrIfGateOn(resourceId)));
362
+ (_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(this, getSourceInfoErrorPayload(error.message, resourceId, getSourceProductFromResourceIdSafe(resourceId)));
364
363
  }
365
364
  return Promise.resolve(undefined);
366
365
  }
@@ -555,7 +554,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
555
554
  }
556
555
  if (syncBlockInstance.error) {
557
556
  var _this5$fireAnalyticsE2, _syncBlockInstance$da, _syncBlockInstance$da2;
558
- (_this5$fireAnalyticsE2 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE2 === void 0 || _this5$fireAnalyticsE2.call(_this5, 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));
557
+ (_this5$fireAnalyticsE2 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE2 === void 0 || _this5$fireAnalyticsE2.call(_this5, 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)));
559
558
  if (syncBlockInstance.error.type === SyncBlockError.NotFound || syncBlockInstance.error.type === SyncBlockError.Forbidden) {
560
559
  hasExpectedError = true;
561
560
  } else if (syncBlockInstance.error) {
@@ -567,9 +566,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
567
566
  var localIds = callbacks ? Object.keys(callbacks) : [];
568
567
  localIds.forEach(function (localId) {
569
568
  var _this5$fireAnalyticsE3, _syncBlockInstance$da3, _syncBlockInstance$da4;
570
- (_this5$fireAnalyticsE3 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE3 === void 0 || _this5$fireAnalyticsE3.call(_this5, fetchSuccessPayload(syncBlockInstance.resourceId, localId,
571
- // Prefer cached product when available; fall back to parsing the resourceId.
572
- 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));
569
+ (_this5$fireAnalyticsE3 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE3 === void 0 || _this5$fireAnalyticsE3.call(_this5, 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)));
573
570
  });
574
571
  _this5.fetchSyncBlockSourceInfo(resolvedSyncBlockInstance.resourceId);
575
572
  });
@@ -3,17 +3,21 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
3
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
4
  import _createClass from "@babel/runtime/helpers/createClass";
5
5
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
6
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
6
7
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
7
8
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
8
9
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
9
- import _regeneratorRuntime from "@babel/runtime/regenerator";
10
10
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
11
11
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
12
12
  import { logException } from '@atlaskit/editor-common/monitoring';
13
+ import { fg } from '@atlaskit/platform-feature-flags';
13
14
  import { SyncBlockError } from '../common/types';
14
15
  import { updateErrorPayload, createErrorPayload, deleteErrorPayload, updateCacheErrorPayload, getSourceInfoErrorPayload, updateSuccessPayload, createSuccessPayload, deleteSuccessPayload, fetchReferencesErrorPayload } from '../utils/errorHandling';
15
16
  import { getCreateSourceExperience, getDeleteSourceExperience, getSaveSourceExperience, getFetchSourceInfoExperience } from '../utils/experienceTracking';
16
- import { convertSyncBlockPMNodeToSyncBlockData, productAttrIfGateOn } from '../utils/utils';
17
+ import { convertSyncBlockPMNodeToSyncBlockData, getSourceProductFromResourceIdSafe } from '../utils/utils';
18
+ /** Maximum time (ms) flush() will wait for in-flight block creations before proceeding. */
19
+ var FLUSH_CREATION_AWAIT_TIMEOUT_MS = 1000;
20
+
17
21
  // A store manager responsible for the lifecycle and state management of source sync blocks in an editor instance.
18
22
  // Designed to manage local in-memory state and synchronize with an external data provider.
19
23
  // Supports create, flush, and delete operations for source sync blocks.
@@ -24,6 +28,22 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
24
28
  var _this = this;
25
29
  _classCallCheck(this, SourceSyncBlockStoreManager);
26
30
  _defineProperty(this, "hasReceivedContentChange", false);
31
+ /**
32
+ * Promises for in-flight block creations, keyed by resourceId.
33
+ * `flush()` awaits these so that blocks created from existing content are
34
+ * persisted even if no further edits trigger a subsequent flush.
35
+ * See EDITOR-7112.
36
+ */
37
+ _defineProperty(this, "pendingCreationPromises", new Map());
38
+ /**
39
+ * Set of resource IDs whose creation was still in-flight when a `flush()`
40
+ * timed out. Each completion (success or failure) is removed from this set;
41
+ * the first successful completion of any of these IDs triggers
42
+ * `postCreationFlushCallback` so the content is eventually persisted.
43
+ * Tracking IDs (not just a boolean) avoids dropping late completions when
44
+ * multiple blocks are created concurrently. See EDITOR-7112.
45
+ */
46
+ _defineProperty(this, "creationsTimedOutDuringFlush", new Set());
27
47
  _defineProperty(this, "setPendingDeletion", function (Ids, value) {
28
48
  if (_this.viewMode === 'view') {
29
49
  return;
@@ -50,6 +70,18 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
50
70
  value: function registerFlushCompletionCallback(callback) {
51
71
  this.flushCompletionCallback = callback;
52
72
  }
73
+
74
+ /**
75
+ * Register a callback to be invoked when flush() timed out waiting for a
76
+ * pending block creation and that creation subsequently completes. The
77
+ * callback should trigger a deferred flush to persist the content that
78
+ * was skipped due to the timeout. See EDITOR-7112.
79
+ */
80
+ }, {
81
+ key: "registerPostCreationFlushCallback",
82
+ value: function registerPostCreationFlushCallback(callback) {
83
+ this.postCreationFlushCallback = callback;
84
+ }
53
85
  }, {
54
86
  key: "setFireAnalyticsEvent",
55
87
  value: function setFireAnalyticsEvent(fireAnalyticsEvent) {
@@ -112,7 +144,7 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
112
144
  });
113
145
  // We can derive the product from `syncBlockNode.attrs.resourceId` even though
114
146
  // the variable wasn't destructured (the destructuring step itself may have thrown).
115
- (_this$fireAnalyticsEv = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv === void 0 || _this$fireAnalyticsEv.call(this, updateCacheErrorPayload(error.message, syncBlockNode === null || syncBlockNode === void 0 || (_syncBlockNode$attrs2 = syncBlockNode.attrs) === null || _syncBlockNode$attrs2 === void 0 ? void 0 : _syncBlockNode$attrs2.resourceId, productAttrIfGateOn(syncBlockNode === null || syncBlockNode === void 0 || (_syncBlockNode$attrs3 = syncBlockNode.attrs) === null || _syncBlockNode$attrs3 === void 0 ? void 0 : _syncBlockNode$attrs3.resourceId)));
147
+ (_this$fireAnalyticsEv = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv === void 0 || _this$fireAnalyticsEv.call(this, updateCacheErrorPayload(error.message, syncBlockNode === null || syncBlockNode === void 0 || (_syncBlockNode$attrs2 = syncBlockNode.attrs) === null || _syncBlockNode$attrs2 === void 0 ? void 0 : _syncBlockNode$attrs2.resourceId, getSourceProductFromResourceIdSafe(syncBlockNode === null || syncBlockNode === void 0 || (_syncBlockNode$attrs3 = syncBlockNode.attrs) === null || _syncBlockNode$attrs3 === void 0 ? void 0 : _syncBlockNode$attrs3.resourceId)));
116
148
  return false;
117
149
  }
118
150
  }
@@ -127,7 +159,7 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
127
159
  value: (function () {
128
160
  var _flush = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
129
161
  var _this2 = this;
130
- var _this$saveExperience, bodiedSyncBlockNodes, bodiedSyncBlockData, writeResults, _this$saveExperience2, _this$saveExperience3, _this$fireAnalyticsEv2, _this$flushCompletion;
162
+ var _this$saveExperience, timedOut, timeoutId, timeout, _iterator, _step, resourceId, bodiedSyncBlockNodes, bodiedSyncBlockData, writeResults, _this$saveExperience2, _this$saveExperience3, _this$fireAnalyticsEv2, _this$flushCompletion;
131
163
  return _regeneratorRuntime.wrap(function _callee$(_context) {
132
164
  while (1) switch (_context.prev = _context.next) {
133
165
  case 0:
@@ -138,6 +170,39 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
138
170
  }
139
171
  return _context.abrupt("return", true);
140
172
  case 3:
173
+ if (!(this.pendingCreationPromises.size > 0 && fg('platform_synced_block_patch_12'))) {
174
+ _context.next = 10;
175
+ break;
176
+ }
177
+ timedOut = false;
178
+ timeout = new Promise(function (resolve) {
179
+ timeoutId = setTimeout(function () {
180
+ timedOut = true;
181
+ resolve();
182
+ }, FLUSH_CREATION_AWAIT_TIMEOUT_MS);
183
+ });
184
+ _context.next = 8;
185
+ return Promise.race([Promise.all(this.pendingCreationPromises.values()), timeout]);
186
+ case 8:
187
+ if (timeoutId !== undefined) {
188
+ clearTimeout(timeoutId);
189
+ }
190
+ if (timedOut) {
191
+ // Record every still-in-flight creation so each late
192
+ // completion is tracked independently.
193
+ _iterator = _createForOfIteratorHelper(this.pendingCreationPromises.keys());
194
+ try {
195
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
196
+ resourceId = _step.value;
197
+ this.creationsTimedOutDuringFlush.add(resourceId);
198
+ }
199
+ } catch (err) {
200
+ _iterator.e(err);
201
+ } finally {
202
+ _iterator.f();
203
+ }
204
+ }
205
+ case 10:
141
206
  bodiedSyncBlockNodes = [];
142
207
  bodiedSyncBlockData = [];
143
208
  Array.from(this.syncBlockCache.values()).forEach(function (syncBlockData) {
@@ -167,21 +232,21 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
167
232
  }
168
233
  });
169
234
  if (!(bodiedSyncBlockNodes.length === 0)) {
170
- _context.next = 8;
235
+ _context.next = 15;
171
236
  break;
172
237
  }
173
238
  return _context.abrupt("return", Promise.resolve(true));
174
- case 8:
239
+ case 15:
175
240
  if (this.dataProvider) {
176
- _context.next = 10;
241
+ _context.next = 17;
177
242
  break;
178
243
  }
179
244
  throw new Error('Data provider not set');
180
- case 10:
245
+ case 17:
181
246
  (_this$saveExperience = this.saveExperience) === null || _this$saveExperience === void 0 || _this$saveExperience.start({});
182
- _context.next = 13;
247
+ _context.next = 20;
183
248
  return this.dataProvider.writeNodesData(bodiedSyncBlockNodes, bodiedSyncBlockData);
184
- case 13:
249
+ case 20:
185
250
  writeResults = _context.sent;
186
251
  writeResults.forEach(function (result) {
187
252
  // set isDirty to true for cases where it failed to save the sync block to the BE
@@ -195,7 +260,7 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
195
260
  if (!writeResults.every(function (result) {
196
261
  return result.resourceId && !result.error;
197
262
  })) {
198
- _context.next = 21;
263
+ _context.next = 28;
199
264
  break;
200
265
  }
201
266
  (_this$saveExperience2 = this.saveExperience) === null || _this$saveExperience2 === void 0 || _this$saveExperience2.success();
@@ -207,24 +272,24 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
207
272
  if (cachedData && result.status) {
208
273
  cachedData.status = result.status;
209
274
  }
210
- (_this2$fireAnalyticsE = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE === void 0 || _this2$fireAnalyticsE.call(_this2, updateSuccessPayload(result.resourceId, false, productAttrIfGateOn(result.resourceId)));
275
+ (_this2$fireAnalyticsE = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE === void 0 || _this2$fireAnalyticsE.call(_this2, updateSuccessPayload(result.resourceId, false, getSourceProductFromResourceIdSafe(result.resourceId)));
211
276
  }
212
277
  });
213
278
  return _context.abrupt("return", true);
214
- case 21:
279
+ case 28:
215
280
  (_this$saveExperience3 = this.saveExperience) === null || _this$saveExperience3 === void 0 || _this$saveExperience3.failure();
216
281
  writeResults.filter(function (result) {
217
282
  return !result.resourceId || result.error;
218
283
  }).forEach(function (result) {
219
284
  var _this2$fireAnalyticsE2;
220
- (_this2$fireAnalyticsE2 = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE2 === void 0 || _this2$fireAnalyticsE2.call(_this2, updateErrorPayload(result.error || 'Failed to write data', result.resourceId, productAttrIfGateOn(result.resourceId)));
285
+ (_this2$fireAnalyticsE2 = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE2 === void 0 || _this2$fireAnalyticsE2.call(_this2, updateErrorPayload(result.error || 'Failed to write data', result.resourceId, getSourceProductFromResourceIdSafe(result.resourceId)));
221
286
  });
222
287
  return _context.abrupt("return", false);
223
- case 24:
224
- _context.next = 31;
288
+ case 31:
289
+ _context.next = 38;
225
290
  break;
226
- case 26:
227
- _context.prev = 26;
291
+ case 33:
292
+ _context.prev = 33;
228
293
  _context.t0 = _context["catch"](0);
229
294
  logException(_context.t0, {
230
295
  location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
@@ -232,15 +297,15 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
232
297
  // Top-level flush failure is not tied to a single resourceId.
233
298
  (_this$fireAnalyticsEv2 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 || _this$fireAnalyticsEv2.call(this, updateErrorPayload(_context.t0.message));
234
299
  return _context.abrupt("return", false);
235
- case 31:
236
- _context.prev = 31;
300
+ case 38:
301
+ _context.prev = 38;
237
302
  (_this$flushCompletion = this.flushCompletionCallback) === null || _this$flushCompletion === void 0 || _this$flushCompletion.call(this);
238
- return _context.finish(31);
239
- case 34:
303
+ return _context.finish(38);
304
+ case 41:
240
305
  case "end":
241
306
  return _context.stop();
242
307
  }
243
- }, _callee, this, [[0, 26, 31, 34]]);
308
+ }, _callee, this, [[0, 33, 38, 41]]);
244
309
  }));
245
310
  function flush() {
246
311
  return _flush.apply(this, arguments);
@@ -296,23 +361,33 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
296
361
  if (onCompletion) {
297
362
  this.creationCompletionCallbacks.delete(resourceId);
298
363
  onCompletion(success);
364
+ // If a previous flush() timed out waiting for this specific
365
+ // creation, drop it from the tracking set regardless of outcome so
366
+ // it does not leak. See EDITOR-7112.
367
+ var wasTimedOut = this.creationsTimedOutDuringFlush.delete(resourceId);
299
368
  if (success) {
300
369
  // If creation is successful, set hasReceivedContentChange to true
301
370
  // to indicate that there are unsaved changes in the cache
302
371
  this.hasReceivedContentChange = true;
372
+ // If flush() timed out waiting for this creation, notify the
373
+ // plugin so it can trigger a deferred flush. See EDITOR-7112.
374
+ if (wasTimedOut) {
375
+ var _this$postCreationFlu;
376
+ (_this$postCreationFlu = this.postCreationFlushCallback) === null || _this$postCreationFlu === void 0 || _this$postCreationFlu.call(this);
377
+ }
303
378
  }
304
379
  } else {
305
380
  var _this$fireAnalyticsEv3;
306
- (_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(this, createErrorPayload('creation complete callback missing', resourceId, productAttrIfGateOn(resourceId)));
381
+ (_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(this, createErrorPayload('creation complete callback missing', resourceId, getSourceProductFromResourceIdSafe(resourceId)));
307
382
  }
308
383
  if (success) {
309
384
  var _this$fireAnalyticsEv4;
310
- (_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(this, createSuccessPayload(resourceId || '', productAttrIfGateOn(resourceId)));
385
+ (_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(this, createSuccessPayload(resourceId || '', getSourceProductFromResourceIdSafe(resourceId)));
311
386
  } else {
312
387
  var _this$fireAnalyticsEv5;
313
388
  // Delete the node from cache if fail to create so it's not flushed to BE
314
389
  this.syncBlockCache.delete(resourceId || '');
315
- (_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 || _this$fireAnalyticsEv5.call(this, createErrorPayload('Fail to create bodied sync block', resourceId, productAttrIfGateOn(resourceId)));
390
+ (_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 || _this$fireAnalyticsEv5.call(this, createErrorPayload('Fail to create bodied sync block', resourceId, getSourceProductFromResourceIdSafe(resourceId)));
316
391
  }
317
392
  }
318
393
  }, {
@@ -379,7 +454,7 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
379
454
  }
380
455
  this.creationCompletionCallbacks.set(resourceId, onCompletion);
381
456
  (_this$createExperienc = this.createExperience) === null || _this$createExperienc === void 0 || _this$createExperienc.start({});
382
- this.dataProvider.createNodeData({
457
+ var creationPromise = this.dataProvider.createNodeData({
383
458
  content: [],
384
459
  blockInstanceId: blockInstanceId,
385
460
  resourceId: resourceId
@@ -395,7 +470,7 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
395
470
  (_this4$createExperien2 = _this4.createExperience) === null || _this4$createExperien2 === void 0 || _this4$createExperien2.failure({
396
471
  reason: result.error || 'Failed to create bodied sync block'
397
472
  });
398
- (_this4$fireAnalyticsE = _this4.fireAnalyticsEvent) === null || _this4$fireAnalyticsE === void 0 || _this4$fireAnalyticsE.call(_this4, createErrorPayload(result.error || 'Failed to create bodied sync block', resourceId, productAttrIfGateOn(resourceId)));
473
+ (_this4$fireAnalyticsE = _this4.fireAnalyticsEvent) === null || _this4$fireAnalyticsE === void 0 || _this4$fireAnalyticsE.call(_this4, createErrorPayload(result.error || 'Failed to create bodied sync block', resourceId, getSourceProductFromResourceIdSafe(resourceId)));
399
474
  }
400
475
  }).catch(function (error) {
401
476
  var _this4$createExperien3, _this4$fireAnalyticsE2;
@@ -406,8 +481,11 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
406
481
  (_this4$createExperien3 = _this4.createExperience) === null || _this4$createExperien3 === void 0 || _this4$createExperien3.failure({
407
482
  reason: error.message
408
483
  });
409
- (_this4$fireAnalyticsE2 = _this4.fireAnalyticsEvent) === null || _this4$fireAnalyticsE2 === void 0 || _this4$fireAnalyticsE2.call(_this4, createErrorPayload(error.message, resourceId, productAttrIfGateOn(resourceId)));
484
+ (_this4$fireAnalyticsE2 = _this4.fireAnalyticsEvent) === null || _this4$fireAnalyticsE2 === void 0 || _this4$fireAnalyticsE2.call(_this4, createErrorPayload(error.message, resourceId, getSourceProductFromResourceIdSafe(resourceId)));
485
+ }).finally(function () {
486
+ _this4.pendingCreationPromises.delete(resourceId);
410
487
  });
488
+ this.pendingCreationPromises.set(resourceId, creationPromise);
411
489
  } catch (error) {
412
490
  var _this$fireAnalyticsEv6;
413
491
  if (this.isPendingCreation(resourceId)) {
@@ -416,7 +494,7 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
416
494
  logException(error, {
417
495
  location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
418
496
  });
419
- (_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 || _this$fireAnalyticsEv6.call(this, createErrorPayload(error.message, resourceId, productAttrIfGateOn(resourceId)));
497
+ (_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 || _this$fireAnalyticsEv6.call(this, createErrorPayload(error.message, resourceId, getSourceProductFromResourceIdSafe(resourceId)));
420
498
  }
421
499
  }
422
500
  }, {
@@ -464,7 +542,7 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
464
542
  (_this$deleteExperienc2 = this.deleteExperience) === null || _this$deleteExperienc2 === void 0 || _this$deleteExperienc2.success();
465
543
  results.forEach(function (result) {
466
544
  var _this5$fireAnalyticsE;
467
- (_this5$fireAnalyticsE = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE === void 0 || _this5$fireAnalyticsE.call(_this5, deleteSuccessPayload(result.resourceId, productAttrIfGateOn(result.resourceId)));
545
+ (_this5$fireAnalyticsE = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE === void 0 || _this5$fireAnalyticsE.call(_this5, deleteSuccessPayload(result.resourceId, getSourceProductFromResourceIdSafe(result.resourceId)));
468
546
  });
469
547
  } else {
470
548
  callback = function callback(Ids) {
@@ -474,10 +552,10 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
474
552
  results.forEach(function (result) {
475
553
  if (result.success) {
476
554
  var _this5$fireAnalyticsE2;
477
- (_this5$fireAnalyticsE2 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE2 === void 0 || _this5$fireAnalyticsE2.call(_this5, deleteSuccessPayload(result.resourceId, productAttrIfGateOn(result.resourceId)));
555
+ (_this5$fireAnalyticsE2 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE2 === void 0 || _this5$fireAnalyticsE2.call(_this5, deleteSuccessPayload(result.resourceId, getSourceProductFromResourceIdSafe(result.resourceId)));
478
556
  } else {
479
557
  var _this5$fireAnalyticsE3;
480
- (_this5$fireAnalyticsE3 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE3 === void 0 || _this5$fireAnalyticsE3.call(_this5, deleteErrorPayload(result.error || 'Failed to delete synced block', result.resourceId, productAttrIfGateOn(result.resourceId)));
558
+ (_this5$fireAnalyticsE3 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE3 === void 0 || _this5$fireAnalyticsE3.call(_this5, deleteErrorPayload(result.error || 'Failed to delete synced block', result.resourceId, getSourceProductFromResourceIdSafe(result.resourceId)));
481
559
  }
482
560
  });
483
561
  }
@@ -489,7 +567,7 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
489
567
  syncBlockIds.forEach(function (Ids) {
490
568
  var _this5$fireAnalyticsE4;
491
569
  _this5.setPendingDeletion(Ids, false);
492
- (_this5$fireAnalyticsE4 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE4 === void 0 || _this5$fireAnalyticsE4.call(_this5, deleteErrorPayload(_context2.t0.message, Ids.resourceId, productAttrIfGateOn(Ids.resourceId)));
570
+ (_this5$fireAnalyticsE4 = _this5.fireAnalyticsEvent) === null || _this5$fireAnalyticsE4 === void 0 || _this5$fireAnalyticsE4.call(_this5, deleteErrorPayload(_context2.t0.message, Ids.resourceId, getSourceProductFromResourceIdSafe(Ids.resourceId)));
493
571
  });
494
572
  logException(_context2.t0, {
495
573
  location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
@@ -568,7 +646,7 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
568
646
  value: (function () {
569
647
  var _fetchAndCacheStatuses = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
570
648
  var _this6 = this;
571
- var sourceToReferenceMap, syncBlockNodes, results, _iterator, _step, _sourceToReferenceMap, _result$data, result, sourceResourceId, cached;
649
+ var sourceToReferenceMap, syncBlockNodes, results, _iterator2, _step2, _sourceToReferenceMap, _result$data, result, sourceResourceId, cached;
572
650
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
573
651
  while (1) switch (_context4.prev = _context4.next) {
574
652
  case 0:
@@ -604,10 +682,10 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
604
682
  return this.dataProvider.fetchNodesData(syncBlockNodes);
605
683
  case 7:
606
684
  results = _context4.sent;
607
- _iterator = _createForOfIteratorHelper(results);
685
+ _iterator2 = _createForOfIteratorHelper(results);
608
686
  try {
609
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
610
- result = _step.value;
687
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
688
+ result = _step2.value;
611
689
  // Map the reference resourceId back to the source resourceId
612
690
  sourceResourceId = (_sourceToReferenceMap = sourceToReferenceMap.get(result.resourceId)) !== null && _sourceToReferenceMap !== void 0 ? _sourceToReferenceMap : result.resourceId;
613
691
  cached = this.syncBlockCache.get(sourceResourceId);
@@ -616,9 +694,9 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
616
694
  }
617
695
  }
618
696
  } catch (err) {
619
- _iterator.e(err);
697
+ _iterator2.e(err);
620
698
  } finally {
621
- _iterator.f();
699
+ _iterator2.f();
622
700
  }
623
701
  _context4.next = 14;
624
702
  break;
@@ -780,7 +858,7 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
780
858
  logException(error, {
781
859
  location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
782
860
  });
783
- (_this$fireAnalyticsEv8 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv8 === void 0 || _this$fireAnalyticsEv8.call(this, fetchReferencesErrorPayload(error.message, resourceId, productAttrIfGateOn(resourceId)));
861
+ (_this$fireAnalyticsEv8 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv8 === void 0 || _this$fireAnalyticsEv8.call(this, fetchReferencesErrorPayload(error.message, resourceId, getSourceProductFromResourceIdSafe(resourceId)));
784
862
  return Promise.resolve({
785
863
  error: SyncBlockError.Errored
786
864
  });
@@ -794,6 +872,9 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
794
872
  this.confirmationCallback = undefined;
795
873
  this.creationCompletionCallbacks.clear();
796
874
  this.flushCompletionCallback = undefined;
875
+ this.postCreationFlushCallback = undefined;
876
+ this.pendingCreationPromises.clear();
877
+ this.creationsTimedOutDuringFlush.clear();
797
878
  this.dataProvider = undefined;
798
879
  (_this$saveExperience4 = this.saveExperience) === null || _this$saveExperience4 === void 0 || _this$saveExperience4.abort({
799
880
  reason: 'editorDestroyed'
@@ -4,7 +4,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  import rafSchedule from 'raf-schd';
5
5
  import { logException } from '@atlaskit/editor-common/monitoring';
6
6
  import { fetchErrorPayload } from '../utils/errorHandling';
7
- import { createSyncBlockNode, productAttrIfGateOn } from '../utils/utils';
7
+ import { createSyncBlockNode, getSourceProductFromResourceIdSafe } from '../utils/utils';
8
8
  /**
9
9
  * Handles debounced batch-fetching of sync block data via `raf-schd`.
10
10
  * Accumulates resource IDs and flushes them in a single fetch per
@@ -33,7 +33,7 @@ export var SyncBlockBatchFetcher = /*#__PURE__*/function () {
33
33
  });
34
34
  resourceIds.forEach(function (resId) {
35
35
  var _this$deps$getFireAna;
36
- (_this$deps$getFireAna = _this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna === void 0 || _this$deps$getFireAna(fetchErrorPayload(error.message, resId, productAttrIfGateOn(resId)));
36
+ (_this$deps$getFireAna = _this.deps.getFireAnalyticsEvent()) === null || _this$deps$getFireAna === void 0 || _this$deps$getFireAna(fetchErrorPayload(error.message, resId, getSourceProductFromResourceIdSafe(resId)));
37
37
  });
38
38
  });
39
39
  });