@atlaskit/editor-synced-block-provider 3.10.0 → 3.12.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,20 @@
1
1
  # @atlaskit/editor-synced-block-provider
2
2
 
3
+ ## 3.12.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`3d9abca1c1cd9`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3d9abca1c1cd9) -
8
+ The batch retrieve of the blocks must also send document ARI and also the local instance ID of the
9
+ reference blocks
10
+
11
+ ## 3.11.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [`7b4cb91fc67a6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7b4cb91fc67a6) -
16
+ Do not immediately show error state on initial load of blocks
17
+
3
18
  ## 3.10.0
4
19
 
5
20
  ### Minor Changes
@@ -137,11 +137,11 @@ var BlockError = exports.BlockError = /*#__PURE__*/function (_Error) {
137
137
  }( /*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
138
138
  var getSyncedBlockContent = exports.getSyncedBlockContent = /*#__PURE__*/function () {
139
139
  var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(_ref2) {
140
- var blockAri, queryParams, response;
140
+ var blockAri, documentAri, queryParams, response;
141
141
  return _regenerator.default.wrap(function _callee2$(_context2) {
142
142
  while (1) switch (_context2.prev = _context2.next) {
143
143
  case 0:
144
- blockAri = _ref2.blockAri;
144
+ blockAri = _ref2.blockAri, documentAri = _ref2.documentAri;
145
145
  // Disable sending documentAri for now. We'll add it back if we find a way to update references that follows the save & refresh principle.
146
146
  // Slack discussion here: https://atlassian.slack.com/archives/C09DZT1TBNW/p1767836775552099?thread_ts=1767836754.024889&cid=C09DZT1TBNW
147
147
  // const queryParams = documentAri ? `?documentAri=${encodeURIComponent(documentAri)}` : '';
@@ -346,7 +346,7 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
346
346
 
347
347
  /**
348
348
  * Batch fetches multiple synced blocks by their resource IDs.
349
- * @param blockNodeIdentifiers - Array of block node identifiers, containing block instance (local) ID + resource IDs to fetch
349
+ * @param resourceIds - Array of resource IDs to fetch
350
350
  * @returns Array of SyncBlockInstance results
351
351
  */
352
352
  }, {
@@ -115,11 +115,21 @@ var SyncBlockProvider = exports.SyncBlockProvider = /*#__PURE__*/function (_Sync
115
115
  case 10:
116
116
  _context.prev = 10;
117
117
  _context.t0 = _context["catch"](4);
118
- return _context.abrupt("return", blockIdentifiers.map(function (blockIdentifier) {
119
- return {
120
- error: _types.SyncBlockError.Errored,
121
- resourceId: blockIdentifier.resourceId
122
- };
118
+ return _context.abrupt("return", Promise.allSettled(blockIdentifiers.map(function (blockIdentifier) {
119
+ return _this2.fetchProvider.fetchData(blockIdentifier.resourceId).then(function (data) {
120
+ return data;
121
+ }, function () {
122
+ return {
123
+ error: _types.SyncBlockError.Errored,
124
+ resourceId: blockIdentifier.resourceId
125
+ };
126
+ });
127
+ })).then(function (results) {
128
+ return results.filter(function (result) {
129
+ return result.status === 'fulfilled';
130
+ }).map(function (result) {
131
+ return result.value;
132
+ });
123
133
  }));
124
134
  case 13:
125
135
  _context.next = 16;
@@ -100,8 +100,8 @@ export class BlockError extends Error {
100
100
  }
101
101
  }
102
102
  export const getSyncedBlockContent = async ({
103
- blockAri
104
- // documentAri,
103
+ blockAri,
104
+ documentAri
105
105
  }) => {
106
106
  // Disable sending documentAri for now. We'll add it back if we find a way to update references that follows the save & refresh principle.
107
107
  // Slack discussion here: https://atlassian.slack.com/archives/C09DZT1TBNW/p1767836775552099?thread_ts=1767836754.024889&cid=C09DZT1TBNW
@@ -256,7 +256,7 @@ class BlockServiceADFFetchProvider {
256
256
 
257
257
  /**
258
258
  * Batch fetches multiple synced blocks by their resource IDs.
259
- * @param blockNodeIdentifiers - Array of block node identifiers, containing block instance (local) ID + resource IDs to fetch
259
+ * @param resourceIds - Array of resource IDs to fetch
260
260
  * @returns Array of SyncBlockInstance results
261
261
  */
262
262
  async batchFetchData(blockNodeIdentifiers) {
@@ -66,11 +66,22 @@ export class SyncBlockProvider extends SyncBlockDataProvider {
66
66
  try {
67
67
  return await this.fetchProvider.batchFetchData(blockIdentifiers);
68
68
  } catch {
69
- // If batch fetch fails, return error for all resourceIds
70
- return blockIdentifiers.map(blockIdentifier => ({
71
- error: SyncBlockError.Errored,
72
- resourceId: blockIdentifier.resourceId
73
- }));
69
+ // If batch fetch fails, fall back to individual fetch behavior
70
+ // This allows loading states to be shown before errors, matching non-batch behavior
71
+ return Promise.allSettled(blockIdentifiers.map(blockIdentifier => {
72
+ return this.fetchProvider.fetchData(blockIdentifier.resourceId).then(data => {
73
+ return data;
74
+ }, () => {
75
+ return {
76
+ error: SyncBlockError.Errored,
77
+ resourceId: blockIdentifier.resourceId
78
+ };
79
+ });
80
+ })).then(results => {
81
+ return results.filter(result => {
82
+ return result.status === 'fulfilled';
83
+ }).map(result => result.value);
84
+ });
74
85
  }
75
86
  } else {
76
87
  return Promise.allSettled(blockIdentifiers.map(blockIdentifier => {
@@ -130,11 +130,11 @@ export var BlockError = /*#__PURE__*/function (_Error) {
130
130
  }( /*#__PURE__*/_wrapNativeSuper(Error));
131
131
  export var getSyncedBlockContent = /*#__PURE__*/function () {
132
132
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref2) {
133
- var blockAri, queryParams, response;
133
+ var blockAri, documentAri, queryParams, response;
134
134
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
135
135
  while (1) switch (_context2.prev = _context2.next) {
136
136
  case 0:
137
- blockAri = _ref2.blockAri;
137
+ blockAri = _ref2.blockAri, documentAri = _ref2.documentAri;
138
138
  // Disable sending documentAri for now. We'll add it back if we find a way to update references that follows the save & refresh principle.
139
139
  // Slack discussion here: https://atlassian.slack.com/archives/C09DZT1TBNW/p1767836775552099?thread_ts=1767836754.024889&cid=C09DZT1TBNW
140
140
  // const queryParams = documentAri ? `?documentAri=${encodeURIComponent(documentAri)}` : '';
@@ -340,7 +340,7 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
340
340
 
341
341
  /**
342
342
  * Batch fetches multiple synced blocks by their resource IDs.
343
- * @param blockNodeIdentifiers - Array of block node identifiers, containing block instance (local) ID + resource IDs to fetch
343
+ * @param resourceIds - Array of resource IDs to fetch
344
344
  * @returns Array of SyncBlockInstance results
345
345
  */
346
346
  }, {
@@ -108,11 +108,21 @@ export var SyncBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
108
108
  case 10:
109
109
  _context.prev = 10;
110
110
  _context.t0 = _context["catch"](4);
111
- return _context.abrupt("return", blockIdentifiers.map(function (blockIdentifier) {
112
- return {
113
- error: SyncBlockError.Errored,
114
- resourceId: blockIdentifier.resourceId
115
- };
111
+ return _context.abrupt("return", Promise.allSettled(blockIdentifiers.map(function (blockIdentifier) {
112
+ return _this2.fetchProvider.fetchData(blockIdentifier.resourceId).then(function (data) {
113
+ return data;
114
+ }, function () {
115
+ return {
116
+ error: SyncBlockError.Errored,
117
+ resourceId: blockIdentifier.resourceId
118
+ };
119
+ });
120
+ })).then(function (results) {
121
+ return results.filter(function (result) {
122
+ return result.status === 'fulfilled';
123
+ }).map(function (result) {
124
+ return result.value;
125
+ });
116
126
  }));
117
127
  case 13:
118
128
  _context.next = 16;
@@ -92,14 +92,14 @@ type UpdateReferenceSyncedBlockOnDocumentRequest = {
92
92
  documentAri: string;
93
93
  noContent?: boolean;
94
94
  };
95
- type BlockIdentifier = {
96
- blockAri: string;
97
- blockInstanceId: string;
98
- };
99
95
  export type BatchRetrieveSyncedBlocksRequest = {
100
96
  blockIdentifiers: BlockIdentifier[];
101
97
  documentAri: string;
102
98
  };
99
+ type BlockIdentifier = {
100
+ blockAri: string;
101
+ blockInstanceId: string;
102
+ };
103
103
  export type BatchRetrieveSyncedBlocksResponse = {
104
104
  error?: Array<ErrorResponse>;
105
105
  success?: Array<BlockContentResponse>;
@@ -116,7 +116,7 @@ export declare class BlockError extends Error {
116
116
  readonly status: number;
117
117
  constructor(status: number);
118
118
  }
119
- export declare const getSyncedBlockContent: ({ blockAri, }: GetSyncedBlockContentRequest) => Promise<BlockContentResponse>;
119
+ export declare const getSyncedBlockContent: ({ blockAri, documentAri, }: GetSyncedBlockContentRequest) => Promise<BlockContentResponse>;
120
120
  /**
121
121
  * Batch retrieves multiple synced blocks by their ARIs.
122
122
  *
@@ -40,7 +40,7 @@ declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
40
40
  private extractResourceIdFromBlockAri;
41
41
  /**
42
42
  * Batch fetches multiple synced blocks by their resource IDs.
43
- * @param blockNodeIdentifiers - Array of block node identifiers, containing block instance (local) ID + resource IDs to fetch
43
+ * @param resourceIds - Array of resource IDs to fetch
44
44
  * @returns Array of SyncBlockInstance results
45
45
  */
46
46
  batchFetchData(blockNodeIdentifiers: BlockNodeIdentifiers[]): Promise<SyncBlockInstance[]>;
@@ -5,6 +5,10 @@ import type { MentionProvider } from '@atlaskit/mention/types';
5
5
  import { NodeDataProvider } from '@atlaskit/node-data-provider';
6
6
  import type { TaskDecisionProvider } from '@atlaskit/task-decision/types';
7
7
  import type { SyncBlockData, ResourceId, SyncBlockError, SyncBlockNode, SyncBlockProduct, BlockInstanceId, SyncBlockAttrs, ReferenceSyncBlockData } from '../common/types';
8
+ export type BlockNodeIdentifiers = {
9
+ blockInstanceId: string;
10
+ resourceId: string;
11
+ };
8
12
  /**
9
13
  * The instance of a sync block, containing its data and metadata.
10
14
  * Mainly used for representing the state of a sync block after fetching from a data provider.
@@ -52,10 +56,6 @@ export type UpdateReferenceSyncBlockResult = {
52
56
  error?: string;
53
57
  success: boolean;
54
58
  };
55
- export type BlockNodeIdentifiers = {
56
- blockInstanceId: string;
57
- resourceId: string;
58
- };
59
59
  export interface ADFFetchProvider {
60
60
  batchFetchData: (blockNodeIdentifiers: BlockNodeIdentifiers[]) => Promise<SyncBlockInstance[]>;
61
61
  fetchData: (resourceId: ResourceId) => Promise<SyncBlockInstance>;
@@ -88,8 +88,8 @@ export type SyncedBlockRendererDataProviders = {
88
88
  export type SyncBlockRendererProviderCreator = {
89
89
  createEmojiProvider: ((options: MediaEmojiProviderOptions) => Promise<EmojiProvider> | undefined) | undefined;
90
90
  createMediaProvider: ((options: MediaEmojiProviderOptions) => Promise<MediaProvider> | undefined) | undefined;
91
- createSmartLinkProvider: (() => Promise<CardProvider>) | undefined;
92
91
  createSSRMediaProvider?: ((options: MediaEmojiProviderOptions) => MediaProvider | undefined) | undefined;
92
+ createSmartLinkProvider: (() => Promise<CardProvider>) | undefined;
93
93
  };
94
94
  export type SyncedBlockRendererProviderOptions = {
95
95
  parentDataProviders?: SyncedBlockRendererDataProviders;
@@ -92,14 +92,14 @@ type UpdateReferenceSyncedBlockOnDocumentRequest = {
92
92
  documentAri: string;
93
93
  noContent?: boolean;
94
94
  };
95
- type BlockIdentifier = {
96
- blockAri: string;
97
- blockInstanceId: string;
98
- };
99
95
  export type BatchRetrieveSyncedBlocksRequest = {
100
96
  blockIdentifiers: BlockIdentifier[];
101
97
  documentAri: string;
102
98
  };
99
+ type BlockIdentifier = {
100
+ blockAri: string;
101
+ blockInstanceId: string;
102
+ };
103
103
  export type BatchRetrieveSyncedBlocksResponse = {
104
104
  error?: Array<ErrorResponse>;
105
105
  success?: Array<BlockContentResponse>;
@@ -116,7 +116,7 @@ export declare class BlockError extends Error {
116
116
  readonly status: number;
117
117
  constructor(status: number);
118
118
  }
119
- export declare const getSyncedBlockContent: ({ blockAri, }: GetSyncedBlockContentRequest) => Promise<BlockContentResponse>;
119
+ export declare const getSyncedBlockContent: ({ blockAri, documentAri, }: GetSyncedBlockContentRequest) => Promise<BlockContentResponse>;
120
120
  /**
121
121
  * Batch retrieves multiple synced blocks by their ARIs.
122
122
  *
@@ -40,7 +40,7 @@ declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
40
40
  private extractResourceIdFromBlockAri;
41
41
  /**
42
42
  * Batch fetches multiple synced blocks by their resource IDs.
43
- * @param blockNodeIdentifiers - Array of block node identifiers, containing block instance (local) ID + resource IDs to fetch
43
+ * @param resourceIds - Array of resource IDs to fetch
44
44
  * @returns Array of SyncBlockInstance results
45
45
  */
46
46
  batchFetchData(blockNodeIdentifiers: BlockNodeIdentifiers[]): Promise<SyncBlockInstance[]>;
@@ -5,6 +5,10 @@ import type { MentionProvider } from '@atlaskit/mention/types';
5
5
  import { NodeDataProvider } from '@atlaskit/node-data-provider';
6
6
  import type { TaskDecisionProvider } from '@atlaskit/task-decision/types';
7
7
  import type { SyncBlockData, ResourceId, SyncBlockError, SyncBlockNode, SyncBlockProduct, BlockInstanceId, SyncBlockAttrs, ReferenceSyncBlockData } from '../common/types';
8
+ export type BlockNodeIdentifiers = {
9
+ blockInstanceId: string;
10
+ resourceId: string;
11
+ };
8
12
  /**
9
13
  * The instance of a sync block, containing its data and metadata.
10
14
  * Mainly used for representing the state of a sync block after fetching from a data provider.
@@ -52,10 +56,6 @@ export type UpdateReferenceSyncBlockResult = {
52
56
  error?: string;
53
57
  success: boolean;
54
58
  };
55
- export type BlockNodeIdentifiers = {
56
- blockInstanceId: string;
57
- resourceId: string;
58
- };
59
59
  export interface ADFFetchProvider {
60
60
  batchFetchData: (blockNodeIdentifiers: BlockNodeIdentifiers[]) => Promise<SyncBlockInstance[]>;
61
61
  fetchData: (resourceId: ResourceId) => Promise<SyncBlockInstance>;
@@ -88,8 +88,8 @@ export type SyncedBlockRendererDataProviders = {
88
88
  export type SyncBlockRendererProviderCreator = {
89
89
  createEmojiProvider: ((options: MediaEmojiProviderOptions) => Promise<EmojiProvider> | undefined) | undefined;
90
90
  createMediaProvider: ((options: MediaEmojiProviderOptions) => Promise<MediaProvider> | undefined) | undefined;
91
- createSmartLinkProvider: (() => Promise<CardProvider>) | undefined;
92
91
  createSSRMediaProvider?: ((options: MediaEmojiProviderOptions) => MediaProvider | undefined) | undefined;
92
+ createSmartLinkProvider: (() => Promise<CardProvider>) | undefined;
93
93
  };
94
94
  export type SyncedBlockRendererProviderOptions = {
95
95
  parentDataProviders?: SyncedBlockRendererDataProviders;
package/package.json CHANGED
@@ -24,7 +24,7 @@
24
24
  ],
25
25
  "atlaskit:src": "src/index.ts",
26
26
  "dependencies": {
27
- "@atlaskit/adf-utils": "^19.26.0",
27
+ "@atlaskit/adf-utils": "^19.27.0",
28
28
  "@atlaskit/editor-json-transformer": "^8.31.0",
29
29
  "@atlaskit/editor-prosemirror": "^7.2.0",
30
30
  "@atlaskit/node-data-provider": "^8.0.0",
@@ -77,7 +77,7 @@
77
77
  }
78
78
  },
79
79
  "name": "@atlaskit/editor-synced-block-provider",
80
- "version": "3.10.0",
80
+ "version": "3.12.0",
81
81
  "description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
82
82
  "author": "Atlassian Pty Ltd",
83
83
  "license": "Apache-2.0",