@atlaskit/media-client 28.5.0 → 29.0.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 +17 -0
- package/dist/cjs/client/file-fetcher/error.js +5 -7
- package/dist/cjs/client/file-fetcher/index.js +181 -71
- package/dist/cjs/client/media-client.js +1 -2
- package/dist/cjs/client/media-store/MediaStore.js +34 -24
- package/dist/cjs/client/media-store/error.js +5 -7
- package/dist/cjs/client/mobile-upload.js +1 -2
- package/dist/cjs/client/stargate-client.js +1 -2
- package/dist/cjs/file-streams-cache.js +1 -2
- package/dist/cjs/models/errors/index.js +6 -8
- package/dist/cjs/upload-controller.js +1 -2
- package/dist/cjs/uploader/error.js +5 -7
- package/dist/cjs/utils/createCopyIntentRegisterationBatcher.js +123 -0
- package/dist/cjs/utils/hashing/sha256SimpleHasher.js +1 -2
- package/dist/cjs/utils/hashing/simpleHasher.js +1 -2
- package/dist/cjs/utils/hashing/workerHasher.js +1 -2
- package/dist/cjs/utils/mobileUpload/error.js +5 -7
- package/dist/cjs/utils/polling/errors.js +5 -7
- package/dist/cjs/utils/polling/index.js +1 -2
- package/dist/cjs/utils/request/errors.js +5 -7
- package/dist/cjs/utils/request/helpers.js +10 -4
- package/dist/es2019/client/file-fetcher/index.js +60 -8
- package/dist/es2019/client/media-store/MediaStore.js +17 -14
- package/dist/es2019/utils/createCopyIntentRegisterationBatcher.js +75 -0
- package/dist/es2019/utils/request/helpers.js +7 -2
- package/dist/esm/client/file-fetcher/error.js +5 -7
- package/dist/esm/client/file-fetcher/index.js +181 -71
- package/dist/esm/client/media-client.js +1 -2
- package/dist/esm/client/media-store/MediaStore.js +36 -26
- package/dist/esm/client/media-store/error.js +5 -7
- package/dist/esm/client/mobile-upload.js +1 -2
- package/dist/esm/client/stargate-client.js +1 -2
- package/dist/esm/file-streams-cache.js +1 -2
- package/dist/esm/models/errors/index.js +6 -8
- package/dist/esm/upload-controller.js +1 -2
- package/dist/esm/uploader/error.js +5 -7
- package/dist/esm/utils/createCopyIntentRegisterationBatcher.js +115 -0
- package/dist/esm/utils/hashing/sha256SimpleHasher.js +1 -2
- package/dist/esm/utils/hashing/simpleHasher.js +1 -2
- package/dist/esm/utils/hashing/workerHasher.js +1 -2
- package/dist/esm/utils/mobileUpload/error.js +5 -7
- package/dist/esm/utils/polling/errors.js +5 -7
- package/dist/esm/utils/polling/index.js +1 -2
- package/dist/esm/utils/request/errors.js +5 -7
- package/dist/esm/utils/request/helpers.js +9 -4
- package/dist/types/client/file-fetcher/index.d.ts +7 -2
- package/dist/types/client/media-store/MediaStore.d.ts +4 -1
- package/dist/types/client/media-store/types.d.ts +5 -1
- package/dist/types/utils/createCopyIntentRegisterationBatcher.d.ts +20 -0
- package/dist/types/utils/request/helpers.d.ts +1 -0
- package/dist/types/utils/request/types.d.ts +1 -0
- package/dist/types-ts4.5/client/file-fetcher/index.d.ts +7 -2
- package/dist/types-ts4.5/client/media-store/MediaStore.d.ts +4 -1
- package/dist/types-ts4.5/client/media-store/types.d.ts +5 -1
- package/dist/types-ts4.5/utils/createCopyIntentRegisterationBatcher.d.ts +20 -0
- package/dist/types-ts4.5/utils/request/helpers.d.ts +1 -0
- package/dist/types-ts4.5/utils/request/types.d.ts +1 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/media-client
|
|
2
2
|
|
|
3
|
+
## 29.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#98696](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/98696)
|
|
8
|
+
[`bb55fa33eaf3f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/bb55fa33eaf3f) -
|
|
9
|
+
Changed API of unused registerCopyIntents to enable mutli-file uploads and added bulk reigster
|
|
10
|
+
copy intent endpoint in file
|
|
11
|
+
|
|
12
|
+
## 28.6.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- [#179378](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/179378)
|
|
17
|
+
[`cb26b4db4b6ad`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/cb26b4db4b6ad) -
|
|
18
|
+
Calling the /v2/file/copy endpoint in file.copyFile if auth providers are not given
|
|
19
|
+
|
|
3
20
|
## 28.5.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
|
@@ -9,27 +9,26 @@ exports.isFileFetcherError = isFileFetcherError;
|
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
11
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
13
12
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
14
13
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
14
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
15
15
|
var _errors = require("../../models/errors");
|
|
16
16
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
17
17
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
18
|
-
function
|
|
18
|
+
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
19
19
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
20
20
|
var FileFetcherError = exports.FileFetcherError = /*#__PURE__*/function (_BaseMediaClientError) {
|
|
21
|
-
(0, _inherits2.default)(FileFetcherError, _BaseMediaClientError);
|
|
22
|
-
var _super = _createSuper(FileFetcherError);
|
|
23
21
|
function FileFetcherError(reason, id, metadata) {
|
|
24
22
|
var _this;
|
|
25
23
|
(0, _classCallCheck2.default)(this, FileFetcherError);
|
|
26
|
-
_this =
|
|
24
|
+
_this = _callSuper(this, FileFetcherError, [reason]);
|
|
27
25
|
_this.reason = reason;
|
|
28
26
|
_this.id = id;
|
|
29
27
|
_this.metadata = metadata;
|
|
30
28
|
return _this;
|
|
31
29
|
}
|
|
32
|
-
(0,
|
|
30
|
+
(0, _inherits2.default)(FileFetcherError, _BaseMediaClientError);
|
|
31
|
+
return (0, _createClass2.default)(FileFetcherError, [{
|
|
33
32
|
key: "attributes",
|
|
34
33
|
get: function get() {
|
|
35
34
|
var reason = this.reason,
|
|
@@ -51,7 +50,6 @@ var FileFetcherError = exports.FileFetcherError = /*#__PURE__*/function (_BaseMe
|
|
|
51
50
|
});
|
|
52
51
|
}
|
|
53
52
|
}]);
|
|
54
|
-
return FileFetcherError;
|
|
55
53
|
}(_errors.BaseMediaClientError);
|
|
56
54
|
function isFileFetcherError(err) {
|
|
57
55
|
return err instanceof FileFetcherError;
|
|
@@ -49,10 +49,18 @@ var _shouldFetchRemoteFileStates = require("../../utils/shouldFetchRemoteFileSta
|
|
|
49
49
|
var _polling = require("../../utils/polling");
|
|
50
50
|
var _detectEmptyFile = require("../../utils/detectEmptyFile");
|
|
51
51
|
var _mediaState = require("@atlaskit/media-state");
|
|
52
|
+
var _createCopyIntentRegisterationBatcher = require("../../utils/createCopyIntentRegisterationBatcher");
|
|
53
|
+
var _helpers = require("../../utils/request/helpers");
|
|
52
54
|
var _excluded = ["metadata"],
|
|
53
55
|
_excluded2 = ["metadata"];
|
|
54
56
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
55
57
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
58
|
+
var isCopySourceFileWithToken = function isCopySourceFileWithToken(token) {
|
|
59
|
+
return !!token.authProvider;
|
|
60
|
+
};
|
|
61
|
+
var isCopyDestinationWithToken = function isCopyDestinationWithToken(token) {
|
|
62
|
+
return !!token.authProvider;
|
|
63
|
+
};
|
|
56
64
|
var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
57
65
|
function FileFetcherImpl(mediaApi) {
|
|
58
66
|
var _this = this;
|
|
@@ -183,8 +191,9 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
183
191
|
this.mediaApi = mediaApi;
|
|
184
192
|
this.store = store;
|
|
185
193
|
this.dataloader = (0, _createFileDataLoader.createFileDataloader)(mediaApi);
|
|
194
|
+
this.copyIntentRegisterationBatcher = (0, _createCopyIntentRegisterationBatcher.createCopyIntentRegisterationBatcher)(mediaApi);
|
|
186
195
|
}
|
|
187
|
-
(0, _createClass2.default)(FileFetcherImpl, [{
|
|
196
|
+
return (0, _createClass2.default)(FileFetcherImpl, [{
|
|
188
197
|
key: "getFileState",
|
|
189
198
|
value: function getFileState(id) {
|
|
190
199
|
var _this2 = this;
|
|
@@ -513,29 +522,143 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
513
522
|
}
|
|
514
523
|
return downloadBinary;
|
|
515
524
|
}()
|
|
525
|
+
}, {
|
|
526
|
+
key: "registerCopyIntent",
|
|
527
|
+
value: function () {
|
|
528
|
+
var _registerCopyIntent = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(id, collectionName) {
|
|
529
|
+
var auth, key, error;
|
|
530
|
+
return _regenerator.default.wrap(function _callee6$(_context6) {
|
|
531
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
532
|
+
case 0:
|
|
533
|
+
_context6.next = 2;
|
|
534
|
+
return this.mediaApi.resolveAuth({
|
|
535
|
+
collectionName: collectionName
|
|
536
|
+
});
|
|
537
|
+
case 2:
|
|
538
|
+
auth = _context6.sent;
|
|
539
|
+
key = {
|
|
540
|
+
id: id,
|
|
541
|
+
collectionName: collectionName,
|
|
542
|
+
resolvedAuth: auth
|
|
543
|
+
};
|
|
544
|
+
_context6.next = 6;
|
|
545
|
+
return this.copyIntentRegisterationBatcher.load(key);
|
|
546
|
+
case 6:
|
|
547
|
+
error = _context6.sent;
|
|
548
|
+
if (!error) {
|
|
549
|
+
_context6.next = 10;
|
|
550
|
+
break;
|
|
551
|
+
}
|
|
552
|
+
// if the error is retryable then it should not be cached
|
|
553
|
+
if ((0, _helpers.defaultShouldRetryError)(error)) {
|
|
554
|
+
this.copyIntentRegisterationBatcher.clear(key);
|
|
555
|
+
}
|
|
556
|
+
throw error;
|
|
557
|
+
case 10:
|
|
558
|
+
case "end":
|
|
559
|
+
return _context6.stop();
|
|
560
|
+
}
|
|
561
|
+
}, _callee6, this);
|
|
562
|
+
}));
|
|
563
|
+
function registerCopyIntent(_x9, _x10) {
|
|
564
|
+
return _registerCopyIntent.apply(this, arguments);
|
|
565
|
+
}
|
|
566
|
+
return registerCopyIntent;
|
|
567
|
+
}()
|
|
568
|
+
}, {
|
|
569
|
+
key: "copyFileWithToken",
|
|
570
|
+
value: function () {
|
|
571
|
+
var _copyFileWithToken = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(source, destination, traceContext) {
|
|
572
|
+
var authProvider, sourceCollection, id, destinationAuthProvider, destinationCollectionName, replaceFileId, occurrenceKey, mediaStore, owner, body, params, _yield$mediaStore$cop, data;
|
|
573
|
+
return _regenerator.default.wrap(function _callee7$(_context7) {
|
|
574
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
575
|
+
case 0:
|
|
576
|
+
authProvider = source.authProvider, sourceCollection = source.collection, id = source.id;
|
|
577
|
+
destinationAuthProvider = destination.authProvider, destinationCollectionName = destination.collection, replaceFileId = destination.replaceFileId, occurrenceKey = destination.occurrenceKey;
|
|
578
|
+
mediaStore = destination.mediaStore || new _mediaStore.MediaStore({
|
|
579
|
+
authProvider: destinationAuthProvider
|
|
580
|
+
});
|
|
581
|
+
_context7.t0 = _mediaCore.authToOwner;
|
|
582
|
+
_context7.next = 6;
|
|
583
|
+
return authProvider({
|
|
584
|
+
collectionName: sourceCollection
|
|
585
|
+
});
|
|
586
|
+
case 6:
|
|
587
|
+
_context7.t1 = _context7.sent;
|
|
588
|
+
owner = (0, _context7.t0)(_context7.t1);
|
|
589
|
+
body = {
|
|
590
|
+
sourceFile: {
|
|
591
|
+
id: id,
|
|
592
|
+
collection: sourceCollection,
|
|
593
|
+
owner: owner
|
|
594
|
+
}
|
|
595
|
+
};
|
|
596
|
+
params = {
|
|
597
|
+
collection: destinationCollectionName,
|
|
598
|
+
replaceFileId: replaceFileId,
|
|
599
|
+
occurrenceKey: occurrenceKey
|
|
600
|
+
};
|
|
601
|
+
_context7.next = 12;
|
|
602
|
+
return mediaStore.copyFileWithToken(body, params, traceContext);
|
|
603
|
+
case 12:
|
|
604
|
+
_yield$mediaStore$cop = _context7.sent;
|
|
605
|
+
data = _yield$mediaStore$cop.data;
|
|
606
|
+
return _context7.abrupt("return", data);
|
|
607
|
+
case 15:
|
|
608
|
+
case "end":
|
|
609
|
+
return _context7.stop();
|
|
610
|
+
}
|
|
611
|
+
}, _callee7);
|
|
612
|
+
}));
|
|
613
|
+
function copyFileWithToken(_x11, _x12, _x13) {
|
|
614
|
+
return _copyFileWithToken.apply(this, arguments);
|
|
615
|
+
}
|
|
616
|
+
return copyFileWithToken;
|
|
617
|
+
}()
|
|
618
|
+
}, {
|
|
619
|
+
key: "copyFileWithIntent",
|
|
620
|
+
value: function () {
|
|
621
|
+
var _copyFileWithIntent = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(source, destination, traceContext) {
|
|
622
|
+
var res, data;
|
|
623
|
+
return _regenerator.default.wrap(function _callee8$(_context8) {
|
|
624
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
625
|
+
case 0:
|
|
626
|
+
_context8.next = 2;
|
|
627
|
+
return this.mediaApi.copyFile(source.id, {
|
|
628
|
+
sourceCollection: source.collection,
|
|
629
|
+
collection: destination.collection,
|
|
630
|
+
replaceFileId: destination.replaceFileId
|
|
631
|
+
}, traceContext);
|
|
632
|
+
case 2:
|
|
633
|
+
res = _context8.sent;
|
|
634
|
+
data = res.data;
|
|
635
|
+
return _context8.abrupt("return", data);
|
|
636
|
+
case 5:
|
|
637
|
+
case "end":
|
|
638
|
+
return _context8.stop();
|
|
639
|
+
}
|
|
640
|
+
}, _callee8, this);
|
|
641
|
+
}));
|
|
642
|
+
function copyFileWithIntent(_x14, _x15, _x16) {
|
|
643
|
+
return _copyFileWithIntent.apply(this, arguments);
|
|
644
|
+
}
|
|
645
|
+
return copyFileWithIntent;
|
|
646
|
+
}()
|
|
516
647
|
}, {
|
|
517
648
|
key: "copyFile",
|
|
518
649
|
value: function () {
|
|
519
|
-
var _copyFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
650
|
+
var _copyFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(source, destination) {
|
|
520
651
|
var _this5 = this;
|
|
521
652
|
var options,
|
|
522
653
|
traceContext,
|
|
523
|
-
authProvider,
|
|
524
|
-
sourceCollection,
|
|
525
654
|
id,
|
|
526
|
-
destinationAuthProvider,
|
|
527
655
|
destinationCollectionName,
|
|
528
656
|
replaceFileId,
|
|
529
657
|
occurrenceKey,
|
|
530
658
|
preview,
|
|
531
659
|
mimeType,
|
|
532
|
-
mediaStore,
|
|
533
|
-
owner,
|
|
534
|
-
body,
|
|
535
|
-
params,
|
|
536
660
|
cache,
|
|
537
661
|
processingSubscription,
|
|
538
|
-
_yield$mediaStore$cop,
|
|
539
662
|
copiedFile,
|
|
540
663
|
copiedFileWithMimeType,
|
|
541
664
|
copiedId,
|
|
@@ -551,45 +674,33 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
551
674
|
replaceFileState,
|
|
552
675
|
key,
|
|
553
676
|
errorFileState,
|
|
554
|
-
|
|
555
|
-
return _regenerator.default.wrap(function
|
|
556
|
-
while (1) switch (
|
|
677
|
+
_args9 = arguments;
|
|
678
|
+
return _regenerator.default.wrap(function _callee9$(_context9) {
|
|
679
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
557
680
|
case 0:
|
|
558
|
-
options =
|
|
559
|
-
traceContext =
|
|
560
|
-
|
|
561
|
-
|
|
681
|
+
options = _args9.length > 2 && _args9[2] !== undefined ? _args9[2] : {};
|
|
682
|
+
traceContext = _args9.length > 3 ? _args9[3] : undefined;
|
|
683
|
+
id = source.id;
|
|
684
|
+
destinationCollectionName = destination.collection, replaceFileId = destination.replaceFileId, occurrenceKey = destination.occurrenceKey;
|
|
562
685
|
preview = options.preview, mimeType = options.mimeType;
|
|
563
|
-
mediaStore = destination.mediaStore || new _mediaStore.MediaStore({
|
|
564
|
-
authProvider: destinationAuthProvider
|
|
565
|
-
});
|
|
566
|
-
_context6.t0 = _mediaCore.authToOwner;
|
|
567
|
-
_context6.next = 9;
|
|
568
|
-
return authProvider({
|
|
569
|
-
collectionName: sourceCollection
|
|
570
|
-
});
|
|
571
|
-
case 9:
|
|
572
|
-
_context6.t1 = _context6.sent;
|
|
573
|
-
owner = (0, _context6.t0)(_context6.t1);
|
|
574
|
-
body = {
|
|
575
|
-
sourceFile: {
|
|
576
|
-
id: id,
|
|
577
|
-
collection: sourceCollection,
|
|
578
|
-
owner: owner
|
|
579
|
-
}
|
|
580
|
-
};
|
|
581
|
-
params = {
|
|
582
|
-
collection: destinationCollectionName,
|
|
583
|
-
replaceFileId: replaceFileId,
|
|
584
|
-
occurrenceKey: occurrenceKey
|
|
585
|
-
};
|
|
586
686
|
cache = (0, _fileStreamsCache.getFileStreamsCache)();
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
687
|
+
_context9.prev = 6;
|
|
688
|
+
if (!(isCopySourceFileWithToken(source) && isCopyDestinationWithToken(destination))) {
|
|
689
|
+
_context9.next = 13;
|
|
690
|
+
break;
|
|
691
|
+
}
|
|
692
|
+
_context9.next = 10;
|
|
693
|
+
return this.copyFileWithToken(source, destination, traceContext);
|
|
694
|
+
case 10:
|
|
695
|
+
copiedFile = _context9.sent;
|
|
696
|
+
_context9.next = 16;
|
|
697
|
+
break;
|
|
698
|
+
case 13:
|
|
699
|
+
_context9.next = 15;
|
|
700
|
+
return this.copyFileWithIntent(source, destination, traceContext);
|
|
701
|
+
case 15:
|
|
702
|
+
copiedFile = _context9.sent;
|
|
703
|
+
case 16:
|
|
593
704
|
// if we were passed a "mimeType", we propagate it into copiedFileWithMimeType
|
|
594
705
|
copiedFileWithMimeType = _objectSpread(_objectSpread({}, copiedFile), mimeType ? {
|
|
595
706
|
mimeType: mimeType
|
|
@@ -605,21 +716,21 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
605
716
|
previewOverride = !(0, _fileState2.isErrorFileState)(copiedFileState) && !!preview ? {
|
|
606
717
|
preview: preview
|
|
607
718
|
} : {};
|
|
608
|
-
|
|
719
|
+
_context9.t0 = !(0, _fileState2.isFinalFileState)(copiedFileState) &&
|
|
609
720
|
// mimeType should always be returned by "copyFileWithToken"
|
|
610
721
|
// but in case it's not, we don't want to penalize "copyFile"
|
|
611
722
|
copiedMimeType;
|
|
612
|
-
if (!
|
|
613
|
-
|
|
723
|
+
if (!_context9.t0) {
|
|
724
|
+
_context9.next = 28;
|
|
614
725
|
break;
|
|
615
726
|
}
|
|
616
|
-
|
|
727
|
+
_context9.next = 27;
|
|
617
728
|
return (0, _shouldFetchRemoteFileStates.shouldFetchRemoteFileStates)(mediaType, copiedMimeType, preview);
|
|
618
|
-
case
|
|
619
|
-
|
|
620
|
-
case
|
|
621
|
-
if (!
|
|
622
|
-
|
|
729
|
+
case 27:
|
|
730
|
+
_context9.t0 = _context9.sent;
|
|
731
|
+
case 28:
|
|
732
|
+
if (!_context9.t0) {
|
|
733
|
+
_context9.next = 35;
|
|
623
734
|
break;
|
|
624
735
|
}
|
|
625
736
|
fileState = _objectSpread(_objectSpread(_objectSpread({}, copiedFileState), (0, _overrideMediaTypeIfUnknown.overrideMediaTypeIfUnknown)(copiedFileState, mediaType)), previewOverride);
|
|
@@ -640,22 +751,22 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
640
751
|
return subject.complete();
|
|
641
752
|
}
|
|
642
753
|
});
|
|
643
|
-
|
|
754
|
+
_context9.next = 36;
|
|
644
755
|
break;
|
|
645
|
-
case
|
|
756
|
+
case 35:
|
|
646
757
|
if (!(0, _fileState2.isProcessingFileState)(copiedFileState)) {
|
|
647
758
|
_fileState = _objectSpread(_objectSpread({}, copiedFileState), !(0, _fileState2.isErrorFileState)(copiedFileState) && previewOverride);
|
|
648
759
|
subject.next(_fileState);
|
|
649
760
|
this.setFileState(copiedId, _fileState);
|
|
650
761
|
}
|
|
651
|
-
case
|
|
762
|
+
case 36:
|
|
652
763
|
if (!cache.has(copiedId)) {
|
|
653
764
|
(0, _fileStreamsCache.getFileStreamsCache)().set(copiedId, subject);
|
|
654
765
|
}
|
|
655
|
-
return
|
|
656
|
-
case
|
|
657
|
-
|
|
658
|
-
|
|
766
|
+
return _context9.abrupt("return", copiedFile);
|
|
767
|
+
case 40:
|
|
768
|
+
_context9.prev = 40;
|
|
769
|
+
_context9.t1 = _context9["catch"](6);
|
|
659
770
|
if (processingSubscription) {
|
|
660
771
|
processingSubscription.unsubscribe();
|
|
661
772
|
}
|
|
@@ -663,27 +774,26 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
663
774
|
_fileCache = cache.get(replaceFileId);
|
|
664
775
|
replaceFileState = this.store.getState().files[replaceFileId];
|
|
665
776
|
if (_fileCache) {
|
|
666
|
-
_fileCache.error(
|
|
777
|
+
_fileCache.error(_context9.t1);
|
|
667
778
|
} else {
|
|
668
779
|
// Create a new subject with the error state for new subscriptions
|
|
669
|
-
cache.set(id, (0, _createMediaSubject.createMediaSubject)(
|
|
780
|
+
cache.set(id, (0, _createMediaSubject.createMediaSubject)(_context9.t1));
|
|
670
781
|
}
|
|
671
782
|
key = replaceFileState ? replaceFileId : id;
|
|
672
|
-
errorFileState = this.getErrorFileState(
|
|
783
|
+
errorFileState = this.getErrorFileState(_context9.t1, id, occurrenceKey);
|
|
673
784
|
this.setFileState(key, errorFileState);
|
|
674
785
|
}
|
|
675
|
-
throw
|
|
676
|
-
case
|
|
786
|
+
throw _context9.t1;
|
|
787
|
+
case 45:
|
|
677
788
|
case "end":
|
|
678
|
-
return
|
|
789
|
+
return _context9.stop();
|
|
679
790
|
}
|
|
680
|
-
},
|
|
791
|
+
}, _callee9, this, [[6, 40]]);
|
|
681
792
|
}));
|
|
682
|
-
function copyFile(
|
|
793
|
+
function copyFile(_x17, _x18) {
|
|
683
794
|
return _copyFile.apply(this, arguments);
|
|
684
795
|
}
|
|
685
796
|
return copyFile;
|
|
686
797
|
}()
|
|
687
798
|
}]);
|
|
688
|
-
return FileFetcherImpl;
|
|
689
799
|
}();
|
|
@@ -44,7 +44,7 @@ var MediaClient = exports.MediaClient = /*#__PURE__*/function () {
|
|
|
44
44
|
/**
|
|
45
45
|
* @internal
|
|
46
46
|
*/
|
|
47
|
-
(0, _createClass2.default)(MediaClient, [{
|
|
47
|
+
return (0, _createClass2.default)(MediaClient, [{
|
|
48
48
|
key: "__DO_NOT_USE__getMediaStore",
|
|
49
49
|
value: function __DO_NOT_USE__getMediaStore() {
|
|
50
50
|
return this.store;
|
|
@@ -155,5 +155,4 @@ var MediaClient = exports.MediaClient = /*#__PURE__*/function () {
|
|
|
155
155
|
return this.eventEmitter.emit(event, payload);
|
|
156
156
|
}
|
|
157
157
|
}]);
|
|
158
|
-
return MediaClient;
|
|
159
158
|
}();
|
|
@@ -61,7 +61,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
61
61
|
this.config = config;
|
|
62
62
|
this._chunkHashAlgorithm = config.chunkHashAlgorithm || _mediaCore.ChunkHashAlgorithm.Sha1;
|
|
63
63
|
}
|
|
64
|
-
(0, _createClass2.default)(MediaStore, [{
|
|
64
|
+
return (0, _createClass2.default)(MediaStore, [{
|
|
65
65
|
key: "removeCollectionFile",
|
|
66
66
|
value: function () {
|
|
67
67
|
var _removeCollectionFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(id, collectionName, occurrenceKey, traceContext) {
|
|
@@ -609,41 +609,41 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
609
609
|
body: JSON.stringify({
|
|
610
610
|
id: id
|
|
611
611
|
}),
|
|
612
|
-
traceContext: traceContext
|
|
612
|
+
traceContext: traceContext,
|
|
613
|
+
clientOptions: {
|
|
614
|
+
retryOptions: {
|
|
615
|
+
shouldRetryError: function shouldRetryError(err) {
|
|
616
|
+
var _err$metadata;
|
|
617
|
+
return (0, _helpers.defaultShouldRetryError)(err) || (0, _request3.isRequestError)(err) && (err === null || err === void 0 || (_err$metadata = err.metadata) === null || _err$metadata === void 0 ? void 0 : _err$metadata.statusCode) === 401;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
}
|
|
613
621
|
});
|
|
614
622
|
return this.request('/v2/file/copy', options).then((0, _helpers.createMapResponseToJson)(metadata));
|
|
615
623
|
}
|
|
616
624
|
}, {
|
|
617
625
|
key: "registerCopyIntents",
|
|
618
626
|
value: function () {
|
|
619
|
-
var _registerCopyIntents = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12(
|
|
620
|
-
var
|
|
627
|
+
var _registerCopyIntents = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12(files, traceContext, resolvedAuth) {
|
|
628
|
+
var metadata, options;
|
|
621
629
|
return _regenerator.default.wrap(function _callee12$(_context12) {
|
|
622
630
|
while (1) switch (_context12.prev = _context12.next) {
|
|
623
631
|
case 0:
|
|
624
|
-
files = ids.map(function (id) {
|
|
625
|
-
return {
|
|
626
|
-
id: id,
|
|
627
|
-
collection: collectionName
|
|
628
|
-
};
|
|
629
|
-
});
|
|
630
632
|
metadata = {
|
|
631
633
|
method: 'POST',
|
|
632
634
|
endpoint: '/file/copy/intents'
|
|
633
635
|
};
|
|
634
636
|
options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
635
|
-
authContext: {
|
|
636
|
-
collectionName: collectionName
|
|
637
|
-
},
|
|
638
637
|
headers: jsonHeaders,
|
|
639
638
|
body: JSON.stringify({
|
|
640
639
|
files: files
|
|
641
640
|
}),
|
|
642
|
-
traceContext: traceContext
|
|
641
|
+
traceContext: traceContext,
|
|
642
|
+
resolvedAuth: resolvedAuth
|
|
643
643
|
});
|
|
644
|
-
_context12.next =
|
|
644
|
+
_context12.next = 4;
|
|
645
645
|
return this.request('/file/copy/intents', options);
|
|
646
|
-
case
|
|
646
|
+
case 4:
|
|
647
647
|
case "end":
|
|
648
648
|
return _context12.stop();
|
|
649
649
|
}
|
|
@@ -670,6 +670,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
670
670
|
clientOptions,
|
|
671
671
|
traceContext,
|
|
672
672
|
addMediaClientParam,
|
|
673
|
+
resolvedAuth,
|
|
673
674
|
auth,
|
|
674
675
|
clientId,
|
|
675
676
|
extendedTraceContext,
|
|
@@ -687,11 +688,21 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
687
688
|
};
|
|
688
689
|
controller = _args13.length > 2 ? _args13[2] : undefined;
|
|
689
690
|
useMediaCdn = _args13.length > 3 ? _args13[3] : undefined;
|
|
690
|
-
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;
|
|
691
|
-
|
|
691
|
+
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, resolvedAuth = options.resolvedAuth;
|
|
692
|
+
if (!(resolvedAuth !== null && resolvedAuth !== void 0)) {
|
|
693
|
+
_context13.next = 8;
|
|
694
|
+
break;
|
|
695
|
+
}
|
|
696
|
+
_context13.t0 = resolvedAuth;
|
|
697
|
+
_context13.next = 11;
|
|
698
|
+
break;
|
|
699
|
+
case 8:
|
|
700
|
+
_context13.next = 10;
|
|
692
701
|
return this.resolveAuth(authContext);
|
|
693
|
-
case
|
|
694
|
-
|
|
702
|
+
case 10:
|
|
703
|
+
_context13.t0 = _context13.sent;
|
|
704
|
+
case 11:
|
|
705
|
+
auth = _context13.t0;
|
|
695
706
|
clientId = (0, _mediaCore.isClientBasedAuth)(auth) ? auth.clientId : undefined;
|
|
696
707
|
extendedTraceContext = (0, _helpers.extendTraceContext)(traceContext);
|
|
697
708
|
extendedParams = addMediaClientParam ? _objectSpread(_objectSpread({}, params), {}, {
|
|
@@ -701,7 +712,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
701
712
|
if (useMediaCdn) {
|
|
702
713
|
url = (0, _mediaCdn.mapToMediaCdnUrl)(url, auth.token);
|
|
703
714
|
}
|
|
704
|
-
_context13.next =
|
|
715
|
+
_context13.next = 19;
|
|
705
716
|
return (0, _request3.request)(url, {
|
|
706
717
|
method: method,
|
|
707
718
|
endpoint: endpoint,
|
|
@@ -712,12 +723,12 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
712
723
|
clientOptions: clientOptions,
|
|
713
724
|
traceContext: extendedTraceContext
|
|
714
725
|
}, controller);
|
|
715
|
-
case
|
|
726
|
+
case 19:
|
|
716
727
|
response = _context13.sent;
|
|
717
728
|
setKeyValueInSessionStorage(MEDIA_API_REGION, response.headers.get('x-media-region'));
|
|
718
729
|
setKeyValueInSessionStorage(MEDIA_API_ENVIRONMENT, response.headers.get('x-media-env'));
|
|
719
730
|
return _context13.abrupt("return", response);
|
|
720
|
-
case
|
|
731
|
+
case 23:
|
|
721
732
|
case "end":
|
|
722
733
|
return _context13.stop();
|
|
723
734
|
}
|
|
@@ -767,7 +778,6 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
767
778
|
return this._chunkHashAlgorithm;
|
|
768
779
|
}
|
|
769
780
|
}]);
|
|
770
|
-
return MediaStore;
|
|
771
781
|
}();
|
|
772
782
|
var getValueFromSessionStorage = function getValueFromSessionStorage(key) {
|
|
773
783
|
return window && window.sessionStorage && window.sessionStorage.getItem(key) || undefined;
|
|
@@ -8,24 +8,23 @@ exports.MediaStoreError = void 0;
|
|
|
8
8
|
exports.isMediaStoreError = isMediaStoreError;
|
|
9
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
12
11
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
13
12
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
13
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
14
14
|
var _errors = require("../../models/errors");
|
|
15
|
-
function
|
|
15
|
+
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
16
16
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
17
17
|
var MediaStoreError = exports.MediaStoreError = /*#__PURE__*/function (_BaseMediaClientError) {
|
|
18
|
-
(0, _inherits2.default)(MediaStoreError, _BaseMediaClientError);
|
|
19
|
-
var _super = _createSuper(MediaStoreError);
|
|
20
18
|
function MediaStoreError(reason, innerError) {
|
|
21
19
|
var _this;
|
|
22
20
|
(0, _classCallCheck2.default)(this, MediaStoreError);
|
|
23
|
-
_this =
|
|
21
|
+
_this = _callSuper(this, MediaStoreError, [reason]);
|
|
24
22
|
_this.reason = reason;
|
|
25
23
|
_this.innerError = innerError;
|
|
26
24
|
return _this;
|
|
27
25
|
}
|
|
28
|
-
(0,
|
|
26
|
+
(0, _inherits2.default)(MediaStoreError, _BaseMediaClientError);
|
|
27
|
+
return (0, _createClass2.default)(MediaStoreError, [{
|
|
29
28
|
key: "attributes",
|
|
30
29
|
get: function get() {
|
|
31
30
|
var reason = this.reason,
|
|
@@ -36,7 +35,6 @@ var MediaStoreError = exports.MediaStoreError = /*#__PURE__*/function (_BaseMedi
|
|
|
36
35
|
};
|
|
37
36
|
}
|
|
38
37
|
}]);
|
|
39
|
-
return MediaStoreError;
|
|
40
38
|
}(_errors.BaseMediaClientError);
|
|
41
39
|
function isMediaStoreError(err) {
|
|
42
40
|
return err instanceof MediaStoreError;
|
|
@@ -43,7 +43,7 @@ var MobileUploadImpl = exports.MobileUploadImpl = /*#__PURE__*/function () {
|
|
|
43
43
|
this.dataloader = (0, _createFileDataLoader.createFileDataloader)(mediaApi);
|
|
44
44
|
this.servicesCache = (0, _mobileUpload.createServicesCache)();
|
|
45
45
|
}
|
|
46
|
-
(0, _createClass2.default)(MobileUploadImpl, [{
|
|
46
|
+
return (0, _createClass2.default)(MobileUploadImpl, [{
|
|
47
47
|
key: "notifyUploadStart",
|
|
48
48
|
value: function notifyUploadStart(event) {
|
|
49
49
|
var _this2 = this;
|
|
@@ -116,5 +116,4 @@ var MobileUploadImpl = exports.MobileUploadImpl = /*#__PURE__*/function () {
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
}]);
|
|
119
|
-
return MobileUploadImpl;
|
|
120
119
|
}();
|
|
@@ -14,7 +14,7 @@ var StargateClient = exports.StargateClient = /*#__PURE__*/function () {
|
|
|
14
14
|
(0, _classCallCheck2.default)(this, StargateClient);
|
|
15
15
|
this.baseUrl = baseUrl || '/gateway/api';
|
|
16
16
|
}
|
|
17
|
-
(0, _createClass2.default)(StargateClient, [{
|
|
17
|
+
return (0, _createClass2.default)(StargateClient, [{
|
|
18
18
|
key: "fetchToken",
|
|
19
19
|
value: function () {
|
|
20
20
|
var _fetchToken = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(clientId) {
|
|
@@ -48,5 +48,4 @@ var StargateClient = exports.StargateClient = /*#__PURE__*/function () {
|
|
|
48
48
|
return token.data.iat + token.data.expiresIn - currentTimeInSeconds < 0;
|
|
49
49
|
}
|
|
50
50
|
}]);
|
|
51
|
-
return StargateClient;
|
|
52
51
|
}();
|
|
@@ -12,7 +12,7 @@ var StreamsCache = exports.StreamsCache = /*#__PURE__*/function () {
|
|
|
12
12
|
(0, _classCallCheck2.default)(this, StreamsCache);
|
|
13
13
|
this.streams = streams;
|
|
14
14
|
}
|
|
15
|
-
(0, _createClass2.default)(StreamsCache, [{
|
|
15
|
+
return (0, _createClass2.default)(StreamsCache, [{
|
|
16
16
|
key: "has",
|
|
17
17
|
value: function has(id) {
|
|
18
18
|
return !!this.streams.find(id);
|
|
@@ -51,7 +51,6 @@ var StreamsCache = exports.StreamsCache = /*#__PURE__*/function () {
|
|
|
51
51
|
return this.streams.size;
|
|
52
52
|
}
|
|
53
53
|
}]);
|
|
54
|
-
return StreamsCache;
|
|
55
54
|
}();
|
|
56
55
|
var streamCache;
|
|
57
56
|
var getFileStreamsCache = exports.getFileStreamsCache = function getFileStreamsCache() {
|