@atlaskit/media-client 35.7.1 → 36.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/cjs/client/file-fetcher/index.js +3 -3
- package/dist/cjs/client/media-client.js +43 -24
- package/dist/cjs/client/media-store/MediaStore.js +189 -148
- package/dist/cjs/models/file-state.js +4 -2
- package/dist/cjs/utils/url.js +3 -1
- package/dist/es2019/client/file-fetcher/index.js +2 -2
- package/dist/es2019/client/media-client.js +3 -0
- package/dist/es2019/client/media-store/MediaStore.js +21 -2
- package/dist/es2019/models/file-state.js +4 -2
- package/dist/es2019/utils/url.js +3 -1
- package/dist/esm/client/file-fetcher/index.js +3 -3
- package/dist/esm/client/media-client.js +43 -24
- package/dist/esm/client/media-store/MediaStore.js +189 -148
- package/dist/esm/models/file-state.js +4 -2
- package/dist/esm/utils/url.js +3 -1
- package/dist/types/client/file-fetcher/index.d.ts +1 -0
- package/dist/types/client/media-client.d.ts +1 -0
- package/dist/types/client/media-store/MediaStore.d.ts +2 -1
- package/dist/types/models/item.d.ts +2 -0
- package/dist/types/models/media.d.ts +3 -1
- package/dist/types/utils/url.d.ts +1 -0
- package/dist/types-ts4.5/client/file-fetcher/index.d.ts +1 -0
- package/dist/types-ts4.5/client/media-client.d.ts +1 -0
- package/dist/types-ts4.5/client/media-store/MediaStore.d.ts +2 -1
- package/dist/types-ts4.5/models/item.d.ts +2 -0
- package/dist/types-ts4.5/models/media.d.ts +3 -1
- package/dist/types-ts4.5/utils/url.d.ts +1 -0
- package/package.json +6 -5
|
@@ -45,6 +45,9 @@ var cdnFeatureFlag = function cdnFeatureFlag(endpoint) {
|
|
|
45
45
|
}
|
|
46
46
|
return result;
|
|
47
47
|
};
|
|
48
|
+
var decodeJwtToken = function decodeJwtToken(token) {
|
|
49
|
+
return JSON.parse(atob(token.split('.')[1].replace(/-/g, '+').replace(/_/g, '/')));
|
|
50
|
+
};
|
|
48
51
|
var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
49
52
|
function MediaStore(config) {
|
|
50
53
|
var _this = this;
|
|
@@ -170,12 +173,49 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
170
173
|
this._chunkHashAlgorithm = config.chunkHashAlgorithm || _mediaCore.ChunkHashAlgorithm.Sha256;
|
|
171
174
|
}
|
|
172
175
|
return (0, _createClass2.default)(MediaStore, [{
|
|
173
|
-
key: "
|
|
176
|
+
key: "getClientId",
|
|
174
177
|
value: function () {
|
|
175
|
-
var
|
|
176
|
-
var
|
|
178
|
+
var _getClientId = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(collectionName) {
|
|
179
|
+
var auth, jwtPayload;
|
|
177
180
|
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
178
181
|
while (1) switch (_context4.prev = _context4.next) {
|
|
182
|
+
case 0:
|
|
183
|
+
_context4.next = 2;
|
|
184
|
+
return this.resolveAuth({
|
|
185
|
+
collectionName: collectionName
|
|
186
|
+
});
|
|
187
|
+
case 2:
|
|
188
|
+
auth = _context4.sent;
|
|
189
|
+
if ((0, _mediaCore.isClientBasedAuth)(auth)) {
|
|
190
|
+
_context4.next = 11;
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
_context4.prev = 4;
|
|
194
|
+
jwtPayload = decodeJwtToken(auth.token);
|
|
195
|
+
return _context4.abrupt("return", jwtPayload.clientId);
|
|
196
|
+
case 9:
|
|
197
|
+
_context4.prev = 9;
|
|
198
|
+
_context4.t0 = _context4["catch"](4);
|
|
199
|
+
case 11:
|
|
200
|
+
return _context4.abrupt("return", (0, _mediaCore.isClientBasedAuth)(auth) ? auth.clientId : undefined);
|
|
201
|
+
case 12:
|
|
202
|
+
case "end":
|
|
203
|
+
return _context4.stop();
|
|
204
|
+
}
|
|
205
|
+
}, _callee4, this, [[4, 9]]);
|
|
206
|
+
}));
|
|
207
|
+
function getClientId(_x11) {
|
|
208
|
+
return _getClientId.apply(this, arguments);
|
|
209
|
+
}
|
|
210
|
+
return getClientId;
|
|
211
|
+
}()
|
|
212
|
+
}, {
|
|
213
|
+
key: "removeCollectionFile",
|
|
214
|
+
value: function () {
|
|
215
|
+
var _removeCollectionFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(id, collectionName, occurrenceKey, traceContext) {
|
|
216
|
+
var metadata, body, options;
|
|
217
|
+
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
218
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
179
219
|
case 0:
|
|
180
220
|
metadata = {
|
|
181
221
|
method: 'PUT',
|
|
@@ -202,15 +242,15 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
202
242
|
body: JSON.stringify(body),
|
|
203
243
|
traceContext: traceContext
|
|
204
244
|
});
|
|
205
|
-
|
|
245
|
+
_context5.next = 5;
|
|
206
246
|
return this.request("/collection/".concat(collectionName), options);
|
|
207
247
|
case 5:
|
|
208
248
|
case "end":
|
|
209
|
-
return
|
|
249
|
+
return _context5.stop();
|
|
210
250
|
}
|
|
211
|
-
},
|
|
251
|
+
}, _callee5, this);
|
|
212
252
|
}));
|
|
213
|
-
function removeCollectionFile(
|
|
253
|
+
function removeCollectionFile(_x12, _x13, _x14, _x15) {
|
|
214
254
|
return _removeCollectionFile.apply(this, arguments);
|
|
215
255
|
}
|
|
216
256
|
return removeCollectionFile;
|
|
@@ -243,10 +283,10 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
243
283
|
}, {
|
|
244
284
|
key: "uploadChunk",
|
|
245
285
|
value: function () {
|
|
246
|
-
var _uploadChunk = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
286
|
+
var _uploadChunk = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(etag, blob, uploadId, partNumber, collectionName, traceContext) {
|
|
247
287
|
var metadata, options;
|
|
248
|
-
return _regenerator.default.wrap(function
|
|
249
|
-
while (1) switch (
|
|
288
|
+
return _regenerator.default.wrap(function _callee6$(_context6) {
|
|
289
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
250
290
|
case 0:
|
|
251
291
|
metadata = {
|
|
252
292
|
method: 'PUT',
|
|
@@ -263,15 +303,15 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
263
303
|
body: blob,
|
|
264
304
|
traceContext: traceContext
|
|
265
305
|
});
|
|
266
|
-
|
|
306
|
+
_context6.next = 4;
|
|
267
307
|
return this.request("/chunk/".concat(etag), options);
|
|
268
308
|
case 4:
|
|
269
309
|
case "end":
|
|
270
|
-
return
|
|
310
|
+
return _context6.stop();
|
|
271
311
|
}
|
|
272
|
-
},
|
|
312
|
+
}, _callee6, this);
|
|
273
313
|
}));
|
|
274
|
-
function uploadChunk(
|
|
314
|
+
function uploadChunk(_x16, _x17, _x18, _x19, _x20, _x21) {
|
|
275
315
|
return _uploadChunk.apply(this, arguments);
|
|
276
316
|
}
|
|
277
317
|
return uploadChunk;
|
|
@@ -313,17 +353,17 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
313
353
|
}, {
|
|
314
354
|
key: "touchFiles",
|
|
315
355
|
value: function () {
|
|
316
|
-
var _touchFiles = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
356
|
+
var _touchFiles = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(body) {
|
|
317
357
|
var params,
|
|
318
358
|
traceContext,
|
|
319
359
|
metadata,
|
|
320
360
|
options,
|
|
321
|
-
|
|
322
|
-
return _regenerator.default.wrap(function
|
|
323
|
-
while (1) switch (
|
|
361
|
+
_args7 = arguments;
|
|
362
|
+
return _regenerator.default.wrap(function _callee7$(_context7) {
|
|
363
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
324
364
|
case 0:
|
|
325
|
-
params =
|
|
326
|
-
traceContext =
|
|
365
|
+
params = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : {};
|
|
366
|
+
traceContext = _args7.length > 2 ? _args7[2] : undefined;
|
|
327
367
|
metadata = {
|
|
328
368
|
method: 'POST',
|
|
329
369
|
endpoint: '/upload/createWithFiles'
|
|
@@ -339,14 +379,14 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
339
379
|
hashAlgorithm: this._chunkHashAlgorithm
|
|
340
380
|
}
|
|
341
381
|
});
|
|
342
|
-
return
|
|
382
|
+
return _context7.abrupt("return", this.request('/upload/createWithFiles', options).then((0, _helpers.createMapResponseToJson)(metadata)));
|
|
343
383
|
case 5:
|
|
344
384
|
case "end":
|
|
345
|
-
return
|
|
385
|
+
return _context7.stop();
|
|
346
386
|
}
|
|
347
|
-
},
|
|
387
|
+
}, _callee7, this);
|
|
348
388
|
}));
|
|
349
|
-
function touchFiles(
|
|
389
|
+
function touchFiles(_x22) {
|
|
350
390
|
return _touchFiles.apply(this, arguments);
|
|
351
391
|
}
|
|
352
392
|
return touchFiles;
|
|
@@ -372,26 +412,26 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
372
412
|
}, {
|
|
373
413
|
key: "getFileImageURL",
|
|
374
414
|
value: function () {
|
|
375
|
-
var _getFileImageURL = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
415
|
+
var _getFileImageURL = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(id, params) {
|
|
376
416
|
var _ref5, collectionName, auth;
|
|
377
|
-
return _regenerator.default.wrap(function
|
|
378
|
-
while (1) switch (
|
|
417
|
+
return _regenerator.default.wrap(function _callee8$(_context8) {
|
|
418
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
379
419
|
case 0:
|
|
380
420
|
_ref5 = params || {}, collectionName = _ref5.collection;
|
|
381
|
-
|
|
421
|
+
_context8.next = 3;
|
|
382
422
|
return this.resolveAuth({
|
|
383
423
|
collectionName: collectionName
|
|
384
424
|
});
|
|
385
425
|
case 3:
|
|
386
|
-
auth =
|
|
387
|
-
return
|
|
426
|
+
auth = _context8.sent;
|
|
427
|
+
return _context8.abrupt("return", this.createFileImageURL(id, auth, params));
|
|
388
428
|
case 5:
|
|
389
429
|
case "end":
|
|
390
|
-
return
|
|
430
|
+
return _context8.stop();
|
|
391
431
|
}
|
|
392
|
-
},
|
|
432
|
+
}, _callee8, this);
|
|
393
433
|
}));
|
|
394
|
-
function getFileImageURL(
|
|
434
|
+
function getFileImageURL(_x23, _x24) {
|
|
395
435
|
return _getFileImageURL.apply(this, arguments);
|
|
396
436
|
}
|
|
397
437
|
return getFileImageURL;
|
|
@@ -418,17 +458,17 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
418
458
|
}, {
|
|
419
459
|
key: "getFileBinary",
|
|
420
460
|
value: function () {
|
|
421
|
-
var _getFileBinary = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
461
|
+
var _getFileBinary = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(id, collectionName, abortController) {
|
|
422
462
|
var maxAge,
|
|
423
463
|
headers,
|
|
424
464
|
binaryEndpoint,
|
|
425
465
|
metadata,
|
|
426
466
|
options,
|
|
427
|
-
|
|
428
|
-
return _regenerator.default.wrap(function
|
|
429
|
-
while (1) switch (
|
|
467
|
+
_args9 = arguments;
|
|
468
|
+
return _regenerator.default.wrap(function _callee9$(_context9) {
|
|
469
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
430
470
|
case 0:
|
|
431
|
-
maxAge =
|
|
471
|
+
maxAge = _args9.length > 3 && _args9[3] !== undefined ? _args9[3] : _constants.FILE_CACHE_MAX_AGE;
|
|
432
472
|
headers = {};
|
|
433
473
|
binaryEndpoint = cdnFeatureFlag('binary');
|
|
434
474
|
metadata = {
|
|
@@ -445,14 +485,14 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
445
485
|
'max-age': "".concat(maxAge)
|
|
446
486
|
}
|
|
447
487
|
});
|
|
448
|
-
return
|
|
488
|
+
return _context9.abrupt("return", this.request("/file/".concat(id, "/").concat(binaryEndpoint), options, abortController, true).then((0, _helpers.createMapResponseToBlob)(metadata)));
|
|
449
489
|
case 6:
|
|
450
490
|
case "end":
|
|
451
|
-
return
|
|
491
|
+
return _context9.stop();
|
|
452
492
|
}
|
|
453
|
-
},
|
|
493
|
+
}, _callee9, this);
|
|
454
494
|
}));
|
|
455
|
-
function getFileBinary(
|
|
495
|
+
function getFileBinary(_x25, _x26, _x27) {
|
|
456
496
|
return _getFileBinary.apply(this, arguments);
|
|
457
497
|
}
|
|
458
498
|
return getFileBinary;
|
|
@@ -460,22 +500,22 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
460
500
|
}, {
|
|
461
501
|
key: "getFileBinaryURL",
|
|
462
502
|
value: function () {
|
|
463
|
-
var _getFileBinaryURL = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
503
|
+
var _getFileBinaryURL = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee0(id, collectionName) {
|
|
464
504
|
var maxAge,
|
|
465
505
|
auth,
|
|
466
506
|
options,
|
|
467
507
|
binaryEndpoint,
|
|
468
|
-
|
|
469
|
-
return _regenerator.default.wrap(function
|
|
470
|
-
while (1) switch (
|
|
508
|
+
_args0 = arguments;
|
|
509
|
+
return _regenerator.default.wrap(function _callee0$(_context0) {
|
|
510
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
471
511
|
case 0:
|
|
472
|
-
maxAge =
|
|
473
|
-
|
|
512
|
+
maxAge = _args0.length > 2 && _args0[2] !== undefined ? _args0[2] : _constants.FILE_CACHE_MAX_AGE;
|
|
513
|
+
_context0.next = 3;
|
|
474
514
|
return this.resolveAuth({
|
|
475
515
|
collectionName: collectionName
|
|
476
516
|
});
|
|
477
517
|
case 3:
|
|
478
|
-
auth =
|
|
518
|
+
auth = _context0.sent;
|
|
479
519
|
options = {
|
|
480
520
|
params: {
|
|
481
521
|
dl: true,
|
|
@@ -486,19 +526,19 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
486
526
|
};
|
|
487
527
|
binaryEndpoint = cdnFeatureFlag('binary');
|
|
488
528
|
if (!(0, _pathBasedUrl.isPathBasedEnabled)()) {
|
|
489
|
-
|
|
529
|
+
_context0.next = 8;
|
|
490
530
|
break;
|
|
491
531
|
}
|
|
492
|
-
return
|
|
532
|
+
return _context0.abrupt("return", (0, _pathBasedUrl.mapToPathBasedUrl)((0, _helpers.createUrl)("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(binaryEndpoint), options)));
|
|
493
533
|
case 8:
|
|
494
|
-
return
|
|
534
|
+
return _context0.abrupt("return", (0, _mediaCdn.mapToMediaCdnUrl)((0, _helpers.createUrl)("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(binaryEndpoint), options), auth.token));
|
|
495
535
|
case 9:
|
|
496
536
|
case "end":
|
|
497
|
-
return
|
|
537
|
+
return _context0.stop();
|
|
498
538
|
}
|
|
499
|
-
},
|
|
539
|
+
}, _callee0, this);
|
|
500
540
|
}));
|
|
501
|
-
function getFileBinaryURL(
|
|
541
|
+
function getFileBinaryURL(_x28, _x29) {
|
|
502
542
|
return _getFileBinaryURL.apply(this, arguments);
|
|
503
543
|
}
|
|
504
544
|
return getFileBinaryURL;
|
|
@@ -506,17 +546,17 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
506
546
|
}, {
|
|
507
547
|
key: "getArtifactURL",
|
|
508
548
|
value: function () {
|
|
509
|
-
var _getArtifactURL = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
549
|
+
var _getArtifactURL = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee1(artifacts, artifactName, collectionName) {
|
|
510
550
|
var maxAge,
|
|
511
551
|
artifactUrl,
|
|
512
552
|
auth,
|
|
513
553
|
options,
|
|
514
554
|
url,
|
|
515
|
-
|
|
516
|
-
return _regenerator.default.wrap(function
|
|
517
|
-
while (1) switch (
|
|
555
|
+
_args1 = arguments;
|
|
556
|
+
return _regenerator.default.wrap(function _callee1$(_context1) {
|
|
557
|
+
while (1) switch (_context1.prev = _context1.next) {
|
|
518
558
|
case 0:
|
|
519
|
-
maxAge =
|
|
559
|
+
maxAge = _args1.length > 3 && _args1[3] !== undefined ? _args1[3] : _constants.FILE_CACHE_MAX_AGE;
|
|
520
560
|
// ----- WARNING ----------
|
|
521
561
|
// DO NOT USE!!!!!
|
|
522
562
|
// artifact.cdnUrl fails in Jira.
|
|
@@ -531,17 +571,17 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
531
571
|
} */
|
|
532
572
|
artifactUrl = (0, _artifacts.getArtifactUrl)(artifacts, artifactName);
|
|
533
573
|
if (artifactUrl) {
|
|
534
|
-
|
|
574
|
+
_context1.next = 4;
|
|
535
575
|
break;
|
|
536
576
|
}
|
|
537
577
|
throw new Error("artifact ".concat(artifactName, " not found"));
|
|
538
578
|
case 4:
|
|
539
|
-
|
|
579
|
+
_context1.next = 6;
|
|
540
580
|
return this.resolveAuth({
|
|
541
581
|
collectionName: collectionName
|
|
542
582
|
});
|
|
543
583
|
case 6:
|
|
544
|
-
auth =
|
|
584
|
+
auth = _context1.sent;
|
|
545
585
|
options = {
|
|
546
586
|
params: {
|
|
547
587
|
collection: collectionName,
|
|
@@ -551,19 +591,19 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
551
591
|
};
|
|
552
592
|
url = (0, _mediaCdn.mapToMediaCdnUrl)((0, _helpers.createUrl)("".concat(auth.baseUrl).concat(artifactUrl), options), auth.token);
|
|
553
593
|
if (!(0, _pathBasedUrl.isPathBasedEnabled)()) {
|
|
554
|
-
|
|
594
|
+
_context1.next = 11;
|
|
555
595
|
break;
|
|
556
596
|
}
|
|
557
|
-
return
|
|
597
|
+
return _context1.abrupt("return", (0, _pathBasedUrl.mapToPathBasedUrl)(url));
|
|
558
598
|
case 11:
|
|
559
|
-
return
|
|
599
|
+
return _context1.abrupt("return", url);
|
|
560
600
|
case 12:
|
|
561
601
|
case "end":
|
|
562
|
-
return
|
|
602
|
+
return _context1.stop();
|
|
563
603
|
}
|
|
564
|
-
},
|
|
604
|
+
}, _callee1, this);
|
|
565
605
|
}));
|
|
566
|
-
function getArtifactURL(
|
|
606
|
+
function getArtifactURL(_x30, _x31, _x32) {
|
|
567
607
|
return _getArtifactURL.apply(this, arguments);
|
|
568
608
|
}
|
|
569
609
|
return getArtifactURL;
|
|
@@ -571,10 +611,10 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
571
611
|
}, {
|
|
572
612
|
key: "getImage",
|
|
573
613
|
value: function () {
|
|
574
|
-
var _getImage = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
614
|
+
var _getImage = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(id, params, controller, fetchMaxRes, traceContext) {
|
|
575
615
|
var isWebpSupported, headers, imageEndpoint, metadata, options;
|
|
576
|
-
return _regenerator.default.wrap(function
|
|
577
|
-
while (1) switch (
|
|
616
|
+
return _regenerator.default.wrap(function _callee10$(_context10) {
|
|
617
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
578
618
|
case 0:
|
|
579
619
|
// TODO add checkWebpSupport() back https://product-fabric.atlassian.net/browse/MPT-584
|
|
580
620
|
isWebpSupported = false;
|
|
@@ -596,14 +636,14 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
596
636
|
traceContext: traceContext,
|
|
597
637
|
addMediaClientParam: true
|
|
598
638
|
});
|
|
599
|
-
return
|
|
639
|
+
return _context10.abrupt("return", this.request("/file/".concat(id, "/").concat(imageEndpoint), options, controller, true).then((0, _helpers.createMapResponseToBlob)(metadata)));
|
|
600
640
|
case 7:
|
|
601
641
|
case "end":
|
|
602
|
-
return
|
|
642
|
+
return _context10.stop();
|
|
603
643
|
}
|
|
604
|
-
},
|
|
644
|
+
}, _callee10, this);
|
|
605
645
|
}));
|
|
606
|
-
function getImage(
|
|
646
|
+
function getImage(_x33, _x34, _x35, _x36, _x37) {
|
|
607
647
|
return _getImage.apply(this, arguments);
|
|
608
648
|
}
|
|
609
649
|
return getImage;
|
|
@@ -611,10 +651,10 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
611
651
|
}, {
|
|
612
652
|
key: "getItems",
|
|
613
653
|
value: function () {
|
|
614
|
-
var _getItems = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
654
|
+
var _getItems = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11(ids, collectionName, traceContext, includeHashForDuplicateFiles) {
|
|
615
655
|
var descriptors, metadata, options;
|
|
616
|
-
return _regenerator.default.wrap(function
|
|
617
|
-
while (1) switch (
|
|
656
|
+
return _regenerator.default.wrap(function _callee11$(_context11) {
|
|
657
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
618
658
|
case 0:
|
|
619
659
|
descriptors = ids.map(function (id) {
|
|
620
660
|
return {
|
|
@@ -638,14 +678,14 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
638
678
|
}),
|
|
639
679
|
traceContext: traceContext
|
|
640
680
|
});
|
|
641
|
-
return
|
|
681
|
+
return _context11.abrupt("return", this.request('/items', options).then((0, _helpers.createMapResponseToJson)(metadata)));
|
|
642
682
|
case 4:
|
|
643
683
|
case "end":
|
|
644
|
-
return
|
|
684
|
+
return _context11.stop();
|
|
645
685
|
}
|
|
646
|
-
},
|
|
686
|
+
}, _callee11, this);
|
|
647
687
|
}));
|
|
648
|
-
function getItems(
|
|
688
|
+
function getItems(_x38, _x39, _x40, _x41) {
|
|
649
689
|
return _getItems.apply(this, arguments);
|
|
650
690
|
}
|
|
651
691
|
return getItems;
|
|
@@ -653,10 +693,10 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
653
693
|
}, {
|
|
654
694
|
key: "getImageMetadata",
|
|
655
695
|
value: function () {
|
|
656
|
-
var _getImageMetadata = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
696
|
+
var _getImageMetadata = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12(id, params, traceContext) {
|
|
657
697
|
var metadata, options;
|
|
658
|
-
return _regenerator.default.wrap(function
|
|
659
|
-
while (1) switch (
|
|
698
|
+
return _regenerator.default.wrap(function _callee12$(_context12) {
|
|
699
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
660
700
|
case 0:
|
|
661
701
|
metadata = {
|
|
662
702
|
method: 'GET',
|
|
@@ -669,14 +709,14 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
669
709
|
params: params,
|
|
670
710
|
traceContext: traceContext
|
|
671
711
|
});
|
|
672
|
-
return
|
|
712
|
+
return _context12.abrupt("return", this.request("/file/".concat(id, "/image/metadata"), options).then((0, _helpers.createMapResponseToJson)(metadata)));
|
|
673
713
|
case 3:
|
|
674
714
|
case "end":
|
|
675
|
-
return
|
|
715
|
+
return _context12.stop();
|
|
676
716
|
}
|
|
677
|
-
},
|
|
717
|
+
}, _callee12, this);
|
|
678
718
|
}));
|
|
679
|
-
function getImageMetadata(
|
|
719
|
+
function getImageMetadata(_x42, _x43, _x44) {
|
|
680
720
|
return _getImageMetadata.apply(this, arguments);
|
|
681
721
|
}
|
|
682
722
|
return getImageMetadata;
|
|
@@ -684,10 +724,10 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
684
724
|
}, {
|
|
685
725
|
key: "getDocumentContent",
|
|
686
726
|
value: function () {
|
|
687
|
-
var _getDocumentContent = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
727
|
+
var _getDocumentContent = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13(id, options, traceContext) {
|
|
688
728
|
var shouldCache, endpoint, metadata, headers, requestOptions;
|
|
689
|
-
return _regenerator.default.wrap(function
|
|
690
|
-
while (1) switch (
|
|
729
|
+
return _regenerator.default.wrap(function _callee13$(_context13) {
|
|
730
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
691
731
|
case 0:
|
|
692
732
|
// when requesting for password protected document don't use CDN as it won't forward headers
|
|
693
733
|
// this is deliberate to avoid caching Password protected files
|
|
@@ -714,14 +754,14 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
714
754
|
},
|
|
715
755
|
traceContext: traceContext
|
|
716
756
|
});
|
|
717
|
-
return
|
|
757
|
+
return _context13.abrupt("return", this.request("/file/".concat(id, "/document/").concat(endpoint), requestOptions).then((0, _helpers.createMapResponseToJson)(metadata)));
|
|
718
758
|
case 6:
|
|
719
759
|
case "end":
|
|
720
|
-
return
|
|
760
|
+
return _context13.stop();
|
|
721
761
|
}
|
|
722
|
-
},
|
|
762
|
+
}, _callee13, this);
|
|
723
763
|
}));
|
|
724
|
-
function getDocumentContent(
|
|
764
|
+
function getDocumentContent(_x45, _x46, _x47) {
|
|
725
765
|
return _getDocumentContent.apply(this, arguments);
|
|
726
766
|
}
|
|
727
767
|
return getDocumentContent;
|
|
@@ -729,10 +769,10 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
729
769
|
}, {
|
|
730
770
|
key: "getDocumentPageImage",
|
|
731
771
|
value: function () {
|
|
732
|
-
var _getDocumentPageImage = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
772
|
+
var _getDocumentPageImage = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14(id, options, traceContext) {
|
|
733
773
|
var shouldCache, endpoint, metadata, headers, requestOptions;
|
|
734
|
-
return _regenerator.default.wrap(function
|
|
735
|
-
while (1) switch (
|
|
774
|
+
return _regenerator.default.wrap(function _callee14$(_context14) {
|
|
775
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
736
776
|
case 0:
|
|
737
777
|
// when requesting for password protected document don't use CDN as it won't forward headers
|
|
738
778
|
// this is deliberate to avoid caching Password protected files
|
|
@@ -759,14 +799,14 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
759
799
|
},
|
|
760
800
|
traceContext: traceContext
|
|
761
801
|
});
|
|
762
|
-
return
|
|
802
|
+
return _context14.abrupt("return", this.request("/file/".concat(id, "/document/").concat(endpoint), requestOptions).then((0, _helpers.createMapResponseToBlob)(metadata)));
|
|
763
803
|
case 6:
|
|
764
804
|
case "end":
|
|
765
|
-
return
|
|
805
|
+
return _context14.stop();
|
|
766
806
|
}
|
|
767
|
-
},
|
|
807
|
+
}, _callee14, this);
|
|
768
808
|
}));
|
|
769
|
-
function getDocumentPageImage(
|
|
809
|
+
function getDocumentPageImage(_x48, _x49, _x50) {
|
|
770
810
|
return _getDocumentPageImage.apply(this, arguments);
|
|
771
811
|
}
|
|
772
812
|
return getDocumentPageImage;
|
|
@@ -774,10 +814,10 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
774
814
|
}, {
|
|
775
815
|
key: "appendChunksToUpload",
|
|
776
816
|
value: function () {
|
|
777
|
-
var _appendChunksToUpload = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
817
|
+
var _appendChunksToUpload = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15(uploadId, body, collectionName, traceContext) {
|
|
778
818
|
var metadata, options;
|
|
779
|
-
return _regenerator.default.wrap(function
|
|
780
|
-
while (1) switch (
|
|
819
|
+
return _regenerator.default.wrap(function _callee15$(_context15) {
|
|
820
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
781
821
|
case 0:
|
|
782
822
|
metadata = {
|
|
783
823
|
method: 'PUT',
|
|
@@ -791,15 +831,15 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
791
831
|
body: JSON.stringify(body),
|
|
792
832
|
traceContext: traceContext
|
|
793
833
|
});
|
|
794
|
-
|
|
834
|
+
_context15.next = 4;
|
|
795
835
|
return this.request("/upload/".concat(uploadId, "/chunks"), options);
|
|
796
836
|
case 4:
|
|
797
837
|
case "end":
|
|
798
|
-
return
|
|
838
|
+
return _context15.stop();
|
|
799
839
|
}
|
|
800
|
-
},
|
|
840
|
+
}, _callee15, this);
|
|
801
841
|
}));
|
|
802
|
-
function appendChunksToUpload(
|
|
842
|
+
function appendChunksToUpload(_x51, _x52, _x53, _x54) {
|
|
803
843
|
return _appendChunksToUpload.apply(this, arguments);
|
|
804
844
|
}
|
|
805
845
|
return appendChunksToUpload;
|
|
@@ -827,7 +867,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
827
867
|
}
|
|
828
868
|
}, {
|
|
829
869
|
key: "copyFile",
|
|
830
|
-
value: function copyFile(id, params, traceContext) {
|
|
870
|
+
value: function copyFile(id, params, traceContext, clientId) {
|
|
831
871
|
var metadata = {
|
|
832
872
|
method: 'POST',
|
|
833
873
|
endpoint: '/v2/file/copy'
|
|
@@ -839,7 +879,8 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
839
879
|
params: params,
|
|
840
880
|
headers: jsonHeaders,
|
|
841
881
|
body: JSON.stringify({
|
|
842
|
-
id: id
|
|
882
|
+
id: id,
|
|
883
|
+
clientId: clientId
|
|
843
884
|
}),
|
|
844
885
|
traceContext: traceContext,
|
|
845
886
|
clientOptions: {
|
|
@@ -856,10 +897,10 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
856
897
|
}, {
|
|
857
898
|
key: "registerCopyIntents",
|
|
858
899
|
value: function () {
|
|
859
|
-
var _registerCopyIntents = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
900
|
+
var _registerCopyIntents = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16(files, traceContext, resolvedAuth) {
|
|
860
901
|
var metadata, options;
|
|
861
|
-
return _regenerator.default.wrap(function
|
|
862
|
-
while (1) switch (
|
|
902
|
+
return _regenerator.default.wrap(function _callee16$(_context16) {
|
|
903
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
863
904
|
case 0:
|
|
864
905
|
metadata = {
|
|
865
906
|
method: 'POST',
|
|
@@ -873,15 +914,15 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
873
914
|
traceContext: traceContext,
|
|
874
915
|
resolvedAuth: resolvedAuth
|
|
875
916
|
});
|
|
876
|
-
|
|
917
|
+
_context16.next = 4;
|
|
877
918
|
return this.request('/file/copy/intents', options);
|
|
878
919
|
case 4:
|
|
879
920
|
case "end":
|
|
880
|
-
return
|
|
921
|
+
return _context16.stop();
|
|
881
922
|
}
|
|
882
|
-
},
|
|
923
|
+
}, _callee16, this);
|
|
883
924
|
}));
|
|
884
|
-
function registerCopyIntents(
|
|
925
|
+
function registerCopyIntents(_x55, _x56, _x57) {
|
|
885
926
|
return _registerCopyIntents.apply(this, arguments);
|
|
886
927
|
}
|
|
887
928
|
return registerCopyIntents;
|
|
@@ -889,7 +930,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
889
930
|
}, {
|
|
890
931
|
key: "request",
|
|
891
932
|
value: function () {
|
|
892
|
-
var _request2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
933
|
+
var _request2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17(path) {
|
|
893
934
|
var options,
|
|
894
935
|
controller,
|
|
895
936
|
useMediaCdn,
|
|
@@ -909,32 +950,32 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
909
950
|
extendedParams,
|
|
910
951
|
url,
|
|
911
952
|
response,
|
|
912
|
-
|
|
913
|
-
return _regenerator.default.wrap(function
|
|
914
|
-
while (1) switch (
|
|
953
|
+
_args17 = arguments;
|
|
954
|
+
return _regenerator.default.wrap(function _callee17$(_context17) {
|
|
955
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
915
956
|
case 0:
|
|
916
|
-
options =
|
|
957
|
+
options = _args17.length > 1 && _args17[1] !== undefined ? _args17[1] : {
|
|
917
958
|
method: 'GET',
|
|
918
959
|
endpoint: undefined,
|
|
919
960
|
authContext: {}
|
|
920
961
|
};
|
|
921
|
-
controller =
|
|
922
|
-
useMediaCdn =
|
|
962
|
+
controller = _args17.length > 2 ? _args17[2] : undefined;
|
|
963
|
+
useMediaCdn = _args17.length > 3 ? _args17[3] : undefined;
|
|
923
964
|
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;
|
|
924
965
|
if (!(resolvedAuth !== null && resolvedAuth !== void 0)) {
|
|
925
|
-
|
|
966
|
+
_context17.next = 8;
|
|
926
967
|
break;
|
|
927
968
|
}
|
|
928
|
-
|
|
929
|
-
|
|
969
|
+
_context17.t0 = resolvedAuth;
|
|
970
|
+
_context17.next = 11;
|
|
930
971
|
break;
|
|
931
972
|
case 8:
|
|
932
|
-
|
|
973
|
+
_context17.next = 10;
|
|
933
974
|
return this.resolveAuth(authContext);
|
|
934
975
|
case 10:
|
|
935
|
-
|
|
976
|
+
_context17.t0 = _context17.sent;
|
|
936
977
|
case 11:
|
|
937
|
-
auth =
|
|
978
|
+
auth = _context17.t0;
|
|
938
979
|
clientId = (0, _mediaCore.isClientBasedAuth)(auth) ? auth.clientId : undefined;
|
|
939
980
|
extendedTraceContext = (0, _helpers.extendTraceContext)(traceContext);
|
|
940
981
|
extendedParams = addMediaClientParam ? _objectSpread(_objectSpread({}, params), {}, {
|
|
@@ -947,7 +988,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
947
988
|
if ((0, _pathBasedUrl.isPathBasedEnabled)()) {
|
|
948
989
|
url = (0, _pathBasedUrl.mapToPathBasedUrl)(url);
|
|
949
990
|
}
|
|
950
|
-
|
|
991
|
+
_context17.next = 20;
|
|
951
992
|
return (0, _request3.request)(url, {
|
|
952
993
|
method: method,
|
|
953
994
|
endpoint: endpoint,
|
|
@@ -959,17 +1000,17 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
959
1000
|
traceContext: extendedTraceContext
|
|
960
1001
|
}, controller);
|
|
961
1002
|
case 20:
|
|
962
|
-
response =
|
|
1003
|
+
response = _context17.sent;
|
|
963
1004
|
setKeyValueInSessionStorage(MEDIA_API_REGION, response.headers.get('x-media-region'));
|
|
964
1005
|
setKeyValueInSessionStorage(MEDIA_API_ENVIRONMENT, response.headers.get('x-media-env'));
|
|
965
|
-
return
|
|
1006
|
+
return _context17.abrupt("return", response);
|
|
966
1007
|
case 24:
|
|
967
1008
|
case "end":
|
|
968
|
-
return
|
|
1009
|
+
return _context17.stop();
|
|
969
1010
|
}
|
|
970
|
-
},
|
|
1011
|
+
}, _callee17, this);
|
|
971
1012
|
}));
|
|
972
|
-
function request(
|
|
1013
|
+
function request(_x58) {
|
|
973
1014
|
return _request2.apply(this, arguments);
|
|
974
1015
|
}
|
|
975
1016
|
return request;
|
|
@@ -977,16 +1018,16 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
977
1018
|
}, {
|
|
978
1019
|
key: "testUrl",
|
|
979
1020
|
value: function () {
|
|
980
|
-
var _testUrl = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
1021
|
+
var _testUrl = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18(url) {
|
|
981
1022
|
var options,
|
|
982
1023
|
traceContext,
|
|
983
|
-
|
|
984
|
-
return _regenerator.default.wrap(function
|
|
985
|
-
while (1) switch (
|
|
1024
|
+
_args18 = arguments;
|
|
1025
|
+
return _regenerator.default.wrap(function _callee18$(_context18) {
|
|
1026
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
986
1027
|
case 0:
|
|
987
|
-
options =
|
|
1028
|
+
options = _args18.length > 1 && _args18[1] !== undefined ? _args18[1] : {};
|
|
988
1029
|
traceContext = options.traceContext;
|
|
989
|
-
|
|
1030
|
+
_context18.next = 4;
|
|
990
1031
|
return (0, _request3.request)(url, {
|
|
991
1032
|
method: 'HEAD',
|
|
992
1033
|
traceContext: (0, _helpers.extendTraceContext)(traceContext),
|
|
@@ -998,11 +1039,11 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
998
1039
|
});
|
|
999
1040
|
case 4:
|
|
1000
1041
|
case "end":
|
|
1001
|
-
return
|
|
1042
|
+
return _context18.stop();
|
|
1002
1043
|
}
|
|
1003
|
-
},
|
|
1044
|
+
}, _callee18);
|
|
1004
1045
|
}));
|
|
1005
|
-
function testUrl(
|
|
1046
|
+
function testUrl(_x59) {
|
|
1006
1047
|
return _testUrl.apply(this, arguments);
|
|
1007
1048
|
}
|
|
1008
1049
|
return testUrl;
|