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