@atlaskit/media-client 33.3.1 → 33.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.
@@ -218,112 +218,145 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
218
218
  return _ref2.apply(this, arguments);
219
219
  };
220
220
  }());
221
- (0, _defineProperty2.default)(this, "getOrFetchFileState", /*#__PURE__*/function () {
222
- var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(id, collectionName) {
223
- var fileState;
221
+ (0, _defineProperty2.default)(this, "deleteArtifact", /*#__PURE__*/function () {
222
+ var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(id, params, collectionName, traceContext) {
223
+ var file, updatedArtifacts, updatedFileState;
224
224
  return _regenerator.default.wrap(function _callee3$(_context3) {
225
225
  while (1) switch (_context3.prev = _context3.next) {
226
+ case 0:
227
+ if (!(process.env.NODE_ENV === 'test')) {
228
+ _context3.next = 3;
229
+ break;
230
+ }
231
+ _context3.next = 3;
232
+ return _this.mediaApi.deleteArtifact(id, params, collectionName, traceContext);
233
+ case 3:
234
+ // Manually remove the artifact from file state instead of re-requesting the entire payload.
235
+ file = _this.store.getState().files[id];
236
+ if (file && file.status === 'processed' && file.artifacts) {
237
+ updatedArtifacts = _objectSpread({}, file.artifacts);
238
+ delete updatedArtifacts[params.artifactName];
239
+ updatedFileState = _objectSpread(_objectSpread({}, file), {}, {
240
+ artifacts: updatedArtifacts
241
+ });
242
+ _this.setFileState(id, updatedFileState);
243
+ }
244
+ case 5:
245
+ case "end":
246
+ return _context3.stop();
247
+ }
248
+ }, _callee3);
249
+ }));
250
+ return function (_x6, _x7, _x8, _x9) {
251
+ return _ref3.apply(this, arguments);
252
+ };
253
+ }());
254
+ (0, _defineProperty2.default)(this, "getOrFetchFileState", /*#__PURE__*/function () {
255
+ var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(id, collectionName) {
256
+ var fileState;
257
+ return _regenerator.default.wrap(function _callee4$(_context4) {
258
+ while (1) switch (_context4.prev = _context4.next) {
226
259
  case 0:
227
260
  fileState = _this.store.getState().files[id];
228
261
  if (!(fileState !== null && fileState !== void 0)) {
229
- _context3.next = 5;
262
+ _context4.next = 5;
230
263
  break;
231
264
  }
232
- _context3.t0 = fileState;
233
- _context3.next = 8;
265
+ _context4.t0 = fileState;
266
+ _context4.next = 8;
234
267
  break;
235
268
  case 5:
236
- _context3.next = 7;
269
+ _context4.next = 7;
237
270
  return _this.getCurrentState(id, {
238
271
  collectionName: collectionName
239
272
  });
240
273
  case 7:
241
- _context3.t0 = _context3.sent;
274
+ _context4.t0 = _context4.sent;
242
275
  case 8:
243
- return _context3.abrupt("return", _context3.t0);
276
+ return _context4.abrupt("return", _context4.t0);
244
277
  case 9:
245
278
  case "end":
246
- return _context3.stop();
279
+ return _context4.stop();
247
280
  }
248
- }, _callee3);
281
+ }, _callee4);
249
282
  }));
250
- return function (_x6, _x7) {
251
- return _ref3.apply(this, arguments);
283
+ return function (_x0, _x1) {
284
+ return _ref4.apply(this, arguments);
252
285
  };
253
286
  }());
