@atlaskit/media-client 20.2.1 → 21.1.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 +35 -0
- package/dist/cjs/client/file-fetcher/error.js +4 -4
- package/dist/cjs/client/file-fetcher/index.js +275 -287
- package/dist/cjs/client/media-client.js +48 -34
- package/dist/cjs/client/media-store/index.js +367 -314
- package/dist/cjs/client/media-store/resolveAuth.js +30 -32
- package/dist/cjs/client/stargate-client.js +14 -16
- package/dist/cjs/index.js +6 -13
- package/dist/cjs/models/media.js +8 -9
- package/dist/cjs/uploader/error.js +4 -4
- package/dist/cjs/uploader/index.js +88 -96
- package/dist/cjs/utils/convertBase64ToBlob.js +2 -2
- package/dist/cjs/utils/createFileDataLoader.js +67 -70
- package/dist/cjs/utils/getDimensionsFromBlob.js +23 -25
- package/dist/cjs/utils/getVideoDimensionsFromBlob.js +24 -26
- package/dist/cjs/utils/hashing/hasherCreator.js +32 -34
- package/dist/cjs/utils/mediaSubscribable/fromObservable.js +2 -2
- package/dist/cjs/utils/mobileUpload/error.js +4 -4
- package/dist/cjs/utils/mobileUpload/helpers.js +41 -43
- package/dist/cjs/utils/mobileUpload/stateMachine/index.js +14 -16
- package/dist/cjs/utils/parseJwt.js +52 -0
- package/dist/cjs/utils/polling/index.js +40 -42
- package/dist/cjs/utils/request/errors.js +9 -9
- package/dist/cjs/utils/request/helpers.js +143 -155
- package/dist/cjs/utils/request/index.js +24 -26
- package/dist/cjs/utils/shouldFetchRemoteFileStates.js +39 -41
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/client/file-fetcher/index.js +1 -3
- package/dist/es2019/client/media-client.js +3 -2
- package/dist/es2019/client/media-store/index.js +58 -15
- package/dist/es2019/index.js +2 -3
- package/dist/es2019/models/media.js +6 -4
- package/dist/es2019/uploader/index.js +3 -0
- package/dist/es2019/utils/mediaSubscribable/fromObservable.js +2 -2
- package/dist/es2019/utils/mediaSubscribable/toPromise.js +10 -12
- package/dist/es2019/utils/parseJwt.js +46 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/client/file-fetcher/error.js +4 -4
- package/dist/esm/client/file-fetcher/index.js +273 -286
- package/dist/esm/client/media-client.js +46 -32
- package/dist/esm/client/media-store/index.js +367 -314
- package/dist/esm/client/media-store/resolveAuth.js +30 -32
- package/dist/esm/client/stargate-client.js +14 -16
- package/dist/esm/index.js +2 -3
- package/dist/esm/models/media.js +6 -6
- package/dist/esm/uploader/error.js +4 -4
- package/dist/esm/uploader/index.js +89 -96
- package/dist/esm/utils/convertBase64ToBlob.js +2 -2
- package/dist/esm/utils/createFileDataLoader.js +65 -69
- package/dist/esm/utils/getDimensionsFromBlob.js +23 -25
- package/dist/esm/utils/getVideoDimensionsFromBlob.js +24 -26
- package/dist/esm/utils/hashing/hasherCreator.js +28 -30
- package/dist/esm/utils/mediaSubscribable/fromObservable.js +2 -2
- package/dist/esm/utils/mobileUpload/error.js +4 -4
- package/dist/esm/utils/mobileUpload/helpers.js +41 -43
- package/dist/esm/utils/mobileUpload/stateMachine/index.js +14 -16
- package/dist/esm/utils/parseJwt.js +46 -0
- package/dist/esm/utils/polling/index.js +40 -42
- package/dist/esm/utils/request/errors.js +9 -9
- package/dist/esm/utils/request/helpers.js +143 -155
- package/dist/esm/utils/request/index.js +24 -26
- package/dist/esm/utils/shouldFetchRemoteFileStates.js +39 -41
- package/dist/esm/version.json +1 -1
- package/dist/types/client/__mocks__/media-client.d.ts +0 -2
- package/dist/types/client/file-fetcher/index.d.ts +4 -4
- package/dist/types/client/media-client.d.ts +1 -2
- package/dist/types/client/media-store/index.d.ts +17 -13
- package/dist/types/index.d.ts +4 -6
- package/dist/types/models/file-state.d.ts +2 -2
- package/dist/types/models/media.d.ts +1 -21
- package/dist/types/utils/createFileDataLoader.d.ts +2 -2
- package/dist/types/utils/createMediaSubject.d.ts +2 -2
- package/dist/types/utils/detectEmptyFile.d.ts +2 -2
- package/dist/types/utils/mediaSubscribable/fromObservable.d.ts +3 -3
- package/dist/types/utils/mediaSubscribable/toPromise.d.ts +2 -2
- package/dist/types/utils/mediaSubscribable/types.d.ts +9 -8
- package/dist/types/utils/parseJwt.d.ts +1 -0
- package/package.json +2 -2
- package/report.api.md +77 -126
- package/dist/cjs/client/collection-fetcher.js +0 -98
- package/dist/cjs/models/media-subscribable.js +0 -5
- package/dist/cjs/utils/deprecatedEndpointError.js +0 -43
- package/dist/es2019/client/collection-fetcher.js +0 -38
- package/dist/es2019/models/media-subscribable.js +0 -1
- package/dist/es2019/utils/deprecatedEndpointError.js +0 -20
- package/dist/esm/client/collection-fetcher.js +0 -89
- package/dist/esm/models/media-subscribable.js +0 -1
- package/dist/esm/utils/deprecatedEndpointError.js +0 -34
- package/dist/types/client/collection-fetcher.d.ts +0 -42
- package/dist/types/models/media-subscribable.d.ts +0 -3
- package/dist/types/utils/deprecatedEndpointError.d.ts +0 -16
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
1
4
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
5
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
6
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
+
var _excluded = ["size"];
|
|
5
9
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
10
|
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; }
|
|
7
11
|
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; }
|
|
@@ -11,7 +15,7 @@ import { getArtifactUrl } from '../../models/artifacts';
|
|
|
11
15
|
import { request as _request } from '../../utils/request';
|
|
12
16
|
import { createUrl, createMapResponseToJson, createMapResponseToBlob } from '../../utils/request/helpers';
|
|
13
17
|
import { resolveAuth, resolveInitialAuth } from './resolveAuth';
|
|
14
|
-
import
|
|
18
|
+
import parseJwt from '../../utils/parseJwt';
|
|
15
19
|
export { MediaStoreError, isMediaStoreError } from './error';
|
|
16
20
|
var MEDIA_API_REGION = 'media-api-region';
|
|
17
21
|
var MEDIA_API_ENVIRONMENT = 'media-api-environment';
|
|
@@ -44,76 +48,48 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
44
48
|
this.config = config;
|
|
45
49
|
this.featureFlags = featureFlags;
|
|
46
50
|
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-170 Internal documentation for deprecation (no external access)}
|
|
50
|
-
* This method is no longer working. Will be removed in the next release
|
|
51
|
-
*/
|
|
52
51
|
_createClass(MediaStore, [{
|
|
53
|
-
key: "getCollectionItems",
|
|
54
|
-
value: function () {
|
|
55
|
-
var _getCollectionItems = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(collectionName, params, traceContext) {
|
|
56
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
57
|
-
while (1) {
|
|
58
|
-
switch (_context.prev = _context.next) {
|
|
59
|
-
case 0:
|
|
60
|
-
throw new DeprecatedError('collection/:name/items');
|
|
61
|
-
case 1:
|
|
62
|
-
case "end":
|
|
63
|
-
return _context.stop();
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}, _callee);
|
|
67
|
-
}));
|
|
68
|
-
function getCollectionItems(_x, _x2, _x3) {
|
|
69
|
-
return _getCollectionItems.apply(this, arguments);
|
|
70
|
-
}
|
|
71
|
-
return getCollectionItems;
|
|
72
|
-
}()
|
|
73
|
-
}, {
|
|
74
52
|
key: "removeCollectionFile",
|
|
75
53
|
value: function () {
|
|
76
|
-
var _removeCollectionFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
54
|
+
var _removeCollectionFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(id, collectionName, occurrenceKey, traceContext) {
|
|
77
55
|
var metadata, body, options;
|
|
78
|
-
return _regeneratorRuntime.wrap(function
|
|
79
|
-
while (1) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
return _context2.stop();
|
|
112
|
-
}
|
|
56
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
57
|
+
while (1) switch (_context.prev = _context.next) {
|
|
58
|
+
case 0:
|
|
59
|
+
metadata = {
|
|
60
|
+
method: 'PUT',
|
|
61
|
+
endpoint: '/collection/{collectionName}'
|
|
62
|
+
};
|
|
63
|
+
body = {
|
|
64
|
+
actions: [{
|
|
65
|
+
action: 'remove',
|
|
66
|
+
item: {
|
|
67
|
+
type: 'file',
|
|
68
|
+
id: id,
|
|
69
|
+
occurrenceKey: occurrenceKey
|
|
70
|
+
}
|
|
71
|
+
}]
|
|
72
|
+
};
|
|
73
|
+
options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
74
|
+
authContext: {
|
|
75
|
+
collectionName: collectionName
|
|
76
|
+
},
|
|
77
|
+
headers: {
|
|
78
|
+
Accept: 'application/json',
|
|
79
|
+
'Content-Type': 'application/json'
|
|
80
|
+
},
|
|
81
|
+
body: JSON.stringify(body),
|
|
82
|
+
traceContext: traceContext
|
|
83
|
+
});
|
|
84
|
+
_context.next = 5;
|
|
85
|
+
return this.request("/collection/".concat(collectionName), options);
|
|
86
|
+
case 5:
|
|
87
|
+
case "end":
|
|
88
|
+
return _context.stop();
|
|
113
89
|
}
|
|
114
|
-
},
|
|
90
|
+
}, _callee, this);
|
|
115
91
|
}));
|
|
116
|
-
function removeCollectionFile(
|
|
92
|
+
function removeCollectionFile(_x, _x2, _x3, _x4) {
|
|
117
93
|
return _removeCollectionFile.apply(this, arguments);
|
|
118
94
|
}
|
|
119
95
|
return removeCollectionFile;
|
|
@@ -145,37 +121,35 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
145
121
|
}, {
|
|
146
122
|
key: "uploadChunk",
|
|
147
123
|
value: function () {
|
|
148
|
-
var _uploadChunk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
124
|
+
var _uploadChunk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(etag, blob, uploadId, partNumber, collectionName, traceContext) {
|
|
149
125
|
var metadata, options;
|
|
150
|
-
return _regeneratorRuntime.wrap(function
|
|
151
|
-
while (1) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
return _context3.stop();
|
|
174
|
-
}
|
|
126
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
127
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
128
|
+
case 0:
|
|
129
|
+
metadata = {
|
|
130
|
+
method: 'PUT',
|
|
131
|
+
endpoint: '/chunk/{etag}'
|
|
132
|
+
};
|
|
133
|
+
options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
134
|
+
params: {
|
|
135
|
+
uploadId: uploadId,
|
|
136
|
+
partNumber: partNumber
|
|
137
|
+
},
|
|
138
|
+
authContext: {
|
|
139
|
+
collectionName: collectionName
|
|
140
|
+
},
|
|
141
|
+
body: blob,
|
|
142
|
+
traceContext: traceContext
|
|
143
|
+
});
|
|
144
|
+
_context2.next = 4;
|
|
145
|
+
return this.request("/chunk/".concat(etag), options);
|
|
146
|
+
case 4:
|
|
147
|
+
case "end":
|
|
148
|
+
return _context2.stop();
|
|
175
149
|
}
|
|
176
|
-
},
|
|
150
|
+
}, _callee2, this);
|
|
177
151
|
}));
|
|
178
|
-
function uploadChunk(
|
|
152
|
+
function uploadChunk(_x5, _x6, _x7, _x8, _x9, _x10) {
|
|
179
153
|
return _uploadChunk.apply(this, arguments);
|
|
180
154
|
}
|
|
181
155
|
return uploadChunk;
|
|
@@ -223,24 +197,108 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
223
197
|
return this.request('/file/upload', options).then(createMapResponseToJson(metadata));
|
|
224
198
|
}
|
|
225
199
|
}, {
|
|
226
|
-
key: "
|
|
227
|
-
value: function
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
200
|
+
key: "getRejectedResponseFromDescriptor",
|
|
201
|
+
value: function getRejectedResponseFromDescriptor(descriptor, limit) {
|
|
202
|
+
return {
|
|
203
|
+
fileId: descriptor.fileId,
|
|
204
|
+
error: {
|
|
205
|
+
code: 'ExceedMaxFileSizeLimit',
|
|
206
|
+
title: 'The expected file size exceeded the maximum size limit.',
|
|
207
|
+
href: 'https://dt-api-filestore--app.ap-southeast-2.dev.atl-paas.net/api.html#BadRequest',
|
|
208
|
+
limit: limit,
|
|
209
|
+
size: descriptor.size
|
|
210
|
+
}
|
|
233
211
|
};
|
|
234
|
-
var options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
235
|
-
authContext: {
|
|
236
|
-
collectionName: params.collection
|
|
237
|
-
},
|
|
238
|
-
headers: jsonHeaders,
|
|
239
|
-
body: JSON.stringify(body),
|
|
240
|
-
traceContext: traceContext
|
|
241
|
-
});
|
|
242
|
-
return this.request('/upload/createWithFiles', options).then(createMapResponseToJson(metadata));
|
|
243
212
|
}
|
|
213
|
+
}, {
|
|
214
|
+
key: "touchFiles",
|
|
215
|
+
value: function () {
|
|
216
|
+
var _touchFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(body) {
|
|
217
|
+
var _this2 = this;
|
|
218
|
+
var params,
|
|
219
|
+
traceContext,
|
|
220
|
+
metadata,
|
|
221
|
+
auth,
|
|
222
|
+
maxFileSize,
|
|
223
|
+
decoded,
|
|
224
|
+
_body$descriptors$red,
|
|
225
|
+
_body$descriptors$red2,
|
|
226
|
+
filteredDescriptors,
|
|
227
|
+
rejectedResponse,
|
|
228
|
+
options,
|
|
229
|
+
_args3 = arguments;
|
|
230
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
231
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
232
|
+
case 0:
|
|
233
|
+
params = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
|
|
234
|
+
traceContext = _args3.length > 2 ? _args3[2] : undefined;
|
|
235
|
+
metadata = {
|
|
236
|
+
method: 'POST',
|
|
237
|
+
endpoint: '/upload/createWithFiles'
|
|
238
|
+
};
|
|
239
|
+
_context3.next = 5;
|
|
240
|
+
return this.resolveAuth({
|
|
241
|
+
collectionName: params.collection
|
|
242
|
+
});
|
|
243
|
+
case 5:
|
|
244
|
+
auth = _context3.sent;
|
|
245
|
+
try {
|
|
246
|
+
decoded = parseJwt(auth.token);
|
|
247
|
+
maxFileSize = decoded.fileSizeLimit;
|
|
248
|
+
} catch (error) {
|
|
249
|
+
// we're relying on the backend to throw an error when there's an invalid token
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// TODO MEX-2318: backend eventually will allow `size` in the body of this request, then some of this logic will need to be altered
|
|
253
|
+
_body$descriptors$red = body.descriptors.reduce(function (_ref, curr) {
|
|
254
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
255
|
+
filtered = _ref2[0],
|
|
256
|
+
rejected = _ref2[1];
|
|
257
|
+
var size = curr.size,
|
|
258
|
+
descriptor = _objectWithoutProperties(curr, _excluded);
|
|
259
|
+
if (maxFileSize && size && size > maxFileSize) {
|
|
260
|
+
return [filtered, [].concat(_toConsumableArray(rejected), [_this2.getRejectedResponseFromDescriptor(curr, maxFileSize)])];
|
|
261
|
+
}
|
|
262
|
+
return [[].concat(_toConsumableArray(filtered), [descriptor]), rejected];
|
|
263
|
+
}, [[], []]), _body$descriptors$red2 = _slicedToArray(_body$descriptors$red, 2), filteredDescriptors = _body$descriptors$red2[0], rejectedResponse = _body$descriptors$red2[1];
|
|
264
|
+
options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
265
|
+
authContext: {
|
|
266
|
+
collectionName: params.collection
|
|
267
|
+
},
|
|
268
|
+
headers: jsonHeaders,
|
|
269
|
+
body: JSON.stringify(_objectSpread(_objectSpread({}, body), {}, {
|
|
270
|
+
descriptors: filteredDescriptors
|
|
271
|
+
})),
|
|
272
|
+
traceContext: traceContext,
|
|
273
|
+
resolvedAuth: auth
|
|
274
|
+
});
|
|
275
|
+
if (!(filteredDescriptors.length === 0)) {
|
|
276
|
+
_context3.next = 11;
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
return _context3.abrupt("return", {
|
|
280
|
+
data: {
|
|
281
|
+
created: [],
|
|
282
|
+
rejected: rejectedResponse
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
case 11:
|
|
286
|
+
return _context3.abrupt("return", this.request('/upload/createWithFiles', options).then(createMapResponseToJson(metadata)).then(function (res) {
|
|
287
|
+
// TODO MEX-2318: backend eventually will include `rejected`, then this logic will need to be removed
|
|
288
|
+
res.data.rejected = rejectedResponse;
|
|
289
|
+
return res;
|
|
290
|
+
}));
|
|
291
|
+
case 12:
|
|
292
|
+
case "end":
|
|
293
|
+
return _context3.stop();
|
|
294
|
+
}
|
|
295
|
+
}, _callee3, this);
|
|
296
|
+
}));
|
|
297
|
+
function touchFiles(_x11) {
|
|
298
|
+
return _touchFiles.apply(this, arguments);
|
|
299
|
+
}
|
|
300
|
+
return touchFiles;
|
|
301
|
+
}()
|
|
244
302
|
}, {
|
|
245
303
|
key: "getFile",
|
|
246
304
|
value: function getFile(fileId) {
|
|
@@ -263,27 +321,25 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
263
321
|
key: "getFileImageURL",
|
|
264
322
|
value: function () {
|
|
265
323
|
var _getFileImageURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(id, params) {
|
|
266
|
-
var
|
|
324
|
+
var _ref3, collectionName, auth;
|
|
267
325
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
268
|
-
while (1) {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
return _context4.stop();
|
|
282
|
-
}
|
|
326
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
327
|
+
case 0:
|
|
328
|
+
_ref3 = params || {}, collectionName = _ref3.collection;
|
|
329
|
+
_context4.next = 3;
|
|
330
|
+
return this.resolveAuth({
|
|
331
|
+
collectionName: collectionName
|
|
332
|
+
});
|
|
333
|
+
case 3:
|
|
334
|
+
auth = _context4.sent;
|
|
335
|
+
return _context4.abrupt("return", this.createFileImageURL(id, auth, params));
|
|
336
|
+
case 5:
|
|
337
|
+
case "end":
|
|
338
|
+
return _context4.stop();
|
|
283
339
|
}
|
|
284
340
|
}, _callee4, this);
|
|
285
341
|
}));
|
|
286
|
-
function getFileImageURL(
|
|
342
|
+
function getFileImageURL(_x12, _x13) {
|
|
287
343
|
return _getFileImageURL.apply(this, arguments);
|
|
288
344
|
}
|
|
289
345
|
return getFileImageURL;
|
|
@@ -309,32 +365,30 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
309
365
|
var _getFileBinaryURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(id, collectionName) {
|
|
310
366
|
var auth, options;
|
|
311
367
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
312
|
-
while (1) {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
return _context5.stop();
|
|
333
|
-
}
|
|
368
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
369
|
+
case 0:
|
|
370
|
+
_context5.next = 2;
|
|
371
|
+
return this.resolveAuth({
|
|
372
|
+
collectionName: collectionName
|
|
373
|
+
});
|
|
374
|
+
case 2:
|
|
375
|
+
auth = _context5.sent;
|
|
376
|
+
options = {
|
|
377
|
+
params: {
|
|
378
|
+
dl: true,
|
|
379
|
+
collection: collectionName,
|
|
380
|
+
'max-age': FILE_CACHE_MAX_AGE
|
|
381
|
+
},
|
|
382
|
+
auth: auth
|
|
383
|
+
};
|
|
384
|
+
return _context5.abrupt("return", createUrl("".concat(auth.baseUrl, "/file/").concat(id, "/binary"), options));
|
|
385
|
+
case 5:
|
|
386
|
+
case "end":
|
|
387
|
+
return _context5.stop();
|
|
334
388
|
}
|
|
335
389
|
}, _callee5, this);
|
|
336
390
|
}));
|
|
337
|
-
function getFileBinaryURL(
|
|
391
|
+
function getFileBinaryURL(_x14, _x15) {
|
|
338
392
|
return _getFileBinaryURL.apply(this, arguments);
|
|
339
393
|
}
|
|
340
394
|
return getFileBinaryURL;
|
|
@@ -345,38 +399,36 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
345
399
|
var _getArtifactURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(artifacts, artifactName, collectionName) {
|
|
346
400
|
var artifactUrl, auth, options;
|
|
347
401
|
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
348
|
-
while (1) {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
return _context6.stop();
|
|
375
|
-
}
|
|
402
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
403
|
+
case 0:
|
|
404
|
+
artifactUrl = getArtifactUrl(artifacts, artifactName);
|
|
405
|
+
if (artifactUrl) {
|
|
406
|
+
_context6.next = 3;
|
|
407
|
+
break;
|
|
408
|
+
}
|
|
409
|
+
throw new Error("artifact ".concat(artifactName, " not found"));
|
|
410
|
+
case 3:
|
|
411
|
+
_context6.next = 5;
|
|
412
|
+
return this.resolveAuth({
|
|
413
|
+
collectionName: collectionName
|
|
414
|
+
});
|
|
415
|
+
case 5:
|
|
416
|
+
auth = _context6.sent;
|
|
417
|
+
options = {
|
|
418
|
+
params: {
|
|
419
|
+
collection: collectionName,
|
|
420
|
+
'max-age': FILE_CACHE_MAX_AGE
|
|
421
|
+
},
|
|
422
|
+
auth: auth
|
|
423
|
+
};
|
|
424
|
+
return _context6.abrupt("return", createUrl("".concat(auth.baseUrl).concat(artifactUrl), options));
|
|
425
|
+
case 8:
|
|
426
|
+
case "end":
|
|
427
|
+
return _context6.stop();
|
|
376
428
|
}
|
|
377
429
|
}, _callee6, this);
|
|
378
430
|
}));
|
|
379
|
-
function getArtifactURL(
|
|
431
|
+
function getArtifactURL(_x16, _x17, _x18) {
|
|
380
432
|
return _getArtifactURL.apply(this, arguments);
|
|
381
433
|
}
|
|
382
434
|
return getArtifactURL;
|
|
@@ -387,36 +439,34 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
387
439
|
var _getImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(id, params, controller, fetchMaxRes, traceContext) {
|
|
388
440
|
var isWebpSupported, headers, metadata, options;
|
|
389
441
|
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
390
|
-
while (1) {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
return _context7.stop();
|
|
415
|
-
}
|
|
442
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
443
|
+
case 0:
|
|
444
|
+
// TODO add checkWebpSupport() back https://product-fabric.atlassian.net/browse/MPT-584
|
|
445
|
+
isWebpSupported = false;
|
|
446
|
+
headers = {};
|
|
447
|
+
if (isWebpSupported) {
|
|
448
|
+
headers.accept = 'image/webp,image/*,*/*;q=0.8';
|
|
449
|
+
}
|
|
450
|
+
metadata = {
|
|
451
|
+
method: 'GET',
|
|
452
|
+
endpoint: '/file/{fileId}/image'
|
|
453
|
+
};
|
|
454
|
+
options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
455
|
+
authContext: {
|
|
456
|
+
collectionName: params && params.collection
|
|
457
|
+
},
|
|
458
|
+
params: extendImageParams(params, fetchMaxRes),
|
|
459
|
+
headers: headers,
|
|
460
|
+
traceContext: traceContext
|
|
461
|
+
});
|
|
462
|
+
return _context7.abrupt("return", this.request("/file/".concat(id, "/image"), options, controller).then(createMapResponseToBlob(metadata)));
|
|
463
|
+
case 6:
|
|
464
|
+
case "end":
|
|
465
|
+
return _context7.stop();
|
|
416
466
|
}
|
|
417
467
|
}, _callee7, this);
|
|
418
468
|
}));
|
|
419
|
-
function getImage(
|
|
469
|
+
function getImage(_x19, _x20, _x21, _x22, _x23) {
|
|
420
470
|
return _getImage.apply(this, arguments);
|
|
421
471
|
}
|
|
422
472
|
return getImage;
|
|
@@ -427,39 +477,37 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
427
477
|
var _getItems = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(ids, collectionName, traceContext) {
|
|
428
478
|
var descriptors, metadata, options;
|
|
429
479
|
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
430
|
-
while (1) {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
collection: collectionName
|
|
438
|
-
};
|
|
439
|
-
});
|
|
440
|
-
metadata = {
|
|
441
|
-
method: 'POST',
|
|
442
|
-
endpoint: '/items'
|
|
480
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
481
|
+
case 0:
|
|
482
|
+
descriptors = ids.map(function (id) {
|
|
483
|
+
return {
|
|
484
|
+
type: 'file',
|
|
485
|
+
id: id,
|
|
486
|
+
collection: collectionName
|
|
443
487
|
};
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
488
|
+
});
|
|
489
|
+
metadata = {
|
|
490
|
+
method: 'POST',
|
|
491
|
+
endpoint: '/items'
|
|
492
|
+
};
|
|
493
|
+
options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
494
|
+
authContext: {
|
|
495
|
+
collectionName: collectionName
|
|
496
|
+
},
|
|
497
|
+
headers: jsonHeaders,
|
|
498
|
+
body: JSON.stringify({
|
|
499
|
+
descriptors: descriptors
|
|
500
|
+
}),
|
|
501
|
+
traceContext: traceContext
|
|
502
|
+
});
|
|
503
|
+
return _context8.abrupt("return", this.request('/items', options).then(createMapResponseToJson(metadata)));
|
|
504
|
+
case 4:
|
|
505
|
+
case "end":
|
|
506
|
+
return _context8.stop();
|
|
459
507
|
}
|
|
460
508
|
}, _callee8, this);
|
|
461
509
|
}));
|
|
462
|
-
function getItems(
|
|
510
|
+
function getItems(_x24, _x25, _x26) {
|
|
463
511
|
return _getItems.apply(this, arguments);
|
|
464
512
|
}
|
|
465
513
|
return getItems;
|
|
@@ -470,29 +518,27 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
470
518
|
var _getImageMetadata = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(id, params, traceContext) {
|
|
471
519
|
var metadata, options;
|
|
472
520
|
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
473
|
-
while (1) {
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
return _context9.stop();
|
|
491
|
-
}
|
|
521
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
522
|
+
case 0:
|
|
523
|
+
metadata = {
|
|
524
|
+
method: 'GET',
|
|
525
|
+
endpoint: '/file/{fileId}/image/metadata'
|
|
526
|
+
};
|
|
527
|
+
options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
528
|
+
authContext: {
|
|
529
|
+
collectionName: params && params.collection
|
|
530
|
+
},
|
|
531
|
+
params: params,
|
|
532
|
+
traceContext: traceContext
|
|
533
|
+
});
|
|
534
|
+
return _context9.abrupt("return", this.request("/file/".concat(id, "/image/metadata"), options).then(createMapResponseToJson(metadata)));
|
|
535
|
+
case 3:
|
|
536
|
+
case "end":
|
|
537
|
+
return _context9.stop();
|
|
492
538
|
}
|
|
493
539
|
}, _callee9, this);
|
|
494
540
|
}));
|
|
495
|
-
function getImageMetadata(
|
|
541
|
+
function getImageMetadata(_x27, _x28, _x29) {
|
|
496
542
|
return _getImageMetadata.apply(this, arguments);
|
|
497
543
|
}
|
|
498
544
|
return getImageMetadata;
|
|
@@ -503,31 +549,29 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
503
549
|
var _appendChunksToUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(uploadId, body, collectionName, traceContext) {
|
|
504
550
|
var metadata, options;
|
|
505
551
|
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
506
|
-
while (1) {
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
return _context10.stop();
|
|
526
|
-
}
|
|
552
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
553
|
+
case 0:
|
|
554
|
+
metadata = {
|
|
555
|
+
method: 'PUT',
|
|
556
|
+
endpoint: '/upload/{uploadId}/chunks'
|
|
557
|
+
};
|
|
558
|
+
options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
559
|
+
authContext: {
|
|
560
|
+
collectionName: collectionName
|
|
561
|
+
},
|
|
562
|
+
headers: jsonHeaders,
|
|
563
|
+
body: JSON.stringify(body),
|
|
564
|
+
traceContext: traceContext
|
|
565
|
+
});
|
|
566
|
+
_context10.next = 4;
|
|
567
|
+
return this.request("/upload/".concat(uploadId, "/chunks"), options);
|
|
568
|
+
case 4:
|
|
569
|
+
case "end":
|
|
570
|
+
return _context10.stop();
|
|
527
571
|
}
|
|
528
572
|
}, _callee10, this);
|
|
529
573
|
}));
|
|
530
|
-
function appendChunksToUpload(
|
|
574
|
+
function appendChunksToUpload(_x30, _x31, _x32, _x33) {
|
|
531
575
|
return _appendChunksToUpload.apply(this, arguments);
|
|
532
576
|
}
|
|
533
577
|
return appendChunksToUpload;
|
|
@@ -567,52 +611,61 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
567
611
|
body,
|
|
568
612
|
clientOptions,
|
|
569
613
|
traceContext,
|
|
614
|
+
resolvedAuth,
|
|
570
615
|
auth,
|
|
571
616
|
extendedTraceContext,
|
|
572
617
|
response,
|
|
573
618
|
_args11 = arguments;
|
|
574
619
|
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
575
|
-
while (1) {
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
_context11.next =
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
620
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
621
|
+
case 0:
|
|
622
|
+
options = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {
|
|
623
|
+
method: 'GET',
|
|
624
|
+
endpoint: undefined,
|
|
625
|
+
authContext: {}
|
|
626
|
+
};
|
|
627
|
+
controller = _args11.length > 2 ? _args11[2] : undefined;
|
|
628
|
+
method = options.method, endpoint = options.endpoint, authContext = options.authContext, params = options.params, headers = options.headers, body = options.body, clientOptions = options.clientOptions, traceContext = options.traceContext, resolvedAuth = options.resolvedAuth;
|
|
629
|
+
if (!(resolvedAuth !== null && resolvedAuth !== void 0)) {
|
|
630
|
+
_context11.next = 7;
|
|
631
|
+
break;
|
|
632
|
+
}
|
|
633
|
+
_context11.t0 = resolvedAuth;
|
|
634
|
+
_context11.next = 10;
|
|
635
|
+
break;
|
|
636
|
+
case 7:
|
|
637
|
+
_context11.next = 9;
|
|
638
|
+
return this.resolveAuth(authContext);
|
|
639
|
+
case 9:
|
|
640
|
+
_context11.t0 = _context11.sent;
|
|
641
|
+
case 10:
|
|
642
|
+
auth = _context11.t0;
|
|
643
|
+
extendedTraceContext = traceContext ? _objectSpread(_objectSpread({}, traceContext), {}, {
|
|
644
|
+
spanId: (traceContext === null || traceContext === void 0 ? void 0 : traceContext.spanId) || getRandomHex(8)
|
|
645
|
+
}) : undefined;
|
|
646
|
+
_context11.next = 14;
|
|
647
|
+
return _request("".concat(auth.baseUrl).concat(path), {
|
|
648
|
+
method: method,
|
|
649
|
+
endpoint: endpoint,
|
|
650
|
+
auth: auth,
|
|
651
|
+
params: params,
|
|
652
|
+
headers: headers,
|
|
653
|
+
body: body,
|
|
654
|
+
clientOptions: clientOptions,
|
|
655
|
+
traceContext: extendedTraceContext
|
|
656
|
+
}, controller);
|
|
657
|
+
case 14:
|
|
658
|
+
response = _context11.sent;
|
|
659
|
+
setKeyValueInSessionStorage(MEDIA_API_REGION, response.headers.get('x-media-region'));
|
|
660
|
+
setKeyValueInSessionStorage(MEDIA_API_ENVIRONMENT, response.headers.get('x-media-env'));
|
|
661
|
+
return _context11.abrupt("return", response);
|
|
662
|
+
case 18:
|
|
663
|
+
case "end":
|
|
664
|
+
return _context11.stop();
|
|
612
665
|
}
|
|
613
666
|
}, _callee11, this);
|
|
614
667
|
}));
|
|
615
|
-
function request(
|
|
668
|
+
function request(_x34) {
|
|
616
669
|
return _request2.apply(this, arguments);
|
|
617
670
|
}
|
|
618
671
|
return request;
|