@atlaskit/media-client 33.0.0 → 33.1.1
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 +20 -0
- package/dist/cjs/client/file-fetcher/index.js +143 -114
- package/dist/cjs/client/media-store/MediaStore.js +226 -137
- package/dist/cjs/utils/request/helpers.js +1 -1
- package/dist/es2019/client/file-fetcher/index.js +15 -0
- package/dist/es2019/client/media-store/MediaStore.js +62 -6
- package/dist/es2019/utils/request/helpers.js +1 -1
- package/dist/esm/client/file-fetcher/index.js +143 -114
- package/dist/esm/client/media-store/MediaStore.js +226 -137
- 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-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/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/media-client
|
|
2
2
|
|
|
3
|
+
## 33.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#154915](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/154915)
|
|
8
|
+
[`f5aa2998ecd93`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f5aa2998ecd93) -
|
|
9
|
+
Fixing internal type import
|
|
10
|
+
|
|
11
|
+
## 33.1.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [#151188](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/151188)
|
|
16
|
+
[`0701e2ec739df`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0701e2ec739df) -
|
|
17
|
+
Exposed methods to fetch and upload file artifact binaries
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
|
|
3
23
|
## 33.0.0
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -189,6 +189,35 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
189
189
|
preview: preview
|
|
190
190
|
};
|
|
191
191
|
});
|
|
192
|
+
(0, _defineProperty2.default)(this, "uploadArtifact", /*#__PURE__*/function () {
|
|
193
|
+
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(id, file, params, collectionName, traceContext) {
|
|
194
|
+
var _yield$_this$mediaApi, data, _yield$_this$mediaApi2, altData, itemDetails;
|
|
195
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
196
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
197
|
+
case 0:
|
|
198
|
+
_context2.next = 2;
|
|
199
|
+
return _this.mediaApi.uploadArtifact(id, file, params, collectionName, traceContext);
|
|
200
|
+
case 2:
|
|
201
|
+
_yield$_this$mediaApi = _context2.sent;
|
|
202
|
+
data = _yield$_this$mediaApi.data;
|
|
203
|
+
_context2.next = 6;
|
|
204
|
+
return _this.mediaApi.getItems([id], collectionName, traceContext);
|
|
205
|
+
case 6:
|
|
206
|
+
_yield$_this$mediaApi2 = _context2.sent;
|
|
207
|
+
altData = _yield$_this$mediaApi2.data;
|
|
208
|
+
itemDetails = altData.items[0].details; // ------------------------------------------------------------
|
|
209
|
+
_this.setFileState(id, (0, _fileState2.mapMediaItemToFileState)(id, itemDetails));
|
|
210
|
+
return _context2.abrupt("return", data);
|
|
211
|
+
case 11:
|
|
212
|
+
case "end":
|
|
213
|
+
return _context2.stop();
|
|
214
|
+
}
|
|
215
|
+
}, _callee2);
|
|
216
|
+
}));
|
|
217
|
+
return function (_x, _x2, _x3, _x4, _x5) {
|
|
218
|
+
return _ref2.apply(this, arguments);
|
|
219
|
+
};
|
|
220
|
+
}());
|
|
192
221
|
this.mediaApi = mediaApi;
|
|
193
222
|
this.store = store;
|
|
194
223
|
this.dataloader = (0, _createFileDataLoader.createFileDataloader)(mediaApi);
|
|
@@ -254,8 +283,8 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
254
283
|
descriptors: descriptors
|
|
255
284
|
}, {
|
|
256
285
|
collection: collection
|
|
257
|
-
}, traceContext).then(function (
|
|
258
|
-
var data =
|
|
286
|
+
}, traceContext).then(function (_ref3) {
|
|
287
|
+
var data = _ref3.data;
|
|
259
288
|
return data;
|
|
260
289
|
});
|
|
261
290
|
}
|
|
@@ -281,11 +310,11 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
281
310
|
}, {
|
|
282
311
|
key: "uploadExternal",
|
|
283
312
|
value: function () {
|
|
284
|
-
var _uploadExternal = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
313
|
+
var _uploadExternal = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(url, collection, traceContext) {
|
|
285
314
|
var _this3 = this;
|
|
286
315
|
var uploadableFileUpfrontIds, id, occurrenceKey, subject, deferredBlob, preview, name, fileState;
|
|
287
|
-
return _regenerator.default.wrap(function
|
|
288
|
-
while (1) switch (
|
|
316
|
+
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
317
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
289
318
|
case 0:
|
|
290
319
|
uploadableFileUpfrontIds = this.generateUploadableFileUpfrontIds(collection, traceContext);
|
|
291
320
|
id = uploadableFileUpfrontIds.id, occurrenceKey = uploadableFileUpfrontIds.occurrenceKey;
|
|
@@ -296,15 +325,15 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
296
325
|
return undefined;
|
|
297
326
|
});
|
|
298
327
|
preview = new Promise( /*#__PURE__*/function () {
|
|
299
|
-
var
|
|
328
|
+
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(resolve, reject) {
|
|
300
329
|
var blob;
|
|
301
|
-
return _regenerator.default.wrap(function
|
|
302
|
-
while (1) switch (
|
|
330
|
+
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
331
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
303
332
|
case 0:
|
|
304
|
-
|
|
333
|
+
_context3.next = 2;
|
|
305
334
|
return deferredBlob;
|
|
306
335
|
case 2:
|
|
307
|
-
blob =
|
|
336
|
+
blob = _context3.sent;
|
|
308
337
|
if (!blob) {
|
|
309
338
|
reject('Could not fetch the blob');
|
|
310
339
|
}
|
|
@@ -314,12 +343,12 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
314
343
|
});
|
|
315
344
|
case 5:
|
|
316
345
|
case "end":
|
|
317
|
-
return
|
|
346
|
+
return _context3.stop();
|
|
318
347
|
}
|
|
319
|
-
},
|
|
348
|
+
}, _callee3);
|
|
320
349
|
}));
|
|
321
|
-
return function (
|
|
322
|
-
return
|
|
350
|
+
return function (_x9, _x10) {
|
|
351
|
+
return _ref4.apply(this, arguments);
|
|
323
352
|
};
|
|
324
353
|
}());
|
|
325
354
|
name = url.split('/').pop() || ''; // we create a initial fileState with the minimum info that we have at this point
|
|
@@ -337,21 +366,21 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
337
366
|
// we save it into the cache as soon as possible, in case someone subscribes
|
|
338
367
|
(0, _fileStreamsCache.getFileStreamsCache)().set(id, subject);
|
|
339
368
|
this.setFileState(id, fileState);
|
|
340
|
-
return
|
|
341
|
-
var
|
|
369
|
+
return _context5.abrupt("return", new Promise( /*#__PURE__*/function () {
|
|
370
|
+
var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(resolve, reject) {
|
|
342
371
|
var blob, type, size, file, mediaType, dimensions;
|
|
343
|
-
return _regenerator.default.wrap(function
|
|
344
|
-
while (1) switch (
|
|
372
|
+
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
373
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
345
374
|
case 0:
|
|
346
|
-
|
|
375
|
+
_context4.next = 2;
|
|
347
376
|
return deferredBlob;
|
|
348
377
|
case 2:
|
|
349
|
-
blob =
|
|
378
|
+
blob = _context4.sent;
|
|
350
379
|
if (blob) {
|
|
351
|
-
|
|
380
|
+
_context4.next = 5;
|
|
352
381
|
break;
|
|
353
382
|
}
|
|
354
|
-
return
|
|
383
|
+
return _context4.abrupt("return", reject('Could not download remote file'));
|
|
355
384
|
case 5:
|
|
356
385
|
type = blob.type, size = blob.size;
|
|
357
386
|
file = {
|
|
@@ -374,18 +403,18 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
374
403
|
});
|
|
375
404
|
// we don't want to wait for the file to be upload
|
|
376
405
|
_this3.upload(file, undefined, uploadableFileUpfrontIds, traceContext);
|
|
377
|
-
|
|
378
|
-
|
|
406
|
+
_context4.prev = 10;
|
|
407
|
+
_context4.next = 13;
|
|
379
408
|
return (0, _getDimensionsFromBlob.getDimensionsFromBlob)(mediaType, blob);
|
|
380
409
|
case 13:
|
|
381
|
-
dimensions =
|
|
382
|
-
|
|
410
|
+
dimensions = _context4.sent;
|
|
411
|
+
_context4.next = 20;
|
|
383
412
|
break;
|
|
384
413
|
case 16:
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
reject(
|
|
388
|
-
return
|
|
414
|
+
_context4.prev = 16;
|
|
415
|
+
_context4.t0 = _context4["catch"](10);
|
|
416
|
+
reject(_context4.t0);
|
|
417
|
+
return _context4.abrupt("return");
|
|
389
418
|
case 20:
|
|
390
419
|
resolve({
|
|
391
420
|
dimensions: dimensions,
|
|
@@ -394,21 +423,21 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
394
423
|
});
|
|
395
424
|
case 21:
|
|
396
425
|
case "end":
|
|
397
|
-
return
|
|
426
|
+
return _context4.stop();
|
|
398
427
|
}
|
|
399
|
-
},
|
|
428
|
+
}, _callee4, null, [[10, 16]]);
|
|
400
429
|
}));
|
|
401
|
-
return function (
|
|
402
|
-
return
|
|
430
|
+
return function (_x11, _x12) {
|
|
431
|
+
return _ref5.apply(this, arguments);
|
|
403
432
|
};
|
|
404
433
|
}()));
|
|
405
434
|
case 11:
|
|
406
435
|
case "end":
|
|
407
|
-
return
|
|
436
|
+
return _context5.stop();
|
|
408
437
|
}
|
|
409
|
-
},
|
|
438
|
+
}, _callee5, this);
|
|
410
439
|
}));
|
|
411
|
-
function uploadExternal(
|
|
440
|
+
function uploadExternal(_x6, _x7, _x8) {
|
|
412
441
|
return _uploadExternal.apply(this, arguments);
|
|
413
442
|
}
|
|
414
443
|
return uploadExternal;
|
|
@@ -475,22 +504,22 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
475
504
|
}, {
|
|
476
505
|
key: "downloadBinary",
|
|
477
506
|
value: function () {
|
|
478
|
-
var _downloadBinary = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
507
|
+
var _downloadBinary = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(id) {
|
|
479
508
|
var name,
|
|
480
509
|
collectionName,
|
|
481
510
|
traceContext,
|
|
482
511
|
url,
|
|
483
|
-
|
|
484
|
-
return _regenerator.default.wrap(function
|
|
485
|
-
while (1) switch (
|
|
512
|
+
_args6 = arguments;
|
|
513
|
+
return _regenerator.default.wrap(function _callee6$(_context6) {
|
|
514
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
486
515
|
case 0:
|
|
487
|
-
name =
|
|
488
|
-
collectionName =
|
|
489
|
-
traceContext =
|
|
490
|
-
|
|
516
|
+
name = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : 'download';
|
|
517
|
+
collectionName = _args6.length > 2 ? _args6[2] : undefined;
|
|
518
|
+
traceContext = _args6.length > 3 ? _args6[3] : undefined;
|
|
519
|
+
_context6.next = 5;
|
|
491
520
|
return this.mediaApi.getFileBinaryURL(id, collectionName);
|
|
492
521
|
case 5:
|
|
493
|
-
url =
|
|
522
|
+
url = _context6.sent;
|
|
494
523
|
(0, _downloadUrl.downloadUrl)(url, {
|
|
495
524
|
name: name
|
|
496
525
|
});
|
|
@@ -500,17 +529,17 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
500
529
|
viewingLevel: 'download'
|
|
501
530
|
});
|
|
502
531
|
// Test the download after initiated the Browser process to catch any potential errors.
|
|
503
|
-
|
|
532
|
+
_context6.next = 10;
|
|
504
533
|
return this.mediaApi.testUrl(url, {
|
|
505
534
|
traceContext: traceContext
|
|
506
535
|
});
|
|
507
536
|
case 10:
|
|
508
537
|
case "end":
|
|
509
|
-
return
|
|
538
|
+
return _context6.stop();
|
|
510
539
|
}
|
|
511
|
-
},
|
|
540
|
+
}, _callee6, this);
|
|
512
541
|
}));
|
|
513
|
-
function downloadBinary(
|
|
542
|
+
function downloadBinary(_x13) {
|
|
514
543
|
return _downloadBinary.apply(this, arguments);
|
|
515
544
|
}
|
|
516
545
|
return downloadBinary;
|
|
@@ -518,28 +547,28 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
518
547
|
}, {
|
|
519
548
|
key: "registerCopyIntent",
|
|
520
549
|
value: function () {
|
|
521
|
-
var _registerCopyIntent = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
550
|
+
var _registerCopyIntent = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(id, collectionName) {
|
|
522
551
|
var auth, key, error;
|
|
523
|
-
return _regenerator.default.wrap(function
|
|
524
|
-
while (1) switch (
|
|
552
|
+
return _regenerator.default.wrap(function _callee7$(_context7) {
|
|
553
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
525
554
|
case 0:
|
|
526
|
-
|
|
555
|
+
_context7.next = 2;
|
|
527
556
|
return this.mediaApi.resolveAuth({
|
|
528
557
|
collectionName: collectionName
|
|
529
558
|
});
|
|
530
559
|
case 2:
|
|
531
|
-
auth =
|
|
560
|
+
auth = _context7.sent;
|
|
532
561
|
key = {
|
|
533
562
|
id: id,
|
|
534
563
|
collectionName: collectionName,
|
|
535
564
|
resolvedAuth: auth
|
|
536
565
|
};
|
|
537
|
-
|
|
566
|
+
_context7.next = 6;
|
|
538
567
|
return this.copyIntentRegisterationBatcher.load(key);
|
|
539
568
|
case 6:
|
|
540
|
-
error =
|
|
569
|
+
error = _context7.sent;
|
|
541
570
|
if (!error) {
|
|
542
|
-
|
|
571
|
+
_context7.next = 10;
|
|
543
572
|
break;
|
|
544
573
|
}
|
|
545
574
|
// if the error is retryable then it should not be cached
|
|
@@ -549,11 +578,11 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
549
578
|
throw error;
|
|
550
579
|
case 10:
|
|
551
580
|
case "end":
|
|
552
|
-
return
|
|
581
|
+
return _context7.stop();
|
|
553
582
|
}
|
|
554
|
-
},
|
|
583
|
+
}, _callee7, this);
|
|
555
584
|
}));
|
|
556
|
-
function registerCopyIntent(
|
|
585
|
+
function registerCopyIntent(_x14, _x15) {
|
|
557
586
|
return _registerCopyIntent.apply(this, arguments);
|
|
558
587
|
}
|
|
559
588
|
return registerCopyIntent;
|
|
@@ -561,24 +590,24 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
561
590
|
}, {
|
|
562
591
|
key: "copyFileWithToken",
|
|
563
592
|
value: function () {
|
|
564
|
-
var _copyFileWithToken = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
593
|
+
var _copyFileWithToken = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(source, destination, traceContext) {
|
|
565
594
|
var authProvider, sourceCollection, id, destinationAuthProvider, destinationCollectionName, replaceFileId, occurrenceKey, mediaStore, owner, body, params, _yield$mediaStore$cop, data;
|
|
566
|
-
return _regenerator.default.wrap(function
|
|
567
|
-
while (1) switch (
|
|
595
|
+
return _regenerator.default.wrap(function _callee8$(_context8) {
|
|
596
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
568
597
|
case 0:
|
|
569
598
|
authProvider = source.authProvider, sourceCollection = source.collection, id = source.id;
|
|
570
599
|
destinationAuthProvider = destination.authProvider, destinationCollectionName = destination.collection, replaceFileId = destination.replaceFileId, occurrenceKey = destination.occurrenceKey;
|
|
571
600
|
mediaStore = destination.mediaStore || new _mediaStore.MediaStore({
|
|
572
601
|
authProvider: destinationAuthProvider
|
|
573
602
|
});
|
|
574
|
-
|
|
575
|
-
|
|
603
|
+
_context8.t0 = _mediaCore.authToOwner;
|
|
604
|
+
_context8.next = 6;
|
|
576
605
|
return authProvider({
|
|
577
606
|
collectionName: sourceCollection
|
|
578
607
|
});
|
|
579
608
|
case 6:
|
|
580
|
-
|
|
581
|
-
owner = (0,
|
|
609
|
+
_context8.t1 = _context8.sent;
|
|
610
|
+
owner = (0, _context8.t0)(_context8.t1);
|
|
582
611
|
body = {
|
|
583
612
|
sourceFile: {
|
|
584
613
|
id: id,
|
|
@@ -591,19 +620,19 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
591
620
|
replaceFileId: replaceFileId,
|
|
592
621
|
occurrenceKey: occurrenceKey
|
|
593
622
|
};
|
|
594
|
-
|
|
623
|
+
_context8.next = 12;
|
|
595
624
|
return mediaStore.copyFileWithToken(body, params, traceContext);
|
|
596
625
|
case 12:
|
|
597
|
-
_yield$mediaStore$cop =
|
|
626
|
+
_yield$mediaStore$cop = _context8.sent;
|
|
598
627
|
data = _yield$mediaStore$cop.data;
|
|
599
|
-
return
|
|
628
|
+
return _context8.abrupt("return", data);
|
|
600
629
|
case 15:
|
|
601
630
|
case "end":
|
|
602
|
-
return
|
|
631
|
+
return _context8.stop();
|
|
603
632
|
}
|
|
604
|
-
},
|
|
633
|
+
}, _callee8);
|
|
605
634
|
}));
|
|
606
|
-
function copyFileWithToken(
|
|
635
|
+
function copyFileWithToken(_x16, _x17, _x18) {
|
|
607
636
|
return _copyFileWithToken.apply(this, arguments);
|
|
608
637
|
}
|
|
609
638
|
return copyFileWithToken;
|
|
@@ -611,28 +640,28 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
611
640
|
}, {
|
|
612
641
|
key: "copyFileWithIntent",
|
|
613
642
|
value: function () {
|
|
614
|
-
var _copyFileWithIntent = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
643
|
+
var _copyFileWithIntent = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(source, destination, traceContext) {
|
|
615
644
|
var res, data;
|
|
616
|
-
return _regenerator.default.wrap(function
|
|
617
|
-
while (1) switch (
|
|
645
|
+
return _regenerator.default.wrap(function _callee9$(_context9) {
|
|
646
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
618
647
|
case 0:
|
|
619
|
-
|
|
648
|
+
_context9.next = 2;
|
|
620
649
|
return this.mediaApi.copyFile(source.id, {
|
|
621
650
|
sourceCollection: source.collection,
|
|
622
651
|
collection: destination.collection,
|
|
623
652
|
replaceFileId: destination.replaceFileId
|
|
624
653
|
}, traceContext);
|
|
625
654
|
case 2:
|
|
626
|
-
res =
|
|
655
|
+
res = _context9.sent;
|
|
627
656
|
data = res.data;
|
|
628
|
-
return
|
|
657
|
+
return _context9.abrupt("return", data);
|
|
629
658
|
case 5:
|
|
630
659
|
case "end":
|
|
631
|
-
return
|
|
660
|
+
return _context9.stop();
|
|
632
661
|
}
|
|
633
|
-
},
|
|
662
|
+
}, _callee9, this);
|
|
634
663
|
}));
|
|
635
|
-
function copyFileWithIntent(
|
|
664
|
+
function copyFileWithIntent(_x19, _x20, _x21) {
|
|
636
665
|
return _copyFileWithIntent.apply(this, arguments);
|
|
637
666
|
}
|
|
638
667
|
return copyFileWithIntent;
|
|
@@ -640,7 +669,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
640
669
|
}, {
|
|
641
670
|
key: "copyFile",
|
|
642
671
|
value: function () {
|
|
643
|
-
var _copyFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
672
|
+
var _copyFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(source, destination) {
|
|
644
673
|
var _this5 = this;
|
|
645
674
|
var options,
|
|
646
675
|
traceContext,
|
|
@@ -667,32 +696,32 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
667
696
|
replaceFileState,
|
|
668
697
|
key,
|
|
669
698
|
errorFileState,
|
|
670
|
-
|
|
671
|
-
return _regenerator.default.wrap(function
|
|
672
|
-
while (1) switch (
|
|
699
|
+
_args10 = arguments;
|
|
700
|
+
return _regenerator.default.wrap(function _callee10$(_context10) {
|
|
701
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
673
702
|
case 0:
|
|
674
|
-
options =
|
|
675
|
-
traceContext =
|
|
703
|
+
options = _args10.length > 2 && _args10[2] !== undefined ? _args10[2] : {};
|
|
704
|
+
traceContext = _args10.length > 3 ? _args10[3] : undefined;
|
|
676
705
|
id = source.id;
|
|
677
706
|
destinationCollectionName = destination.collection, replaceFileId = destination.replaceFileId, occurrenceKey = destination.occurrenceKey;
|
|
678
707
|
preview = options.preview, mimeType = options.mimeType;
|
|
679
708
|
cache = (0, _fileStreamsCache.getFileStreamsCache)();
|
|
680
|
-
|
|
709
|
+
_context10.prev = 6;
|
|
681
710
|
if (!(isCopySourceFileWithToken(source) && isCopyDestinationWithToken(destination))) {
|
|
682
|
-
|
|
711
|
+
_context10.next = 13;
|
|
683
712
|
break;
|
|
684
713
|
}
|
|
685
|
-
|
|
714
|
+
_context10.next = 10;
|
|
686
715
|
return this.copyFileWithToken(source, destination, traceContext);
|
|
687
716
|
case 10:
|
|
688
|
-
copiedFile =
|
|
689
|
-
|
|
717
|
+
copiedFile = _context10.sent;
|
|
718
|
+
_context10.next = 16;
|
|
690
719
|
break;
|
|
691
720
|
case 13:
|
|
692
|
-
|
|
721
|
+
_context10.next = 15;
|
|
693
722
|
return this.copyFileWithIntent(source, destination, traceContext);
|
|
694
723
|
case 15:
|
|
695
|
-
copiedFile =
|
|
724
|
+
copiedFile = _context10.sent;
|
|
696
725
|
case 16:
|
|
697
726
|
// if we were passed a "mimeType", we propagate it into copiedFileWithMimeType
|
|
698
727
|
copiedFileWithMimeType = _objectSpread(_objectSpread({}, copiedFile), mimeType ? {
|
|
@@ -709,21 +738,21 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
709
738
|
previewOverride = !(0, _fileState2.isErrorFileState)(copiedFileState) && !!preview ? {
|
|
710
739
|
preview: preview
|
|
711
740
|
} : {};
|
|
712
|
-
|
|
741
|
+
_context10.t0 = !(0, _fileState2.isFinalFileState)(copiedFileState) &&
|
|
713
742
|
// mimeType should always be returned by "copyFileWithToken"
|
|
714
743
|
// but in case it's not, we don't want to penalize "copyFile"
|
|
715
744
|
copiedMimeType;
|
|
716
|
-
if (!
|
|
717
|
-
|
|
745
|
+
if (!_context10.t0) {
|
|
746
|
+
_context10.next = 28;
|
|
718
747
|
break;
|
|
719
748
|
}
|
|
720
|
-
|
|
749
|
+
_context10.next = 27;
|
|
721
750
|
return (0, _shouldFetchRemoteFileStates.shouldFetchRemoteFileStates)(mediaType, copiedMimeType, preview);
|
|
722
751
|
case 27:
|
|
723
|
-
|
|
752
|
+
_context10.t0 = _context10.sent;
|
|
724
753
|
case 28:
|
|
725
|
-
if (!
|
|
726
|
-
|
|
754
|
+
if (!_context10.t0) {
|
|
755
|
+
_context10.next = 35;
|
|
727
756
|
break;
|
|
728
757
|
}
|
|
729
758
|
fileState = _objectSpread(_objectSpread(_objectSpread({}, copiedFileState), (0, _overrideMediaTypeIfUnknown.overrideMediaTypeIfUnknown)(copiedFileState, mediaType)), previewOverride);
|
|
@@ -744,7 +773,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
744
773
|
return subject.complete();
|
|
745
774
|
}
|
|
746
775
|
});
|
|
747
|
-
|
|
776
|
+
_context10.next = 36;
|
|
748
777
|
break;
|
|
749
778
|
case 35:
|
|
750
779
|
if (!(0, _fileState2.isProcessingFileState)(copiedFileState)) {
|
|
@@ -756,10 +785,10 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
756
785
|
if (!cache.has(copiedId)) {
|
|
757
786
|
(0, _fileStreamsCache.getFileStreamsCache)().set(copiedId, subject);
|
|
758
787
|
}
|
|
759
|
-
return
|
|
788
|
+
return _context10.abrupt("return", copiedFile);
|
|
760
789
|
case 40:
|
|
761
|
-
|
|
762
|
-
|
|
790
|
+
_context10.prev = 40;
|
|
791
|
+
_context10.t1 = _context10["catch"](6);
|
|
763
792
|
if (processingSubscription) {
|
|
764
793
|
processingSubscription.unsubscribe();
|
|
765
794
|
}
|
|
@@ -767,23 +796,23 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
767
796
|
_fileCache = cache.get(replaceFileId);
|
|
768
797
|
replaceFileState = this.store.getState().files[replaceFileId];
|
|
769
798
|
if (_fileCache) {
|
|
770
|
-
_fileCache.error(
|
|
799
|
+
_fileCache.error(_context10.t1);
|
|
771
800
|
} else {
|
|
772
801
|
// Create a new subject with the error state for new subscriptions
|
|
773
|
-
cache.set(id, (0, _createMediaSubject.createMediaSubject)(
|
|
802
|
+
cache.set(id, (0, _createMediaSubject.createMediaSubject)(_context10.t1));
|
|
774
803
|
}
|
|
775
804
|
key = replaceFileState ? replaceFileId : id;
|
|
776
|
-
errorFileState = this.getErrorFileState(
|
|
805
|
+
errorFileState = this.getErrorFileState(_context10.t1, id, occurrenceKey);
|
|
777
806
|
this.setFileState(key, errorFileState);
|
|
778
807
|
}
|
|
779
|
-
throw
|
|
808
|
+
throw _context10.t1;
|
|
780
809
|
case 45:
|
|
781
810
|
case "end":
|
|
782
|
-
return
|
|
811
|
+
return _context10.stop();
|
|
783
812
|
}
|
|
784
|
-
},
|
|
813
|
+
}, _callee10, this, [[6, 40]]);
|
|
785
814
|
}));
|
|
786
|
-
function copyFile(
|
|
815
|
+
function copyFile(_x22, _x23) {
|
|
787
816
|
return _copyFile.apply(this, arguments);
|
|
788
817
|
}
|
|
789
818
|
return copyFile;
|