@atlaskit/editor-synced-block-provider 8.3.0 → 8.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @atlaskit/editor-synced-block-provider
2
2
 
3
+ ## 8.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`5e439884aa23d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5e439884aa23d) -
8
+ Add a readiness guard to the source synced-block cache-update path. When a `bodiedSyncBlock` node
9
+ is updated before its `localId`/`resourceId` has been populated (a benign timing/initialisation
10
+ ordering case), the cache update is now skipped as a no-op instead of throwing. This stops the
11
+ `Local ID or resource ID is not set` error from being logged and from firing the synced-block
12
+ update-cache operational error event, so it no longer counts as a genuine cache-update failure.
13
+ Gated behind `platform_editor_blocks_patch_4`.
14
+
15
+ ## 8.3.1
16
+
17
+ ### Patch Changes
18
+
19
+ - [`73743eb8b36e6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/73743eb8b36e6) -
20
+ CLeanup prefer static regex violations
21
+ - Updated dependencies
22
+
3
23
  ## 8.3.0
4
24
 
5
25
  ### Minor Changes
@@ -6,6 +6,10 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.getProductFromSourceAri = exports.getLocalIdFromBlockResourceId = exports.generateBlockAriFromReference = exports.generateBlockAri = void 0;
7
7
  /* eslint-disable require-unicode-regexp */
8
8
 
9
+ var GET_LOCAL_ID_FROM_BLOCK_RESOURCE_ID_REGEX = /ari:cloud:blocks:[^:]+:synced-block\/([a-zA-Z0-9-]+)/;
10
+ var JIRA_SOURCE_ARI_REGEX = /ari:cloud:jira:.*/;
11
+ var CONFLUENCE_SOURCE_ARI_REGEX = /ari:cloud:confluence:.*/;
12
+
9
13
  /**
10
14
  * Generates the block ARI from the source page ARI and the source block's resource ID.
11
15
  * @param cloudId - the cloudId of the block. E.G the cloudId of the confluence page, or the cloudId of the Jira instance
@@ -42,18 +46,18 @@ var generateBlockAriFromReference = exports.generateBlockAriFromReference = func
42
46
  * @returns the localId of the block node. A randomly generated UUID
43
47
  */
44
48
  var getLocalIdFromBlockResourceId = exports.getLocalIdFromBlockResourceId = function getLocalIdFromBlockResourceId(ari) {
45
- var match = ari.match(/ari:cloud:blocks:[^:]+:synced-block\/([a-zA-Z0-9-]+)/);
49
+ var match = ari.match(GET_LOCAL_ID_FROM_BLOCK_RESOURCE_ID_REGEX);
46
50
  if (match !== null && match !== void 0 && match[1]) {
47
51
  return match[1];
48
52
  }
49
53
  throw new Error("Invalid block ARI: ".concat(ari));
50
54
  };
51
55
  var getProductFromSourceAri = exports.getProductFromSourceAri = function getProductFromSourceAri(ari) {
52
- var jiraMatch = ari === null || ari === void 0 ? void 0 : ari.search(/ari:cloud:jira:.*/);
56
+ var jiraMatch = ari === null || ari === void 0 ? void 0 : ari.search(JIRA_SOURCE_ARI_REGEX);
53
57
  if (jiraMatch !== -1) {
54
58
  return 'jira-work-item';
55
59
  }
56
- var confluenceMatch = ari === null || ari === void 0 ? void 0 : ari.search(/ari:cloud:confluence:.*/);
60
+ var confluenceMatch = ari === null || ari === void 0 ? void 0 : ari.search(CONFLUENCE_SOURCE_ARI_REGEX);
57
61
  if (confluenceMatch !== -1) {
58
62
  return 'confluence-page';
59
63
  }
@@ -10,6 +10,9 @@ var _graphqlWs = require("graphql-ws");
10
10
  var _coreUtils = require("@atlaskit/editor-common/core-utils");
11
11
  var _utils = require("../../utils/utils");
12
12
  var GRAPHQL_WS_ENDPOINT = '/gateway/api/graphql/subscriptions';
13
+
14
+ // eslint-disable-next-line require-unicode-regexp
15
+ var EXTRACT_RESOURCE_ID_FROM_BLOCK_ARI_REGEX = /ari:cloud:blocks:[^:]+:synced-block\/(.+)$/;
13
16
  var blockServiceClient = null;
14
17
 
15
18
  /**
@@ -129,8 +132,7 @@ var extractGraphQLWSErrorMessage = exports.extractGraphQLWSErrorMessage = functi
129
132
  * @returns The resourceId portion of the ARI
130
133
  */
131
134
  var extractResourceIdFromBlockAri = function extractResourceIdFromBlockAri(blockAri) {
132
- // eslint-disable-next-line require-unicode-regexp
133
- var match = blockAri.match(/ari:cloud:blocks:[^:]+:synced-block\/(.+)$/);
135
+ var match = blockAri.match(EXTRACT_RESOURCE_ID_FROM_BLOCK_ARI_REGEX);
134
136
  return (match === null || match === void 0 ? void 0 : match[1]) || null;
135
137
  };
136
138
 
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.getPageIdAndTypeFromConfluencePageAri = exports.getConfluencePageAri = void 0;
7
7
  /* eslint-disable require-unicode-regexp */
8
8
 
9
+ var CONFLUENCE_PAGE_ARI_REGEX = /ari:cloud:confluence:[^:]+:(page|blogpost)\/(\d+)/;
10
+
9
11
  /**
10
12
  * The type of the Confluence page
11
13
  */
@@ -31,7 +33,7 @@ var getConfluencePageAri = exports.getConfluencePageAri = function getConfluence
31
33
  */
32
34
  var getPageIdAndTypeFromConfluencePageAri = exports.getPageIdAndTypeFromConfluencePageAri = function getPageIdAndTypeFromConfluencePageAri(_ref2) {
33
35
  var ari = _ref2.ari;
34
- var match = ari.match(/ari:cloud:confluence:[^:]+:(page|blogpost)\/(\d+)/);
36
+ var match = ari.match(CONFLUENCE_PAGE_ARI_REGEX);
35
37
  if (match !== null && match !== void 0 && match[2]) {
36
38
  return {
37
39
  type: match[1],
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.getJiraWorkItemIdFromAri = exports.getJiraWorkItemAri = void 0;
7
7
  /* eslint-disable require-unicode-regexp */
8
8
 
9
+ var JIRA_WORK_ITEM_ARI_REGEX = /ari:cloud:jira:([^:]+):issue\/(\d+)/;
10
+
9
11
  /**
10
12
  * Generates the Jira work item ARI
11
13
  * @param workItemId - the ID of the work item
@@ -25,7 +27,7 @@ var getJiraWorkItemAri = exports.getJiraWorkItemAri = function getJiraWorkItemAr
25
27
  */
26
28
  var getJiraWorkItemIdFromAri = exports.getJiraWorkItemIdFromAri = function getJiraWorkItemIdFromAri(_ref2) {
27
29
  var ari = _ref2.ari;
28
- var match = ari.match(/ari:cloud:jira:([^:]+):issue\/(\d+)/);
30
+ var match = ari.match(JIRA_WORK_ITEM_ARI_REGEX);
29
31
  if (match !== null && match !== void 0 && match[2]) {
30
32
  return match[2];
31
33
  }
@@ -26,6 +26,8 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
26
26
  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; } } }; }
27
27
  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; } }
28
28
  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; } /* eslint-disable require-unicode-regexp */
29
+ var BLOCK_ARI_TO_RESOURCE_ID_REGEX = /^ari:cloud:blocks:.*:synced-block\/(.+)$/;
30
+ var EXTRACT_RESOURCE_ID_FROM_BLOCK_ARI_REGEX = /ari:cloud:blocks:[^:]+:synced-block\/(.+)$/;
29
31
  var mapBlockError = function mapBlockError(error) {
30
32
  switch (error.status) {
31
33
  case 400:
@@ -92,7 +94,7 @@ var blockAriToResourceId = exports.blockAriToResourceId = function blockAriToRes
92
94
  // The regex captures the full path after synced-block/
93
95
  // e.g. ari:cloud:blocks:DUMMY-a5a01d21-1cc3-4f29-9565-f2bb8cd969f5:synced-block/confluence-page/455232061495/e8cf64e3-1b6e-489b-ad86-8465b0905bb4
94
96
  // should return confluence-page/455232061495/e8cf64e3-1b6e-489b-ad86-8465b0905bb4
95
- var match = blockAri.match(/^ari:cloud:blocks:.*:synced-block\/(.+)$/);
97
+ var match = blockAri.match(BLOCK_ARI_TO_RESOURCE_ID_REGEX);
96
98
  return (match === null || match === void 0 ? void 0 : match[1]) || null;
97
99
  };
98
100
 
@@ -201,7 +203,7 @@ var fetchReferences = exports.fetchReferences = /*#__PURE__*/function () {
201
203
  * Block ARI format: ari:cloud:blocks:<cloudId>:synced-block/<resourceId>
202
204
  */
203
205
  var extractResourceIdFromBlockAri = exports.extractResourceIdFromBlockAri = function extractResourceIdFromBlockAri(blockAri) {
204
- var match = blockAri.match(/ari:cloud:blocks:[^:]+:synced-block\/(.+)$/);
206
+ var match = blockAri.match(EXTRACT_RESOURCE_ID_FROM_BLOCK_ARI_REGEX);
205
207
  return match === null || match === void 0 ? void 0 : match[1];
206
208
  };
207
209
 
@@ -123,6 +123,10 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
123
123
  localId = _syncBlockNode$attrs.localId,
124
124
  resourceId = _syncBlockNode$attrs.resourceId;
125
125
  if (!localId || !resourceId) {
126
+ // Identifiers not populated yet: benign timing case, skip as a no-op.
127
+ if ((0, _platformFeatureFlags.fg)('platform_editor_blocks_patch_4')) {
128
+ return false;
129
+ }
126
130
  throw new Error('Local ID or resource ID is not set');
127
131
  }
128
132
  var cachedBlock = this.syncBlockCache.get(resourceId);
@@ -10,6 +10,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
10
10
  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) { (0, _defineProperty2.default)(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; }
11
11
  /* eslint-disable require-unicode-regexp */
12
12
 
13
+ var GET_CONTENT_ID_AND_PRODUCT_REGEX = /^(confluence-page|jira-work-item)\/([^/]+)/;
13
14
  var _normalizeSyncBlockJSONContentInternal = function normalizeSyncBlockJSONContentInternal(content, options) {
14
15
  var normalizedContent;
15
16
  content.forEach(function (contentNode, index) {
@@ -109,7 +110,7 @@ var convertPMNodesToSyncBlockNodes = exports.convertPMNodesToSyncBlockNodes = fu
109
110
  * Extracts the source page content id and source product
110
111
  */
111
112
  var getContentIdAndProductFromResourceId = exports.getContentIdAndProductFromResourceId = function getContentIdAndProductFromResourceId(resourceId) {
112
- var match = resourceId.match(/^(confluence-page|jira-work-item)\/([^/]+)/);
113
+ var match = resourceId.match(GET_CONTENT_ID_AND_PRODUCT_REGEX);
113
114
  if (match !== null && match !== void 0 && match[2]) {
114
115
  return {
115
116
  sourceProduct: match[1],
@@ -1,5 +1,9 @@
1
1
  /* eslint-disable require-unicode-regexp */
2
2
 
3
+ const GET_LOCAL_ID_FROM_BLOCK_RESOURCE_ID_REGEX = /ari:cloud:blocks:[^:]+:synced-block\/([a-zA-Z0-9-]+)/;
4
+ const JIRA_SOURCE_ARI_REGEX = /ari:cloud:jira:.*/;
5
+ const CONFLUENCE_SOURCE_ARI_REGEX = /ari:cloud:confluence:.*/;
6
+
3
7
  /**
4
8
  * Generates the block ARI from the source page ARI and the source block's resource ID.
5
9
  * @param cloudId - the cloudId of the block. E.G the cloudId of the confluence page, or the cloudId of the Jira instance
@@ -38,18 +42,18 @@ export const generateBlockAriFromReference = ({
38
42
  * @returns the localId of the block node. A randomly generated UUID
39
43
  */
40
44
  export const getLocalIdFromBlockResourceId = ari => {
41
- const match = ari.match(/ari:cloud:blocks:[^:]+:synced-block\/([a-zA-Z0-9-]+)/);
45
+ const match = ari.match(GET_LOCAL_ID_FROM_BLOCK_RESOURCE_ID_REGEX);
42
46
  if (match !== null && match !== void 0 && match[1]) {
43
47
  return match[1];
44
48
  }
45
49
  throw new Error(`Invalid block ARI: ${ari}`);
46
50
  };
47
51
  export const getProductFromSourceAri = ari => {
48
- const jiraMatch = ari === null || ari === void 0 ? void 0 : ari.search(/ari:cloud:jira:.*/);
52
+ const jiraMatch = ari === null || ari === void 0 ? void 0 : ari.search(JIRA_SOURCE_ARI_REGEX);
49
53
  if (jiraMatch !== -1) {
50
54
  return 'jira-work-item';
51
55
  }
52
- const confluenceMatch = ari === null || ari === void 0 ? void 0 : ari.search(/ari:cloud:confluence:.*/);
56
+ const confluenceMatch = ari === null || ari === void 0 ? void 0 : ari.search(CONFLUENCE_SOURCE_ARI_REGEX);
53
57
  if (confluenceMatch !== -1) {
54
58
  return 'confluence-page';
55
59
  }
@@ -2,6 +2,9 @@ import { createClient } from 'graphql-ws';
2
2
  import { isSSR } from '@atlaskit/editor-common/core-utils';
3
3
  import { convertContentUpdatedAt } from '../../utils/utils';
4
4
  const GRAPHQL_WS_ENDPOINT = '/gateway/api/graphql/subscriptions';
5
+
6
+ // eslint-disable-next-line require-unicode-regexp
7
+ const EXTRACT_RESOURCE_ID_FROM_BLOCK_ARI_REGEX = /ari:cloud:blocks:[^:]+:synced-block\/(.+)$/;
5
8
  let blockServiceClient = null;
6
9
 
7
10
  /**
@@ -136,8 +139,7 @@ export const extractGraphQLWSErrorMessage = error => {
136
139
  * @returns The resourceId portion of the ARI
137
140
  */
138
141
  const extractResourceIdFromBlockAri = blockAri => {
139
- // eslint-disable-next-line require-unicode-regexp
140
- const match = blockAri.match(/ari:cloud:blocks:[^:]+:synced-block\/(.+)$/);
142
+ const match = blockAri.match(EXTRACT_RESOURCE_ID_FROM_BLOCK_ARI_REGEX);
141
143
  return (match === null || match === void 0 ? void 0 : match[1]) || null;
142
144
  };
143
145
 
@@ -1,5 +1,7 @@
1
1
  /* eslint-disable require-unicode-regexp */
2
2
 
3
+ const CONFLUENCE_PAGE_ARI_REGEX = /ari:cloud:confluence:[^:]+:(page|blogpost)\/(\d+)/;
4
+
3
5
  /**
4
6
  * The type of the Confluence page
5
7
  */
@@ -27,7 +29,7 @@ export const getConfluencePageAri = ({
27
29
  export const getPageIdAndTypeFromConfluencePageAri = ({
28
30
  ari
29
31
  }) => {
30
- const match = ari.match(/ari:cloud:confluence:[^:]+:(page|blogpost)\/(\d+)/);
32
+ const match = ari.match(CONFLUENCE_PAGE_ARI_REGEX);
31
33
  if (match !== null && match !== void 0 && match[2]) {
32
34
  return {
33
35
  type: match[1],
@@ -1,5 +1,7 @@
1
1
  /* eslint-disable require-unicode-regexp */
2
2
 
3
+ const JIRA_WORK_ITEM_ARI_REGEX = /ari:cloud:jira:([^:]+):issue\/(\d+)/;
4
+
3
5
  /**
4
6
  * Generates the Jira work item ARI
5
7
  * @param workItemId - the ID of the work item
@@ -21,7 +23,7 @@ export const getJiraWorkItemAri = ({
21
23
  export const getJiraWorkItemIdFromAri = ({
22
24
  ari
23
25
  }) => {
24
- const match = ari.match(/ari:cloud:jira:([^:]+):issue\/(\d+)/);
26
+ const match = ari.match(JIRA_WORK_ITEM_ARI_REGEX);
25
27
  if (match !== null && match !== void 0 && match[2]) {
26
28
  return match[2];
27
29
  }
@@ -7,6 +7,8 @@ import { SyncBlockError } from '../../common/types';
7
7
  import { stringifyError } from '../../utils/errorHandling';
8
8
  import { createResourceIdForReference } from '../../utils/resourceId';
9
9
  import { convertContentUpdatedAt } from '../../utils/utils';
10
+ const BLOCK_ARI_TO_RESOURCE_ID_REGEX = /^ari:cloud:blocks:.*:synced-block\/(.+)$/;
11
+ const EXTRACT_RESOURCE_ID_FROM_BLOCK_ARI_REGEX = /ari:cloud:blocks:[^:]+:synced-block\/(.+)$/;
10
12
  const mapBlockError = error => {
11
13
  switch (error.status) {
12
14
  case 400:
@@ -73,7 +75,7 @@ export const blockAriToResourceId = blockAri => {
73
75
  // The regex captures the full path after synced-block/
74
76
  // e.g. ari:cloud:blocks:DUMMY-a5a01d21-1cc3-4f29-9565-f2bb8cd969f5:synced-block/confluence-page/455232061495/e8cf64e3-1b6e-489b-ad86-8465b0905bb4
75
77
  // should return confluence-page/455232061495/e8cf64e3-1b6e-489b-ad86-8465b0905bb4
76
- const match = blockAri.match(/^ari:cloud:blocks:.*:synced-block\/(.+)$/);
78
+ const match = blockAri.match(BLOCK_ARI_TO_RESOURCE_ID_REGEX);
77
79
  return (match === null || match === void 0 ? void 0 : match[1]) || null;
78
80
  };
79
81
 
@@ -160,7 +162,7 @@ export const fetchReferences = async documentAri => {
160
162
  * Block ARI format: ari:cloud:blocks:<cloudId>:synced-block/<resourceId>
161
163
  */
162
164
  export const extractResourceIdFromBlockAri = blockAri => {
163
- const match = blockAri.match(/ari:cloud:blocks:[^:]+:synced-block\/(.+)$/);
165
+ const match = blockAri.match(EXTRACT_RESOURCE_ID_FROM_BLOCK_ARI_REGEX);
164
166
  return match === null || match === void 0 ? void 0 : match[1];
165
167
  };
166
168
 
@@ -95,6 +95,10 @@ export class SourceSyncBlockStoreManager {
95
95
  resourceId
96
96
  } = syncBlockNode.attrs;
97
97
  if (!localId || !resourceId) {
98
+ // Identifiers not populated yet: benign timing case, skip as a no-op.
99
+ if (fg('platform_editor_blocks_patch_4')) {
100
+ return false;
101
+ }
98
102
  throw new Error('Local ID or resource ID is not set');
99
103
  }
100
104
  const cachedBlock = this.syncBlockCache.get(resourceId);
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable require-unicode-regexp */
2
2
 
3
+ const GET_CONTENT_ID_AND_PRODUCT_REGEX = /^(confluence-page|jira-work-item)\/([^/]+)/;
3
4
  const normalizeSyncBlockJSONContentInternal = (content, options) => {
4
5
  var _normalizedContent3;
5
6
  let normalizedContent;
@@ -94,7 +95,7 @@ export const convertPMNodesToSyncBlockNodes = nodes => {
94
95
  * Extracts the source page content id and source product
95
96
  */
96
97
  export const getContentIdAndProductFromResourceId = resourceId => {
97
- const match = resourceId.match(/^(confluence-page|jira-work-item)\/([^/]+)/);
98
+ const match = resourceId.match(GET_CONTENT_ID_AND_PRODUCT_REGEX);
98
99
  if (match !== null && match !== void 0 && match[2]) {
99
100
  return {
100
101
  sourceProduct: match[1],
@@ -1,5 +1,9 @@
1
1
  /* eslint-disable require-unicode-regexp */
2
2
 
3
+ var GET_LOCAL_ID_FROM_BLOCK_RESOURCE_ID_REGEX = /ari:cloud:blocks:[^:]+:synced-block\/([a-zA-Z0-9-]+)/;
4
+ var JIRA_SOURCE_ARI_REGEX = /ari:cloud:jira:.*/;
5
+ var CONFLUENCE_SOURCE_ARI_REGEX = /ari:cloud:confluence:.*/;
6
+
3
7
  /**
4
8
  * Generates the block ARI from the source page ARI and the source block's resource ID.
5
9
  * @param cloudId - the cloudId of the block. E.G the cloudId of the confluence page, or the cloudId of the Jira instance
@@ -36,18 +40,18 @@ export var generateBlockAriFromReference = function generateBlockAriFromReferenc
36
40
  * @returns the localId of the block node. A randomly generated UUID
37
41
  */
38
42
  export var getLocalIdFromBlockResourceId = function getLocalIdFromBlockResourceId(ari) {
39
- var match = ari.match(/ari:cloud:blocks:[^:]+:synced-block\/([a-zA-Z0-9-]+)/);
43
+ var match = ari.match(GET_LOCAL_ID_FROM_BLOCK_RESOURCE_ID_REGEX);
40
44
  if (match !== null && match !== void 0 && match[1]) {
41
45
  return match[1];
42
46
  }
43
47
  throw new Error("Invalid block ARI: ".concat(ari));
44
48
  };
45
49
  export var getProductFromSourceAri = function getProductFromSourceAri(ari) {
46
- var jiraMatch = ari === null || ari === void 0 ? void 0 : ari.search(/ari:cloud:jira:.*/);
50
+ var jiraMatch = ari === null || ari === void 0 ? void 0 : ari.search(JIRA_SOURCE_ARI_REGEX);
47
51
  if (jiraMatch !== -1) {
48
52
  return 'jira-work-item';
49
53
  }
50
- var confluenceMatch = ari === null || ari === void 0 ? void 0 : ari.search(/ari:cloud:confluence:.*/);
54
+ var confluenceMatch = ari === null || ari === void 0 ? void 0 : ari.search(CONFLUENCE_SOURCE_ARI_REGEX);
51
55
  if (confluenceMatch !== -1) {
52
56
  return 'confluence-page';
53
57
  }
@@ -3,6 +3,9 @@ import { createClient } from 'graphql-ws';
3
3
  import { isSSR } from '@atlaskit/editor-common/core-utils';
4
4
  import { convertContentUpdatedAt } from '../../utils/utils';
5
5
  var GRAPHQL_WS_ENDPOINT = '/gateway/api/graphql/subscriptions';
6
+
7
+ // eslint-disable-next-line require-unicode-regexp
8
+ var EXTRACT_RESOURCE_ID_FROM_BLOCK_ARI_REGEX = /ari:cloud:blocks:[^:]+:synced-block\/(.+)$/;
6
9
  var blockServiceClient = null;
7
10
 
8
11
  /**
@@ -122,8 +125,7 @@ export var extractGraphQLWSErrorMessage = function extractGraphQLWSErrorMessage(
122
125
  * @returns The resourceId portion of the ARI
123
126
  */
124
127
  var extractResourceIdFromBlockAri = function extractResourceIdFromBlockAri(blockAri) {
125
- // eslint-disable-next-line require-unicode-regexp
126
- var match = blockAri.match(/ari:cloud:blocks:[^:]+:synced-block\/(.+)$/);
128
+ var match = blockAri.match(EXTRACT_RESOURCE_ID_FROM_BLOCK_ARI_REGEX);
127
129
  return (match === null || match === void 0 ? void 0 : match[1]) || null;
128
130
  };
129
131
 
@@ -1,5 +1,7 @@
1
1
  /* eslint-disable require-unicode-regexp */
2
2
 
3
+ var CONFLUENCE_PAGE_ARI_REGEX = /ari:cloud:confluence:[^:]+:(page|blogpost)\/(\d+)/;
4
+
3
5
  /**
4
6
  * The type of the Confluence page
5
7
  */
@@ -25,7 +27,7 @@ export var getConfluencePageAri = function getConfluencePageAri(_ref) {
25
27
  */
26
28
  export var getPageIdAndTypeFromConfluencePageAri = function getPageIdAndTypeFromConfluencePageAri(_ref2) {
27
29
  var ari = _ref2.ari;
28
- var match = ari.match(/ari:cloud:confluence:[^:]+:(page|blogpost)\/(\d+)/);
30
+ var match = ari.match(CONFLUENCE_PAGE_ARI_REGEX);
29
31
  if (match !== null && match !== void 0 && match[2]) {
30
32
  return {
31
33
  type: match[1],
@@ -1,5 +1,7 @@
1
1
  /* eslint-disable require-unicode-regexp */
2
2
 
3
+ var JIRA_WORK_ITEM_ARI_REGEX = /ari:cloud:jira:([^:]+):issue\/(\d+)/;
4
+
3
5
  /**
4
6
  * Generates the Jira work item ARI
5
7
  * @param workItemId - the ID of the work item
@@ -19,7 +21,7 @@ export var getJiraWorkItemAri = function getJiraWorkItemAri(_ref) {
19
21
  */
20
22
  export var getJiraWorkItemIdFromAri = function getJiraWorkItemIdFromAri(_ref2) {
21
23
  var ari = _ref2.ari;
22
- var match = ari.match(/ari:cloud:jira:([^:]+):issue\/(\d+)/);
24
+ var match = ari.match(JIRA_WORK_ITEM_ARI_REGEX);
23
25
  if (match !== null && match !== void 0 && match[2]) {
24
26
  return match[2];
25
27
  }
@@ -18,6 +18,8 @@ import { SyncBlockError } from '../../common/types';
18
18
  import { stringifyError } from '../../utils/errorHandling';
19
19
  import { createResourceIdForReference } from '../../utils/resourceId';
20
20
  import { convertContentUpdatedAt } from '../../utils/utils';
21
+ var BLOCK_ARI_TO_RESOURCE_ID_REGEX = /^ari:cloud:blocks:.*:synced-block\/(.+)$/;
22
+ var EXTRACT_RESOURCE_ID_FROM_BLOCK_ARI_REGEX = /ari:cloud:blocks:[^:]+:synced-block\/(.+)$/;
21
23
  var mapBlockError = function mapBlockError(error) {
22
24
  switch (error.status) {
23
25
  case 400:
@@ -84,7 +86,7 @@ export var blockAriToResourceId = function blockAriToResourceId(blockAri) {
84
86
  // The regex captures the full path after synced-block/
85
87
  // e.g. ari:cloud:blocks:DUMMY-a5a01d21-1cc3-4f29-9565-f2bb8cd969f5:synced-block/confluence-page/455232061495/e8cf64e3-1b6e-489b-ad86-8465b0905bb4
86
88
  // should return confluence-page/455232061495/e8cf64e3-1b6e-489b-ad86-8465b0905bb4
87
- var match = blockAri.match(/^ari:cloud:blocks:.*:synced-block\/(.+)$/);
89
+ var match = blockAri.match(BLOCK_ARI_TO_RESOURCE_ID_REGEX);
88
90
  return (match === null || match === void 0 ? void 0 : match[1]) || null;
89
91
  };
90
92
 
@@ -193,7 +195,7 @@ export var fetchReferences = /*#__PURE__*/function () {
193
195
  * Block ARI format: ari:cloud:blocks:<cloudId>:synced-block/<resourceId>
194
196
  */
195
197
  export var extractResourceIdFromBlockAri = function extractResourceIdFromBlockAri(blockAri) {
196
- var match = blockAri.match(/ari:cloud:blocks:[^:]+:synced-block\/(.+)$/);
198
+ var match = blockAri.match(EXTRACT_RESOURCE_ID_FROM_BLOCK_ARI_REGEX);
197
199
  return match === null || match === void 0 ? void 0 : match[1];
198
200
  };
199
201
 
@@ -116,6 +116,10 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
116
116
  localId = _syncBlockNode$attrs.localId,
117
117
  resourceId = _syncBlockNode$attrs.resourceId;
118
118
  if (!localId || !resourceId) {
119
+ // Identifiers not populated yet: benign timing case, skip as a no-op.
120
+ if (fg('platform_editor_blocks_patch_4')) {
121
+ return false;
122
+ }
119
123
  throw new Error('Local ID or resource ID is not set');
120
124
  }
121
125
  var cachedBlock = this.syncBlockCache.get(resourceId);
@@ -3,6 +3,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
3
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
4
  /* eslint-disable require-unicode-regexp */
5
5
 
6
+ var GET_CONTENT_ID_AND_PRODUCT_REGEX = /^(confluence-page|jira-work-item)\/([^/]+)/;
6
7
  var _normalizeSyncBlockJSONContentInternal = function normalizeSyncBlockJSONContentInternal(content, options) {
7
8
  var normalizedContent;
8
9
  content.forEach(function (contentNode, index) {
@@ -102,7 +103,7 @@ export var convertPMNodesToSyncBlockNodes = function convertPMNodesToSyncBlockNo
102
103
  * Extracts the source page content id and source product
103
104
  */
104
105
  export var getContentIdAndProductFromResourceId = function getContentIdAndProductFromResourceId(resourceId) {
105
- var match = resourceId.match(/^(confluence-page|jira-work-item)\/([^/]+)/);
106
+ var match = resourceId.match(GET_CONTENT_ID_AND_PRODUCT_REGEX);
106
107
  if (match !== null && match !== void 0 && match[2]) {
107
108
  return {
108
109
  sourceProduct: match[1],
package/package.json CHANGED
@@ -21,7 +21,7 @@
21
21
  "@atlaskit/editor-prosemirror": "^8.0.0",
22
22
  "@atlaskit/node-data-provider": "^13.0.0",
23
23
  "@atlaskit/platform-feature-flags": "^2.0.0",
24
- "@atlaskit/tmp-editor-statsig": "^114.4.0",
24
+ "@atlaskit/tmp-editor-statsig": "^114.6.0",
25
25
  "@babel/runtime": "^7.0.0",
26
26
  "@compiled/react": "^0.20.0",
27
27
  "graphql-ws": "^5.14.2",
@@ -74,7 +74,7 @@
74
74
  }
75
75
  },
76
76
  "name": "@atlaskit/editor-synced-block-provider",
77
- "version": "8.3.0",
77
+ "version": "8.4.0",
78
78
  "description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
79
79
  "author": "Atlassian Pty Ltd",
80
80
  "license": "Apache-2.0",
@@ -88,6 +88,9 @@
88
88
  "platform_editor_blocks_patch_3": {
89
89
  "type": "boolean"
90
90
  },
91
+ "platform_editor_blocks_patch_4": {
92
+ "type": "boolean"
93
+ },
91
94
  "platform_synced_block_patch_13": {
92
95
  "type": "boolean"
93
96
  },