@atlaskit/media-client 28.4.0 → 28.6.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.
Files changed (53) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/client/file-fetcher/error.js +5 -7
  3. package/dist/cjs/client/file-fetcher/index.js +135 -71
  4. package/dist/cjs/client/media-client.js +1 -2
  5. package/dist/cjs/client/media-store/MediaStore.js +94 -26
  6. package/dist/cjs/client/media-store/error.js +5 -7
  7. package/dist/cjs/client/mobile-upload.js +1 -2
  8. package/dist/cjs/client/stargate-client.js +1 -2
  9. package/dist/cjs/file-streams-cache.js +1 -2
  10. package/dist/cjs/models/errors/index.js +6 -8
  11. package/dist/cjs/upload-controller.js +1 -2
  12. package/dist/cjs/uploader/error.js +5 -7
  13. package/dist/cjs/utils/hashing/sha256SimpleHasher.js +1 -2
  14. package/dist/cjs/utils/hashing/simpleHasher.js +1 -2
  15. package/dist/cjs/utils/hashing/workerHasher.js +1 -2
  16. package/dist/cjs/utils/mobileUpload/error.js +5 -7
  17. package/dist/cjs/utils/polling/errors.js +5 -7
  18. package/dist/cjs/utils/polling/index.js +1 -2
  19. package/dist/cjs/utils/request/errors.js +5 -7
  20. package/dist/cjs/utils/request/helpers.js +10 -4
  21. package/dist/es2019/client/file-fetcher/index.js +38 -8
  22. package/dist/es2019/client/media-store/MediaStore.js +51 -2
  23. package/dist/es2019/utils/request/helpers.js +7 -2
  24. package/dist/esm/client/file-fetcher/error.js +5 -7
  25. package/dist/esm/client/file-fetcher/index.js +135 -71
  26. package/dist/esm/client/media-client.js +1 -2
  27. package/dist/esm/client/media-store/MediaStore.js +96 -28
  28. package/dist/esm/client/media-store/error.js +5 -7
  29. package/dist/esm/client/mobile-upload.js +1 -2
  30. package/dist/esm/client/stargate-client.js +1 -2
  31. package/dist/esm/file-streams-cache.js +1 -2
  32. package/dist/esm/models/errors/index.js +6 -8
  33. package/dist/esm/upload-controller.js +1 -2
  34. package/dist/esm/uploader/error.js +5 -7
  35. package/dist/esm/utils/hashing/sha256SimpleHasher.js +1 -2
  36. package/dist/esm/utils/hashing/simpleHasher.js +1 -2
  37. package/dist/esm/utils/hashing/workerHasher.js +1 -2
  38. package/dist/esm/utils/mobileUpload/error.js +5 -7
  39. package/dist/esm/utils/polling/errors.js +5 -7
  40. package/dist/esm/utils/polling/index.js +1 -2
  41. package/dist/esm/utils/request/errors.js +5 -7
  42. package/dist/esm/utils/request/helpers.js +9 -4
  43. package/dist/types/client/file-fetcher/index.d.ts +4 -2
  44. package/dist/types/client/media-store/MediaStore.d.ts +3 -1
  45. package/dist/types/client/media-store/types.d.ts +7 -0
  46. package/dist/types/utils/request/helpers.d.ts +1 -0
  47. package/dist/types/utils/request/types.d.ts +1 -0
  48. package/dist/types-ts4.5/client/file-fetcher/index.d.ts +4 -2
  49. package/dist/types-ts4.5/client/media-store/MediaStore.d.ts +3 -1
  50. package/dist/types-ts4.5/client/media-store/types.d.ts +7 -0
  51. package/dist/types-ts4.5/utils/request/helpers.d.ts +1 -0
  52. package/dist/types-ts4.5/utils/request/types.d.ts +1 -0
  53. package/package.json +1 -1
@@ -35,6 +35,12 @@ import { PollingFunction } from '../../utils/polling';
35
35
  import { isEmptyFile } from '../../utils/detectEmptyFile';
36
36
  import { mediaStore } from '@atlaskit/media-state';
37
37
  export { isFileFetcherError, FileFetcherError } from './error';
