@atlaskit/media-client 20.0.1 → 20.0.3
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 +12 -0
- package/dist/cjs/client/collection-fetcher.js +4 -44
- package/dist/cjs/client/file-fetcher/error.js +3 -19
- package/dist/cjs/client/file-fetcher/index.js +72 -191
- package/dist/cjs/client/media-client.js +2 -26
- package/dist/cjs/client/media-store/error.js +1 -17
- package/dist/cjs/client/media-store/index.js +13 -103
- package/dist/cjs/client/media-store/resolveAuth.js +2 -23
- package/dist/cjs/client/mobile-upload.js +9 -22
- package/dist/cjs/client/stargate-client.js +0 -12
- package/dist/cjs/constants.js +1 -4
- package/dist/cjs/file-streams-cache.js +0 -11
- package/dist/cjs/globalMediaEventEmitter.js +0 -3
- package/dist/cjs/identifier.js +0 -8
- package/dist/cjs/index.js +0 -38
- package/dist/cjs/models/artifacts.js +0 -4
- package/dist/cjs/models/auth-headers.js +0 -2
- package/dist/cjs/models/auth-query-parameters.js +0 -2
- package/dist/cjs/models/errors/helpers.js +0 -2
- package/dist/cjs/models/errors/index.js +4 -20
- package/dist/cjs/models/file-state.js +10 -36
- package/dist/cjs/models/media.js +2 -8
- package/dist/cjs/upload-controller.js +0 -6
- package/dist/cjs/uploader/calculateChunkSize.js +1 -10
- package/dist/cjs/uploader/error.js +3 -19
- package/dist/cjs/uploader/index.js +3 -43
- package/dist/cjs/utils/checkWebpSupport.js +3 -7
- package/dist/cjs/utils/convertBase64ToBlob.js +0 -5
- package/dist/cjs/utils/createFileDataLoader.js +4 -28
- package/dist/cjs/utils/createMediaSubject.js +0 -4
- package/dist/cjs/utils/detectEmptyFile.js +8 -15
- package/dist/cjs/utils/getDimensionsFromBlob.js +0 -14
- package/dist/cjs/utils/getImageDimensionsFromBlob.js +0 -4
- package/dist/cjs/utils/getMediaTypeFromUploadableFile.js +0 -3
- package/dist/cjs/utils/getVideoDimensionsFromBlob.js +2 -8
- package/dist/cjs/utils/hashing/hasherCreator.js +0 -20
- package/dist/cjs/utils/hashing/simpleHasher.js +0 -12
- package/dist/cjs/utils/hashing/workerHasher.js +3 -24
- package/dist/cjs/utils/imageResizeModeToFileImageMode.js +0 -2
- package/dist/cjs/utils/isImageRemote.js +0 -5
- package/dist/cjs/utils/mediaSubscribable/fromObservable.js +2 -4
- package/dist/cjs/utils/mediaSubscribable/index.js +0 -2
- package/dist/cjs/utils/mediaSubscribable/toPromise.js +1 -3
- package/dist/cjs/utils/mobileUpload/error.js +3 -19
- package/dist/cjs/utils/mobileUpload/helpers.js +2 -26
- package/dist/cjs/utils/mobileUpload/index.js +0 -4
- package/dist/cjs/utils/mobileUpload/servicesCache.js +0 -2
- package/dist/cjs/utils/mobileUpload/stateMachine/index.js +0 -22
- package/dist/cjs/utils/mobileUpload/stateMachine/states/processing.js +0 -2
- package/dist/cjs/utils/mobileUpload/stateMachine/states/uploading.js +0 -7
- package/dist/cjs/utils/overrideMediaTypeIfUnknown.js +0 -4
- package/dist/cjs/utils/polling/errors.js +1 -17
- package/dist/cjs/utils/polling/index.js +1 -30
- package/dist/cjs/utils/request/errors.js +8 -24
- package/dist/cjs/utils/request/helpers.js +19 -103
- package/dist/cjs/utils/request/index.js +15 -26
- package/dist/cjs/utils/safeUnsubscribe.js +0 -2
- package/dist/cjs/utils/setTimeoutPromise.js +0 -4
- package/dist/cjs/utils/shouldFetchRemoteFileStates.js +0 -21
- package/dist/cjs/utils/url.js +4 -27
- package/dist/cjs/utils/with-media-client-hoc.js +12 -28
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/client/collection-fetcher.js +6 -18
- package/dist/es2019/client/file-fetcher/error.js +0 -2
- package/dist/es2019/client/file-fetcher/index.js +49 -91
- package/dist/es2019/client/media-client.js +3 -13
- package/dist/es2019/client/media-store/error.js +0 -2
- package/dist/es2019/client/media-store/index.js +37 -52
- package/dist/es2019/client/media-store/resolveAuth.js +1 -5
- package/dist/es2019/client/mobile-upload.js +0 -8
- package/dist/es2019/client/stargate-client.js +0 -3
- package/dist/es2019/constants.js +1 -2
- package/dist/es2019/file-streams-cache.js +0 -11
- package/dist/es2019/globalMediaEventEmitter.js +0 -4
- package/dist/es2019/index.js +4 -11
- package/dist/es2019/models/artifacts.js +0 -2
- package/dist/es2019/models/errors/index.js +5 -4
- package/dist/es2019/models/file-state.js +6 -7
- package/dist/es2019/models/media.js +2 -3
- package/dist/es2019/upload-controller.js +0 -3
- package/dist/es2019/uploader/calculateChunkSize.js +1 -4
- package/dist/es2019/uploader/error.js +0 -2
- package/dist/es2019/uploader/index.js +0 -13
- package/dist/es2019/utils/checkWebpSupport.js +3 -4
- package/dist/es2019/utils/convertBase64ToBlob.js +0 -2
- package/dist/es2019/utils/createFileDataLoader.js +6 -9
- package/dist/es2019/utils/createMediaSubject.js +0 -2
- package/dist/es2019/utils/detectEmptyFile.js +1 -5
- package/dist/es2019/utils/getDimensionsFromBlob.js +0 -3
- package/dist/es2019/utils/getImageDimensionsFromBlob.js +0 -2
- package/dist/es2019/utils/getVideoDimensionsFromBlob.js +2 -1
- package/dist/es2019/utils/hashing/hasherCreator.js +0 -2
- package/dist/es2019/utils/hashing/simpleHasher.js +0 -3
- package/dist/es2019/utils/hashing/workerHasher.js +1 -16
- package/dist/es2019/utils/isImageRemote.js +0 -2
- package/dist/es2019/utils/mediaSubscribable/fromObservable.js +2 -1
- package/dist/es2019/utils/mediaSubscribable/toPromise.js +1 -1
- package/dist/es2019/utils/mobileUpload/error.js +0 -2
- package/dist/es2019/utils/mobileUpload/helpers.js +2 -7
- package/dist/es2019/utils/mobileUpload/stateMachine/index.js +0 -2
- package/dist/es2019/utils/mobileUpload/stateMachine/states/uploading.js +2 -1
- package/dist/es2019/utils/overrideMediaTypeIfUnknown.js +0 -1
- package/dist/es2019/utils/polling/errors.js +0 -2
- package/dist/es2019/utils/polling/index.js +3 -20
- package/dist/es2019/utils/request/errors.js +0 -2
- package/dist/es2019/utils/request/helpers.js +24 -35
- package/dist/es2019/utils/request/index.js +2 -2
- package/dist/es2019/utils/shouldFetchRemoteFileStates.js +1 -5
- package/dist/es2019/utils/url.js +6 -14
- package/dist/es2019/utils/with-media-client-hoc.js +10 -7
- package/dist/es2019/version.json +1 -1
- package/dist/esm/client/collection-fetcher.js +4 -34
- package/dist/esm/client/file-fetcher/error.js +3 -12
- package/dist/esm/client/file-fetcher/index.js +74 -161
- package/dist/esm/client/media-client.js +3 -16
- package/dist/esm/client/media-store/error.js +1 -10
- package/dist/esm/client/media-store/index.js +13 -89
- package/dist/esm/client/media-store/resolveAuth.js +2 -13
- package/dist/esm/client/mobile-upload.js +9 -15
- package/dist/esm/client/stargate-client.js +0 -7
- package/dist/esm/constants.js +1 -2
- package/dist/esm/file-streams-cache.js +0 -6
- package/dist/esm/globalMediaEventEmitter.js +0 -1
- package/dist/esm/index.js +4 -11
- package/dist/esm/models/artifacts.js +0 -2
- package/dist/esm/models/errors/index.js +5 -12
- package/dist/esm/models/file-state.js +10 -17
- package/dist/esm/models/media.js +2 -3
- package/dist/esm/upload-controller.js +0 -2
- package/dist/esm/uploader/calculateChunkSize.js +1 -4
- package/dist/esm/uploader/error.js +3 -12
- package/dist/esm/uploader/index.js +3 -32
- package/dist/esm/utils/checkWebpSupport.js +3 -4
- package/dist/esm/utils/convertBase64ToBlob.js +0 -3
- package/dist/esm/utils/createFileDataLoader.js +4 -18
- package/dist/esm/utils/createMediaSubject.js +0 -2
- package/dist/esm/utils/detectEmptyFile.js +8 -12
- package/dist/esm/utils/getDimensionsFromBlob.js +0 -7
- package/dist/esm/utils/getImageDimensionsFromBlob.js +0 -2
- package/dist/esm/utils/getVideoDimensionsFromBlob.js +2 -3
- package/dist/esm/utils/hashing/hasherCreator.js +0 -9
- package/dist/esm/utils/hashing/simpleHasher.js +0 -4
- package/dist/esm/utils/hashing/workerHasher.js +3 -18
- package/dist/esm/utils/isImageRemote.js +0 -3
- package/dist/esm/utils/mediaSubscribable/fromObservable.js +2 -1
- package/dist/esm/utils/mediaSubscribable/toPromise.js +1 -1
- package/dist/esm/utils/mobileUpload/error.js +3 -12
- package/dist/esm/utils/mobileUpload/helpers.js +2 -11
- package/dist/esm/utils/mobileUpload/stateMachine/index.js +0 -6
- package/dist/esm/utils/mobileUpload/stateMachine/states/uploading.js +0 -3
- package/dist/esm/utils/overrideMediaTypeIfUnknown.js +0 -1
- package/dist/esm/utils/polling/errors.js +1 -10
- package/dist/esm/utils/polling/index.js +1 -27
- package/dist/esm/utils/request/errors.js +8 -17
- package/dist/esm/utils/request/helpers.js +22 -76
- package/dist/esm/utils/request/index.js +15 -20
- package/dist/esm/utils/shouldFetchRemoteFileStates.js +1 -15
- package/dist/esm/utils/url.js +4 -18
- package/dist/esm/utils/with-media-client-hoc.js +12 -17
- package/dist/esm/version.json +1 -1
- package/package.json +7 -5
|
@@ -9,10 +9,11 @@ import { FileFetcherImpl } from './file-fetcher';
|
|
|
9
9
|
import { StargateClient } from './stargate-client';
|
|
10
10
|
export var MediaClient = /*#__PURE__*/function () {
|
|
11
11
|
// mobile upload is lazily loaded
|
|
12
|
+
|
|
12
13
|
// Deprecated value introduced for backward compatibility with Context
|
|
14
|
+
|
|
13
15
|
function MediaClient(mediaClientConfig, featureFlags) {
|
|
14
16
|
_classCallCheck(this, MediaClient);
|
|
15
|
-
|
|
16
17
|
this.mediaClientConfig = mediaClientConfig;
|
|
17
18
|
this.featureFlags = featureFlags;
|
|
18
19
|
this.mediaStore = new MediaStore({
|
|
@@ -25,7 +26,6 @@ export var MediaClient = /*#__PURE__*/function () {
|
|
|
25
26
|
this.eventEmitter = new EventEmitter2();
|
|
26
27
|
this.stargate = new StargateClient(mediaClientConfig.stargateBaseUrl);
|
|
27
28
|
}
|
|
28
|
-
|
|
29
29
|
_createClass(MediaClient, [{
|
|
30
30
|
key: "getImage",
|
|
31
31
|
value: function getImage(id, params, controller, fetchMaxRes, traceContext) {
|
|
@@ -51,10 +51,8 @@ export var MediaClient = /*#__PURE__*/function () {
|
|
|
51
51
|
case 0:
|
|
52
52
|
_context.next = 2;
|
|
53
53
|
return this.mediaStore.getImageMetadata(id, params);
|
|
54
|
-
|
|
55
54
|
case 2:
|
|
56
55
|
return _context.abrupt("return", _context.sent.metadata);
|
|
57
|
-
|
|
58
56
|
case 3:
|
|
59
57
|
case "end":
|
|
60
58
|
return _context.stop();
|
|
@@ -62,11 +60,9 @@ export var MediaClient = /*#__PURE__*/function () {
|
|
|
62
60
|
}
|
|
63
61
|
}, _callee, this);
|
|
64
62
|
}));
|
|
65
|
-
|
|
66
63
|
function getImageMetadata(_x, _x2) {
|
|
67
64
|
return _getImageMetadata.apply(this, arguments);
|
|
68
65
|
}
|
|
69
|
-
|
|
70
66
|
return getImageMetadata;
|
|
71
67
|
}()
|
|
72
68
|
}, {
|
|
@@ -82,20 +78,14 @@ export var MediaClient = /*#__PURE__*/function () {
|
|
|
82
78
|
_context2.next = 2;
|
|
83
79
|
break;
|
|
84
80
|
}
|
|
85
|
-
|
|
86
81
|
return _context2.abrupt("return", this.mobileUpload);
|
|
87
|
-
|
|
88
82
|
case 2:
|
|
89
83
|
_context2.next = 4;
|
|
90
|
-
return import(
|
|
91
|
-
/* webpackChunkName: "@atlaskit-internal_media-client-mobile-upload" */
|
|
92
|
-
'./mobile-upload');
|
|
93
|
-
|
|
84
|
+
return import( /* webpackChunkName: "@atlaskit-internal_media-client-mobile-upload" */'./mobile-upload');
|
|
94
85
|
case 4:
|
|
95
86
|
module = _context2.sent;
|
|
96
87
|
this.mobileUpload = new module.MobileUploadImpl(this.mediaStore);
|
|
97
88
|
return _context2.abrupt("return", this.mobileUpload);
|
|
98
|
-
|
|
99
89
|
case 7:
|
|
100
90
|
case "end":
|
|
101
91
|
return _context2.stop();
|
|
@@ -103,11 +93,9 @@ export var MediaClient = /*#__PURE__*/function () {
|
|
|
103
93
|
}
|
|
104
94
|
}, _callee2, this);
|
|
105
95
|
}));
|
|
106
|
-
|
|
107
96
|
function mobileUploadPromise() {
|
|
108
97
|
return _mobileUploadPromise.apply(this, arguments);
|
|
109
98
|
}
|
|
110
|
-
|
|
111
99
|
return mobileUploadPromise;
|
|
112
100
|
}()
|
|
113
101
|
}, {
|
|
@@ -126,6 +114,5 @@ export var MediaClient = /*#__PURE__*/function () {
|
|
|
126
114
|
return this.eventEmitter.emit(event, payload);
|
|
127
115
|
}
|
|
128
116
|
}]);
|
|
129
|
-
|
|
130
117
|
return MediaClient;
|
|
131
118
|
}();
|
|
@@ -3,40 +3,31 @@ import _createClass from "@babel/runtime/helpers/createClass";
|
|
|
3
3
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
4
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
5
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
-
|
|
7
6
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
8
|
-
|
|
9
7
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
10
|
-
|
|
11
8
|
import { BaseMediaClientError } from '../../models/errors';
|
|
12
9
|
export var MediaStoreError = /*#__PURE__*/function (_BaseMediaClientError) {
|
|
13
10
|
_inherits(MediaStoreError, _BaseMediaClientError);
|
|
14
|
-
|
|
15
11
|
var _super = _createSuper(MediaStoreError);
|
|
16
|
-
|
|
17
12
|
function MediaStoreError(reason, innerError) {
|
|
18
13
|
var _this;
|
|
19
|
-
|
|
20
14
|
_classCallCheck(this, MediaStoreError);
|
|
21
|
-
|
|
22
15
|
_this = _super.call(this, reason);
|
|
23
16
|
_this.reason = reason;
|
|
24
17
|
_this.innerError = innerError;
|
|
25
18
|
return _this;
|
|
26
19
|
}
|
|
27
|
-
|
|
28
20
|
_createClass(MediaStoreError, [{
|
|
29
21
|
key: "attributes",
|
|
30
22
|
get: function get() {
|
|
31
23
|
var reason = this.reason,
|
|
32
|
-
|
|
24
|
+
innerError = this.innerError;
|
|
33
25
|
return {
|
|
34
26
|
reason: reason,
|
|
35
27
|
innerError: innerError
|
|
36
28
|
};
|
|
37
29
|
}
|
|
38
30
|
}]);
|
|
39
|
-
|
|
40
31
|
return MediaStoreError;
|
|
41
32
|
}(BaseMediaClientError);
|
|
42
33
|
export function isMediaStoreError(err) {
|
|
@@ -3,11 +3,8 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
|
3
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
4
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
5
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
|
-
|
|
7
6
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
8
|
-
|
|
9
7
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
10
|
-
|
|
11
8
|
import { getRandomHex } from '@atlaskit/media-common';
|
|
12
9
|
import { FILE_CACHE_MAX_AGE, MAX_RESOLUTION } from '../../constants';
|
|
13
10
|
import { getArtifactUrl } from '../../models/artifacts';
|
|
@@ -26,7 +23,6 @@ var defaultGetCollectionItems = {
|
|
|
26
23
|
limit: 30,
|
|
27
24
|
sortDirection: 'desc'
|
|
28
25
|
};
|
|
29
|
-
|
|
30
26
|
var extendImageParams = function extendImageParams(params) {
|
|
31
27
|
var fetchMaxRes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
32
28
|
return _objectSpread(_objectSpread(_objectSpread({}, defaultImageOptions), params), fetchMaxRes ? {
|
|
@@ -34,7 +30,6 @@ var extendImageParams = function extendImageParams(params) {
|
|
|
34
30
|
height: MAX_RESOLUTION
|
|
35
31
|
} : {});
|
|
36
32
|
};
|
|
37
|
-
|
|
38
33
|
var jsonHeaders = {
|
|
39
34
|
Accept: 'application/json',
|
|
40
35
|
'Content-Type': 'application/json'
|
|
@@ -42,27 +37,21 @@ var jsonHeaders = {
|
|
|
42
37
|
export var MediaStore = /*#__PURE__*/function () {
|
|
43
38
|
function MediaStore(config, featureFlags) {
|
|
44
39
|
var _this = this;
|
|
45
|
-
|
|
46
40
|
_classCallCheck(this, MediaStore);
|
|
47
|
-
|
|
48
41
|
_defineProperty(this, "resolveAuth", function (authContext) {
|
|
49
42
|
return resolveAuth(_this.config.authProvider, authContext);
|
|
50
43
|
});
|
|
51
|
-
|
|
52
44
|
_defineProperty(this, "resolveInitialAuth", function () {
|
|
53
45
|
return resolveInitialAuth(_this.config.initialAuth);
|
|
54
46
|
});
|
|
55
|
-
|
|
56
47
|
this.config = config;
|
|
57
48
|
this.featureFlags = featureFlags;
|
|
58
49
|
}
|
|
59
|
-
|
|
60
50
|
_createClass(MediaStore, [{
|
|
61
51
|
key: "getCollectionItems",
|
|
62
52
|
value: function () {
|
|
63
53
|
var _getCollectionItems = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(collectionName, params, traceContext) {
|
|
64
54
|
var metadata, options, response, _yield$createMapRespo, _yield$createMapRespo2, contents, nextInclusiveStartKey, contentsWithoutEmptyFiles;
|
|
65
|
-
|
|
66
55
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
67
56
|
while (1) {
|
|
68
57
|
switch (_context.prev = _context.next) {
|
|
@@ -83,12 +72,10 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
83
72
|
});
|
|
84
73
|
_context.next = 4;
|
|
85
74
|
return this.request("/collection/".concat(collectionName, "/items"), options);
|
|
86
|
-
|
|
87
75
|
case 4:
|
|
88
76
|
response = _context.sent;
|
|
89
77
|
_context.next = 7;
|
|
90
78
|
return createMapResponseToJson(metadata)(response);
|
|
91
|
-
|
|
92
79
|
case 7:
|
|
93
80
|
_yield$createMapRespo = _context.sent;
|
|
94
81
|
_yield$createMapRespo2 = _yield$createMapRespo.data;
|
|
@@ -105,7 +92,6 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
105
92
|
nextInclusiveStartKey: nextInclusiveStartKey
|
|
106
93
|
}
|
|
107
94
|
});
|
|
108
|
-
|
|
109
95
|
case 13:
|
|
110
96
|
case "end":
|
|
111
97
|
return _context.stop();
|
|
@@ -113,11 +99,9 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
113
99
|
}
|
|
114
100
|
}, _callee, this);
|
|
115
101
|
}));
|
|
116
|
-
|
|
117
102
|
function getCollectionItems(_x, _x2, _x3) {
|
|
118
103
|
return _getCollectionItems.apply(this, arguments);
|
|
119
104
|
}
|
|
120
|
-
|
|
121
105
|
return getCollectionItems;
|
|
122
106
|
}()
|
|
123
107
|
}, {
|
|
@@ -156,7 +140,6 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
156
140
|
});
|
|
157
141
|
_context2.next = 5;
|
|
158
142
|
return this.request("/collection/".concat(collectionName), options);
|
|
159
|
-
|
|
160
143
|
case 5:
|
|
161
144
|
case "end":
|
|
162
145
|
return _context2.stop();
|
|
@@ -164,11 +147,9 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
164
147
|
}
|
|
165
148
|
}, _callee2, this);
|
|
166
149
|
}));
|
|
167
|
-
|
|
168
150
|
function removeCollectionFile(_x4, _x5, _x6, _x7) {
|
|
169
151
|
return _removeCollectionFile.apply(this, arguments);
|
|
170
152
|
}
|
|
171
|
-
|
|
172
153
|
return removeCollectionFile;
|
|
173
154
|
}()
|
|
174
155
|
}, {
|
|
@@ -181,7 +162,6 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
181
162
|
method: 'POST',
|
|
182
163
|
endpoint: '/upload'
|
|
183
164
|
};
|
|
184
|
-
|
|
185
165
|
var options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
186
166
|
authContext: {
|
|
187
167
|
collectionName: collectionName
|
|
@@ -194,7 +174,6 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
194
174
|
},
|
|
195
175
|
traceContext: traceContext
|
|
196
176
|
});
|
|
197
|
-
|
|
198
177
|
return this.request("/upload", options).then(createMapResponseToJson(metadata));
|
|
199
178
|
}
|
|
200
179
|
}, {
|
|
@@ -223,7 +202,6 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
223
202
|
});
|
|
224
203
|
_context3.next = 4;
|
|
225
204
|
return this.request("/chunk/".concat(etag), options);
|
|
226
|
-
|
|
227
205
|
case 4:
|
|
228
206
|
case "end":
|
|
229
207
|
return _context3.stop();
|
|
@@ -231,11 +209,9 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
231
209
|
}
|
|
232
210
|
}, _callee3, this);
|
|
233
211
|
}));
|
|
234
|
-
|
|
235
212
|
function uploadChunk(_x8, _x9, _x10, _x11, _x12, _x13) {
|
|
236
213
|
return _uploadChunk.apply(this, arguments);
|
|
237
214
|
}
|
|
238
|
-
|
|
239
215
|
return uploadChunk;
|
|
240
216
|
}()
|
|
241
217
|
}, {
|
|
@@ -245,7 +221,6 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
245
221
|
method: 'POST',
|
|
246
222
|
endpoint: '/chunk/probe'
|
|
247
223
|
};
|
|
248
|
-
|
|
249
224
|
var options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
250
225
|
params: {
|
|
251
226
|
uploadId: uploadId
|
|
@@ -259,7 +234,6 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
259
234
|
}),
|
|
260
235
|
traceContext: traceContext
|
|
261
236
|
});
|
|
262
|
-
|
|
263
237
|
return this.request("/chunk/probe", options).then(createMapResponseToJson(metadata));
|
|
264
238
|
}
|
|
265
239
|
}, {
|
|
@@ -271,7 +245,6 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
271
245
|
method: 'POST',
|
|
272
246
|
endpoint: '/file/upload'
|
|
273
247
|
};
|
|
274
|
-
|
|
275
248
|
var options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
276
249
|
authContext: {
|
|
277
250
|
collectionName: params.collection
|
|
@@ -281,7 +254,6 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
281
254
|
body: JSON.stringify(body),
|
|
282
255
|
traceContext: traceContext
|
|
283
256
|
});
|
|
284
|
-
|
|
285
257
|
return this.request('/file/upload', options).then(createMapResponseToJson(metadata));
|
|
286
258
|
}
|
|
287
259
|
}, {
|
|
@@ -293,7 +265,6 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
293
265
|
method: 'POST',
|
|
294
266
|
endpoint: '/upload/createWithFiles'
|
|
295
267
|
};
|
|
296
|
-
|
|
297
268
|
var options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
298
269
|
authContext: {
|
|
299
270
|
collectionName: params.collection
|
|
@@ -302,7 +273,6 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
302
273
|
body: JSON.stringify(body),
|
|
303
274
|
traceContext: traceContext
|
|
304
275
|
});
|
|
305
|
-
|
|
306
276
|
return this.request('/upload/createWithFiles', options).then(createMapResponseToJson(metadata));
|
|
307
277
|
}
|
|
308
278
|
}, {
|
|
@@ -314,7 +284,6 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
314
284
|
method: 'GET',
|
|
315
285
|
endpoint: '/file/{fileId}'
|
|
316
286
|
};
|
|
317
|
-
|
|
318
287
|
var options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
319
288
|
authContext: {
|
|
320
289
|
collectionName: params.collection
|
|
@@ -322,7 +291,6 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
322
291
|
params: params,
|
|
323
292
|
traceContext: traceContext
|
|
324
293
|
});
|
|
325
|
-
|
|
326
294
|
return this.request("/file/".concat(fileId), options).then(createMapResponseToJson(metadata));
|
|
327
295
|
}
|
|
328
296
|
}, {
|
|
@@ -330,7 +298,6 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
330
298
|
value: function () {
|
|
331
299
|
var _getFileImageURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(id, params) {
|
|
332
300
|
var _ref, collectionName, auth;
|
|
333
|
-
|
|
334
301
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
335
302
|
while (1) {
|
|
336
303
|
switch (_context4.prev = _context4.next) {
|
|
@@ -340,11 +307,9 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
340
307
|
return this.resolveAuth({
|
|
341
308
|
collectionName: collectionName
|
|
342
309
|
});
|
|
343
|
-
|
|
344
310
|
case 3:
|
|
345
311
|
auth = _context4.sent;
|
|
346
312
|
return _context4.abrupt("return", this.createFileImageURL(id, auth, params));
|
|
347
|
-
|
|
348
313
|
case 5:
|
|
349
314
|
case "end":
|
|
350
315
|
return _context4.stop();
|
|
@@ -352,14 +317,11 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
352
317
|
}
|
|
353
318
|
}, _callee4, this);
|
|
354
319
|
}));
|
|
355
|
-
|
|
356
320
|
function getFileImageURL(_x14, _x15) {
|
|
357
321
|
return _getFileImageURL.apply(this, arguments);
|
|
358
322
|
}
|
|
359
|
-
|
|
360
323
|
return getFileImageURL;
|
|
361
324
|
}() // TODO Create ticket in case Trace Id can be supported through query params
|
|
362
|
-
|
|
363
325
|
}, {
|
|
364
326
|
key: "getFileImageURLSync",
|
|
365
327
|
value: function getFileImageURLSync(id, params) {
|
|
@@ -388,7 +350,6 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
388
350
|
return this.resolveAuth({
|
|
389
351
|
collectionName: collectionName
|
|
390
352
|
});
|
|
391
|
-
|
|
392
353
|
case 2:
|
|
393
354
|
auth = _context5.sent;
|
|
394
355
|
options = {
|
|
@@ -400,7 +361,6 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
400
361
|
auth: auth
|
|
401
362
|
};
|
|
402
363
|
return _context5.abrupt("return", createUrl("".concat(auth.baseUrl, "/file/").concat(id, "/binary"), options));
|
|
403
|
-
|
|
404
364
|
case 5:
|
|
405
365
|
case "end":
|
|
406
366
|
return _context5.stop();
|
|
@@ -408,11 +368,9 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
408
368
|
}
|
|
409
369
|
}, _callee5, this);
|
|
410
370
|
}));
|
|
411
|
-
|
|
412
371
|
function getFileBinaryURL(_x16, _x17) {
|
|
413
372
|
return _getFileBinaryURL.apply(this, arguments);
|
|
414
373
|
}
|
|
415
|
-
|
|
416
374
|
return getFileBinaryURL;
|
|
417
375
|
}()
|
|
418
376
|
}, {
|
|
@@ -425,20 +383,16 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
425
383
|
switch (_context6.prev = _context6.next) {
|
|
426
384
|
case 0:
|
|
427
385
|
artifactUrl = getArtifactUrl(artifacts, artifactName);
|
|
428
|
-
|
|
429
386
|
if (artifactUrl) {
|
|
430
387
|
_context6.next = 3;
|
|
431
388
|
break;
|
|
432
389
|
}
|
|
433
|
-
|
|
434
390
|
throw new Error("artifact ".concat(artifactName, " not found"));
|
|
435
|
-
|
|
436
391
|
case 3:
|
|
437
392
|
_context6.next = 5;
|
|
438
393
|
return this.resolveAuth({
|
|
439
394
|
collectionName: collectionName
|
|
440
395
|
});
|
|
441
|
-
|
|
442
396
|
case 5:
|
|
443
397
|
auth = _context6.sent;
|
|
444
398
|
options = {
|
|
@@ -449,7 +403,6 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
449
403
|
auth: auth
|
|
450
404
|
};
|
|
451
405
|
return _context6.abrupt("return", createUrl("".concat(auth.baseUrl).concat(artifactUrl), options));
|
|
452
|
-
|
|
453
406
|
case 8:
|
|
454
407
|
case "end":
|
|
455
408
|
return _context6.stop();
|
|
@@ -457,11 +410,9 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
457
410
|
}
|
|
458
411
|
}, _callee6, this);
|
|
459
412
|
}));
|
|
460
|
-
|
|
461
413
|
function getArtifactURL(_x18, _x19, _x20) {
|
|
462
414
|
return _getArtifactURL.apply(this, arguments);
|
|
463
415
|
}
|
|
464
|
-
|
|
465
416
|
return getArtifactURL;
|
|
466
417
|
}()
|
|
467
418
|
}, {
|
|
@@ -476,11 +427,9 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
476
427
|
// TODO add checkWebpSupport() back https://product-fabric.atlassian.net/browse/MPT-584
|
|
477
428
|
isWebpSupported = false;
|
|
478
429
|
headers = {};
|
|
479
|
-
|
|
480
430
|
if (isWebpSupported) {
|
|
481
431
|
headers.accept = 'image/webp,image/*,*/*;q=0.8';
|
|
482
432
|
}
|
|
483
|
-
|
|
484
433
|
metadata = {
|
|
485
434
|
method: 'GET',
|
|
486
435
|
endpoint: '/file/{fileId}/image'
|
|
@@ -494,7 +443,6 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
494
443
|
traceContext: traceContext
|
|
495
444
|
});
|
|
496
445
|
return _context7.abrupt("return", this.request("/file/".concat(id, "/image"), options, controller).then(createMapResponseToBlob(metadata)));
|
|
497
|
-
|
|
498
446
|
case 6:
|
|
499
447
|
case "end":
|
|
500
448
|
return _context7.stop();
|
|
@@ -502,11 +450,9 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
502
450
|
}
|
|
503
451
|
}, _callee7, this);
|
|
504
452
|
}));
|
|
505
|
-
|
|
506
453
|
function getImage(_x21, _x22, _x23, _x24, _x25) {
|
|
507
454
|
return _getImage.apply(this, arguments);
|
|
508
455
|
}
|
|
509
|
-
|
|
510
456
|
return getImage;
|
|
511
457
|
}()
|
|
512
458
|
}, {
|
|
@@ -540,7 +486,6 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
540
486
|
traceContext: traceContext
|
|
541
487
|
});
|
|
542
488
|
return _context8.abrupt("return", this.request('/items', options).then(createMapResponseToJson(metadata)));
|
|
543
|
-
|
|
544
489
|
case 4:
|
|
545
490
|
case "end":
|
|
546
491
|
return _context8.stop();
|
|
@@ -548,11 +493,9 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
548
493
|
}
|
|
549
494
|
}, _callee8, this);
|
|
550
495
|
}));
|
|
551
|
-
|
|
552
496
|
function getItems(_x26, _x27, _x28) {
|
|
553
497
|
return _getItems.apply(this, arguments);
|
|
554
498
|
}
|
|
555
|
-
|
|
556
499
|
return getItems;
|
|
557
500
|
}()
|
|
558
501
|
}, {
|
|
@@ -576,7 +519,6 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
576
519
|
traceContext: traceContext
|
|
577
520
|
});
|
|
578
521
|
return _context9.abrupt("return", this.request("/file/".concat(id, "/image/metadata"), options).then(createMapResponseToJson(metadata)));
|
|
579
|
-
|
|
580
522
|
case 3:
|
|
581
523
|
case "end":
|
|
582
524
|
return _context9.stop();
|
|
@@ -584,11 +526,9 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
584
526
|
}
|
|
585
527
|
}, _callee9, this);
|
|
586
528
|
}));
|
|
587
|
-
|
|
588
529
|
function getImageMetadata(_x29, _x30, _x31) {
|
|
589
530
|
return _getImageMetadata.apply(this, arguments);
|
|
590
531
|
}
|
|
591
|
-
|
|
592
532
|
return getImageMetadata;
|
|
593
533
|
}()
|
|
594
534
|
}, {
|
|
@@ -614,7 +554,6 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
614
554
|
});
|
|
615
555
|
_context10.next = 4;
|
|
616
556
|
return this.request("/upload/".concat(uploadId, "/chunks"), options);
|
|
617
|
-
|
|
618
557
|
case 4:
|
|
619
558
|
case "end":
|
|
620
559
|
return _context10.stop();
|
|
@@ -622,11 +561,9 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
622
561
|
}
|
|
623
562
|
}, _callee10, this);
|
|
624
563
|
}));
|
|
625
|
-
|
|
626
564
|
function appendChunksToUpload(_x32, _x33, _x34, _x35) {
|
|
627
565
|
return _appendChunksToUpload.apply(this, arguments);
|
|
628
566
|
}
|
|
629
|
-
|
|
630
567
|
return appendChunksToUpload;
|
|
631
568
|
}()
|
|
632
569
|
}, {
|
|
@@ -636,7 +573,6 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
636
573
|
method: 'POST',
|
|
637
574
|
endpoint: '/file/copy/withToken'
|
|
638
575
|
};
|
|
639
|
-
|
|
640
576
|
var options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
641
577
|
authContext: {
|
|
642
578
|
collectionName: params.collection
|
|
@@ -649,7 +585,6 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
649
585
|
// Contains collection name to read from
|
|
650
586
|
traceContext: traceContext
|
|
651
587
|
});
|
|
652
|
-
|
|
653
588
|
return this.request('/file/copy/withToken', options).then(createMapResponseToJson(metadata));
|
|
654
589
|
}
|
|
655
590
|
}, {
|
|
@@ -657,19 +592,19 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
657
592
|
value: function () {
|
|
658
593
|
var _request2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(path) {
|
|
659
594
|
var options,
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
595
|
+
controller,
|
|
596
|
+
method,
|
|
597
|
+
endpoint,
|
|
598
|
+
authContext,
|
|
599
|
+
params,
|
|
600
|
+
headers,
|
|
601
|
+
body,
|
|
602
|
+
clientOptions,
|
|
603
|
+
traceContext,
|
|
604
|
+
auth,
|
|
605
|
+
extendedTraceContext,
|
|
606
|
+
response,
|
|
607
|
+
_args11 = arguments;
|
|
673
608
|
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
674
609
|
while (1) {
|
|
675
610
|
switch (_context11.prev = _context11.next) {
|
|
@@ -683,7 +618,6 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
683
618
|
method = options.method, endpoint = options.endpoint, authContext = options.authContext, params = options.params, headers = options.headers, body = options.body, clientOptions = options.clientOptions, traceContext = options.traceContext;
|
|
684
619
|
_context11.next = 5;
|
|
685
620
|
return this.resolveAuth(authContext);
|
|
686
|
-
|
|
687
621
|
case 5:
|
|
688
622
|
auth = _context11.sent;
|
|
689
623
|
extendedTraceContext = traceContext ? _objectSpread(_objectSpread({}, traceContext), {}, {
|
|
@@ -700,13 +634,11 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
700
634
|
clientOptions: clientOptions,
|
|
701
635
|
traceContext: extendedTraceContext
|
|
702
636
|
}, controller);
|
|
703
|
-
|
|
704
637
|
case 9:
|
|
705
638
|
response = _context11.sent;
|
|
706
639
|
setKeyValueInSessionStorage(MEDIA_API_REGION, response.headers.get('x-media-region'));
|
|
707
640
|
setKeyValueInSessionStorage(MEDIA_API_ENVIRONMENT, response.headers.get('x-media-env'));
|
|
708
641
|
return _context11.abrupt("return", response);
|
|
709
|
-
|
|
710
642
|
case 13:
|
|
711
643
|
case "end":
|
|
712
644
|
return _context11.stop();
|
|
@@ -714,34 +646,26 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
714
646
|
}
|
|
715
647
|
}, _callee11, this);
|
|
716
648
|
}));
|
|
717
|
-
|
|
718
649
|
function request(_x36) {
|
|
719
650
|
return _request2.apply(this, arguments);
|
|
720
651
|
}
|
|
721
|
-
|
|
722
652
|
return request;
|
|
723
653
|
}()
|
|
724
654
|
}]);
|
|
725
|
-
|
|
726
655
|
return MediaStore;
|
|
727
656
|
}();
|
|
728
|
-
|
|
729
657
|
var getValueFromSessionStorage = function getValueFromSessionStorage(key) {
|
|
730
658
|
return window && window.sessionStorage && window.sessionStorage.getItem(key) || undefined;
|
|
731
659
|
};
|
|
732
|
-
|
|
733
660
|
var setKeyValueInSessionStorage = function setKeyValueInSessionStorage(key, value) {
|
|
734
661
|
if (!value || !(window && window.sessionStorage)) {
|
|
735
662
|
return;
|
|
736
663
|
}
|
|
737
|
-
|
|
738
664
|
var currentValue = window.sessionStorage.getItem(key);
|
|
739
|
-
|
|
740
665
|
if (currentValue !== value) {
|
|
741
666
|
window.sessionStorage.setItem(key, value);
|
|
742
667
|
}
|
|
743
668
|
};
|
|
744
|
-
|
|
745
669
|
export var getMediaEnvironment = function getMediaEnvironment() {
|
|
746
670
|
return getValueFromSessionStorage(MEDIA_API_ENVIRONMENT);
|
|
747
671
|
};
|
|
@@ -6,8 +6,8 @@ export var DEFAULT_AUTH_PROVIDER_TIMEOUT = 10000;
|
|
|
6
6
|
export var resolveAuth = /*#__PURE__*/function () {
|
|
7
7
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(authProvider, authContext) {
|
|
8
8
|
var authProviderTimeout,
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
auth,
|
|
10
|
+
_args = arguments;
|
|
11
11
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
12
12
|
while (1) {
|
|
13
13
|
switch (_context.prev = _context.next) {
|
|
@@ -16,37 +16,28 @@ export var resolveAuth = /*#__PURE__*/function () {
|
|
|
16
16
|
_context.prev = 1;
|
|
17
17
|
_context.next = 4;
|
|
18
18
|
return Promise.race([authProvider(authContext), rejectTimeout(authProviderTimeout, new MediaStoreError('authProviderTimedOut'))]);
|
|
19
|
-
|
|
20
19
|
case 4:
|
|
21
20
|
auth = _context.sent;
|
|
22
21
|
_context.next = 12;
|
|
23
22
|
break;
|
|
24
|
-
|
|
25
23
|
case 7:
|
|
26
24
|
_context.prev = 7;
|
|
27
25
|
_context.t0 = _context["catch"](1);
|
|
28
|
-
|
|
29
26
|
if (!(_context.t0 instanceof MediaStoreError)) {
|
|
30
27
|
_context.next = 11;
|
|
31
28
|
break;
|
|
32
29
|
}
|
|
33
|
-
|
|
34
30
|
throw _context.t0;
|
|
35
|
-
|
|
36
31
|
case 11:
|
|
37
32
|
throw new MediaStoreError('failedAuthProvider', _context.t0 instanceof Error ? _context.t0 : undefined);
|
|
38
|
-
|
|
39
33
|
case 12:
|
|
40
34
|
if (auth) {
|
|
41
35
|
_context.next = 14;
|
|
42
36
|
break;
|
|
43
37
|
}
|
|
44
|
-
|
|
45
38
|
throw new MediaStoreError('emptyAuth');
|
|
46
|
-
|
|
47
39
|
case 14:
|
|
48
40
|
return _context.abrupt("return", auth);
|
|
49
|
-
|
|
50
41
|
case 15:
|
|
51
42
|
case "end":
|
|
52
43
|
return _context.stop();
|
|
@@ -54,7 +45,6 @@ export var resolveAuth = /*#__PURE__*/function () {
|
|
|
54
45
|
}
|
|
55
46
|
}, _callee, null, [[1, 7]]);
|
|
56
47
|
}));
|
|
57
|
-
|
|
58
48
|
return function resolveAuth(_x, _x2) {
|
|
59
49
|
return _ref.apply(this, arguments);
|
|
60
50
|
};
|
|
@@ -63,6 +53,5 @@ export var resolveInitialAuth = function resolveInitialAuth(auth) {
|
|
|
63
53
|
if (!auth) {
|
|
64
54
|
throw new MediaStoreError('missingInitialAuth');
|
|
65
55
|
}
|
|
66
|
-
|
|
67
56
|
return auth;
|
|
68
57
|
};
|