@atlaskit/media-client 28.3.0 → 28.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,22 @@
1
1
  # @atlaskit/media-client
2
2
 
3
+ ## 28.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#170821](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/170821)
8
+ [`52532d238c0b6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/52532d238c0b6) -
9
+ Enabled the deduplication of files in media-filmstrip by passing includeHashForDuplicateFiles flag
10
+ to /items
11
+
12
+ ## 28.3.1
13
+
14
+ ### Patch Changes
15
+
16
+ - [#165609](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/165609)
17
+ [`b29c0cc4fef46`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b29c0cc4fef46) -
18
+ Cleaned up media card perf observer feature flag
19
+
3
20
  ## 28.3.0
4
21
 
5
22
  ### Minor Changes
@@ -86,7 +86,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
86
86
  });
87
87
  });
88
88
  // TODO: ----- ADD TICKET TO PASS TRACE ID to this.dataloader.load
89
- (0, _defineProperty2.default)(this, "createDownloadFileStream", function (id, collectionName, occurrenceKey) {
89
+ (0, _defineProperty2.default)(this, "createDownloadFileStream", function (id, collectionName, occurrenceKey, includeHashForDuplicateFiles) {
90
90
  var subject = (0, _createMediaSubject.createMediaSubject)();
91
91
  var poll = new _polling.PollingFunction();
92
92
 
@@ -102,7 +102,8 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
102
102
  _context.next = 2;
103
103
  return _this.dataloader.load({
104
104
  id: id,
105
- collectionName: collectionName
105
+ collectionName: collectionName,
106
+ includeHashForDuplicateFiles: includeHashForDuplicateFiles
106
107
  });
107
108
  case 2:
108
109
  response = _context.sent;
@@ -189,7 +190,8 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
189
190
  var _this2 = this;
190
191
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
191
192
  var collectionName = options.collectionName,
192
- occurrenceKey = options.occurrenceKey;
193
+ occurrenceKey = options.occurrenceKey,
194
+ includeHashForDuplicateFiles = options.includeHashForDuplicateFiles;
193
195
  if (!(0, _uuidValidate.default)(id)) {
194
196
  var _err$attributes;
195
197
  var subject = (0, _createMediaSubject.createMediaSubject)();
@@ -215,7 +217,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
215
217
  return (0, _mediaSubscribable.fromObservable)(subject);
216
218
  }
217
219
  return (0, _mediaSubscribable.fromObservable)((0, _fileStreamsCache.getFileStreamsCache)().getOrInsert(id, function () {
218
- var subject = _this2.createDownloadFileStream(id, collectionName);
220
+ var subject = _this2.createDownloadFileStream(id, collectionName, undefined, includeHashForDuplicateFiles);
219
221
  subject.subscribe({
220
222
  next: function next(fileState) {
221
223
  _this2.setFileState(id, fileState);
@@ -452,7 +452,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
452
452
  params: extendImageParams(params, fetchMaxRes),
453
453
  headers: headers,
454
454
  traceContext: traceContext,
455
- addMediaClientParam: (0, _platformFeatureFlags.fg)('platform.media-card-performance-observer_a803k') && true
455
+ addMediaClientParam: true
456
456
  });
457
457
  return _context8.abrupt("return", this.request("/file/".concat(id, "/").concat(imageEndpoint), options, controller, true).then((0, _helpers.createMapResponseToBlob)(metadata)));
458
458
  case 7:
@@ -469,7 +469,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
469
469
  }, {
470
470
  key: "getItems",
471
471
  value: function () {
472
- var _getItems = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(ids, collectionName, traceContext) {
472
+ var _getItems = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(ids, collectionName, traceContext, includeHashForDuplicateFiles) {
473
473
  var descriptors, metadata, options;
474
474
  return _regenerator.default.wrap(function _callee9$(_context9) {
475
475
  while (1) switch (_context9.prev = _context9.next) {
@@ -491,7 +491,8 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
491
491
  },
492
492
  headers: jsonHeaders,
493
493
  body: JSON.stringify({
494
- descriptors: descriptors
494
+ descriptors: descriptors,
495
+ includeHashForDuplicateFiles: includeHashForDuplicateFiles
495
496
  }),
496
497
  traceContext: traceContext
497
498
  });
@@ -502,7 +503,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
502
503
  }
503
504
  }, _callee9, this);
504
505
  }));
505
- function getItems(_x27, _x28, _x29) {
506
+ function getItems(_x27, _x28, _x29, _x30) {
506
507
  return _getItems.apply(this, arguments);
507
508
  }
508
509
  return getItems;
@@ -533,7 +534,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
533
534
  }
534
535
  }, _callee10, this);
535
536
  }));
536
- function getImageMetadata(_x30, _x31, _x32) {
537
+ function getImageMetadata(_x31, _x32, _x33) {
537
538
  return _getImageMetadata.apply(this, arguments);
538
539
  }
539
540
  return getImageMetadata;
@@ -566,7 +567,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
566
567
  }
567
568
  }, _callee11, this);
568
569
  }));
569
- function appendChunksToUpload(_x33, _x34, _x35, _x36) {
570
+ function appendChunksToUpload(_x34, _x35, _x36, _x37) {
570
571
  return _appendChunksToUpload.apply(this, arguments);
571
572
  }
572
573
  return appendChunksToUpload;
@@ -661,7 +662,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
661
662
  }
662
663
  }, _callee12, this);
663
664
  }));
664
- function request(_x37) {
665
+ function request(_x38) {
665
666
  return _request2.apply(this, arguments);
666
667
  }
667
668
  return request;
@@ -694,7 +695,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
694
695
  }
695
696
  }, _callee13);
696
697
  }));
697
- function testUrl(_x38) {
698
+ function testUrl(_x39) {
698
699
  return _testUrl.apply(this, arguments);
699
700
  }
700
701
  return testUrl;
@@ -47,7 +47,8 @@ var mapMediaFileToFileState = exports.mapMediaFileToFileState = function mapMedi
47
47
  mimeType = _mediaFile$data.mimeType,
48
48
  representations = _mediaFile$data.representations,
49
49
  createdAt = _mediaFile$data.createdAt,
50
- metadataTraceContext = _mediaFile$data.metadataTraceContext;
50
+ metadataTraceContext = _mediaFile$data.metadataTraceContext,
51
+ hash = _mediaFile$data.hash;
51
52
  var baseState = {
52
53
  id: id,
53
54
  name: name,
@@ -57,6 +58,7 @@ var mapMediaFileToFileState = exports.mapMediaFileToFileState = function mapMedi
57
58
  artifacts: artifacts,
58
59
  representations: representations,
59
60
  createdAt: createdAt,
61
+ hash: hash,
60
62
  metadataTraceContext: metadataTraceContext
61
63
  };
62
64
  switch (processingStatus) {
@@ -69,11 +69,18 @@ var getItemsFromKeys = exports.getItemsFromKeys = function getItemsFromKeys(data
69
69
  function createBatchLoadingFunc(mediaStore) {
70
70
  return /*#__PURE__*/function () {
71
71
  var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(keys) {
72
- var nonCollectionName, fileIdsByCollection, items;
72
+ var nonCollectionName, includeHashByCollection, fileIdsByCollection, items;
73
73
  return _regenerator.default.wrap(function _callee2$(_context2) {
74
74
  while (1) switch (_context2.prev = _context2.next) {
75
75
  case 0:
76
76
  nonCollectionName = '__media-single-file-collection__';
77
+ includeHashByCollection = keys.reduce(function (acc, key) {
78
+ var collectionName = key.collectionName || nonCollectionName;
79
+ if (key.includeHashForDuplicateFiles) {
80
+ acc[collectionName] = key.includeHashForDuplicateFiles;
81
+ }
82
+ return acc;
83
+ }, {});
77
84
  fileIdsByCollection = keys.reduce(function (acc, key) {
78
85
  var collectionName = key.collectionName || nonCollectionName;
79
86
  var fileIds = acc[collectionName] || [];
@@ -86,10 +93,10 @@ function createBatchLoadingFunc(mediaStore) {
86
93
  return acc;
87
94
  }, {});
88
95
  items = [];
89
- _context2.next = 5;
96
+ _context2.next = 6;
90
97
  return Promise.all(Object.keys(fileIdsByCollection).map( /*#__PURE__*/function () {
91
98
  var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(collectionNameKey) {
92
- var metadataTraceContext, fileIds, collectionName, response, itemsWithMetadataTraceContext, itemsIds, fileIdsNotFound;
99
+ var metadataTraceContext, fileIds, includeHashForDuplicateFiles, collectionName, response, itemsWithMetadataTraceContext, itemsIds, fileIdsNotFound;
93
100
  return _regenerator.default.wrap(function _callee$(_context) {
94
101
  while (1) switch (_context.prev = _context.next) {
95
102
  case 0:
@@ -98,11 +105,12 @@ function createBatchLoadingFunc(mediaStore) {
98
105
  spanId: (0, _mediaCommon.getRandomHex)(8)
99
106
  };
100
107
  fileIds = fileIdsByCollection[collectionNameKey];
108
+ includeHashForDuplicateFiles = includeHashByCollection[collectionNameKey];
101
109
  collectionName = collectionNameKey === nonCollectionName ? undefined : collectionNameKey;
102
- _context.prev = 3;
103
- _context.next = 6;
104
- return mediaStore.getItems(fileIds, collectionName, metadataTraceContext);
105
- case 6:
110
+ _context.prev = 4;
111
+ _context.next = 7;
112
+ return mediaStore.getItems(fileIds, collectionName, metadataTraceContext, includeHashForDuplicateFiles);
113
+ case 7:
106
114
  response = _context.sent;
107
115
  itemsWithMetadataTraceContext = response.data.items.map(function (item) {
108
116
  return _objectSpread(_objectSpread({}, item), {}, {
@@ -126,11 +134,11 @@ function createBatchLoadingFunc(mediaStore) {
126
134
  metadataTraceContext: metadataTraceContext
127
135
  });
128
136
  });
129
- _context.next = 17;
137
+ _context.next = 18;
130
138
  break;
131
- case 14:
132
- _context.prev = 14;
133
- _context.t0 = _context["catch"](3);
139
+ case 15:
140
+ _context.prev = 15;
141
+ _context.t0 = _context["catch"](4);
134
142
  fileIds.forEach(function (fileId) {
135
143
  items.push({
136
144
  id: fileId,
@@ -138,19 +146,19 @@ function createBatchLoadingFunc(mediaStore) {
138
146
  error: _context.t0
139
147
  });
140
148
  });
141
- case 17:
149
+ case 18:
142
150
  case "end":
143
151
  return _context.stop();
144
152
  }
145
- }, _callee, null, [[3, 14]]);
153
+ }, _callee, null, [[4, 15]]);
146
154
  }));
147
155
  return function (_x2) {
148
156
  return _ref2.apply(this, arguments);
149
157
  };
150
158
  }()));
151
- case 5:
152
- return _context2.abrupt("return", getItemsFromKeys(keys, items));
153
159
  case 6:
160
+ return _context2.abrupt("return", getItemsFromKeys(keys, items));
161
+ case 7:
154
162
  case "end":
155
163
  return _context2.stop();
156
164
  }
@@ -60,7 +60,7 @@ export class FileFetcherImpl {
60
60
  });
61
61
  });
62
62
  // TODO: ----- ADD TICKET TO PASS TRACE ID to this.dataloader.load
63
- _defineProperty(this, "createDownloadFileStream", (id, collectionName, occurrenceKey) => {
63
+ _defineProperty(this, "createDownloadFileStream", (id, collectionName, occurrenceKey, includeHashForDuplicateFiles) => {
64
64
  const subject = createMediaSubject();
65
65
  const poll = new PollingFunction();
66
66
 
@@ -69,7 +69,8 @@ export class FileFetcherImpl {
69
69
  poll.execute(async () => {
70
70
  const response = await this.dataloader.load({
71
71
  id,
72
- collectionName
72
+ collectionName,
73
+ includeHashForDuplicateFiles
73
74
  });
74
75
  if (isNotFoundMediaItemDetails(response)) {
75
76
  throw new FileFetcherError('emptyItems', id, {
@@ -142,7 +143,8 @@ export class FileFetcherImpl {
142
143
  getFileState(id, options = {}) {
143
144
  const {
144
145
  collectionName,
145
- occurrenceKey
146
+ occurrenceKey,
147
+ includeHashForDuplicateFiles
146
148
  } = options;
147
149
  if (!isValidId(id)) {
148
150
  var _err$attributes;
@@ -173,7 +175,7 @@ export class FileFetcherImpl {
173
175
  return fromObservable(subject);
174
176
  }
175
177
  return fromObservable(getFileStreamsCache().getOrInsert(id, () => {
176
- const subject = this.createDownloadFileStream(id, collectionName);
178
+ const subject = this.createDownloadFileStream(id, collectionName, undefined, includeHashForDuplicateFiles);
177
179
  subject.subscribe({
178
180
  next: fileState => {
179
181
  this.setFileState(id, fileState);
@@ -271,11 +271,11 @@ export class MediaStore {
271
271
  params: extendImageParams(params, fetchMaxRes),
272
272
  headers,
273
273
  traceContext,
274
- addMediaClientParam: fg('platform.media-card-performance-observer_a803k') && true
274
+ addMediaClientParam: true
275
275
  };
276
276
  return this.request(`/file/${id}/${imageEndpoint}`, options, controller, true).then(createMapResponseToBlob(metadata));
277
277
  }
278
- async getItems(ids, collectionName, traceContext) {
278
+ async getItems(ids, collectionName, traceContext, includeHashForDuplicateFiles) {
279
279
  const descriptors = ids.map(id => ({
280
280
  type: 'file',
281
281
  id,
@@ -292,7 +292,8 @@ export class MediaStore {
292
292
  },
293
293
  headers: jsonHeaders,
294
294
  body: JSON.stringify({
295
- descriptors
295
+ descriptors,
296
+ includeHashForDuplicateFiles
296
297
  }),
297
298
  traceContext
298
299
  };
@@ -25,7 +25,8 @@ export const mapMediaFileToFileState = mediaFile => {
25
25
  mimeType,
26
26
  representations,
27
27
  createdAt,
28
- metadataTraceContext
28
+ metadataTraceContext,
29
+ hash
29
30
  } = mediaFile.data;
30
31
  const baseState = {
31
32
  id,
@@ -36,6 +37,7 @@ export const mapMediaFileToFileState = mediaFile => {
36
37
  artifacts,
37
38
  representations,
38
39
  createdAt,
40
+ hash,
39
41
  metadataTraceContext
40
42
  };
41
43
  switch (processingStatus) {
@@ -56,6 +56,13 @@ export const getItemsFromKeys = (dataloaderKeys, fileItems) => {
56
56
  export function createBatchLoadingFunc(mediaStore) {
57
57
  return async keys => {
58
58
  const nonCollectionName = '__media-single-file-collection__';
59
+ const includeHashByCollection = keys.reduce((acc, key) => {
60
+ const collectionName = key.collectionName || nonCollectionName;
61
+ if (key.includeHashForDuplicateFiles) {
62
+ acc[collectionName] = key.includeHashForDuplicateFiles;
63
+ }
64
+ return acc;
65
+ }, {});
59
66
  const fileIdsByCollection = keys.reduce((acc, key) => {
60
67
  const collectionName = key.collectionName || nonCollectionName;
61
68
  const fileIds = acc[collectionName] || [];
@@ -74,9 +81,10 @@ export function createBatchLoadingFunc(mediaStore) {
74
81
  spanId: getRandomHex(8)
75
82
  };
76
83
  const fileIds = fileIdsByCollection[collectionNameKey];
84
+ const includeHashForDuplicateFiles = includeHashByCollection[collectionNameKey];
77
85
  const collectionName = collectionNameKey === nonCollectionName ? undefined : collectionNameKey;
78
86
  try {
79
- const response = await mediaStore.getItems(fileIds, collectionName, metadataTraceContext);
87
+ const response = await mediaStore.getItems(fileIds, collectionName, metadataTraceContext, includeHashForDuplicateFiles);
80
88
  const itemsWithMetadataTraceContext = response.data.items.map(item => ({
81
89
  ...item,
82
90
  metadataTraceContext
@@ -68,7 +68,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
68
68
  });
69
69
  });
70
70
  // TODO: ----- ADD TICKET TO PASS TRACE ID to this.dataloader.load
71
- _defineProperty(this, "createDownloadFileStream", function (id, collectionName, occurrenceKey) {
71
+ _defineProperty(this, "createDownloadFileStream", function (id, collectionName, occurrenceKey, includeHashForDuplicateFiles) {
72
72
  var subject = createMediaSubject();
73
73
  var poll = new PollingFunction();
74
74
 
@@ -84,7 +84,8 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
84
84
  _context.next = 2;
85
85
  return _this.dataloader.load({
86
86
  id: id,
87
- collectionName: collectionName
87
+ collectionName: collectionName,
88
+ includeHashForDuplicateFiles: includeHashForDuplicateFiles
88
89
  });
89
90
  case 2:
90
91
  response = _context.sent;
@@ -171,7 +172,8 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
171
172
  var _this2 = this;
172
173
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
173
174
  var collectionName = options.collectionName,
174
- occurrenceKey = options.occurrenceKey;
175
+ occurrenceKey = options.occurrenceKey,
176
+ includeHashForDuplicateFiles = options.includeHashForDuplicateFiles;
175
177
  if (!isValidId(id)) {
176
178
  var _err$attributes;
177
179
  var subject = createMediaSubject();
@@ -197,7 +199,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
197
199
  return fromObservable(subject);
198
200
  }
199
201
  return fromObservable(getFileStreamsCache().getOrInsert(id, function () {
200
- var subject = _this2.createDownloadFileStream(id, collectionName);
202
+ var subject = _this2.createDownloadFileStream(id, collectionName, undefined, includeHashForDuplicateFiles);
201
203
  subject.subscribe({
202
204
  next: function next(fileState) {
203
205
  _this2.setFileState(id, fileState);
@@ -446,7 +446,7 @@ export var MediaStore = /*#__PURE__*/function () {
446
446
  params: extendImageParams(params, fetchMaxRes),
447
447
  headers: headers,
448
448
  traceContext: traceContext,
449
- addMediaClientParam: fg('platform.media-card-performance-observer_a803k') && true
449
+ addMediaClientParam: true
450
450
  });
451
451
  return _context8.abrupt("return", this.request("/file/".concat(id, "/").concat(imageEndpoint), options, controller, true).then(createMapResponseToBlob(metadata)));
452
452
  case 7:
@@ -463,7 +463,7 @@ export var MediaStore = /*#__PURE__*/function () {
463
463
  }, {
464
464
  key: "getItems",
465
465
  value: function () {
466
- var _getItems = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(ids, collectionName, traceContext) {
466
+ var _getItems = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(ids, collectionName, traceContext, includeHashForDuplicateFiles) {
467
467
  var descriptors, metadata, options;
468
468
  return _regeneratorRuntime.wrap(function _callee9$(_context9) {
469
469
  while (1) switch (_context9.prev = _context9.next) {
@@ -485,7 +485,8 @@ export var MediaStore = /*#__PURE__*/function () {
485
485
  },
486
486
  headers: jsonHeaders,
487
487
  body: JSON.stringify({
488
- descriptors: descriptors
488
+ descriptors: descriptors,
489
+ includeHashForDuplicateFiles: includeHashForDuplicateFiles
489
490
  }),
490
491
  traceContext: traceContext
491
492
  });
@@ -496,7 +497,7 @@ export var MediaStore = /*#__PURE__*/function () {
496
497
  }
497
498
  }, _callee9, this);
498
499
  }));
499
- function getItems(_x27, _x28, _x29) {
500
+ function getItems(_x27, _x28, _x29, _x30) {
500
501
  return _getItems.apply(this, arguments);
501
502
  }
502
503
  return getItems;
@@ -527,7 +528,7 @@ export var MediaStore = /*#__PURE__*/function () {
527
528
  }
528
529
  }, _callee10, this);
529
530
  }));
530
- function getImageMetadata(_x30, _x31, _x32) {
531
+ function getImageMetadata(_x31, _x32, _x33) {
531
532
  return _getImageMetadata.apply(this, arguments);
532
533
  }
533
534
  return getImageMetadata;
@@ -560,7 +561,7 @@ export var MediaStore = /*#__PURE__*/function () {
560
561
  }
561
562
  }, _callee11, this);
562
563
  }));
563
- function appendChunksToUpload(_x33, _x34, _x35, _x36) {
564
+ function appendChunksToUpload(_x34, _x35, _x36, _x37) {
564
565
  return _appendChunksToUpload.apply(this, arguments);
565
566
  }
566
567
  return appendChunksToUpload;
@@ -655,7 +656,7 @@ export var MediaStore = /*#__PURE__*/function () {
655
656
  }
656
657
  }, _callee12, this);
657
658
  }));
658
- function request(_x37) {
659
+ function request(_x38) {
659
660
  return _request2.apply(this, arguments);
660
661
  }
661
662
  return request;
@@ -688,7 +689,7 @@ export var MediaStore = /*#__PURE__*/function () {
688
689
  }
689
690
  }, _callee13);
690
691
  }));
691
- function testUrl(_x38) {
692
+ function testUrl(_x39) {
692
693
  return _testUrl.apply(this, arguments);
693
694
  }
694
695
  return testUrl;
@@ -40,7 +40,8 @@ export var mapMediaFileToFileState = function mapMediaFileToFileState(mediaFile)
40
40
  mimeType = _mediaFile$data.mimeType,
41
41
  representations = _mediaFile$data.representations,
42
42
  createdAt = _mediaFile$data.createdAt,
43
- metadataTraceContext = _mediaFile$data.metadataTraceContext;
43
+ metadataTraceContext = _mediaFile$data.metadataTraceContext,
44
+ hash = _mediaFile$data.hash;
44
45
  var baseState = {
45
46
  id: id,
46
47
  name: name,
@@ -50,6 +51,7 @@ export var mapMediaFileToFileState = function mapMediaFileToFileState(mediaFile)
50
51
  artifacts: artifacts,
51
52
  representations: representations,
52
53
  createdAt: createdAt,
54
+ hash: hash,
53
55
  metadataTraceContext: metadataTraceContext
54
56
  };
55
57
  switch (processingStatus) {
@@ -59,11 +59,18 @@ export var getItemsFromKeys = function getItemsFromKeys(dataloaderKeys, fileItem
59
59
  export function createBatchLoadingFunc(mediaStore) {
60
60
  return /*#__PURE__*/function () {
61
61
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(keys) {
62
- var nonCollectionName, fileIdsByCollection, items;
62
+ var nonCollectionName, includeHashByCollection, fileIdsByCollection, items;
63
63
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
64
64
  while (1) switch (_context2.prev = _context2.next) {
65
65
  case 0:
66
66
  nonCollectionName = '__media-single-file-collection__';
67
+ includeHashByCollection = keys.reduce(function (acc, key) {
68
+ var collectionName = key.collectionName || nonCollectionName;
69
+ if (key.includeHashForDuplicateFiles) {
70
+ acc[collectionName] = key.includeHashForDuplicateFiles;
71
+ }
72
+ return acc;
73
+ }, {});
67
74
  fileIdsByCollection = keys.reduce(function (acc, key) {
68
75
  var collectionName = key.collectionName || nonCollectionName;
69
76
  var fileIds = acc[collectionName] || [];
@@ -76,10 +83,10 @@ export function createBatchLoadingFunc(mediaStore) {
76
83
  return acc;
77
84
  }, {});
78
85
  items = [];
79
- _context2.next = 5;
86
+ _context2.next = 6;
80
87
  return Promise.all(Object.keys(fileIdsByCollection).map( /*#__PURE__*/function () {
81
88
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(collectionNameKey) {
82
- var metadataTraceContext, fileIds, collectionName, response, itemsWithMetadataTraceContext, itemsIds, fileIdsNotFound;
89
+ var metadataTraceContext, fileIds, includeHashForDuplicateFiles, collectionName, response, itemsWithMetadataTraceContext, itemsIds, fileIdsNotFound;
83
90
  return _regeneratorRuntime.wrap(function _callee$(_context) {
84
91
  while (1) switch (_context.prev = _context.next) {
85
92
  case 0:
@@ -88,11 +95,12 @@ export function createBatchLoadingFunc(mediaStore) {
88
95
  spanId: getRandomHex(8)
89
96
  };
90
97
  fileIds = fileIdsByCollection[collectionNameKey];
98
+ includeHashForDuplicateFiles = includeHashByCollection[collectionNameKey];
91
99
  collectionName = collectionNameKey === nonCollectionName ? undefined : collectionNameKey;
92
- _context.prev = 3;
93
- _context.next = 6;
94
- return mediaStore.getItems(fileIds, collectionName, metadataTraceContext);
95
- case 6:
100
+ _context.prev = 4;
101
+ _context.next = 7;
102
+ return mediaStore.getItems(fileIds, collectionName, metadataTraceContext, includeHashForDuplicateFiles);
103
+ case 7:
96
104
  response = _context.sent;
97
105
  itemsWithMetadataTraceContext = response.data.items.map(function (item) {
98
106
  return _objectSpread(_objectSpread({}, item), {}, {
@@ -116,11 +124,11 @@ export function createBatchLoadingFunc(mediaStore) {
116
124
  metadataTraceContext: metadataTraceContext
117
125
  });
118
126
  });
119
- _context.next = 17;
127
+ _context.next = 18;
120
128
  break;
121
- case 14:
122
- _context.prev = 14;
123
- _context.t0 = _context["catch"](3);
129
+ case 15:
130
+ _context.prev = 15;
131
+ _context.t0 = _context["catch"](4);
124
132
  fileIds.forEach(function (fileId) {
125
133
  items.push({
126
134
  id: fileId,
@@ -128,19 +136,19 @@ export function createBatchLoadingFunc(mediaStore) {
128
136
  error: _context.t0
129
137
  });
130
138
  });
131
- case 17:
139
+ case 18:
132
140
  case "end":
133
141
  return _context.stop();
134
142
  }
135
- }, _callee, null, [[3, 14]]);
143
+ }, _callee, null, [[4, 15]]);
136
144
  }));
137
145
  return function (_x2) {
138
146
  return _ref2.apply(this, arguments);
139
147
  };
140
148
  }()));
141
- case 5:
142
- return _context2.abrupt("return", getItemsFromKeys(keys, items));
143
149
  case 6:
150
+ return _context2.abrupt("return", getItemsFromKeys(keys, items));
151
+ case 7:
144
152
  case "end":
145
153
  return _context2.stop();
146
154
  }
@@ -22,7 +22,7 @@ export declare class MediaStore implements MediaApi {
22
22
  getFileBinaryURL(id: string, collectionName?: string, maxAge?: number): Promise<string>;
23
23
  getArtifactURL(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string): Promise<string>;
24
24
  getImage(id: string, params?: MediaStoreGetFileImageParams, controller?: AbortController, fetchMaxRes?: boolean, traceContext?: MediaTraceContext): Promise<Blob>;
25
- getItems(ids: string[], collectionName?: string, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<ItemsPayload>>;
25
+ getItems(ids: string[], collectionName?: string, traceContext?: MediaTraceContext, includeHashForDuplicateFiles?: boolean): Promise<MediaStoreResponse<ItemsPayload>>;
26
26
  getImageMetadata(id: string, params?: MediaStoreGetFileImageParams, traceContext?: MediaTraceContext): Promise<{
27
27
  metadata: ImageMetadata;
28
28
  }>;
@@ -160,7 +160,7 @@ export interface MediaApi {
160
160
  getFileBinaryURL: (id: string, collectionName?: string) => Promise<string>;
161
161
  getArtifactURL: (artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string) => Promise<string>;
162
162
  getImage: (id: string, params?: MediaStoreGetFileImageParams, controller?: AbortController, fetchMaxRes?: boolean, traceContext?: MediaTraceContext) => Promise<Blob>;
163
- getItems: (ids: string[], collectionName?: string, traceContext?: MediaTraceContext) => Promise<MediaStoreResponse<ItemsPayload>>;
163
+ getItems: (ids: string[], collectionName?: string, traceContext?: MediaTraceContext, includeHashForDuplicateFiles?: boolean) => Promise<MediaStoreResponse<ItemsPayload>>;
164
164
  getImageMetadata: (id: string, params?: MediaStoreGetFileImageParams, traceContext?: MediaTraceContext) => Promise<{
165
165
  metadata: ImageMetadata;
166
166
  }>;
@@ -9,6 +9,7 @@ export interface GetFileOptions {
9
9
  preview?: PreviewOptions;
10
10
  collectionName?: string;
11
11
  occurrenceKey?: string;
12
+ includeHashForDuplicateFiles?: boolean;
12
13
  }
13
14
  export interface PreviewableFileState {
14
15
  preview: FilePreview | Promise<FilePreview>;
@@ -13,6 +13,7 @@ export type MediaFile = {
13
13
  readonly artifacts: MediaFileArtifacts;
14
14
  readonly representations: MediaRepresentations;
15
15
  readonly createdAt?: number;
16
+ readonly hash?: string;
16
17
  readonly metadataTraceContext?: MediaTraceContext;
17
18
  };
18
19
  export type MediaItemDetails = {
@@ -24,6 +25,7 @@ export type MediaItemDetails = {
24
25
  readonly artifacts: MediaFileArtifacts;
25
26
  readonly representations: MediaRepresentations;
26
27
  readonly createdAt?: number;
28
+ readonly hash?: string;
27
29
  readonly metadataTraceContext?: MediaTraceContext;
28
30
  };
29
31
  export type NotFoundMediaItemDetails = {
@@ -5,6 +5,7 @@ export declare const MAX_BATCH_SIZE = 100;
5
5
  export type DataloaderKey = {
6
6
  readonly id: string;
7
7
  readonly collectionName?: string;
8
+ readonly includeHashForDuplicateFiles?: boolean;
8
9
  };
9
10
  export type DataloaderResult = MediaItemDetails | NotFoundMediaItemDetails;
10
11
  export type BatchLoadingErrorResult = {
@@ -22,7 +22,7 @@ export declare class MediaStore implements MediaApi {
22
22
  getFileBinaryURL(id: string, collectionName?: string, maxAge?: number): Promise<string>;
23
23
  getArtifactURL(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string): Promise<string>;
24
24
  getImage(id: string, params?: MediaStoreGetFileImageParams, controller?: AbortController, fetchMaxRes?: boolean, traceContext?: MediaTraceContext): Promise<Blob>;
25
- getItems(ids: string[], collectionName?: string, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<ItemsPayload>>;
25
+ getItems(ids: string[], collectionName?: string, traceContext?: MediaTraceContext, includeHashForDuplicateFiles?: boolean): Promise<MediaStoreResponse<ItemsPayload>>;
26
26
  getImageMetadata(id: string, params?: MediaStoreGetFileImageParams, traceContext?: MediaTraceContext): Promise<{
27
27
  metadata: ImageMetadata;
28
28
  }>;
@@ -160,7 +160,7 @@ export interface MediaApi {
160
160
  getFileBinaryURL: (id: string, collectionName?: string) => Promise<string>;
161
161
  getArtifactURL: (artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string) => Promise<string>;
162
162
  getImage: (id: string, params?: MediaStoreGetFileImageParams, controller?: AbortController, fetchMaxRes?: boolean, traceContext?: MediaTraceContext) => Promise<Blob>;
163
- getItems: (ids: string[], collectionName?: string, traceContext?: MediaTraceContext) => Promise<MediaStoreResponse<ItemsPayload>>;
163
+ getItems: (ids: string[], collectionName?: string, traceContext?: MediaTraceContext, includeHashForDuplicateFiles?: boolean) => Promise<MediaStoreResponse<ItemsPayload>>;
164
164
  getImageMetadata: (id: string, params?: MediaStoreGetFileImageParams, traceContext?: MediaTraceContext) => Promise<{
165
165
  metadata: ImageMetadata;
166
166
  }>;
@@ -9,6 +9,7 @@ export interface GetFileOptions {
9
9
  preview?: PreviewOptions;
10
10
  collectionName?: string;
11
11
  occurrenceKey?: string;
12
+ includeHashForDuplicateFiles?: boolean;
12
13
  }
13
14
  export interface PreviewableFileState {
14
15
  preview: FilePreview | Promise<FilePreview>;
@@ -13,6 +13,7 @@ export type MediaFile = {
13
13
  readonly artifacts: MediaFileArtifacts;
14
14
  readonly representations: MediaRepresentations;
15
15
  readonly createdAt?: number;
16
+ readonly hash?: string;
16
17
  readonly metadataTraceContext?: MediaTraceContext;
17
18
  };
18
19
  export type MediaItemDetails = {
@@ -24,6 +25,7 @@ export type MediaItemDetails = {
24
25
  readonly artifacts: MediaFileArtifacts;
25
26
  readonly representations: MediaRepresentations;
26
27
  readonly createdAt?: number;
28
+ readonly hash?: string;
27
29
  readonly metadataTraceContext?: MediaTraceContext;
28
30
  };
29
31
  export type NotFoundMediaItemDetails = {
@@ -5,6 +5,7 @@ export declare const MAX_BATCH_SIZE = 100;
5
5
  export type DataloaderKey = {
6
6
  readonly id: string;
7
7
  readonly collectionName?: string;
8
+ readonly includeHashForDuplicateFiles?: boolean;
8
9
  };
9
10
  export type DataloaderResult = MediaItemDetails | NotFoundMediaItemDetails;
10
11
  export type BatchLoadingErrorResult = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-client",
3
- "version": "28.3.0",
3
+ "version": "28.4.0",
4
4
  "description": "Media API Web Client Library",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -55,9 +55,9 @@
55
55
  },
56
56
  "devDependencies": {
57
57
  "@atlaskit/media-core": "^34.3.0",
58
- "@atlaskit/media-state": "^1.1.0",
58
+ "@atlaskit/media-state": "^1.2.0",
59
59
  "@atlaskit/ssr": "*",
60
- "@atlaskit/tokens": "^2.2.0",
60
+ "@atlaskit/tokens": "^2.4.0",
61
61
  "@atlassian/feature-flags-test-utils": "0.2.3",
62
62
  "@emotion/react": "^11.7.1",
63
63
  "@types/deep-equal": "^1.0.1",
@@ -81,9 +81,6 @@
81
81
  }
82
82
  },
83
83
  "platform-feature-flags": {
84
- "platform.media-card-performance-observer_a803k": {
85
- "type": "boolean"
86
- },
87
84
  "platform_media_cdn_single_host": {
88
85
  "type": "boolean"
89
86
  },