38
+ var isCopySourceFileWithToken = function isCopySourceFileWithToken(token) {
39
+ return !!token.authProvider;
40
+ };
41
+ var isCopyDestinationWithToken = function isCopyDestinationWithToken(token) {
42
+ return !!token.authProvider;
43
+ };
38
44
  export var FileFetcherImpl = /*#__PURE__*/function () {
39
45
  function FileFetcherImpl(mediaApi) {
40
46
  var _this = this;
@@ -166,7 +172,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
166
172
  this.store = store;
167
173
  this.dataloader = createFileDataloader(mediaApi);
168
174
  }
169
- _createClass(FileFetcherImpl, [{
175
+ return _createClass(FileFetcherImpl, [{
170
176
  key: "getFileState",
171
177
  value: function getFileState(id) {
172
178
  var _this2 = this;
@@ -495,29 +501,100 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
495
501
  }
496
502
  return downloadBinary;
497
503
  }()
504
+ }, {
505
+ key: "copyFileWithToken",
506
+ value: function () {
507
+ var _copyFileWithToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(source, destination, traceContext) {
508
+ var authProvider, sourceCollection, id, destinationAuthProvider, destinationCollectionName, replaceFileId, occurrenceKey, mediaStore, owner, body, params, _yield$mediaStore$cop, data;
509
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
510
+ while (1) switch (_context6.prev = _context6.next) {
511
+ case 0:
512
+ authProvider = source.authProvider, sourceCollection = source.collection, id = source.id;
513
+ destinationAuthProvider = destination.authProvider, destinationCollectionName = destination.collection, replaceFileId = destination.replaceFileId, occurrenceKey = destination.occurrenceKey;
514
+ mediaStore = destination.mediaStore || new MediaApi({
515
+ authProvider: destinationAuthProvider
516
+ });
517
+ _context6.t0 = authToOwner;
518
+ _context6.next = 6;
519
+ return authProvider({
520
+ collectionName: sourceCollection
521
+ });
522
+ case 6:
523
+ _context6.t1 = _context6.sent;
524
+ owner = (0, _context6.t0)(_context6.t1);
525
+ body = {
526
+ sourceFile: {
527
+ id: id,
528
+ collection: sourceCollection,
529
+ owner: owner
530
+ }
531
+ };
532
+ params = {
533
+ collection: destinationCollectionName,
534
+ replaceFileId: replaceFileId,
535
+ occurrenceKey: occurrenceKey
536
+ };
537
+ _context6.next = 12;
538
+ return mediaStore.copyFileWithToken(body, params, traceContext);
539
+ case 12:
540
+ _yield$mediaStore$cop = _context6.sent;
541
+ data = _yield$mediaStore$cop.data;
542
+ return _context6.abrupt("return", data);
543
+ case 15:
544
+ case "end":
545
+ return _context6.stop();
546
+ }
547
+ }, _callee6);
548
+ }));
549
+ function copyFileWithToken(_x9, _x10, _x11) {
550
+ return _copyFileWithToken.apply(this, arguments);
551
+ }
552
+ return copyFileWithToken;
553
+ }()
554
+ }, {
555
+ key: "copyFileWithIntent",
556
+ value: function () {
557
+ var _copyFileWithIntent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(source, destination, traceContext) {
558
+ var res, data;
559
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
560
+ while (1) switch (_context7.prev = _context7.next) {
561
+ case 0:
562
+ _context7.next = 2;
563
+ return this.mediaApi.copyFile(source.id, {
564
+ sourceCollection: source.collection,
565
+ collection: destination.collection,
566
+ replaceFileId: destination.replaceFileId
567
+ }, traceContext);
568
+ case 2:
569
+ res = _context7.sent;
570
+ data = res.data;
571
+ return _context7.abrupt("return", data);
572
+ case 5:
573
+ case "end":
574
+ return _context7.stop();
575
+ }
576
+ }, _callee7, this);
577
+ }));
578
+ function copyFileWithIntent(_x12, _x13, _x14) {
579
+ return _copyFileWithIntent.apply(this, arguments);
580
+ }
581
+ return copyFileWithIntent;
582
+ }()
498
583
  }, {
499
584
  key: "copyFile",
500
585
  value: function () {
501
- var _copyFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(source, destination) {
586
+ var _copyFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(source, destination) {
502
587
  var _this5 = this;
503
588
  var options,
504
589
  traceContext,
505
- authProvider,
506
- sourceCollection,
507
590
  id,
508
- destinationAuthProvider,
509
591
  destinationCollectionName,
510
592
  replaceFileId,
511
593
  occurrenceKey,
512
594
  preview,
513
595
  mimeType,
514
- mediaStore,
515
- owner,
516
- body,
517
- params,
518
596
  cache,
519
597
  processingSubscription,
520
- _yield$mediaStore$cop,
521
598
  copiedFile,
522
599
  copiedFileWithMimeType,
523
600
  copiedId,
@@ -533,45 +610,33 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
533
610
  replaceFileState,
534
611
  key,
535
612
  errorFileState,
536
- _args6 = arguments;
537
- return _regeneratorRuntime.wrap(function _callee6$(_context6) {
538
- while (1) switch (_context6.prev = _context6.next) {
613
+ _args8 = arguments;
614
+ return _regeneratorRuntime.wrap(function _callee8$(_context8) {
615
+ while (1) switch (_context8.prev = _context8.next) {
539
616
  case 0:
540
- options = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : {};
541
- traceContext = _args6.length > 3 ? _args6[3] : undefined;
542
- authProvider = source.authProvider, sourceCollection = source.collection, id = source.id;
543
- destinationAuthProvider = destination.authProvider, destinationCollectionName = destination.collection, replaceFileId = destination.replaceFileId, occurrenceKey = destination.occurrenceKey;
617
+ options = _args8.length > 2 && _args8[2] !== undefined ? _args8[2] : {};
618
+ traceContext = _args8.length > 3 ? _args8[3] : undefined;
619
+ id = source.id;
620
+ destinationCollectionName = destination.collection, replaceFileId = destination.replaceFileId, occurrenceKey = destination.occurrenceKey;
544
621
  preview = options.preview, mimeType = options.mimeType;
545
- mediaStore = destination.mediaStore || new MediaApi({
546
- authProvider: destinationAuthProvider
547
- });
548
- _context6.t0 = authToOwner;
549
- _context6.next = 9;
550
- return authProvider({
551
- collectionName: sourceCollection
552
- });
553
- case 9:
554
- _context6.t1 = _context6.sent;
555
- owner = (0, _context6.t0)(_context6.t1);
556
- body = {
557
- sourceFile: {
558
- id: id,
559
- collection: sourceCollection,
560
- owner: owner
561
- }
562
- };
563
- params = {
564
- collection: destinationCollectionName,
565
- replaceFileId: replaceFileId,
566
- occurrenceKey: occurrenceKey
567
- };
568
622
  cache = getFileStreamsCache();
569
- _context6.prev = 14;
570
- _context6.next = 17;
571
- return mediaStore.copyFileWithToken(body, params, traceContext);
572
- case 17:
573
- _yield$mediaStore$cop = _context6.sent;
574
- copiedFile = _yield$mediaStore$cop.data;
623
+ _context8.prev = 6;
624
+ if (!(isCopySourceFileWithToken(source) && isCopyDestinationWithToken(destination))) {
625
+ _context8.next = 13;
626
+ break;
627
+ }
628
+ _context8.next = 10;
629
+ return this.copyFileWithToken(source, destination, traceContext);
630
+ case 10:
631
+ copiedFile = _context8.sent;
632
+ _context8.next = 16;
633
+ break;
634
+ case 13:
635
+ _context8.next = 15;
636
+ return this.copyFileWithIntent(source, destination, traceContext);
637
+ case 15:
638
+ copiedFile = _context8.sent;
639
+ case 16:
575
640
  // if we were passed a "mimeType", we propagate it into copiedFileWithMimeType
576
641
  copiedFileWithMimeType = _objectSpread(_objectSpread({}, copiedFile), mimeType ? {
577
642
  mimeType: mimeType
@@ -587,21 +652,21 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
587
652
  previewOverride = !isErrorFileState(copiedFileState) && !!preview ? {
588
653
  preview: preview
589
654
  } : {};
590
- _context6.t2 = !isFinalFileState(copiedFileState) &&
655
+ _context8.t0 = !isFinalFileState(copiedFileState) &&
591
656
  // mimeType should always be returned by "copyFileWithToken"
592
657
  // but in case it's not, we don't want to penalize "copyFile"
593
658
  copiedMimeType;
594
- if (!_context6.t2) {
595
- _context6.next = 31;
659
+ if (!_context8.t0) {
660
+ _context8.next = 28;
596
661
  break;
597
662
  }
598
- _context6.next = 30;
663
+ _context8.next = 27;
599
664
  return shouldFetchRemoteFileStates(mediaType, copiedMimeType, preview);
600
- case 30:
601
- _context6.t2 = _context6.sent;
602
- case 31:
603
- if (!_context6.t2) {
604
- _context6.next = 38;
665
+ case 27:
666
+ _context8.t0 = _context8.sent;
667
+ case 28:
668
+ if (!_context8.t0) {
669
+ _context8.next = 35;
605
670
  break;
606
671
  }
607
672
  fileState = _objectSpread(_objectSpread(_objectSpread({}, copiedFileState), overrideMediaTypeIfUnknown(copiedFileState, mediaType)), previewOverride);
@@ -622,22 +687,22 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
622
687
  return subject.complete();
623
688
  }
624
689
  });
625
- _context6.next = 39;
690
+ _context8.next = 36;
626
691
  break;
627
- case 38:
692
+ case 35:
628
693
  if (!isProcessingFileState(copiedFileState)) {
629
694
  _fileState = _objectSpread(_objectSpread({}, copiedFileState), !isErrorFileState(copiedFileState) && previewOverride);
630
695
  subject.next(_fileState);
631
696
  this.setFileState(copiedId, _fileState);
632
697
  }
633
- case 39:
698
+ case 36:
634
699
  if (!cache.has(copiedId)) {
635
700
  getFileStreamsCache().set(copiedId, subject);
636
701
  }
637
- return _context6.abrupt("return", copiedFile);
638
- case 43:
639
- _context6.prev = 43;
640
- _context6.t3 = _context6["catch"](14);
702
+ return _context8.abrupt("return", copiedFile);
703
+ case 40:
704
+ _context8.prev = 40;
705
+ _context8.t1 = _context8["catch"](6);
641
706
  if (processingSubscription) {
642
707
  processingSubscription.unsubscribe();
643
708
  }
@@ -645,27 +710,26 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
645
710
  _fileCache = cache.get(replaceFileId);
646
711
  replaceFileState = this.store.getState().files[replaceFileId];
647
712
  if (_fileCache) {
648
- _fileCache.error(_context6.t3);
713
+ _fileCache.error(_context8.t1);
649
714
  } else {
650
715
  // Create a new subject with the error state for new subscriptions
651
- cache.set(id, createMediaSubject(_context6.t3));
716
+ cache.set(id, createMediaSubject(_context8.t1));
652
717
  }
653
718
  key = replaceFileState ? replaceFileId : id;
654
- errorFileState = this.getErrorFileState(_context6.t3, id, occurrenceKey);
719
+ errorFileState = this.getErrorFileState(_context8.t1, id, occurrenceKey);
655
720
  this.setFileState(key, errorFileState);
656
721
  }
657
- throw _context6.t3;
658
- case 48:
722
+ throw _context8.t1;
723
+ case 45:
659
724
  case "end":
660
- return _context6.stop();
725
+ return _context8.stop();
661
726
  }
662
- }, _callee6, this, [[14, 43]]);
727
+ }, _callee8, this, [[6, 40]]);
663
728
  }));
664
- function copyFile(_x9, _x10) {
729
+ function copyFile(_x15, _x16) {
665
730
  return _copyFile.apply(this, arguments);
666
731
  }
667
732
  return copyFile;
668
733
  }()
669
734
  }]);
