@atlaskit/media-client 32.0.2 → 33.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 +21 -0
- package/dist/cjs/client/file-fetcher/index.js +143 -114
- package/dist/cjs/client/media-client.js +1 -1
- package/dist/cjs/client/media-store/MediaStore.js +227 -138
- package/dist/cjs/utils/hashing/hasherCreator.js +20 -32
- package/dist/cjs/utils/request/helpers.js +1 -1
- package/dist/es2019/client/file-fetcher/index.js +15 -0
- package/dist/es2019/client/media-client.js +1 -1
- package/dist/es2019/client/media-store/MediaStore.js +63 -7
- package/dist/es2019/utils/hashing/hasherCreator.js +19 -23
- package/dist/es2019/utils/request/helpers.js +1 -1
- package/dist/esm/client/file-fetcher/index.js +143 -114
- package/dist/esm/client/media-client.js +1 -1
- package/dist/esm/client/media-store/MediaStore.js +227 -138
- package/dist/esm/utils/hashing/hasherCreator.js +19 -29
- package/dist/esm/utils/request/helpers.js +1 -1
- package/dist/types/client/file-fetcher/index.d.ts +4 -1
- package/dist/types/client/media-store/MediaStore.d.ts +3 -1
- package/dist/types/client/media-store/types.d.ts +13 -0
- package/dist/types/utils/hashing/hasherCreator.d.ts +1 -1
- package/dist/types-ts4.5/client/file-fetcher/index.d.ts +4 -1
- package/dist/types-ts4.5/client/media-store/MediaStore.d.ts +3 -1
- package/dist/types-ts4.5/client/media-store/types.d.ts +13 -0
- package/dist/types-ts4.5/utils/hashing/hasherCreator.d.ts +1 -1
- package/package.json +5 -5
- package/dist/cjs/utils/hashing/workerHasher.js +0 -113
- package/dist/es2019/utils/hashing/workerHasher.js +0 -89
- package/dist/esm/utils/hashing/workerHasher.js +0 -106
- package/dist/types/utils/hashing/workerHasher.d.ts +0 -16
- package/dist/types-ts4.5/utils/hashing/workerHasher.d.ts +0 -16
|
@@ -35,10 +35,8 @@ var jsonHeaders = {
|
|
|
35
35
|
};
|
|
36
36
|
var cdnFeatureFlag = function cdnFeatureFlag(endpoint) {
|
|
37
37
|
var result = endpoint;
|
|
38
|
-
if (fg('platform_media_cdn_delivery')) {
|
|
39
|
-
|
|
40
|
-
result += '/cdn';
|
|
41
|
-
}
|
|
38
|
+
if (isCommercial() && fg('platform_media_cdn_delivery')) {
|
|
39
|
+
result += '/cdn';
|
|
42
40
|
}
|
|
43
41
|
return result;
|
|
44
42
|
};
|
|
@@ -46,6 +44,79 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
46
44
|
function MediaStore(config) {
|
|
47
45
|
var _this = this;
|
|
48
46
|
_classCallCheck(this, MediaStore);
|
|
47
|
+
_defineProperty(this, "getArtifactBinary", /*#__PURE__*/function () {
|
|
48
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(artifacts, artifactName, _ref) {
|
|
49
|
+
var collectionName, abortController, _ref$maxAge, maxAge, traceContext, metadata, extendedTraceContext, options, artifactUrl;
|
|
50
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
51
|
+
while (1) switch (_context.prev = _context.next) {
|
|
52
|
+
case 0:
|
|
53
|
+
collectionName = _ref.collectionName, abortController = _ref.abortController, _ref$maxAge = _ref.maxAge, maxAge = _ref$maxAge === void 0 ? FILE_CACHE_MAX_AGE : _ref$maxAge, traceContext = _ref.traceContext;
|
|
54
|
+
metadata = {
|
|
55
|
+
method: 'GET',
|
|
56
|
+
endpoint: "artifact-cdn-url"
|
|
57
|
+
};
|
|
58
|
+
extendedTraceContext = extendTraceContext(traceContext);
|
|
59
|
+
options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
60
|
+
traceContext: extendedTraceContext
|
|
61
|
+
});
|
|
62
|
+
_context.next = 6;
|
|
63
|
+
return _this.getArtifactURL(artifacts, artifactName, collectionName, maxAge);
|
|
64
|
+
case 6:
|
|
65
|
+
artifactUrl = _context.sent;
|
|
66
|
+
return _context.abrupt("return", _request(artifactUrl, options, abortController).then(createMapResponseToBlob(metadata)));
|
|
67
|
+
case 8:
|
|
68
|
+
case "end":
|
|
69
|
+
return _context.stop();
|
|
70
|
+
}
|
|
71
|
+
}, _callee);
|
|
72
|
+
}));
|
|
73
|
+
return function (_x, _x2, _x3) {
|
|
74
|
+
return _ref2.apply(this, arguments);
|
|
75
|
+
};
|
|
76
|
+
}());
|
|
77
|
+
_defineProperty(this, "uploadArtifact", /*#__PURE__*/function () {
|
|
78
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(id, file, params, collectionName, traceContext) {
|
|
79
|
+
var metadata, headers, extendedParams, authContext, options;
|
|
80
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
81
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
82
|
+
case 0:
|
|
83
|
+
metadata = {
|
|
84
|
+
method: 'POST',
|
|
85
|
+
endpoint: '/file/{fileId}/artifact/binary'
|
|
86
|
+
};
|
|
87
|
+
headers = {
|
|
88
|
+
Accept: 'application/json',
|
|
89
|
+
'Content-Type': file.type
|
|
90
|
+
};
|
|
91
|
+
extendedParams = _objectSpread(_objectSpread({}, params), {}, {
|
|
92
|
+
name: file.name
|
|
93
|
+
});
|
|
94
|
+
authContext = {
|
|
95
|
+
collectionName: collectionName,
|
|
96
|
+
access: [{
|
|
97
|
+
type: 'file',
|
|
98
|
+
id: id,
|
|
99
|
+
actions: ['update']
|
|
100
|
+
}]
|
|
101
|
+
};
|
|
102
|
+
options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
103
|
+
authContext: authContext,
|
|
104
|
+
headers: headers,
|
|
105
|
+
params: extendedParams,
|
|
106
|
+
body: file,
|
|
107
|
+
traceContext: traceContext
|
|
108
|
+
});
|
|
109
|
+
return _context2.abrupt("return", _this.request("/file/".concat(id, "/artifact/binary"), options).then(createMapResponseToJson(metadata)));
|
|
110
|
+
case 6:
|
|
111
|
+
case "end":
|
|
112
|
+
return _context2.stop();
|
|
113
|
+
}
|
|
114
|
+
}, _callee2);
|
|
115
|
+
}));
|
|
116
|
+
return function (_x4, _x5, _x6, _x7, _x8) {
|
|
117
|
+
return _ref3.apply(this, arguments);
|
|
118
|
+
};
|
|
119
|
+
}());
|
|
49
120
|
_defineProperty(this, "resolveAuth", function (authContext) {
|
|
50
121
|
return resolveAuth(_this.config.authProvider, authContext, _this.config.authProviderTimeout);
|
|
51
122
|
});
|
|
@@ -53,15 +124,15 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
53
124
|
return resolveInitialAuth(_this.config.initialAuth);
|
|
54
125
|
});
|
|
55
126
|
this.config = config;
|
|
56
|
-
this._chunkHashAlgorithm = config.chunkHashAlgorithm || ChunkHashAlgorithm.
|
|
127
|
+
this._chunkHashAlgorithm = config.chunkHashAlgorithm || ChunkHashAlgorithm.Sha256;
|
|
57
128
|
}
|
|
58
129
|
return _createClass(MediaStore, [{
|
|
59
130
|
key: "removeCollectionFile",
|
|
60
131
|
value: function () {
|
|
61
|
-
var _removeCollectionFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
132
|
+
var _removeCollectionFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(id, collectionName, occurrenceKey, traceContext) {
|
|
62
133
|
var metadata, body, options;
|
|
63
|
-
return _regeneratorRuntime.wrap(function
|
|
64
|
-
while (1) switch (
|
|
134
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
135
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
65
136
|
case 0:
|
|
66
137
|
metadata = {
|
|
67
138
|
method: 'PUT',
|
|
@@ -88,15 +159,15 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
88
159
|
body: JSON.stringify(body),
|
|
89
160
|
traceContext: traceContext
|
|
90
161
|
});
|
|
91
|
-
|
|
162
|
+
_context3.next = 5;
|
|
92
163
|
return this.request("/collection/".concat(collectionName), options);
|
|
93
164
|
case 5:
|
|
94
165
|
case "end":
|
|
95
|
-
return
|
|
166
|
+
return _context3.stop();
|
|
96
167
|
}
|
|
97
|
-
},
|
|
168
|
+
}, _callee3, this);
|
|
98
169
|
}));
|
|
99
|
-
function removeCollectionFile(
|
|
170
|
+
function removeCollectionFile(_x9, _x10, _x11, _x12) {
|
|
100
171
|
return _removeCollectionFile.apply(this, arguments);
|
|
101
172
|
}
|
|
102
173
|
return removeCollectionFile;
|
|
@@ -129,10 +200,10 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
129
200
|
}, {
|
|
130
201
|
key: "uploadChunk",
|
|
131
202
|
value: function () {
|
|
132
|
-
var _uploadChunk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
203
|
+
var _uploadChunk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(etag, blob, uploadId, partNumber, collectionName, traceContext) {
|
|
133
204
|
var metadata, options;
|
|
134
|
-
return _regeneratorRuntime.wrap(function
|
|
135
|
-
while (1) switch (
|
|
205
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
206
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
136
207
|
case 0:
|
|
137
208
|
metadata = {
|
|
138
209
|
method: 'PUT',
|
|
@@ -149,15 +220,15 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
149
220
|
body: blob,
|
|
150
221
|
traceContext: traceContext
|
|
151
222
|
});
|
|
152
|
-
|
|
223
|
+
_context4.next = 4;
|
|
153
224
|
return this.request("/chunk/".concat(etag), options);
|
|
154
225
|
case 4:
|
|
155
226
|
case "end":
|
|
156
|
-
return
|
|
227
|
+
return _context4.stop();
|
|
157
228
|
}
|
|
158
|
-
},
|
|
229
|
+
}, _callee4, this);
|
|
159
230
|
}));
|
|
160
|
-
function uploadChunk(
|
|
231
|
+
function uploadChunk(_x13, _x14, _x15, _x16, _x17, _x18) {
|
|
161
232
|
return _uploadChunk.apply(this, arguments);
|
|
162
233
|
}
|
|
163
234
|
return uploadChunk;
|
|
@@ -199,17 +270,17 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
199
270
|
}, {
|
|
200
271
|
key: "touchFiles",
|
|
201
272
|
value: function () {
|
|
202
|
-
var _touchFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
273
|
+
var _touchFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(body) {
|
|
203
274
|
var params,
|
|
204
275
|
traceContext,
|
|
205
276
|
metadata,
|
|
206
277
|
options,
|
|
207
|
-
|
|
208
|
-
return _regeneratorRuntime.wrap(function
|
|
209
|
-
while (1) switch (
|
|
278
|
+
_args5 = arguments;
|
|
279
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
280
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
210
281
|
case 0:
|
|
211
|
-
params =
|
|
212
|
-
traceContext =
|
|
282
|
+
params = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {};
|
|
283
|
+
traceContext = _args5.length > 2 ? _args5[2] : undefined;
|
|
213
284
|
metadata = {
|
|
214
285
|
method: 'POST',
|
|
215
286
|
endpoint: '/upload/createWithFiles'
|
|
@@ -225,14 +296,14 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
225
296
|
hashAlgorithm: this._chunkHashAlgorithm
|
|
226
297
|
}
|
|
227
298
|
});
|
|
228
|
-
return
|
|
299
|
+
return _context5.abrupt("return", this.request('/upload/createWithFiles', options).then(createMapResponseToJson(metadata)));
|
|
229
300
|
case 5:
|
|
230
301
|
case "end":
|
|
231
|
-
return
|
|
302
|
+
return _context5.stop();
|
|
232
303
|
}
|
|
233
|
-
},
|
|
304
|
+
}, _callee5, this);
|
|
234
305
|
}));
|
|
235
|
-
function touchFiles(
|
|
306
|
+
function touchFiles(_x19) {
|
|
236
307
|
return _touchFiles.apply(this, arguments);
|
|
237
308
|
}
|
|
238
309
|
return touchFiles;
|
|
@@ -258,26 +329,26 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
258
329
|
}, {
|
|
259
330
|
key: "getFileImageURL",
|
|
260
331
|
value: function () {
|
|
261
|
-
var _getFileImageURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
262
|
-
var
|
|
263
|
-
return _regeneratorRuntime.wrap(function
|
|
264
|
-
while (1) switch (
|
|
332
|
+
var _getFileImageURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(id, params) {
|
|
333
|
+
var _ref4, collectionName, auth;
|
|
334
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
335
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
265
336
|
case 0:
|
|
266
|
-
|
|
267
|
-
|
|
337
|
+
_ref4 = params || {}, collectionName = _ref4.collection;
|
|
338
|
+
_context6.next = 3;
|
|
268
339
|
return this.resolveAuth({
|
|
269
340
|
collectionName: collectionName
|
|
270
341
|
});
|
|
271
342
|
case 3:
|
|
272
|
-
auth =
|
|
273
|
-
return
|
|
343
|
+
auth = _context6.sent;
|
|
344
|
+
return _context6.abrupt("return", this.createFileImageURL(id, auth, params));
|
|
274
345
|
case 5:
|
|
275
346
|
case "end":
|
|
276
|
-
return
|
|
347
|
+
return _context6.stop();
|
|
277
348
|
}
|
|
278
|
-
},
|
|
349
|
+
}, _callee6, this);
|
|
279
350
|
}));
|
|
280
|
-
function getFileImageURL(
|
|
351
|
+
function getFileImageURL(_x20, _x21) {
|
|
281
352
|
return _getFileImageURL.apply(this, arguments);
|
|
282
353
|
}
|
|
283
354
|
return getFileImageURL;
|
|
@@ -301,17 +372,17 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
301
372
|
}, {
|
|
302
373
|
key: "getFileBinary",
|
|
303
374
|
value: function () {
|
|
304
|
-
var _getFileBinary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
375
|
+
var _getFileBinary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(id, collectionName, abortController) {
|
|
305
376
|
var maxAge,
|
|
306
377
|
headers,
|
|
307
378
|
binaryEndpoint,
|
|
308
379
|
metadata,
|
|
309
380
|
options,
|
|
310
|
-
|
|
311
|
-
return _regeneratorRuntime.wrap(function
|
|
312
|
-
while (1) switch (
|
|
381
|
+
_args7 = arguments;
|
|
382
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
383
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
313
384
|
case 0:
|
|
314
|
-
maxAge =
|
|
385
|
+
maxAge = _args7.length > 3 && _args7[3] !== undefined ? _args7[3] : FILE_CACHE_MAX_AGE;
|
|
315
386
|
headers = {};
|
|
316
387
|
binaryEndpoint = cdnFeatureFlag('binary');
|
|
317
388
|
metadata = {
|
|
@@ -328,14 +399,14 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
328
399
|
'max-age': "".concat(maxAge)
|
|
329
400
|
}
|
|
330
401
|
});
|
|
331
|
-
return
|
|
402
|
+
return _context7.abrupt("return", this.request("/file/".concat(id, "/").concat(binaryEndpoint), options, abortController, true).then(createMapResponseToBlob(metadata)));
|
|
332
403
|
case 6:
|
|
333
404
|
case "end":
|
|
334
|
-
return
|
|
405
|
+
return _context7.stop();
|
|
335
406
|
}
|
|
336
|
-
},
|
|
407
|
+
}, _callee7, this);
|
|
337
408
|
}));
|
|
338
|
-
function getFileBinary(
|
|
409
|
+
function getFileBinary(_x22, _x23, _x24) {
|
|
339
410
|
return _getFileBinary.apply(this, arguments);
|
|
340
411
|
}
|
|
341
412
|
return getFileBinary;
|
|
@@ -343,22 +414,22 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
343
414
|
}, {
|
|
344
415
|
key: "getFileBinaryURL",
|
|
345
416
|
value: function () {
|
|
346
|
-
var _getFileBinaryURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
417
|
+
var _getFileBinaryURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(id, collectionName) {
|
|
347
418
|
var maxAge,
|
|
348
419
|
auth,
|
|
349
420
|
options,
|
|
350
421
|
binaryEndpoint,
|
|
351
|
-
|
|
352
|
-
return _regeneratorRuntime.wrap(function
|
|
353
|
-
while (1) switch (
|
|
422
|
+
_args8 = arguments;
|
|
423
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
424
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
354
425
|
case 0:
|
|
355
|
-
maxAge =
|
|
356
|
-
|
|
426
|
+
maxAge = _args8.length > 2 && _args8[2] !== undefined ? _args8[2] : FILE_CACHE_MAX_AGE;
|
|
427
|
+
_context8.next = 3;
|
|
357
428
|
return this.resolveAuth({
|
|
358
429
|
collectionName: collectionName
|
|
359
430
|
});
|
|
360
431
|
case 3:
|
|
361
|
-
auth =
|
|
432
|
+
auth = _context8.sent;
|
|
362
433
|
options = {
|
|
363
434
|
params: {
|
|
364
435
|
dl: true,
|
|
@@ -368,14 +439,14 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
368
439
|
auth: auth
|
|
369
440
|
};
|
|
370
441
|
binaryEndpoint = cdnFeatureFlag('binary');
|
|
371
|
-
return
|
|
442
|
+
return _context8.abrupt("return", mapToMediaCdnUrl(createUrl("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(binaryEndpoint), options), auth.token));
|
|
372
443
|
case 7:
|
|
373
444
|
case "end":
|
|
374
|
-
return
|
|
445
|
+
return _context8.stop();
|
|
375
446
|
}
|
|
376
|
-
},
|
|
447
|
+
}, _callee8, this);
|
|
377
448
|
}));
|
|
378
|
-
function getFileBinaryURL(
|
|
449
|
+
function getFileBinaryURL(_x25, _x26) {
|
|
379
450
|
return _getFileBinaryURL.apply(this, arguments);
|
|
380
451
|
}
|
|
381
452
|
return getFileBinaryURL;
|
|
@@ -383,39 +454,57 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
383
454
|
}, {
|
|
384
455
|
key: "getArtifactURL",
|
|
385
456
|
value: function () {
|
|
386
|
-
var _getArtifactURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
387
|
-
var
|
|
388
|
-
|
|
389
|
-
|
|
457
|
+
var _getArtifactURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(artifacts, artifactName, collectionName) {
|
|
458
|
+
var maxAge,
|
|
459
|
+
_artifacts$artifactNa,
|
|
460
|
+
cdnUrl,
|
|
461
|
+
artifactUrl,
|
|
462
|
+
auth,
|
|
463
|
+
options,
|
|
464
|
+
_args9 = arguments;
|
|
465
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
466
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
390
467
|
case 0:
|
|
468
|
+
maxAge = _args9.length > 3 && _args9[3] !== undefined ? _args9[3] : FILE_CACHE_MAX_AGE;
|
|
469
|
+
if (!(isCommercial() && fg('platform_media_cdn_delivery'))) {
|
|
470
|
+
_context9.next = 5;
|
|
471
|
+
break;
|
|
472
|
+
}
|
|
473
|
+
cdnUrl = (_artifacts$artifactNa = artifacts[artifactName]) === null || _artifacts$artifactNa === void 0 ? void 0 : _artifacts$artifactNa.cdnUrl;
|
|
474
|
+
if (!cdnUrl) {
|
|
475
|
+
_context9.next = 5;
|
|
476
|
+
break;
|
|
477
|
+
}
|
|
478
|
+
return _context9.abrupt("return", cdnUrl);
|
|
479
|
+
case 5:
|
|
391
480
|
artifactUrl = getArtifactUrl(artifacts, artifactName);
|
|
392
481
|
if (artifactUrl) {
|
|
393
|
-
|
|
482
|
+
_context9.next = 8;
|
|
394
483
|
break;
|
|
395
484
|
}
|
|
396
485
|
throw new Error("artifact ".concat(artifactName, " not found"));
|
|
397
|
-
case
|
|
398
|
-
|
|
486
|
+
case 8:
|
|
487
|
+
_context9.next = 10;
|
|
399
488
|
return this.resolveAuth({
|
|
400
489
|
collectionName: collectionName
|
|
401
490
|
});
|
|
402
|
-
case
|
|
403
|
-
auth =
|
|
491
|
+
case 10:
|
|
492
|
+
auth = _context9.sent;
|
|
404
493
|
options = {
|
|
405
494
|
params: {
|
|
406
495
|
collection: collectionName,
|
|
407
|
-
'max-age':
|
|
496
|
+
'max-age': maxAge
|
|
408
497
|
},
|
|
409
498
|
auth: auth
|
|
410
499
|
};
|
|
411
|
-
return
|
|
412
|
-
case
|
|
500
|
+
return _context9.abrupt("return", createUrl(mapToMediaCdnUrl(artifactUrl, auth.token), options));
|
|
501
|
+
case 13:
|
|
413
502
|
case "end":
|
|
414
|
-
return
|
|
503
|
+
return _context9.stop();
|
|
415
504
|
}
|
|
416
|
-
},
|
|
505
|
+
}, _callee9, this);
|
|
417
506
|
}));
|
|
418
|
-
function getArtifactURL(
|
|
507
|
+
function getArtifactURL(_x27, _x28, _x29) {
|
|
419
508
|
return _getArtifactURL.apply(this, arguments);
|
|
420
509
|
}
|
|
421
510
|
return getArtifactURL;
|
|
@@ -423,10 +512,10 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
423
512
|
}, {
|
|
424
513
|
key: "getImage",
|
|
425
514
|
value: function () {
|
|
426
|
-
var _getImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
515
|
+
var _getImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(id, params, controller, fetchMaxRes, traceContext) {
|
|
427
516
|
var isWebpSupported, headers, imageEndpoint, metadata, options;
|
|
428
|
-
return _regeneratorRuntime.wrap(function
|
|
429
|
-
while (1) switch (
|
|
517
|
+
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
518
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
430
519
|
case 0:
|
|
431
520
|
// TODO add checkWebpSupport() back https://product-fabric.atlassian.net/browse/MPT-584
|
|
432
521
|
isWebpSupported = false;
|
|
@@ -448,14 +537,14 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
448
537
|
traceContext: traceContext,
|
|
449
538
|
addMediaClientParam: true
|
|
450
539
|
});
|
|
451
|
-
return
|
|
540
|
+
return _context10.abrupt("return", this.request("/file/".concat(id, "/").concat(imageEndpoint), options, controller, true).then(createMapResponseToBlob(metadata)));
|
|
452
541
|
case 7:
|
|
453
542
|
case "end":
|
|
454
|
-
return
|
|
543
|
+
return _context10.stop();
|
|
455
544
|
}
|
|
456
|
-
},
|
|
545
|
+
}, _callee10, this);
|
|
457
546
|
}));
|
|
458
|
-
function getImage(
|
|
547
|
+
function getImage(_x30, _x31, _x32, _x33, _x34) {
|
|
459
548
|
return _getImage.apply(this, arguments);
|
|
460
549
|
}
|
|
461
550
|
return getImage;
|
|
@@ -463,10 +552,10 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
463
552
|
}, {
|
|
464
553
|
key: "getItems",
|
|
465
554
|
value: function () {
|
|
466
|
-
var _getItems = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
555
|
+
var _getItems = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(ids, collectionName, traceContext, includeHashForDuplicateFiles) {
|
|
467
556
|
var descriptors, metadata, options;
|
|
468
|
-
return _regeneratorRuntime.wrap(function
|
|
469
|
-
while (1) switch (
|
|
557
|
+
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
558
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
470
559
|
case 0:
|
|
471
560
|
descriptors = ids.map(function (id) {
|
|
472
561
|
return {
|
|
@@ -490,14 +579,14 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
490
579
|
}),
|
|
491
580
|
traceContext: traceContext
|
|
492
581
|
});
|
|
493
|
-
return
|
|
582
|
+
return _context11.abrupt("return", this.request('/items', options).then(createMapResponseToJson(metadata)));
|
|
494
583
|
case 4:
|
|
495
584
|
case "end":
|
|
496
|
-
return
|
|
585
|
+
return _context11.stop();
|
|
497
586
|
}
|
|
498
|
-
},
|
|
587
|
+
}, _callee11, this);
|
|
499
588
|
}));
|
|
500
|
-
function getItems(
|
|
589
|
+
function getItems(_x35, _x36, _x37, _x38) {
|
|
501
590
|
return _getItems.apply(this, arguments);
|
|
502
591
|
}
|
|
503
592
|
return getItems;
|
|
@@ -505,10 +594,10 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
505
594
|
}, {
|
|
506
595
|
key: "getImageMetadata",
|
|
507
596
|
value: function () {
|
|
508
|
-
var _getImageMetadata = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
597
|
+
var _getImageMetadata = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(id, params, traceContext) {
|
|
509
598
|
var metadata, options;
|
|
510
|
-
return _regeneratorRuntime.wrap(function
|
|
511
|
-
while (1) switch (
|
|
599
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
600
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
512
601
|
case 0:
|
|
513
602
|
metadata = {
|
|
514
603
|
method: 'GET',
|
|
@@ -521,14 +610,14 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
521
610
|
params: params,
|
|
522
611
|
traceContext: traceContext
|
|
523
612
|
});
|
|
524
|
-
return
|
|
613
|
+
return _context12.abrupt("return", this.request("/file/".concat(id, "/image/metadata"), options).then(createMapResponseToJson(metadata)));
|
|
525
614
|
case 3:
|
|
526
615
|
case "end":
|
|
527
|
-
return
|
|
616
|
+
return _context12.stop();
|
|
528
617
|
}
|
|
529
|
-
},
|
|
618
|
+
}, _callee12, this);
|
|
530
619
|
}));
|
|
531
|
-
function getImageMetadata(
|
|
620
|
+
function getImageMetadata(_x39, _x40, _x41) {
|
|
532
621
|
return _getImageMetadata.apply(this, arguments);
|
|
533
622
|
}
|
|
534
623
|
return getImageMetadata;
|
|
@@ -536,10 +625,10 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
536
625
|
}, {
|
|
537
626
|
key: "appendChunksToUpload",
|
|
538
627
|
value: function () {
|
|
539
|
-
var _appendChunksToUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
628
|
+
var _appendChunksToUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(uploadId, body, collectionName, traceContext) {
|
|
540
629
|
var metadata, options;
|
|
541
|
-
return _regeneratorRuntime.wrap(function
|
|
542
|
-
while (1) switch (
|
|
630
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
631
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
543
632
|
case 0:
|
|
544
633
|
metadata = {
|
|
545
634
|
method: 'PUT',
|
|
@@ -553,15 +642,15 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
553
642
|
body: JSON.stringify(body),
|
|
554
643
|
traceContext: traceContext
|
|
555
644
|
});
|
|
556
|
-
|
|
645
|
+
_context13.next = 4;
|
|
557
646
|
return this.request("/upload/".concat(uploadId, "/chunks"), options);
|
|
558
647
|
case 4:
|
|
559
648
|
case "end":
|
|
560
|
-
return
|
|
649
|
+
return _context13.stop();
|
|
561
650
|
}
|
|
562
|
-
},
|
|
651
|
+
}, _callee13, this);
|
|
563
652
|
}));
|
|
564
|
-
function appendChunksToUpload(
|
|
653
|
+
function appendChunksToUpload(_x42, _x43, _x44, _x45) {
|
|
565
654
|
return _appendChunksToUpload.apply(this, arguments);
|
|
566
655
|
}
|
|
567
656
|
return appendChunksToUpload;
|
|
@@ -618,10 +707,10 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
618
707
|
}, {
|
|
619
708
|
key: "registerCopyIntents",
|
|
620
709
|
value: function () {
|
|
621
|
-
var _registerCopyIntents = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
710
|
+
var _registerCopyIntents = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(files, traceContext, resolvedAuth) {
|
|
622
711
|
var metadata, options;
|
|
623
|
-
return _regeneratorRuntime.wrap(function
|
|
624
|
-
while (1) switch (
|
|
712
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
713
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
625
714
|
case 0:
|
|
626
715
|
metadata = {
|
|
627
716
|
method: 'POST',
|
|
@@ -635,15 +724,15 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
635
724
|
traceContext: traceContext,
|
|
636
725
|
resolvedAuth: resolvedAuth
|
|
637
726
|
});
|
|
638
|
-
|
|
727
|
+
_context14.next = 4;
|
|
639
728
|
return this.request('/file/copy/intents', options);
|
|
640
729
|
case 4:
|
|
641
730
|
case "end":
|
|
642
|
-
return
|
|
731
|
+
return _context14.stop();
|
|
643
732
|
}
|
|
644
|
-
},
|
|
733
|
+
}, _callee14, this);
|
|
645
734
|
}));
|
|
646
|
-
function registerCopyIntents(
|
|
735
|
+
function registerCopyIntents(_x46, _x47, _x48) {
|
|
647
736
|
return _registerCopyIntents.apply(this, arguments);
|
|
648
737
|
}
|
|
649
738
|
return registerCopyIntents;
|
|
@@ -651,7 +740,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
651
740
|
}, {
|
|
652
741
|
key: "request",
|
|
653
742
|
value: function () {
|
|
654
|
-
var _request2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
743
|
+
var _request2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(path) {
|
|
655
744
|
var options,
|
|
656
745
|
controller,
|
|
657
746
|
useMediaCdn,
|
|
@@ -671,32 +760,32 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
671
760
|
extendedParams,
|
|
672
761
|
url,
|
|
673
762
|
response,
|
|
674
|
-
|
|
675
|
-
return _regeneratorRuntime.wrap(function
|
|
676
|
-
while (1) switch (
|
|
763
|
+
_args15 = arguments;
|
|
764
|
+
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
765
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
677
766
|
case 0:
|
|
678
|
-
options =
|
|
767
|
+
options = _args15.length > 1 && _args15[1] !== undefined ? _args15[1] : {
|
|
679
768
|
method: 'GET',
|
|
680
769
|
endpoint: undefined,
|
|
681
770
|
authContext: {}
|
|
682
771
|
};
|
|
683
|
-
controller =
|
|
684
|
-
useMediaCdn =
|
|
772
|
+
controller = _args15.length > 2 ? _args15[2] : undefined;
|
|
773
|
+
useMediaCdn = _args15.length > 3 ? _args15[3] : undefined;
|
|
685
774
|
method = options.method, endpoint = options.endpoint, authContext = options.authContext, params = options.params, headers = options.headers, body = options.body, clientOptions = options.clientOptions, traceContext = options.traceContext, addMediaClientParam = options.addMediaClientParam, resolvedAuth = options.resolvedAuth;
|
|
686
775
|
if (!(resolvedAuth !== null && resolvedAuth !== void 0)) {
|
|
687
|
-
|
|
776
|
+
_context15.next = 8;
|
|
688
777
|
break;
|
|
689
778
|
}
|
|
690
|
-
|
|
691
|
-
|
|
779
|
+
_context15.t0 = resolvedAuth;
|
|
780
|
+
_context15.next = 11;
|
|
692
781
|
break;
|
|
693
782
|
case 8:
|
|
694
|
-
|
|
783
|
+
_context15.next = 10;
|
|
695
784
|
return this.resolveAuth(authContext);
|
|
696
785
|
case 10:
|
|
697
|
-
|
|
786
|
+
_context15.t0 = _context15.sent;
|
|
698
787
|
case 11:
|
|
699
|
-
auth =
|
|
788
|
+
auth = _context15.t0;
|
|
700
789
|
clientId = isClientBasedAuth(auth) ? auth.clientId : undefined;
|
|
701
790
|
extendedTraceContext = extendTraceContext(traceContext);
|
|
702
791
|
extendedParams = addMediaClientParam ? _objectSpread(_objectSpread({}, params), {}, {
|
|
@@ -706,7 +795,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
706
795
|
if (useMediaCdn) {
|
|
707
796
|
url = mapToMediaCdnUrl(url, auth.token);
|
|
708
797
|
}
|
|
709
|
-
|
|
798
|
+
_context15.next = 19;
|
|
710
799
|
return _request(url, {
|
|
711
800
|
method: method,
|
|
712
801
|
endpoint: endpoint,
|
|
@@ -718,17 +807,17 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
718
807
|
traceContext: extendedTraceContext
|
|
719
808
|
}, controller);
|
|
720
809
|
case 19:
|
|
721
|
-
response =
|
|
810
|
+
response = _context15.sent;
|
|
722
811
|
setKeyValueInSessionStorage(MEDIA_API_REGION, response.headers.get('x-media-region'));
|
|
723
812
|
setKeyValueInSessionStorage(MEDIA_API_ENVIRONMENT, response.headers.get('x-media-env'));
|
|
724
|
-
return
|
|
813
|
+
return _context15.abrupt("return", response);
|
|
725
814
|
case 23:
|
|
726
815
|
case "end":
|
|
727
|
-
return
|
|
816
|
+
return _context15.stop();
|
|
728
817
|
}
|
|
729
|
-
},
|
|
818
|
+
}, _callee15, this);
|
|
730
819
|
}));
|
|
731
|
-
function request(
|
|
820
|
+
function request(_x49) {
|
|
732
821
|
return _request2.apply(this, arguments);
|
|
733
822
|
}
|
|
734
823
|
return request;
|
|
@@ -736,16 +825,16 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
736
825
|
}, {
|
|
737
826
|
key: "testUrl",
|
|
738
827
|
value: function () {
|
|
739
|
-
var _testUrl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
828
|
+
var _testUrl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(url) {
|
|
740
829
|
var options,
|
|
741
830
|
traceContext,
|
|
742
|
-
|
|
743
|
-
return _regeneratorRuntime.wrap(function
|
|
744
|
-
while (1) switch (
|
|
831
|
+
_args16 = arguments;
|
|
832
|
+
return _regeneratorRuntime.wrap(function _callee16$(_context16) {
|
|
833
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
745
834
|
case 0:
|
|
746
|
-
options =
|
|
835
|
+
options = _args16.length > 1 && _args16[1] !== undefined ? _args16[1] : {};
|
|
747
836
|
traceContext = options.traceContext;
|
|
748
|
-
|
|
837
|
+
_context16.next = 4;
|
|
749
838
|
return _request(url, {
|
|
750
839
|
method: 'HEAD',
|
|
751
840
|
traceContext: extendTraceContext(traceContext),
|
|
@@ -757,11 +846,11 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
757
846
|
});
|
|
758
847
|
case 4:
|
|
759
848
|
case "end":
|
|
760
|
-
return
|
|
849
|
+
return _context16.stop();
|
|
761
850
|
}
|
|
762
|
-
},
|
|
851
|
+
}, _callee16);
|
|
763
852
|
}));
|
|
764
|
-
function testUrl(
|
|
853
|
+
function testUrl(_x50) {
|
|
765
854
|
return _testUrl.apply(this, arguments);
|
|
766
855
|
}
|
|
767
856
|
return testUrl;
|