254
287
  (0, _defineProperty2.default)(this, "getDurationOfVideo", /*#__PURE__*/function () {
255
- var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(id, collectionName) {
288
+ var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(id, collectionName) {
256
289
  var fileState, artifactUrlString, artifactUrl, artifactPath, res, arrayBuffer, uint8Array, mvhdBytes, mvhdIndex, i, j, dataView, start, timeScale, duration, videoLength;
257
- return _regenerator.default.wrap(function _callee4$(_context4) {
258
- while (1) switch (_context4.prev = _context4.next) {
290
+ return _regenerator.default.wrap(function _callee5$(_context5) {
291
+ while (1) switch (_context5.prev = _context5.next) {
259
292
  case 0:
260
- _context4.next = 2;
293
+ _context5.next = 2;
261
294
  return _this.getOrFetchFileState(id, collectionName);
262
295
  case 2:
263
- fileState = _context4.sent;
296
+ fileState = _context5.sent;
264
297
  if (!(fileState.status !== 'processed' || fileState.mediaType !== 'video' || !fileState.artifacts['video.mp4'])) {
265
- _context4.next = 5;
298
+ _context5.next = 5;
266
299
  break;
267
300
  }
268
301
  throw new Error('File is not a video');
269
302
  case 5:
270
- _context4.next = 7;
303
+ _context5.next = 7;
271
304
  return _this.getArtifactURL(fileState.artifacts, 'video.mp4');
272
305
  case 7:
273
- artifactUrlString = _context4.sent;
306
+ artifactUrlString = _context5.sent;
274
307
  artifactUrl = new URL(artifactUrlString);
275
308
  artifactPath = "".concat(artifactUrl.pathname).concat(artifactUrl.search);
276
- _context4.next = 12;
309
+ _context5.next = 12;
277
310
  return _this.mediaApi.request(artifactPath, {
278
311
  headers: {
279
312
  Range: 'bytes=0-199'
280
313
  }
281
314
  });
282
315
  case 12:
283
- res = _context4.sent;
284
- _context4.next = 15;
316
+ res = _context5.sent;
317
+ _context5.next = 15;
285
318
  return res.arrayBuffer();
286
319
  case 15:
287
- arrayBuffer = _context4.sent;
320
+ arrayBuffer = _context5.sent;
288
321
  uint8Array = new Uint8Array(arrayBuffer);
289
322
  mvhdBytes = new Uint8Array([109, 118, 104, 100]); // "mvhd" in ASCII
290
323
  mvhdIndex = -1;
291
324
  i = 0;
292
325
  case 20:
293
326
  if (!(i <= uint8Array.length - mvhdBytes.length)) {
294
- _context4.next = 35;
327
+ _context5.next = 35;
295
328
  break;
296
329
  }
297
330
  mvhdIndex = i;
298
331
  j = 0;
299
332
  case 23:
300
333
  if (!(j < mvhdBytes.length)) {
301
- _context4.next = 30;
334
+ _context5.next = 30;
302
335
  break;
303
336
  }
304
337
  if (!(uint8Array[i + j] !== mvhdBytes[j])) {
305
- _context4.next = 27;
338
+ _context5.next = 27;
306
339
  break;
307
340
  }
308
341
  mvhdIndex = -1;
309
- return _context4.abrupt("break", 30);
342
+ return _context5.abrupt("break", 30);
310
343
  case 27:
311
344
  j++;
312
- _context4.next = 23;
345
+ _context5.next = 23;
313
346
  break;
314
347
  case 30:
315
348
  if (!(mvhdIndex !== -1)) {
316
- _context4.next = 32;
349
+ _context5.next = 32;
317
350
  break;
318
351
  }
319
- return _context4.abrupt("break", 35);
352
+ return _context5.abrupt("break", 35);
320
353
  case 32:
321
354
  i++;
322
- _context4.next = 20;
355
+ _context5.next = 20;
323
356
  break;
324
357
  case 35:
325
358
  if (!(mvhdIndex === -1)) {
326
- _context4.next = 37;
359
+ _context5.next = 37;
327
360
  break;
328
361
  }
329
362
  throw new Error('Unable to find mvhd bytes');
@@ -333,71 +366,71 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
333
366
  start = mvhdIndex + 16; // Skip atom header and version/flags
334
367
  // Check if we have enough bytes to read timescale and duration
335
368
  if (!(start + 8 > arrayBuffer.byteLength)) {
336
- _context4.next = 41;
369
+ _context5.next = 41;
337
370
  break;
338
371
  }
339
- return _context4.abrupt("return", 0);
372
+ return _context5.abrupt("return", 0);
340
373
  case 41:
341
374
  // flase as second parameter indicates big-endian 32-bit integers
342
375
  timeScale = dataView.getUint32(start, false);
343
376
  duration = dataView.getUint32(start + 4, false);
344
377
  if (!(timeScale === 0)) {
345
- _context4.next = 45;
378
+ _context5.next = 45;
346
379
  break;
347
380
  }
348
381
  throw new Error('Timescale is invalid');
349
382
  case 45:
350
383
  // get the video length in seconds
351
384
  videoLength = Math.floor(duration / timeScale);
352
- return _context4.abrupt("return", videoLength);
385
+ return _context5.abrupt("return", videoLength);
353
386
  case 47:
354
387
  case "end":
355
- return _context4.stop();
388
+ return _context5.stop();
356
389
  }
357
- }, _callee4);
390
+ }, _callee5);
358
391
  }));
359
- return function (_x8, _x9) {
360
- return _ref4.apply(this, arguments);
392
+ return function (_x10, _x11) {
393
+ return _ref5.apply(this, arguments);
361
394
  };
362
395
  }());
363
396
  (0, _defineProperty2.default)(this, "getVideoDurations", /*#__PURE__*/function () {
364
- var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(files) {
397
+ var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(files) {
365
398
  var promises, durations;
366
- return _regenerator.default.wrap(function _callee6$(_context6) {
367
- while (1) switch (_context6.prev = _context6.next) {
399
+ return _regenerator.default.wrap(function _callee7$(_context7) {
400
+ while (1) switch (_context7.prev = _context7.next) {
368
401
  case 0:
369
402
  // get all the duration promises
370
403
  promises = files.map( /*#__PURE__*/function () {
371
- var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(_ref6) {
404
+ var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(_ref7) {
372
405
  var id, collectionName;
373
- return _regenerator.default.wrap(function _callee5$(_context5) {
374
- while (1) switch (_context5.prev = _context5.next) {
406
+ return _regenerator.default.wrap(function _callee6$(_context6) {
407
+ while (1) switch (_context6.prev = _context6.next) {
375
408
  case 0:
376
- id = _ref6.id, collectionName = _ref6.collectionName;
377
- _context5.prev = 1;
378
- _context5.next = 4;
409
+ id = _ref7.id, collectionName = _ref7.collectionName;
410
+ _context6.prev = 1;
411
+ _context6.next = 4;
379
412
  return _this.getDurationOfVideo(id, collectionName);
380
413
  case 4:
381
- return _context5.abrupt("return", _context5.sent);
414
+ return _context6.abrupt("return", _context6.sent);
382
415
  case 7:
383
- _context5.prev = 7;
384
- _context5.t0 = _context5["catch"](1);
385
- return _context5.abrupt("return", -1);
416
+ _context6.prev = 7;
417
+ _context6.t0 = _context6["catch"](1);
418
+ return _context6.abrupt("return", -1);
386
419
  case 10:
387
420
  case "end":
388
- return _context5.stop();
421
+ return _context6.stop();
389
422
  }
390
- }, _callee5, null, [[1, 7]]);
423
+ }, _callee6, null, [[1, 7]]);
391
424
  }));
392
- return function (_x11) {
393
- return _ref7.apply(this, arguments);
425
+ return function (_x13) {
426
+ return _ref8.apply(this, arguments);
394
427
  };
395
428
  }());
396
- _context6.next = 3;
429
+ _context7.next = 3;
397
430
  return Promise.all(promises);
398
431
  case 3:
399
- durations = _context6.sent;
400
- return _context6.abrupt("return", durations.reduce(function (acc, curr, i) {
432
+ durations = _context7.sent;
433
+ return _context7.abrupt("return", durations.reduce(function (acc, curr, i) {
401
434
  if (curr !== -1) {
402
435
  var _id = files[i].id;
403
436
  acc[_id] = curr;
@@ -406,12 +439,12 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
406
439
  }, {}));
407
440
  case 5:
408
441
  case "end":
409
- return _context6.stop();
442
+ return _context7.stop();
410
443
  }
411
- }, _callee6);
444
+ }, _callee7);
412
445
  }));
413
- return function (_x10) {
414
- return _ref5.apply(this, arguments);
446
+ return function (_x12) {
447
+ return _ref6.apply(this, arguments);
415
448
  };
416
449
  }());
417
450
  this.mediaApi = mediaApi;
@@ -479,8 +512,8 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
479
512
  descriptors: descriptors
480
513
  }, {
481
514
  collection: collection
482
- }, traceContext).then(function (_ref8) {
483
- var data = _ref8.data;
515
+ }, traceContext).then(function (_ref9) {
516
+ var data = _ref9.data;
484
517
  return data;
485
518
  });
486
519
  }
@@ -506,11 +539,11 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
506
539
  }, {
507
540
  key: "uploadExternal",
508
541
  value: function () {
509
- var _uploadExternal = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(url, collection, traceContext) {
542
+ var _uploadExternal = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee0(url, collection, traceContext) {
510
543
  var _this3 = this;
511
544
  var uploadableFileUpfrontIds, id, occurrenceKey, subject, deferredBlob, preview, name, fileState;
512
- return _regenerator.default.wrap(function _callee9$(_context9) {
513
- while (1) switch (_context9.prev = _context9.next) {
545
+ return _regenerator.default.wrap(function _callee0$(_context0) {
546
+ while (1) switch (_context0.prev = _context0.next) {
514
547
  case 0:
515
548
  uploadableFileUpfrontIds = this.generateUploadableFileUpfrontIds(collection, traceContext);
516
549
  id = uploadableFileUpfrontIds.id, occurrenceKey = uploadableFileUpfrontIds.occurrenceKey;
@@ -521,15 +554,15 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
521
554
  return undefined;
522
555
  });
523
556
  preview = new Promise( /*#__PURE__*/function () {
524
- var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(resolve, reject) {
557
+ var _ref0 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(resolve, reject) {
525
558
  var blob;
526
- return _regenerator.default.wrap(function _callee7$(_context7) {
527
- while (1) switch (_context7.prev = _context7.next) {
559
+ return _regenerator.default.wrap(function _callee8$(_context8) {
560
+ while (1) switch (_context8.prev = _context8.next) {
528
561
  case 0:
529
- _context7.next = 2;
562
+ _context8.next = 2;
530
563
  return deferredBlob;
531
564
  case 2:
532
- blob = _context7.sent;
565
+ blob = _context8.sent;
533
566
  if (!blob) {
534
567
  reject('Could not fetch the blob');
535
568
  }
@@ -539,12 +572,12 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
539
572
  });
540
573
  case 5:
541
574
  case "end":
542
- return _context7.stop();
575
+ return _context8.stop();
543
576
  }
544
- }, _callee7);
577
+ }, _callee8);
545
578
  }));
546
- return function (_x15, _x16) {
547
- return _ref9.apply(this, arguments);
579
+ return function (_x17, _x18) {
580
+ return _ref0.apply(this, arguments);
548
581
  };
549
582
  }());
550
583
  name = url.split('/').pop() || ''; // we create a initial fileState with the minimum info that we have at this point
@@ -562,21 +595,21 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
562
595
  // we save it into the cache as soon as possible, in case someone subscribes
563
596
  (0, _fileStreamsCache.getFileStreamsCache)().set(id, subject);
564
597
  this.setFileState(id, fileState);
565
- return _context9.abrupt("return", new Promise( /*#__PURE__*/function () {
566
- var _ref10 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(resolve, reject) {
598
+ return _context0.abrupt("return", new Promise( /*#__PURE__*/function () {
599
+ var _ref1 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(resolve, reject) {
567
600
  var blob, type, size, file, mediaType, dimensions;
568
- return _regenerator.default.wrap(function _callee8$(_context8) {
569
- while (1) switch (_context8.prev = _context8.next) {
601
+ return _regenerator.default.wrap(function _callee9$(_context9) {
602
+ while (1) switch (_context9.prev = _context9.next) {
570
603
  case 0:
571
- _context8.next = 2;
604
+ _context9.next = 2;
572
605
  return deferredBlob;
573
606
  case 2:
574
- blob = _context8.sent;
607
+ blob = _context9.sent;
575
608
  if (blob) {
576
- _context8.next = 5;
609
+ _context9.next = 5;
577
610
  break;
578
611
  }
579
- return _context8.abrupt("return", reject('Could not download remote file'));
612
+ return _context9.abrupt("return", reject('Could not download remote file'));
580
613
  case 5:
581
614
  type = blob.type, size = blob.size;
582
615
  file = {
@@ -599,18 +632,18 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
599
632
  });
600
633
  // we don't want to wait for the file to be upload
601
634
  _this3.upload(file, undefined, uploadableFileUpfrontIds, traceContext);
602
- _context8.prev = 10;
603
- _context8.next = 13;
635
+ _context9.prev = 10;
636
+ _context9.next = 13;
604
637
  return (0, _getDimensionsFromBlob.getDimensionsFromBlob)(mediaType, blob);
605
638
  case 13:
606
- dimensions = _context8.sent;
607
- _context8.next = 20;
639
+ dimensions = _context9.sent;
640
+ _context9.next = 20;
608
641
  break;
609
642
  case 16:
610
- _context8.prev = 16;
611
- _context8.t0 = _context8["catch"](10);
612
- reject(_context8.t0);
613
- return _context8.abrupt("return");
643
+ _context9.prev = 16;
644
+ _context9.t0 = _context9["catch"](10);
645
+ reject(_context9.t0);
646
+ return _context9.abrupt("return");
614
647
  case 20:
615
648
  resolve({
616
649
  dimensions: dimensions,
@@ -619,21 +652,21 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
619
652
  });
620
653
  case 21:
621
654
  case "end":
622
- return _context8.stop();
655
+ return _context9.stop();
623
656
  }
624
- }, _callee8, null, [[10, 16]]);
657
+ }, _callee9, null, [[10, 16]]);
625
658
  }));
626
- return function (_x17, _x18) {
627
- return _ref10.apply(this, arguments);
659
+ return function (_x19, _x20) {
660
+ return _ref1.apply(this, arguments);
628
661
  };
629
662
  }()));
630
663
  case 11:
631
664
  case "end":
632
- return _context9.stop();
665
+ return _context0.stop();
633
666
  }
634
- }, _callee9, this);
667
+ }, _callee0, this);
635
668
  }));
636
- function uploadExternal(_x12, _x13, _x14) {
669
+ function uploadExternal(_x14, _x15, _x16) {
637
670
  return _uploadExternal.apply(this, arguments);
638
671
  }
639
672
  return uploadExternal;
@@ -700,22 +733,22 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
700
733
  }, {
701
734
  key: "downloadBinary",
702
735
  value: function () {
703
- var _downloadBinary = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(id) {
736
+ var _downloadBinary = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee1(id) {
704
737
  var name,
705
738
  collectionName,
706
739
  traceContext,
707
740
  url,
708
- _args10 = arguments;
709
- return _regenerator.default.wrap(function _callee10$(_context10) {
710
- while (1) switch (_context10.prev = _context10.next) {
741
+ _args1 = arguments;
742
+ return _regenerator.default.wrap(function _callee1$(_context1) {
743
+ while (1) switch (_context1.prev = _context1.next) {
711
744
  case 0:
712
- name = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : 'download';
713
- collectionName = _args10.length > 2 ? _args10[2] : undefined;
714
- traceContext = _args10.length > 3 ? _args10[3] : undefined;
715
- _context10.next = 5;
745
+ name = _args1.length > 1 && _args1[1] !== undefined ? _args1[1] : 'download';
746
+ collectionName = _args1.length > 2 ? _args1[2] : undefined;
747
+ traceContext = _args1.length > 3 ? _args1[3] : undefined;
748
+ _context1.next = 5;
716
749
  return this.mediaApi.getFileBinaryURL(id, collectionName);
717
750
  case 5:
718
- url = _context10.sent;
751
+ url = _context1.sent;
719
752
  (0, _downloadUrl.downloadUrl)(url, {
720
753
  name: name
721
754
  });
@@ -725,17 +758,17 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
725
758
  viewingLevel: 'download'
726
759
  });
727
760
  // Test the download after initiated the Browser process to catch any potential errors.
728
- _context10.next = 10;
761
+ _context1.next = 10;
729
762
  return this.mediaApi.testUrl(url, {
730
763
  traceContext: traceContext
731
764
  });
732
765
  case 10:
733
766
  case "end":
734
- return _context10.stop();
767
+ return _context1.stop();
735
768
  }
736
- }, _callee10, this);
769
+ }, _callee1, this);
737
770
  }));
738
- function downloadBinary(_x19) {
771
+ function downloadBinary(_x21) {
739
772
  return _downloadBinary.apply(this, arguments);
740
773
  }
741
774
  return downloadBinary;
@@ -743,28 +776,28 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
743
776
  }, {
744
777
  key: "registerCopyIntent",
745
778
  value: function () {
746
- var _registerCopyIntent = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11(id, collectionName) {
779
+ var _registerCopyIntent = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(id, collectionName) {
747
780
  var auth, key, error;
748
- return _regenerator.default.wrap(function _callee11$(_context11) {
749
- while (1) switch (_context11.prev = _context11.next) {
781
+ return _regenerator.default.wrap(function _callee10$(_context10) {
782
+ while (1) switch (_context10.prev = _context10.next) {
750
783
  case 0:
751
- _context11.next = 2;
784
+ _context10.next = 2;
752
785
  return this.mediaApi.resolveAuth({
753
786
  collectionName: collectionName
754
787
  });
755
788
  case 2:
756
- auth = _context11.sent;
789
+ auth = _context10.sent;
757
790
  key = {
758
791
  id: id,
759
792
  collectionName: collectionName,
760
793
  resolvedAuth: auth
761
794
  };
762
- _context11.next = 6;
795
+ _context10.next = 6;
763
796
  return this.copyIntentRegisterationBatcher.load(key);
764
797
  case 6:
765
- error = _context11.sent;
798
+ error = _context10.sent;
766
799
  if (!error) {
767
- _context11.next = 10;
800
+ _context10.next = 10;
768
801
  break;
769
802
  }
770
803
  // if the error is retryable then it should not be cached
@@ -774,11 +807,11 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
774
807
  throw error;
775
808
  case 10:
776
809
  case "end":
777
- return _context11.stop();
810
+ return _context10.stop();
778
811
  }
779
- }, _callee11, this);
812
+ }, _callee10, this);
780
813
  }));
781
- function registerCopyIntent(_x20, _x21) {
814
+ function registerCopyIntent(_x22, _x23) {
782
815
  return _registerCopyIntent.apply(this, arguments);
783
816
  }
784
817
  return registerCopyIntent;
@@ -786,24 +819,24 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
786
819
  }, {
787
820
  key: "copyFileWithToken",
788
821
  value: function () {
789
- var _copyFileWithToken = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12(source, destination, traceContext) {
822
+ var _copyFileWithToken = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11(source, destination, traceContext) {
790
823
  var authProvider, sourceCollection, id, destinationAuthProvider, destinationCollectionName, replaceFileId, occurrenceKey, mediaStore, owner, body, params, _yield$mediaStore$cop, data;
791
- return _regenerator.default.wrap(function _callee12$(_context12) {
792
- while (1) switch (_context12.prev = _context12.next) {
824
+ return _regenerator.default.wrap(function _callee11$(_context11) {
825
+ while (1) switch (_context11.prev = _context11.next) {
793
826
  case 0:
794
827
  authProvider = source.authProvider, sourceCollection = source.collection, id = source.id;
795
828
  destinationAuthProvider = destination.authProvider, destinationCollectionName = destination.collection, replaceFileId = destination.replaceFileId, occurrenceKey = destination.occurrenceKey;
796
829
  mediaStore = destination.mediaStore || new _mediaStore.MediaStore({
797
830
  authProvider: destinationAuthProvider
798
831
  });
799
- _context12.t0 = _mediaCore.authToOwner;
800
- _context12.next = 6;
832
+ _context11.t0 = _mediaCore.authToOwner;
833
+ _context11.next = 6;
801
834
  return authProvider({
802
835
  collectionName: sourceCollection
803
836
  });
804
837
  case 6:
805
- _context12.t1 = _context12.sent;
806
- owner = (0, _context12.t0)(_context12.t1);
838
+ _context11.t1 = _context11.sent;
839
+ owner = (0, _context11.t0)(_context11.t1);
807
840
  body = {
808
841
  sourceFile: {
809
842
  id: id,
@@ -816,19 +849,19 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
816
849
  replaceFileId: replaceFileId,
817
850
  occurrenceKey: occurrenceKey
818
851
  };
819
- _context12.next = 12;
852
+ _context11.next = 12;
820
853
  return mediaStore.copyFileWithToken(body, params, traceContext);
821
854
  case 12:
822
- _yield$mediaStore$cop = _context12.sent;
855
+ _yield$mediaStore$cop = _context11.sent;
823
856
  data = _yield$mediaStore$cop.data;
824
- return _context12.abrupt("return", data);
857
+ return _context11.abrupt("return", data);
825
858
  case 15:
826
859
  case "end":
827
- return _context12.stop();
860
+ return _context11.stop();
828
861
  }
829
- }, _callee12);
862
+ }, _callee11);
830
863
  }));
831
- function copyFileWithToken(_x22, _x23, _x24) {
864
+ function copyFileWithToken(_x24, _x25, _x26) {
832
865
  return _copyFileWithToken.apply(this, arguments);
833
866
  }
834
867
  return copyFileWithToken;
@@ -836,28 +869,28 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
836
869
  }, {
837
870
  key: "copyFileWithIntent",
838
871
  value: function () {
839
- var _copyFileWithIntent = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13(source, destination, traceContext) {
872
+ var _copyFileWithIntent = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12(source, destination, traceContext) {
840
873
  var res, data;
841
- return _regenerator.default.wrap(function _callee13$(_context13) {
842
- while (1) switch (_context13.prev = _context13.next) {
874
+ return _regenerator.default.wrap(function _callee12$(_context12) {
875
+ while (1) switch (_context12.prev = _context12.next) {
843
876
  case 0:
844
- _context13.next = 2;
877
+ _context12.next = 2;
845
878
  return this.mediaApi.copyFile(source.id, {
846
879
  sourceCollection: source.collection,
847
880
  collection: destination.collection,
848
881
  replaceFileId: destination.replaceFileId
849
882
  }, traceContext);
850
883
  case 2:
851
- res = _context13.sent;
884
+ res = _context12.sent;
852
885
  data = res.data;
853
- return _context13.abrupt("return", data);
886
+ return _context12.abrupt("return", data);
854
887
  case 5:
855
888
  case "end":
856
- return _context13.stop();
889
+ return _context12.stop();
857
890
  }
858
- }, _callee13, this);
891
+ }, _callee12, this);
859
892
  }));
860
- function copyFileWithIntent(_x25, _x26, _x27) {
893
+ function copyFileWithIntent(_x27, _x28, _x29) {
861
894
  return _copyFileWithIntent.apply(this, arguments);
862
895
  }
863
896
  return copyFileWithIntent;
@@ -865,7 +898,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
865
898
  }, {
866
899
  key: "copyFile",
867
900
  value: function () {
868
- var _copyFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14(source, destination) {
901
+ var _copyFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13(source, destination) {
869
902
  var _this5 = this;
870
903
  var options,
871
904
  traceContext,
@@ -892,32 +925,32 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
892
925
  replaceFileState,
893
926
  key,
894
927
  errorFileState,
895
- _args14 = arguments;
896
- return _regenerator.default.wrap(function _callee14$(_context14) {
897
- while (1) switch (_context14.prev = _context14.next) {
928
+ _args13 = arguments;
929
+ return _regenerator.default.wrap(function _callee13$(_context13) {
930
+ while (1) switch (_context13.prev = _context13.next) {
898
931
  case 0:
899
- options = _args14.length > 2 && _args14[2] !== undefined ? _args14[2] : {};
900
- traceContext = _args14.length > 3 ? _args14[3] : undefined;
932
+ options = _args13.length > 2 && _args13[2] !== undefined ? _args13[2] : {};
933
+ traceContext = _args13.length > 3 ? _args13[3] : undefined;
901
934
  id = source.id;
902
935
  destinationCollectionName = destination.collection, replaceFileId = destination.replaceFileId, occurrenceKey = destination.occurrenceKey;
903
936
  preview = options.preview, mimeType = options.mimeType;
904
937
  cache = (0, _fileStreamsCache.getFileStreamsCache)();
905
- _context14.prev = 6;
938
+ _context13.prev = 6;
906
939
  if (!(isCopySourceFileWithToken(source) && isCopyDestinationWithToken(destination))) {
907
- _context14.next = 13;
940
+ _context13.next = 13;
908
941
  break;
909
942
  }
910
- _context14.next = 10;
943
+ _context13.next = 10;
911
944
  return this.copyFileWithToken(source, destination, traceContext);
912
945
  case 10:
913
- copiedFile = _context14.sent;
914
- _context14.next = 16;
946
+ copiedFile = _context13.sent;
947
+ _context13.next = 16;
915
948
  break;
916
949
  case 13:
917
- _context14.next = 15;
950
+ _context13.next = 15;
918
951
  return this.copyFileWithIntent(source, destination, traceContext);
919
952
  case 15:
920
- copiedFile = _context14.sent;
953
+ copiedFile = _context13.sent;
921
954
  case 16:
922
955
  // if we were passed a "mimeType", we propagate it into copiedFileWithMimeType
923
956
  copiedFileWithMimeType = _objectSpread(_objectSpread({}, copiedFile), mimeType ? {
@@ -934,21 +967,21 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
934
967
  previewOverride = !(0, _fileState2.isErrorFileState)(copiedFileState) && !!preview ? {
935
968
  preview: preview
936
969
  } : {};
937
- _context14.t0 = !(0, _fileState2.isFinalFileState)(copiedFileState) &&
970
+ _context13.t0 = !(0, _fileState2.isFinalFileState)(copiedFileState) &&
938
971
  // mimeType should always be returned by "copyFileWithToken"
939
972
  // but in case it's not, we don't want to penalize "copyFile"
940
973
  copiedMimeType;
941
- if (!_context14.t0) {
942
- _context14.next = 28;
974
+ if (!_context13.t0) {
975
+ _context13.next = 28;
943
976
  break;
944
977
  }
945
- _context14.next = 27;
978
+ _context13.next = 27;
946
979
  return (0, _shouldFetchRemoteFileStates.shouldFetchRemoteFileStates)(mediaType, copiedMimeType, preview);
947
980
  case 27:
948
- _context14.t0 = _context14.sent;
981
+ _context13.t0 = _context13.sent;
949
982
  case 28:
950
- if (!_context14.t0) {
951
- _context14.next = 35;
983
+ if (!_context13.t0) {
984
+ _context13.next = 35;
952
985
  break;
953
986
  }
954
987
  fileState = _objectSpread(_objectSpread(_objectSpread({}, copiedFileState), (0, _overrideMediaTypeIfUnknown.overrideMediaTypeIfUnknown)(copiedFileState, mediaType)), previewOverride);
@@ -969,7 +1002,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
969
1002
  return subject.complete();
970
1003
  }
971
1004
  });
972
- _context14.next = 36;
1005
+ _context13.next = 36;
973
1006
  break;
974
1007
  case 35:
975
1008
  if (!(0, _fileState2.isProcessingFileState)(copiedFileState)) {
@@ -981,10 +1014,10 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
981
1014
  if (!cache.has(copiedId)) {
982
1015
  (0, _fileStreamsCache.getFileStreamsCache)().set(copiedId, subject);
983
1016
  }
984
- return _context14.abrupt("return", copiedFile);
1017
+ return _context13.abrupt("return", copiedFile);
985
1018
  case 40:
986
- _context14.prev = 40;
987
- _context14.t1 = _context14["catch"](6);
1019
+ _context13.prev = 40;
1020
+ _context13.t1 = _context13["catch"](6);
988
1021
  if (processingSubscription) {
989
1022
  processingSubscription.unsubscribe();
990
1023
  }
@@ -992,23 +1025,23 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
992
1025
  _fileCache = cache.get(replaceFileId);
993
1026
  replaceFileState = this.store.getState().files[replaceFileId];
994
1027
  if (_fileCache) {
995
- _fileCache.error(_context14.t1);
1028
+ _fileCache.error(_context13.t1);
996
1029
  } else {
997
1030
  // Create a new subject with the error state for new subscriptions
998
- cache.set(id, (0, _createMediaSubject.createMediaSubject)(_context14.t1));
1031
+ cache.set(id, (0, _createMediaSubject.createMediaSubject)(_context13.t1));
999
1032
  }
1000
1033
  key = replaceFileState ? replaceFileId : id;
1001
- errorFileState = this.getErrorFileState(_context14.t1, id, occurrenceKey);
1034
+ errorFileState = this.getErrorFileState(_context13.t1, id, occurrenceKey);
1002
1035
  this.setFileState(key, errorFileState);
1003
1036
  }
1004
- throw _context14.t1;
1037
+ throw _context13.t1;
1005
1038
  case 45:
1006
1039
  case "end":
1007
- return _context14.stop();
1040
+ return _context13.stop();
1008
1041
  }
1009
- }, _callee14, this, [[6, 40]]);
1042
+ }, _callee13, this, [[6, 40]]);
1010
1043
  }));
1011
- function copyFile(_x28, _x29) {
1044
+ function copyFile(_x30, _x31) {
1012
1045
  return _copyFile.apply(this, arguments);
1013
1046
  }
1014
1047
  return copyFile;