670
- return FileFetcherImpl;
671
735
  }();
@@ -34,7 +34,7 @@ export var MediaClient = /*#__PURE__*/function () {
34
34
  /**
35
35
  * @internal
36
36
  */
37
- _createClass(MediaClient, [{
37
+ return _createClass(MediaClient, [{
38
38
  key: "__DO_NOT_USE__getMediaStore",
39
39
  value: function __DO_NOT_USE__getMediaStore() {
40
40
  return this.store;
@@ -143,5 +143,4 @@ export var MediaClient = /*#__PURE__*/function () {
143
143
  return this.eventEmitter.emit(event, payload);
144
144
  }
145
145
  }]);
146
- return MediaClient;
147
146
  }();
@@ -8,8 +8,8 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
8
8
  import { isClientBasedAuth } from '@atlaskit/media-core';
9
9
  import { FILE_CACHE_MAX_AGE, MAX_RESOLUTION } from '../../constants';
10
10
  import { getArtifactUrl } from '../../models/artifacts';
11
- import { request as _request } from '../../utils/request';
12
- import { createUrl, createMapResponseToJson, createMapResponseToBlob, extendTraceContext } from '../../utils/request/helpers';
11
+ import { isRequestError, request as _request } from '../../utils/request';
12
+ import { createUrl, createMapResponseToJson, createMapResponseToBlob, defaultShouldRetryError, extendTraceContext } from '../../utils/request/helpers';
13
13
  import { mapToMediaCdnUrl } from '../../utils/mediaCdn';
14
14
  import { resolveAuth, resolveInitialAuth } from './resolveAuth';
15
15
  import { ChunkHashAlgorithm } from '@atlaskit/media-core';
@@ -55,7 +55,7 @@ export var MediaStore = /*#__PURE__*/function () {
55
55
  this.config = config;
56
56
  this._chunkHashAlgorithm = config.chunkHashAlgorithm || ChunkHashAlgorithm.Sha1;
57
57
  }
58
- _createClass(MediaStore, [{
58
+ return _createClass(MediaStore, [{
59
59
  key: "removeCollectionFile",
60
60
  value: function () {
61
61
  var _removeCollectionFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(id, collectionName, occurrenceKey, traceContext) {
@@ -587,10 +587,79 @@ export var MediaStore = /*#__PURE__*/function () {
587
587
  });
588
588
  return this.request('/file/copy/withToken', options).then(createMapResponseToJson(metadata));
589
589
  }
590
+ }, {
591
+ key: "copyFile",
592
+ value: function copyFile(id, params, traceContext) {
593
+ var metadata = {
594
+ method: 'POST',
595
+ endpoint: '/v2/file/copy'
596
+ };
597
+ var options = _objectSpread(_objectSpread({}, metadata), {}, {
598
+ authContext: {
599
+ collectionName: params.collection
600
+ },
601
+ params: params,
602
+ headers: jsonHeaders,
603
+ body: JSON.stringify({
604
+ id: id
605
+ }),
606
+ traceContext: traceContext,
607
+ clientOptions: {
608
+ retryOptions: {
609
+ shouldRetryError: function shouldRetryError(err) {
610
+ var _err$metadata;
611
+ return defaultShouldRetryError(err) || isRequestError(err) && (err === null || err === void 0 || (_err$metadata = err.metadata) === null || _err$metadata === void 0 ? void 0 : _err$metadata.statusCode) === 401;
612
+ }
613
+ }
614
+ }
615
+ });
616
+ return this.request('/v2/file/copy', options).then(createMapResponseToJson(metadata));
617
+ }
618
+ }, {
619
+ key: "registerCopyIntents",
620
+ value: function () {
621
+ var _registerCopyIntents = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(ids, collectionName, traceContext) {
622
+ var files, metadata, options;
623
+ return _regeneratorRuntime.wrap(function _callee12$(_context12) {
624
+ while (1) switch (_context12.prev = _context12.next) {
625
+ case 0:
626
+ files = ids.map(function (id) {
627
+ return {
628
+ id: id,
629
+ collection: collectionName
630
+ };
631
+ });
632
+ metadata = {
633
+ method: 'POST',
634
+ endpoint: '/file/copy/intents'
635
+ };
636
+ options = _objectSpread(_objectSpread({}, metadata), {}, {
637
+ authContext: {
638
+ collectionName: collectionName
639
+ },
640
+ headers: jsonHeaders,
641
+ body: JSON.stringify({
642
+ files: files
643
+ }),
644
+ traceContext: traceContext
645
+ });
646
+ _context12.next = 5;
647
+ return this.request('/file/copy/intents', options);
648
+ case 5:
649
+ case "end":
650
+ return _context12.stop();
651
+ }
652
+ }, _callee12, this);
653
+ }));
654
+ function registerCopyIntents(_x38, _x39, _x40) {
655
+ return _registerCopyIntents.apply(this, arguments);
656
+ }
657
+ return registerCopyIntents;
658
+ }()
590
659
  }, {
591
660
  key: "request",
592
661
  value: function () {
593
- var _request2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(path) {
662
+ var _request2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(path) {
594
663
  var options,
595
664
  controller,
596
665
  useMediaCdn,
@@ -609,22 +678,22 @@ export var MediaStore = /*#__PURE__*/function () {
609
678
  extendedParams,
610
679
  url,
611
680
  response,
612
- _args12 = arguments;
613
- return _regeneratorRuntime.wrap(function _callee12$(_context12) {
614
- while (1) switch (_context12.prev = _context12.next) {
681
+ _args13 = arguments;
682
+ return _regeneratorRuntime.wrap(function _callee13$(_context13) {
683
+ while (1) switch (_context13.prev = _context13.next) {
615
684
  case 0:
616
- options = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : {
685
+ options = _args13.length > 1 && _args13[1] !== undefined ? _args13[1] : {
617
686
  method: 'GET',
618
687
  endpoint: undefined,
619
688
  authContext: {}
620
689
  };
621
- controller = _args12.length > 2 ? _args12[2] : undefined;
622
- useMediaCdn = _args12.length > 3 ? _args12[3] : undefined;
690
+ controller = _args13.length > 2 ? _args13[2] : undefined;
691
+ useMediaCdn = _args13.length > 3 ? _args13[3] : undefined;
623
692
  method = options.method, endpoint = options.endpoint, authContext = options.authContext, params = options.params, headers = options.headers, body = options.body, clientOptions = options.clientOptions, traceContext = options.traceContext, addMediaClientParam = options.addMediaClientParam;
624
- _context12.next = 6;
693
+ _context13.next = 6;
625
694
  return this.resolveAuth(authContext);
626
695
  case 6:
627
- auth = _context12.sent;
696
+ auth = _context13.sent;
628
697
  clientId = isClientBasedAuth(auth) ? auth.clientId : undefined;
629
698
  extendedTraceContext = extendTraceContext(traceContext);
630
699
  extendedParams = addMediaClientParam ? _objectSpread(_objectSpread({}, params), {}, {
@@ -634,7 +703,7 @@ export var MediaStore = /*#__PURE__*/function () {
634
703
  if (useMediaCdn) {
635
704
  url = mapToMediaCdnUrl(url, auth.token);
636
705
  }
637
- _context12.next = 14;
706
+ _context13.next = 14;
638
707
  return _request(url, {
639
708
  method: method,
640
709
  endpoint: endpoint,
@@ -646,17 +715,17 @@ export var MediaStore = /*#__PURE__*/function () {
646
715
  traceContext: extendedTraceContext
647
716
  }, controller);
648
717
  case 14:
649
- response = _context12.sent;
718
+ response = _context13.sent;
650
719
  setKeyValueInSessionStorage(MEDIA_API_REGION, response.headers.get('x-media-region'));
651
720
  setKeyValueInSessionStorage(MEDIA_API_ENVIRONMENT, response.headers.get('x-media-env'));
652
- return _context12.abrupt("return", response);
721
+ return _context13.abrupt("return", response);
653
722
  case 18:
654
723
  case "end":
655
- return _context12.stop();
724
+ return _context13.stop();
656
725
  }
657
- }, _callee12, this);
726
+ }, _callee13, this);
658
727
  }));
659
- function request(_x38) {
728
+ function request(_x41) {
660
729
  return _request2.apply(this, arguments);
661
730
  }
662
731
  return request;
@@ -664,16 +733,16 @@ export var MediaStore = /*#__PURE__*/function () {
664
733
  }, {
665
734
  key: "testUrl",
666
735
  value: function () {
667
- var _testUrl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(url) {
736
+ var _testUrl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(url) {
668
737
  var options,
669
738
  traceContext,
670
- _args13 = arguments;
671
- return _regeneratorRuntime.wrap(function _callee13$(_context13) {
672
- while (1) switch (_context13.prev = _context13.next) {
739
+ _args14 = arguments;
740
+ return _regeneratorRuntime.wrap(function _callee14$(_context14) {
741
+ while (1) switch (_context14.prev = _context14.next) {
673
742
  case 0:
674
- options = _args13.length > 1 && _args13[1] !== undefined ? _args13[1] : {};
743
+ options = _args14.length > 1 && _args14[1] !== undefined ? _args14[1] : {};
675
744
  traceContext = options.traceContext;
676
- _context13.next = 4;
745
+ _context14.next = 4;
677
746
  return _request(url, {
678
747
  method: 'HEAD',
679
748
  traceContext: extendTraceContext(traceContext),
@@ -685,11 +754,11 @@ export var MediaStore = /*#__PURE__*/function () {
685
754
  });
686
755
  case 4:
687
756
  case "end":
688
- return _context13.stop();
757
+ return _context14.stop();
689
758
  }
690
- }, _callee13);
759
+ }, _callee14);
691
760
  }));
692
- function testUrl(_x39) {
761
+ function testUrl(_x42) {
693
762
  return _testUrl.apply(this, arguments);
694
763
  }
695
764
  return testUrl;
@@ -700,7 +769,6 @@ export var MediaStore = /*#__PURE__*/function () {
700
769
  return this._chunkHashAlgorithm;
701
770
  }
702
771
  }]);
703
- return MediaStore;
704
772
  }();
705
773
  var getValueFromSessionStorage = function getValueFromSessionStorage(key) {
706
774
  return window && window.sessionStorage && window.sessionStorage.getItem(key) || undefined;
@@ -1,23 +1,22 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
- import _inherits from "@babel/runtime/helpers/inherits";
4
3
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
4
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
- function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
5
+ import _inherits from "@babel/runtime/helpers/inherits";
6
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
7
7
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
8
8
  import { BaseMediaClientError } from '../../models/errors';
9
9
  export var MediaStoreError = /*#__PURE__*/function (_BaseMediaClientError) {
10
- _inherits(MediaStoreError, _BaseMediaClientError);
11
- var _super = _createSuper(MediaStoreError);
12
10
  function MediaStoreError(reason, innerError) {
13
11
  var _this;
14
12
  _classCallCheck(this, MediaStoreError);
15
- _this = _super.call(this, reason);
13
+ _this = _callSuper(this, MediaStoreError, [reason]);
16
14
  _this.reason = reason;
17
15
  _this.innerError = innerError;
18
16
  return _this;
19
17
  }
20
- _createClass(MediaStoreError, [{
18
+ _inherits(MediaStoreError, _BaseMediaClientError);
19
+ return _createClass(MediaStoreError, [{
21
20
  key: "attributes",
22
21
  get: function get() {
23
22
  var reason = this.reason,
@@ -28,7 +27,6 @@ export var MediaStoreError = /*#__PURE__*/function (_BaseMediaClientError) {
28
27
  };
29
28
  }
30
29
  }]);
31
- return MediaStoreError;
32
30
  }(BaseMediaClientError);
33
31
  export function isMediaStoreError(err) {
34
32
  return err instanceof MediaStoreError;
@@ -36,7 +36,7 @@ export var MobileUploadImpl = /*#__PURE__*/function () {
36
36
  this.dataloader = createFileDataloader(mediaApi);
37
37
  this.servicesCache = createServicesCache();
38
38
  }
39
- _createClass(MobileUploadImpl, [{
39
+ return _createClass(MobileUploadImpl, [{
40
40
  key: "notifyUploadStart",
41
41
  value: function notifyUploadStart(event) {
42
42
  var _this2 = this;
@@ -109,5 +109,4 @@ export var MobileUploadImpl = /*#__PURE__*/function () {
109
109
  }
110
110
  }
111
111
  }]);
112
- return MobileUploadImpl;
113
112
  }();
@@ -7,7 +7,7 @@ export var StargateClient = /*#__PURE__*/function () {
7
7
  _classCallCheck(this, StargateClient);
8
8
  this.baseUrl = baseUrl || '/gateway/api';
9
9
  }
10
- _createClass(StargateClient, [{
10
+ return _createClass(StargateClient, [{
11
11
  key: "fetchToken",
12
12
  value: function () {
13
13
  var _fetchToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(clientId) {
@@ -41,5 +41,4 @@ export var StargateClient = /*#__PURE__*/function () {
41
41
  return token.data.iat + token.data.expiresIn - currentTimeInSeconds < 0;
42
42
  }
43
43
  }]);
44
- return StargateClient;
45
44
  }();
@@ -5,7 +5,7 @@ export var StreamsCache = /*#__PURE__*/function () {
5
5
  _classCallCheck(this, StreamsCache);
6
6
  this.streams = streams;
7
7
  }
8
- _createClass(StreamsCache, [{
8
+ return _createClass(StreamsCache, [{
9
9
  key: "has",
10
10
  value: function has(id) {
11
11
  return !!this.streams.find(id);
@@ -44,7 +44,6 @@ export var StreamsCache = /*#__PURE__*/function () {
44
44
  return this.streams.size;
45
45
  }
46
46
  }]);
47
- return StreamsCache;
48
47
  }();
49
48
  var streamCache;
50
49
  export var getFileStreamsCache = function getFileStreamsCache() {
@@ -1,11 +1,10 @@
1
1
  import _createClass from "@babel/runtime/helpers/createClass";
2
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/inherits";
5
3
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
4
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
5
+ import _inherits from "@babel/runtime/helpers/inherits";
7
6
  import _wrapNativeSuper from "@babel/runtime/helpers/wrapNativeSuper";
8
- function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
7
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
9
8
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
10
9
  export { isMediaClientError, getMediaClientErrorReason } from './helpers';
11
10
 
@@ -13,22 +12,21 @@ export { isMediaClientError, getMediaClientErrorReason } from './helpers';
13
12
  * Base class for media errors
14
13
  */
15
14
  export var BaseMediaClientError = /*#__PURE__*/function (_Error) {
16
- _inherits(BaseMediaClientError, _Error);
17
- var _super = _createSuper(BaseMediaClientError);
18
15
  function BaseMediaClientError(message) {
19
16
  var _this;
20
17
  _classCallCheck(this, BaseMediaClientError);
21
- _this = _super.call(this, message);
18
+ _this = _callSuper(this, BaseMediaClientError, [message]);
22
19
 
23
20
  // https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html#support-for-newtarget
24
21
  _this.message = message;
25
- Object.setPrototypeOf(_assertThisInitialized(_this), (this instanceof BaseMediaClientError ? this.constructor : void 0).prototype);
22
+ Object.setPrototypeOf(_this, (this instanceof BaseMediaClientError ? this.constructor : void 0).prototype);
26
23
 
27
24
  // https://v8.dev/docs/stack-trace-api
28
25
  if ('captureStackTrace' in Error) {
29
- Error.captureStackTrace(_assertThisInitialized(_this), this instanceof BaseMediaClientError ? this.constructor : void 0);
26
+ Error.captureStackTrace(_this, this instanceof BaseMediaClientError ? this.constructor : void 0);
30
27
  }
31
28
  return _this;
32
29
  }
30
+ _inherits(BaseMediaClientError, _Error);
33
31
  return _createClass(BaseMediaClientError);
34
32
  }( /*#__PURE__*/_wrapNativeSuper(Error));
@@ -4,7 +4,7 @@ export var UploadController = /*#__PURE__*/function () {
4
4
  function UploadController() {
5
5
  _classCallCheck(this, UploadController);
6
6
  }
7
- _createClass(UploadController, [{
7
+ return _createClass(UploadController, [{
8
8
  key: "setAbort",
9
9
  value: function setAbort(abortFunction) {
10
10
  this.abortFunction = abortFunction;
@@ -17,5 +17,4 @@ export var UploadController = /*#__PURE__*/function () {
17
17
  }
18
18
  }
19
19
  }]);
20
- return UploadController;
21
20
  }();