@atlaskit/media-client 19.1.1 → 20.0.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 +17 -0
- package/dist/cjs/client/file-fetcher/index.js +112 -8
- package/dist/cjs/client/media-client.js +1 -1
- package/dist/cjs/client/media-store/index.js +16 -31
- package/dist/cjs/uploader/index.js +19 -28
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/client/file-fetcher/index.js +112 -2
- package/dist/es2019/client/media-client.js +1 -1
- package/dist/es2019/client/media-store/index.js +2 -9
- package/dist/es2019/uploader/index.js +2 -9
- package/dist/es2019/version.json +1 -1
- package/dist/esm/client/file-fetcher/index.js +112 -8
- package/dist/esm/client/media-client.js +1 -1
- package/dist/esm/client/media-store/index.js +16 -31
- package/dist/esm/uploader/index.js +19 -28
- package/dist/esm/version.json +1 -1
- package/dist/types/client/file-fetcher/index.d.ts +6 -2
- package/dist/types/client/media-store/index.d.ts +2 -9
- package/package.json +3 -3
- package/report.api.md +24 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/media-client
|
|
2
2
|
|
|
3
|
+
## 20.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`90f6203e794`](https://bitbucket.org/atlassian/atlassian-frontend/commits/90f6203e794) - Media Client now fetch remote file state regardless of file browser support (behind feature flag)
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
10
|
+
## 20.0.0
|
|
11
|
+
|
|
12
|
+
### Major Changes
|
|
13
|
+
|
|
14
|
+
- [`2e902a363ad`](https://bitbucket.org/atlassian/atlassian-frontend/commits/2e902a363ad) - MEX-1649 Update uploadChunk and probeChunk functions in mediastore with mandatory params - uploadId and partNumber
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 19.1.1
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -83,12 +83,14 @@ var _polling = require("../../utils/polling");
|
|
|
83
83
|
|
|
84
84
|
var _detectEmptyFile = require("../../utils/detectEmptyFile");
|
|
85
85
|
|
|
86
|
+
var _mediaCommon = require("@atlaskit/media-common");
|
|
87
|
+
|
|
86
88
|
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; }
|
|
87
89
|
|
|
88
90
|
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; }
|
|
89
91
|
|
|
90
92
|
var FileFetcherImpl = /*#__PURE__*/function () {
|
|
91
|
-
function FileFetcherImpl(mediaStore) {
|
|
93
|
+
function FileFetcherImpl(mediaStore, featureFlags) {
|
|
92
94
|
var _this = this;
|
|
93
95
|
|
|
94
96
|
(0, _classCallCheck2.default)(this, FileFetcherImpl);
|
|
@@ -161,7 +163,47 @@ var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
161
163
|
})));
|
|
162
164
|
return subject;
|
|
163
165
|
});
|
|
166
|
+
(0, _defineProperty2.default)(this, "getUploadingFileStateBase", function (file, upfrontId) {
|
|
167
|
+
// TODO: DO not modify the input parameter 'content' attribute
|
|
168
|
+
if (typeof file.content === 'string') {
|
|
169
|
+
file.content = (0, _convertBase64ToBlob.convertBase64ToBlob)(file.content);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
var content = file.content,
|
|
173
|
+
_file$name = file.name,
|
|
174
|
+
name = _file$name === void 0 ? '' : _file$name;
|
|
175
|
+
var id = upfrontId.id,
|
|
176
|
+
occurrenceKey = upfrontId.occurrenceKey;
|
|
177
|
+
var preview; // TODO [MSW-796]: get file size for base64
|
|
178
|
+
|
|
179
|
+
var size = 0;
|
|
180
|
+
var mimeType = '';
|
|
181
|
+
|
|
182
|
+
if (content instanceof Blob) {
|
|
183
|
+
size = content.size;
|
|
184
|
+
mimeType = content.type;
|
|
185
|
+
|
|
186
|
+
if ((0, _mediaTypeUtils.isMimeTypeSupportedByBrowser)(content.type)) {
|
|
187
|
+
preview = {
|
|
188
|
+
value: content,
|
|
189
|
+
origin: 'local'
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
var mediaType = (0, _getMediaTypeFromUploadableFile.getMediaTypeFromUploadableFile)(file);
|
|
195
|
+
return {
|
|
196
|
+
id: id,
|
|
197
|
+
occurrenceKey: occurrenceKey,
|
|
198
|
+
name: name,
|
|
199
|
+
size: size,
|
|
200
|
+
mediaType: mediaType,
|
|
201
|
+
mimeType: mimeType,
|
|
202
|
+
preview: preview
|
|
203
|
+
};
|
|
204
|
+
});
|
|
164
205
|
this.mediaStore = mediaStore;
|
|
206
|
+
this.featureFlags = featureFlags;
|
|
165
207
|
this.dataloader = (0, _createFileDataLoader.createFileDataloader)(mediaStore);
|
|
166
208
|
}
|
|
167
209
|
|
|
@@ -383,17 +425,68 @@ var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
383
425
|
return uploadExternal;
|
|
384
426
|
}()
|
|
385
427
|
}, {
|
|
386
|
-
key: "
|
|
387
|
-
value:
|
|
428
|
+
key: "uploadAwlaysPullFileStates",
|
|
429
|
+
value: // TODO: make this the public upload method when the FF is removed
|
|
430
|
+
function uploadAwlaysPullFileStates(file, controller, uploadableFileUpfrontIds, traceContext) {
|
|
388
431
|
var _this4 = this;
|
|
389
432
|
|
|
433
|
+
var collection = file.collection;
|
|
434
|
+
var upfrontId = uploadableFileUpfrontIds || this.generateUploadableFileUpfrontIds(collection, traceContext);
|
|
435
|
+
var id = upfrontId.id,
|
|
436
|
+
occurrenceKey = upfrontId.occurrenceKey;
|
|
437
|
+
var stateBase = this.getUploadingFileStateBase(file, upfrontId);
|
|
438
|
+
var subject = (0, _createMediaSubject.createMediaSubject)();
|
|
439
|
+
(0, _fileStreamsCache.getFileStreamsCache)().set(id, subject);
|
|
440
|
+
|
|
441
|
+
var onProgress = function onProgress(progress) {
|
|
442
|
+
subject.next(_objectSpread(_objectSpread({
|
|
443
|
+
status: 'uploading'
|
|
444
|
+
}, stateBase), {}, {
|
|
445
|
+
progress: progress
|
|
446
|
+
}));
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
var processingSubscription = new _Subscription.Subscription();
|
|
450
|
+
|
|
451
|
+
var onUploadFinish = function onUploadFinish(error) {
|
|
452
|
+
if (error) {
|
|
453
|
+
return subject.error(error);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
processingSubscription = _this4.createDownloadFileStream(id, collection, occurrenceKey).pipe((0, _map.map)(function (remoteFileState) {
|
|
457
|
+
return _objectSpread(_objectSpread(_objectSpread({}, stateBase), remoteFileState), (0, _overrideMediaTypeIfUnknown.overrideMediaTypeIfUnknown)(remoteFileState, stateBase.mediaType));
|
|
458
|
+
})).subscribe(subject);
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
var _uploadFile = (0, _uploader.uploadFile)(file, this.mediaStore, upfrontId, {
|
|
462
|
+
onUploadFinish: onUploadFinish,
|
|
463
|
+
onProgress: onProgress
|
|
464
|
+
}, traceContext),
|
|
465
|
+
cancel = _uploadFile.cancel;
|
|
466
|
+
|
|
467
|
+
controller === null || controller === void 0 ? void 0 : controller.setAbort(function () {
|
|
468
|
+
cancel(); // TODO: filestate should turn to "Aborted" or something.
|
|
469
|
+
// Consider canceling an upload that is already finished
|
|
470
|
+
|
|
471
|
+
processingSubscription.unsubscribe();
|
|
472
|
+
}); // We should report progress asynchronously, since this is what consumer expects
|
|
473
|
+
// (otherwise in newUploadService file-converting event will be emitted before files-added)
|
|
474
|
+
|
|
475
|
+
setTimeout(onProgress, 0, 0);
|
|
476
|
+
return (0, _mediaSubscribable.fromObservable)(subject);
|
|
477
|
+
}
|
|
478
|
+
}, {
|
|
479
|
+
key: "uploadConditionallyPullFileStates",
|
|
480
|
+
value: function uploadConditionallyPullFileStates(file, controller, uploadableFileUpfrontIds, traceContext) {
|
|
481
|
+
var _this5 = this;
|
|
482
|
+
|
|
390
483
|
if (typeof file.content === 'string') {
|
|
391
484
|
file.content = (0, _convertBase64ToBlob.convertBase64ToBlob)(file.content);
|
|
392
485
|
}
|
|
393
486
|
|
|
394
487
|
var content = file.content,
|
|
395
|
-
_file$
|
|
396
|
-
name = _file$
|
|
488
|
+
_file$name2 = file.name,
|
|
489
|
+
name = _file$name2 === void 0 ? '' : _file$name2,
|
|
397
490
|
collection = file.collection;
|
|
398
491
|
|
|
399
492
|
if (!uploadableFileUpfrontIds) {
|
|
@@ -447,7 +540,7 @@ var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
447
540
|
|
|
448
541
|
processingSubscription.add((0, _shouldFetchRemoteFileStates.shouldFetchRemoteFileStatesObservable)(mediaType, mimeType, preview).pipe((0, _concatMap.concatMap)(function (shouldFetchRemoteFileStates) {
|
|
449
542
|
if (shouldFetchRemoteFileStates) {
|
|
450
|
-
return
|
|
543
|
+
return _this5.createDownloadFileStream(id, collection, occurrenceKey).pipe((0, _map.map)(function (remoteFileState) {
|
|
451
544
|
return _objectSpread(_objectSpread(_objectSpread({}, stateBase), remoteFileState), (0, _overrideMediaTypeIfUnknown.overrideMediaTypeIfUnknown)(remoteFileState, mediaType));
|
|
452
545
|
}));
|
|
453
546
|
}
|
|
@@ -459,11 +552,11 @@ var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
459
552
|
})).subscribe(subject));
|
|
460
553
|
};
|
|
461
554
|
|
|
462
|
-
var
|
|
555
|
+
var _uploadFile2 = (0, _uploader.uploadFile)(file, this.mediaStore, uploadableFileUpfrontIds, {
|
|
463
556
|
onUploadFinish: onUploadFinish,
|
|
464
557
|
onProgress: onProgress
|
|
465
558
|
}, traceContext),
|
|
466
|
-
cancel =
|
|
559
|
+
cancel = _uploadFile2.cancel;
|
|
467
560
|
|
|
468
561
|
(0, _fileStreamsCache.getFileStreamsCache)().set(id, subject); // We should report progress asynchronously, since this is what consumer expects
|
|
469
562
|
// (otherwise in newUploadService file-converting event will be emitted before files-added)
|
|
@@ -480,6 +573,17 @@ var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
480
573
|
}
|
|
481
574
|
|
|
482
575
|
return (0, _mediaSubscribable.fromObservable)(subject);
|
|
576
|
+
}
|
|
577
|
+
}, {
|
|
578
|
+
key: "upload",
|
|
579
|
+
value: function upload(file, controller, uploadableFileUpfrontIds, traceContext) {
|
|
580
|
+
var shouldAlwaysFetchFileState = (0, _mediaCommon.getMediaFeatureFlag)('fetchFileStateAfterUpload', this.featureFlags);
|
|
581
|
+
|
|
582
|
+
if (shouldAlwaysFetchFileState) {
|
|
583
|
+
return this.uploadAwlaysPullFileStates(file, controller, uploadableFileUpfrontIds, traceContext);
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
return this.uploadConditionallyPullFileStates(file, controller, uploadableFileUpfrontIds, traceContext);
|
|
483
587
|
} // TODO: ----- ADD TICKET
|
|
484
588
|
|
|
485
589
|
}, {
|
|
@@ -44,7 +44,7 @@ var MediaClient = /*#__PURE__*/function () {
|
|
|
44
44
|
}, featureFlags);
|
|
45
45
|
this.config = mediaClientConfig;
|
|
46
46
|
this.collection = new _collectionFetcher.CollectionFetcher(this.mediaStore);
|
|
47
|
-
this.file = new _fileFetcher.FileFetcherImpl(this.mediaStore);
|
|
47
|
+
this.file = new _fileFetcher.FileFetcherImpl(this.mediaStore, featureFlags);
|
|
48
48
|
this.eventEmitter = new _eventemitter.EventEmitter2();
|
|
49
49
|
this.stargate = new _stargateClient.StargateClient(mediaClientConfig.stargateBaseUrl);
|
|
50
50
|
}
|
|
@@ -231,22 +231,12 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
231
231
|
}, {
|
|
232
232
|
key: "uploadChunk",
|
|
233
233
|
value: function () {
|
|
234
|
-
var _uploadChunk = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(etag, blob) {
|
|
235
|
-
var
|
|
236
|
-
collectionName,
|
|
237
|
-
uploadId,
|
|
238
|
-
partNumber,
|
|
239
|
-
traceContext,
|
|
240
|
-
metadata,
|
|
241
|
-
options,
|
|
242
|
-
_args3 = arguments;
|
|
243
|
-
|
|
234
|
+
var _uploadChunk = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(etag, blob, uploadId, partNumber, collectionName, traceContext) {
|
|
235
|
+
var metadata, options;
|
|
244
236
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
245
237
|
while (1) {
|
|
246
238
|
switch (_context3.prev = _context3.next) {
|
|
247
239
|
case 0:
|
|
248
|
-
_ref = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : {}, collectionName = _ref.collectionName, uploadId = _ref.uploadId, partNumber = _ref.partNumber;
|
|
249
|
-
traceContext = _args3.length > 3 ? _args3[3] : undefined;
|
|
250
240
|
metadata = {
|
|
251
241
|
method: 'PUT',
|
|
252
242
|
endpoint: '/chunk/{etag}'
|
|
@@ -262,10 +252,10 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
262
252
|
body: blob,
|
|
263
253
|
traceContext: traceContext
|
|
264
254
|
});
|
|
265
|
-
_context3.next =
|
|
255
|
+
_context3.next = 4;
|
|
266
256
|
return this.request("/chunk/".concat(etag), options);
|
|
267
257
|
|
|
268
|
-
case
|
|
258
|
+
case 4:
|
|
269
259
|
case "end":
|
|
270
260
|
return _context3.stop();
|
|
271
261
|
}
|
|
@@ -273,7 +263,7 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
273
263
|
}, _callee3, this);
|
|
274
264
|
}));
|
|
275
265
|
|
|
276
|
-
function uploadChunk(_x8, _x9) {
|
|
266
|
+
function uploadChunk(_x8, _x9, _x10, _x11, _x12, _x13) {
|
|
277
267
|
return _uploadChunk.apply(this, arguments);
|
|
278
268
|
}
|
|
279
269
|
|
|
@@ -281,12 +271,7 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
281
271
|
}()
|
|
282
272
|
}, {
|
|
283
273
|
key: "probeChunks",
|
|
284
|
-
value: function probeChunks(chunks) {
|
|
285
|
-
var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
286
|
-
collectionName = _ref2.collectionName,
|
|
287
|
-
uploadId = _ref2.uploadId;
|
|
288
|
-
|
|
289
|
-
var traceContext = arguments.length > 2 ? arguments[2] : undefined;
|
|
274
|
+
value: function probeChunks(chunks, uploadId, collectionName, traceContext) {
|
|
290
275
|
var metadata = {
|
|
291
276
|
method: 'POST',
|
|
292
277
|
endpoint: '/chunk/probe'
|
|
@@ -375,13 +360,13 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
375
360
|
key: "getFileImageURL",
|
|
376
361
|
value: function () {
|
|
377
362
|
var _getFileImageURL = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(id, params) {
|
|
378
|
-
var
|
|
363
|
+
var _ref, collectionName, auth;
|
|
379
364
|
|
|
380
365
|
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
381
366
|
while (1) {
|
|
382
367
|
switch (_context4.prev = _context4.next) {
|
|
383
368
|
case 0:
|
|
384
|
-
|
|
369
|
+
_ref = params || {}, collectionName = _ref.collection;
|
|
385
370
|
_context4.next = 3;
|
|
386
371
|
return this.resolveAuth({
|
|
387
372
|
collectionName: collectionName
|
|
@@ -399,7 +384,7 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
399
384
|
}, _callee4, this);
|
|
400
385
|
}));
|
|
401
386
|
|
|
402
|
-
function getFileImageURL(
|
|
387
|
+
function getFileImageURL(_x14, _x15) {
|
|
403
388
|
return _getFileImageURL.apply(this, arguments);
|
|
404
389
|
}
|
|
405
390
|
|
|
@@ -455,7 +440,7 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
455
440
|
}, _callee5, this);
|
|
456
441
|
}));
|
|
457
442
|
|
|
458
|
-
function getFileBinaryURL(
|
|
443
|
+
function getFileBinaryURL(_x16, _x17) {
|
|
459
444
|
return _getFileBinaryURL.apply(this, arguments);
|
|
460
445
|
}
|
|
461
446
|
|
|
@@ -504,7 +489,7 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
504
489
|
}, _callee6, this);
|
|
505
490
|
}));
|
|
506
491
|
|
|
507
|
-
function getArtifactURL(
|
|
492
|
+
function getArtifactURL(_x18, _x19, _x20) {
|
|
508
493
|
return _getArtifactURL.apply(this, arguments);
|
|
509
494
|
}
|
|
510
495
|
|
|
@@ -549,7 +534,7 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
549
534
|
}, _callee7, this);
|
|
550
535
|
}));
|
|
551
536
|
|
|
552
|
-
function getImage(
|
|
537
|
+
function getImage(_x21, _x22, _x23, _x24, _x25) {
|
|
553
538
|
return _getImage.apply(this, arguments);
|
|
554
539
|
}
|
|
555
540
|
|
|
@@ -595,7 +580,7 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
595
580
|
}, _callee8, this);
|
|
596
581
|
}));
|
|
597
582
|
|
|
598
|
-
function getItems(
|
|
583
|
+
function getItems(_x26, _x27, _x28) {
|
|
599
584
|
return _getItems.apply(this, arguments);
|
|
600
585
|
}
|
|
601
586
|
|
|
@@ -631,7 +616,7 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
631
616
|
}, _callee9, this);
|
|
632
617
|
}));
|
|
633
618
|
|
|
634
|
-
function getImageMetadata(
|
|
619
|
+
function getImageMetadata(_x29, _x30, _x31) {
|
|
635
620
|
return _getImageMetadata.apply(this, arguments);
|
|
636
621
|
}
|
|
637
622
|
|
|
@@ -669,7 +654,7 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
669
654
|
}, _callee10, this);
|
|
670
655
|
}));
|
|
671
656
|
|
|
672
|
-
function appendChunksToUpload(
|
|
657
|
+
function appendChunksToUpload(_x32, _x33, _x34, _x35) {
|
|
673
658
|
return _appendChunksToUpload.apply(this, arguments);
|
|
674
659
|
}
|
|
675
660
|
|
|
@@ -761,7 +746,7 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
761
746
|
}, _callee11, this);
|
|
762
747
|
}));
|
|
763
748
|
|
|
764
|
-
function request(
|
|
749
|
+
function request(_x36) {
|
|
765
750
|
return _request2.apply(this, arguments);
|
|
766
751
|
}
|
|
767
752
|
|
|
@@ -62,28 +62,24 @@ var createProbingFunction = function createProbingFunction(store, deferredUpload
|
|
|
62
62
|
case 0:
|
|
63
63
|
_context2.t0 = store;
|
|
64
64
|
_context2.t1 = hashedChunks(chunks);
|
|
65
|
-
_context2.
|
|
66
|
-
_context2.next = 5;
|
|
65
|
+
_context2.next = 4;
|
|
67
66
|
return deferredUploadId;
|
|
68
67
|
|
|
69
|
-
case
|
|
70
|
-
_context2.
|
|
71
|
-
_context2.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
_context2.t5 = traceContext;
|
|
76
|
-
_context2.next = 10;
|
|
77
|
-
return _context2.t0.probeChunks.call(_context2.t0, _context2.t1, _context2.t4, _context2.t5);
|
|
68
|
+
case 4:
|
|
69
|
+
_context2.t2 = _context2.sent;
|
|
70
|
+
_context2.t3 = collectionName;
|
|
71
|
+
_context2.t4 = traceContext;
|
|
72
|
+
_context2.next = 9;
|
|
73
|
+
return _context2.t0.probeChunks.call(_context2.t0, _context2.t1, _context2.t2, _context2.t3, _context2.t4);
|
|
78
74
|
|
|
79
|
-
case
|
|
75
|
+
case 9:
|
|
80
76
|
response = _context2.sent;
|
|
81
77
|
results = response.data.results;
|
|
82
78
|
return _context2.abrupt("return", Object.values(results).map(function (result) {
|
|
83
79
|
return result.exists;
|
|
84
80
|
}));
|
|
85
81
|
|
|
86
|
-
case
|
|
82
|
+
case 12:
|
|
87
83
|
case "end":
|
|
88
84
|
return _context2.stop();
|
|
89
85
|
}
|
|
@@ -107,26 +103,21 @@ var createUploadingFunction = function createUploadingFunction(store, deferredUp
|
|
|
107
103
|
_context3.t0 = store;
|
|
108
104
|
_context3.t1 = chunk.hash;
|
|
109
105
|
_context3.t2 = chunk.blob;
|
|
110
|
-
_context3.
|
|
111
|
-
_context3.t4 = chunk.partNumber;
|
|
112
|
-
_context3.next = 7;
|
|
106
|
+
_context3.next = 5;
|
|
113
107
|
return deferredUploadId;
|
|
114
108
|
|
|
115
|
-
case
|
|
116
|
-
_context3.
|
|
117
|
-
_context3.
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
_context3.t7 = traceContext;
|
|
123
|
-
_context3.next = 12;
|
|
124
|
-
return _context3.t0.uploadChunk.call(_context3.t0, _context3.t1, _context3.t2, _context3.t6, _context3.t7);
|
|
109
|
+
case 5:
|
|
110
|
+
_context3.t3 = _context3.sent;
|
|
111
|
+
_context3.t4 = chunk.partNumber;
|
|
112
|
+
_context3.t5 = collectionName;
|
|
113
|
+
_context3.t6 = traceContext;
|
|
114
|
+
_context3.next = 11;
|
|
115
|
+
return _context3.t0.uploadChunk.call(_context3.t0, _context3.t1, _context3.t2, _context3.t3, _context3.t4, _context3.t5, _context3.t6);
|
|
125
116
|
|
|
126
|
-
case
|
|
117
|
+
case 11:
|
|
127
118
|
return _context3.abrupt("return", _context3.sent);
|
|
128
119
|
|
|
129
|
-
case
|
|
120
|
+
case 12:
|
|
130
121
|
case "end":
|
|
131
122
|
return _context3.stop();
|
|
132
123
|
}
|
package/dist/cjs/version.json
CHANGED
|
@@ -28,9 +28,10 @@ import { isMimeTypeSupportedByBrowser, getMediaTypeFromMimeType } from '@atlaski
|
|
|
28
28
|
import { shouldFetchRemoteFileStates, shouldFetchRemoteFileStatesObservable } from '../../utils/shouldFetchRemoteFileStates';
|
|
29
29
|
import { PollingFunction } from '../../utils/polling';
|
|
30
30
|
import { isEmptyFile } from '../../utils/detectEmptyFile';
|
|
31
|
+
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
31
32
|
export { isFileFetcherError, FileFetcherError } from './error';
|
|
32
33
|
export class FileFetcherImpl {
|
|
33
|
-
constructor(mediaStore) {
|
|
34
|
+
constructor(mediaStore, featureFlags) {
|
|
34
35
|
_defineProperty(this, "createDownloadFileStream", (id, collectionName, occurrenceKey) => {
|
|
35
36
|
const subject = createMediaSubject();
|
|
36
37
|
const poll = new PollingFunction(); // ensure subject errors if polling exceeds max iterations or uncaught exception in executor
|
|
@@ -74,7 +75,52 @@ export class FileFetcherImpl {
|
|
|
74
75
|
return subject;
|
|
75
76
|
});
|
|
76
77
|
|
|
78
|
+
_defineProperty(this, "getUploadingFileStateBase", (file, upfrontId) => {
|
|
79
|
+
// TODO: DO not modify the input parameter 'content' attribute
|
|
80
|
+
if (typeof file.content === 'string') {
|
|
81
|
+
file.content = convertBase64ToBlob(file.content);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const {
|
|
85
|
+
content,
|
|
86
|
+
name = '' // name property is not available in base64 image
|
|
87
|
+
|
|
88
|
+
} = file;
|
|
89
|
+
const {
|
|
90
|
+
id,
|
|
91
|
+
occurrenceKey
|
|
92
|
+
} = upfrontId;
|
|
93
|
+
let preview; // TODO [MSW-796]: get file size for base64
|
|
94
|
+
|
|
95
|
+
let size = 0;
|
|
96
|
+
let mimeType = '';
|
|
97
|
+
|
|
98
|
+
if (content instanceof Blob) {
|
|
99
|
+
size = content.size;
|
|
100
|
+
mimeType = content.type;
|
|
101
|
+
|
|
102
|
+
if (isMimeTypeSupportedByBrowser(content.type)) {
|
|
103
|
+
preview = {
|
|
104
|
+
value: content,
|
|
105
|
+
origin: 'local'
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const mediaType = getMediaTypeFromUploadableFile(file);
|
|
111
|
+
return {
|
|
112
|
+
id,
|
|
113
|
+
occurrenceKey,
|
|
114
|
+
name,
|
|
115
|
+
size,
|
|
116
|
+
mediaType,
|
|
117
|
+
mimeType,
|
|
118
|
+
preview
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
|
|
77
122
|
this.mediaStore = mediaStore;
|
|
123
|
+
this.featureFlags = featureFlags;
|
|
78
124
|
this.dataloader = createFileDataloader(mediaStore);
|
|
79
125
|
}
|
|
80
126
|
|
|
@@ -209,7 +255,61 @@ export class FileFetcherImpl {
|
|
|
209
255
|
});
|
|
210
256
|
}
|
|
211
257
|
|
|
212
|
-
upload
|
|
258
|
+
// TODO: make this the public upload method when the FF is removed
|
|
259
|
+
uploadAwlaysPullFileStates(file, controller, uploadableFileUpfrontIds, traceContext) {
|
|
260
|
+
const {
|
|
261
|
+
collection
|
|
262
|
+
} = file;
|
|
263
|
+
const upfrontId = uploadableFileUpfrontIds || this.generateUploadableFileUpfrontIds(collection, traceContext);
|
|
264
|
+
const {
|
|
265
|
+
id,
|
|
266
|
+
occurrenceKey
|
|
267
|
+
} = upfrontId;
|
|
268
|
+
const stateBase = this.getUploadingFileStateBase(file, upfrontId);
|
|
269
|
+
const subject = createMediaSubject();
|
|
270
|
+
getFileStreamsCache().set(id, subject);
|
|
271
|
+
|
|
272
|
+
const onProgress = progress => {
|
|
273
|
+
subject.next({
|
|
274
|
+
status: 'uploading',
|
|
275
|
+
...stateBase,
|
|
276
|
+
progress
|
|
277
|
+
});
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
let processingSubscription = new Subscription();
|
|
281
|
+
|
|
282
|
+
const onUploadFinish = error => {
|
|
283
|
+
if (error) {
|
|
284
|
+
return subject.error(error);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
processingSubscription = this.createDownloadFileStream(id, collection, occurrenceKey).pipe(map(remoteFileState => ({ // merges base state with remote state
|
|
288
|
+
...stateBase,
|
|
289
|
+
...remoteFileState,
|
|
290
|
+
...overrideMediaTypeIfUnknown(remoteFileState, stateBase.mediaType)
|
|
291
|
+
}))).subscribe(subject);
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
const {
|
|
295
|
+
cancel
|
|
296
|
+
} = uploadFile(file, this.mediaStore, upfrontId, {
|
|
297
|
+
onUploadFinish,
|
|
298
|
+
onProgress
|
|
299
|
+
}, traceContext);
|
|
300
|
+
controller === null || controller === void 0 ? void 0 : controller.setAbort(() => {
|
|
301
|
+
cancel(); // TODO: filestate should turn to "Aborted" or something.
|
|
302
|
+
// Consider canceling an upload that is already finished
|
|
303
|
+
|
|
304
|
+
processingSubscription.unsubscribe();
|
|
305
|
+
}); // We should report progress asynchronously, since this is what consumer expects
|
|
306
|
+
// (otherwise in newUploadService file-converting event will be emitted before files-added)
|
|
307
|
+
|
|
308
|
+
setTimeout(onProgress, 0, 0);
|
|
309
|
+
return fromObservable(subject);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
uploadConditionallyPullFileStates(file, controller, uploadableFileUpfrontIds, traceContext) {
|
|
213
313
|
if (typeof file.content === 'string') {
|
|
214
314
|
file.content = convertBase64ToBlob(file.content);
|
|
215
315
|
}
|
|
@@ -308,6 +408,16 @@ export class FileFetcherImpl {
|
|
|
308
408
|
}
|
|
309
409
|
|
|
310
410
|
return fromObservable(subject);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
upload(file, controller, uploadableFileUpfrontIds, traceContext) {
|
|
414
|
+
const shouldAlwaysFetchFileState = getMediaFeatureFlag('fetchFileStateAfterUpload', this.featureFlags);
|
|
415
|
+
|
|
416
|
+
if (shouldAlwaysFetchFileState) {
|
|
417
|
+
return this.uploadAwlaysPullFileStates(file, controller, uploadableFileUpfrontIds, traceContext);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
return this.uploadConditionallyPullFileStates(file, controller, uploadableFileUpfrontIds, traceContext);
|
|
311
421
|
} // TODO: ----- ADD TICKET
|
|
312
422
|
|
|
313
423
|
|
|
@@ -15,7 +15,7 @@ export class MediaClient {
|
|
|
15
15
|
}, featureFlags);
|
|
16
16
|
this.config = mediaClientConfig;
|
|
17
17
|
this.collection = new CollectionFetcher(this.mediaStore);
|
|
18
|
-
this.file = new FileFetcherImpl(this.mediaStore);
|
|
18
|
+
this.file = new FileFetcherImpl(this.mediaStore, featureFlags);
|
|
19
19
|
this.eventEmitter = new EventEmitter2();
|
|
20
20
|
this.stargate = new StargateClient(mediaClientConfig.stargateBaseUrl);
|
|
21
21
|
}
|
|
@@ -126,11 +126,7 @@ export class MediaStore {
|
|
|
126
126
|
return this.request(`/upload`, options).then(createMapResponseToJson(metadata));
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
async uploadChunk(etag, blob, {
|
|
130
|
-
collectionName,
|
|
131
|
-
uploadId,
|
|
132
|
-
partNumber
|
|
133
|
-
} = {}, traceContext) {
|
|
129
|
+
async uploadChunk(etag, blob, uploadId, partNumber, collectionName, traceContext) {
|
|
134
130
|
const metadata = {
|
|
135
131
|
method: 'PUT',
|
|
136
132
|
endpoint: '/chunk/{etag}'
|
|
@@ -149,10 +145,7 @@ export class MediaStore {
|
|
|
149
145
|
await this.request(`/chunk/${etag}`, options);
|
|
150
146
|
}
|
|
151
147
|
|
|
152
|
-
probeChunks(chunks, {
|
|
153
|
-
collectionName,
|
|
154
|
-
uploadId
|
|
155
|
-
} = {}, traceContext) {
|
|
148
|
+
probeChunks(chunks, uploadId, collectionName, traceContext) {
|
|
156
149
|
const metadata = {
|
|
157
150
|
method: 'POST',
|
|
158
151
|
endpoint: '/chunk/probe'
|
|
@@ -12,20 +12,13 @@ const hashingFunction = async blob => {
|
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
const createProbingFunction = (store, deferredUploadId, collectionName, traceContext) => async chunks => {
|
|
15
|
-
const response = await store.probeChunks(hashedChunks(chunks),
|
|
16
|
-
collectionName,
|
|
17
|
-
uploadId: await deferredUploadId
|
|
18
|
-
}, traceContext);
|
|
15
|
+
const response = await store.probeChunks(hashedChunks(chunks), await deferredUploadId, collectionName, traceContext);
|
|
19
16
|
const results = response.data.results;
|
|
20
17
|
return Object.values(results).map(result => result.exists);
|
|
21
18
|
};
|
|
22
19
|
|
|
23
20
|
const createUploadingFunction = (store, deferredUploadId, collectionName, traceContext) => async chunk => {
|
|
24
|
-
return await store.uploadChunk(chunk.hash, chunk.blob,
|
|
25
|
-
collectionName,
|
|
26
|
-
partNumber: chunk.partNumber,
|
|
27
|
-
uploadId: await deferredUploadId
|
|
28
|
-
}, traceContext);
|
|
21
|
+
return await store.uploadChunk(chunk.hash, chunk.blob, await deferredUploadId, chunk.partNumber, collectionName, traceContext);
|
|
29
22
|
};
|
|
30
23
|
|
|
31
24
|
const createProcessingFunction = (store, deferredUploadId, collection, traceContext) => {
|
package/dist/es2019/version.json
CHANGED
|
@@ -37,9 +37,10 @@ import { isMimeTypeSupportedByBrowser, getMediaTypeFromMimeType } from '@atlaski
|
|
|
37
37
|
import { shouldFetchRemoteFileStates, shouldFetchRemoteFileStatesObservable } from '../../utils/shouldFetchRemoteFileStates';
|
|
38
38
|
import { PollingFunction } from '../../utils/polling';
|
|
39
39
|
import { isEmptyFile } from '../../utils/detectEmptyFile';
|
|
40
|
+
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
40
41
|
export { isFileFetcherError, FileFetcherError } from './error';
|
|
41
42
|
export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
42
|
-
function FileFetcherImpl(mediaStore) {
|
|
43
|
+
function FileFetcherImpl(mediaStore, featureFlags) {
|
|
43
44
|
var _this = this;
|
|
44
45
|
|
|
45
46
|
_classCallCheck(this, FileFetcherImpl);
|
|
@@ -114,7 +115,48 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
114
115
|
return subject;
|
|
115
116
|
});
|
|
116
117
|
|
|
118
|
+
_defineProperty(this, "getUploadingFileStateBase", function (file, upfrontId) {
|
|
119
|
+
// TODO: DO not modify the input parameter 'content' attribute
|
|
120
|
+
if (typeof file.content === 'string') {
|
|
121
|
+
file.content = convertBase64ToBlob(file.content);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
var content = file.content,
|
|
125
|
+
_file$name = file.name,
|
|
126
|
+
name = _file$name === void 0 ? '' : _file$name;
|
|
127
|
+
var id = upfrontId.id,
|
|
128
|
+
occurrenceKey = upfrontId.occurrenceKey;
|
|
129
|
+
var preview; // TODO [MSW-796]: get file size for base64
|
|
130
|
+
|
|
131
|
+
var size = 0;
|
|
132
|
+
var mimeType = '';
|
|
133
|
+
|
|
134
|
+
if (content instanceof Blob) {
|
|
135
|
+
size = content.size;
|
|
136
|
+
mimeType = content.type;
|
|
137
|
+
|
|
138
|
+
if (isMimeTypeSupportedByBrowser(content.type)) {
|
|
139
|
+
preview = {
|
|
140
|
+
value: content,
|
|
141
|
+
origin: 'local'
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
var mediaType = getMediaTypeFromUploadableFile(file);
|
|
147
|
+
return {
|
|
148
|
+
id: id,
|
|
149
|
+
occurrenceKey: occurrenceKey,
|
|
150
|
+
name: name,
|
|
151
|
+
size: size,
|
|
152
|
+
mediaType: mediaType,
|
|
153
|
+
mimeType: mimeType,
|
|
154
|
+
preview: preview
|
|
155
|
+
};
|
|
156
|
+
});
|
|
157
|
+
|
|
117
158
|
this.mediaStore = mediaStore;
|
|
159
|
+
this.featureFlags = featureFlags;
|
|
118
160
|
this.dataloader = createFileDataloader(mediaStore);
|
|
119
161
|
}
|
|
120
162
|
|
|
@@ -336,17 +378,68 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
336
378
|
return uploadExternal;
|
|
337
379
|
}()
|
|
338
380
|
}, {
|
|
339
|
-
key: "
|
|
340
|
-
value:
|
|
381
|
+
key: "uploadAwlaysPullFileStates",
|
|
382
|
+
value: // TODO: make this the public upload method when the FF is removed
|
|
383
|
+
function uploadAwlaysPullFileStates(file, controller, uploadableFileUpfrontIds, traceContext) {
|
|
341
384
|
var _this4 = this;
|
|
342
385
|
|
|
386
|
+
var collection = file.collection;
|
|
387
|
+
var upfrontId = uploadableFileUpfrontIds || this.generateUploadableFileUpfrontIds(collection, traceContext);
|
|
388
|
+
var id = upfrontId.id,
|
|
389
|
+
occurrenceKey = upfrontId.occurrenceKey;
|
|
390
|
+
var stateBase = this.getUploadingFileStateBase(file, upfrontId);
|
|
391
|
+
var subject = createMediaSubject();
|
|
392
|
+
getFileStreamsCache().set(id, subject);
|
|
393
|
+
|
|
394
|
+
var onProgress = function onProgress(progress) {
|
|
395
|
+
subject.next(_objectSpread(_objectSpread({
|
|
396
|
+
status: 'uploading'
|
|
397
|
+
}, stateBase), {}, {
|
|
398
|
+
progress: progress
|
|
399
|
+
}));
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
var processingSubscription = new Subscription();
|
|
403
|
+
|
|
404
|
+
var onUploadFinish = function onUploadFinish(error) {
|
|
405
|
+
if (error) {
|
|
406
|
+
return subject.error(error);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
processingSubscription = _this4.createDownloadFileStream(id, collection, occurrenceKey).pipe(map(function (remoteFileState) {
|
|
410
|
+
return _objectSpread(_objectSpread(_objectSpread({}, stateBase), remoteFileState), overrideMediaTypeIfUnknown(remoteFileState, stateBase.mediaType));
|
|
411
|
+
})).subscribe(subject);
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
var _uploadFile = uploadFile(file, this.mediaStore, upfrontId, {
|
|
415
|
+
onUploadFinish: onUploadFinish,
|
|
416
|
+
onProgress: onProgress
|
|
417
|
+
}, traceContext),
|
|
418
|
+
cancel = _uploadFile.cancel;
|
|
419
|
+
|
|
420
|
+
controller === null || controller === void 0 ? void 0 : controller.setAbort(function () {
|
|
421
|
+
cancel(); // TODO: filestate should turn to "Aborted" or something.
|
|
422
|
+
// Consider canceling an upload that is already finished
|
|
423
|
+
|
|
424
|
+
processingSubscription.unsubscribe();
|
|
425
|
+
}); // We should report progress asynchronously, since this is what consumer expects
|
|
426
|
+
// (otherwise in newUploadService file-converting event will be emitted before files-added)
|
|
427
|
+
|
|
428
|
+
setTimeout(onProgress, 0, 0);
|
|
429
|
+
return fromObservable(subject);
|
|
430
|
+
}
|
|
431
|
+
}, {
|
|
432
|
+
key: "uploadConditionallyPullFileStates",
|
|
433
|
+
value: function uploadConditionallyPullFileStates(file, controller, uploadableFileUpfrontIds, traceContext) {
|
|
434
|
+
var _this5 = this;
|
|
435
|
+
|
|
343
436
|
if (typeof file.content === 'string') {
|
|
344
437
|
file.content = convertBase64ToBlob(file.content);
|
|
345
438
|
}
|
|
346
439
|
|
|
347
440
|
var content = file.content,
|
|
348
|
-
_file$
|
|
349
|
-
name = _file$
|
|
441
|
+
_file$name2 = file.name,
|
|
442
|
+
name = _file$name2 === void 0 ? '' : _file$name2,
|
|
350
443
|
collection = file.collection;
|
|
351
444
|
|
|
352
445
|
if (!uploadableFileUpfrontIds) {
|
|
@@ -400,7 +493,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
400
493
|
|
|
401
494
|
processingSubscription.add(shouldFetchRemoteFileStatesObservable(mediaType, mimeType, preview).pipe(concatMap(function (shouldFetchRemoteFileStates) {
|
|
402
495
|
if (shouldFetchRemoteFileStates) {
|
|
403
|
-
return
|
|
496
|
+
return _this5.createDownloadFileStream(id, collection, occurrenceKey).pipe(map(function (remoteFileState) {
|
|
404
497
|
return _objectSpread(_objectSpread(_objectSpread({}, stateBase), remoteFileState), overrideMediaTypeIfUnknown(remoteFileState, mediaType));
|
|
405
498
|
}));
|
|
406
499
|
}
|
|
@@ -412,11 +505,11 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
412
505
|
})).subscribe(subject));
|
|
413
506
|
};
|
|
414
507
|
|
|
415
|
-
var
|
|
508
|
+
var _uploadFile2 = uploadFile(file, this.mediaStore, uploadableFileUpfrontIds, {
|
|
416
509
|
onUploadFinish: onUploadFinish,
|
|
417
510
|
onProgress: onProgress
|
|
418
511
|
}, traceContext),
|
|
419
|
-
cancel =
|
|
512
|
+
cancel = _uploadFile2.cancel;
|
|
420
513
|
|
|
421
514
|
getFileStreamsCache().set(id, subject); // We should report progress asynchronously, since this is what consumer expects
|
|
422
515
|
// (otherwise in newUploadService file-converting event will be emitted before files-added)
|
|
@@ -433,6 +526,17 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
433
526
|
}
|
|
434
527
|
|
|
435
528
|
return fromObservable(subject);
|
|
529
|
+
}
|
|
530
|
+
}, {
|
|
531
|
+
key: "upload",
|
|
532
|
+
value: function upload(file, controller, uploadableFileUpfrontIds, traceContext) {
|
|
533
|
+
var shouldAlwaysFetchFileState = getMediaFeatureFlag('fetchFileStateAfterUpload', this.featureFlags);
|
|
534
|
+
|
|
535
|
+
if (shouldAlwaysFetchFileState) {
|
|
536
|
+
return this.uploadAwlaysPullFileStates(file, controller, uploadableFileUpfrontIds, traceContext);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
return this.uploadConditionallyPullFileStates(file, controller, uploadableFileUpfrontIds, traceContext);
|
|
436
540
|
} // TODO: ----- ADD TICKET
|
|
437
541
|
|
|
438
542
|
}, {
|
|
@@ -21,7 +21,7 @@ export var MediaClient = /*#__PURE__*/function () {
|
|
|
21
21
|
}, featureFlags);
|
|
22
22
|
this.config = mediaClientConfig;
|
|
23
23
|
this.collection = new CollectionFetcher(this.mediaStore);
|
|
24
|
-
this.file = new FileFetcherImpl(this.mediaStore);
|
|
24
|
+
this.file = new FileFetcherImpl(this.mediaStore, featureFlags);
|
|
25
25
|
this.eventEmitter = new EventEmitter2();
|
|
26
26
|
this.stargate = new StargateClient(mediaClientConfig.stargateBaseUrl);
|
|
27
27
|
}
|
|
@@ -200,22 +200,12 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
200
200
|
}, {
|
|
201
201
|
key: "uploadChunk",
|
|
202
202
|
value: function () {
|
|
203
|
-
var _uploadChunk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(etag, blob) {
|
|
204
|
-
var
|
|
205
|
-
collectionName,
|
|
206
|
-
uploadId,
|
|
207
|
-
partNumber,
|
|
208
|
-
traceContext,
|
|
209
|
-
metadata,
|
|
210
|
-
options,
|
|
211
|
-
_args3 = arguments;
|
|
212
|
-
|
|
203
|
+
var _uploadChunk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(etag, blob, uploadId, partNumber, collectionName, traceContext) {
|
|
204
|
+
var metadata, options;
|
|
213
205
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
214
206
|
while (1) {
|
|
215
207
|
switch (_context3.prev = _context3.next) {
|
|
216
208
|
case 0:
|
|
217
|
-
_ref = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : {}, collectionName = _ref.collectionName, uploadId = _ref.uploadId, partNumber = _ref.partNumber;
|
|
218
|
-
traceContext = _args3.length > 3 ? _args3[3] : undefined;
|
|
219
209
|
metadata = {
|
|
220
210
|
method: 'PUT',
|
|
221
211
|
endpoint: '/chunk/{etag}'
|
|
@@ -231,10 +221,10 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
231
221
|
body: blob,
|
|
232
222
|
traceContext: traceContext
|
|
233
223
|
});
|
|
234
|
-
_context3.next =
|
|
224
|
+
_context3.next = 4;
|
|
235
225
|
return this.request("/chunk/".concat(etag), options);
|
|
236
226
|
|
|
237
|
-
case
|
|
227
|
+
case 4:
|
|
238
228
|
case "end":
|
|
239
229
|
return _context3.stop();
|
|
240
230
|
}
|
|
@@ -242,7 +232,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
242
232
|
}, _callee3, this);
|
|
243
233
|
}));
|
|
244
234
|
|
|
245
|
-
function uploadChunk(_x8, _x9) {
|
|
235
|
+
function uploadChunk(_x8, _x9, _x10, _x11, _x12, _x13) {
|
|
246
236
|
return _uploadChunk.apply(this, arguments);
|
|
247
237
|
}
|
|
248
238
|
|
|
@@ -250,12 +240,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
250
240
|
}()
|
|
251
241
|
}, {
|
|
252
242
|
key: "probeChunks",
|
|
253
|
-
value: function probeChunks(chunks) {
|
|
254
|
-
var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
255
|
-
collectionName = _ref2.collectionName,
|
|
256
|
-
uploadId = _ref2.uploadId;
|
|
257
|
-
|
|
258
|
-
var traceContext = arguments.length > 2 ? arguments[2] : undefined;
|
|
243
|
+
value: function probeChunks(chunks, uploadId, collectionName, traceContext) {
|
|
259
244
|
var metadata = {
|
|
260
245
|
method: 'POST',
|
|
261
246
|
endpoint: '/chunk/probe'
|
|
@@ -344,13 +329,13 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
344
329
|
key: "getFileImageURL",
|
|
345
330
|
value: function () {
|
|
346
331
|
var _getFileImageURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(id, params) {
|
|
347
|
-
var
|
|
332
|
+
var _ref, collectionName, auth;
|
|
348
333
|
|
|
349
334
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
350
335
|
while (1) {
|
|
351
336
|
switch (_context4.prev = _context4.next) {
|
|
352
337
|
case 0:
|
|
353
|
-
|
|
338
|
+
_ref = params || {}, collectionName = _ref.collection;
|
|
354
339
|
_context4.next = 3;
|
|
355
340
|
return this.resolveAuth({
|
|
356
341
|
collectionName: collectionName
|
|
@@ -368,7 +353,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
368
353
|
}, _callee4, this);
|
|
369
354
|
}));
|
|
370
355
|
|
|
371
|
-
function getFileImageURL(
|
|
356
|
+
function getFileImageURL(_x14, _x15) {
|
|
372
357
|
return _getFileImageURL.apply(this, arguments);
|
|
373
358
|
}
|
|
374
359
|
|
|
@@ -424,7 +409,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
424
409
|
}, _callee5, this);
|
|
425
410
|
}));
|
|
426
411
|
|
|
427
|
-
function getFileBinaryURL(
|
|
412
|
+
function getFileBinaryURL(_x16, _x17) {
|
|
428
413
|
return _getFileBinaryURL.apply(this, arguments);
|
|
429
414
|
}
|
|
430
415
|
|
|
@@ -473,7 +458,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
473
458
|
}, _callee6, this);
|
|
474
459
|
}));
|
|
475
460
|
|
|
476
|
-
function getArtifactURL(
|
|
461
|
+
function getArtifactURL(_x18, _x19, _x20) {
|
|
477
462
|
return _getArtifactURL.apply(this, arguments);
|
|
478
463
|
}
|
|
479
464
|
|
|
@@ -518,7 +503,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
518
503
|
}, _callee7, this);
|
|
519
504
|
}));
|
|
520
505
|
|
|
521
|
-
function getImage(
|
|
506
|
+
function getImage(_x21, _x22, _x23, _x24, _x25) {
|
|
522
507
|
return _getImage.apply(this, arguments);
|
|
523
508
|
}
|
|
524
509
|
|
|
@@ -564,7 +549,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
564
549
|
}, _callee8, this);
|
|
565
550
|
}));
|
|
566
551
|
|
|
567
|
-
function getItems(
|
|
552
|
+
function getItems(_x26, _x27, _x28) {
|
|
568
553
|
return _getItems.apply(this, arguments);
|
|
569
554
|
}
|
|
570
555
|
|
|
@@ -600,7 +585,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
600
585
|
}, _callee9, this);
|
|
601
586
|
}));
|
|
602
587
|
|
|
603
|
-
function getImageMetadata(
|
|
588
|
+
function getImageMetadata(_x29, _x30, _x31) {
|
|
604
589
|
return _getImageMetadata.apply(this, arguments);
|
|
605
590
|
}
|
|
606
591
|
|
|
@@ -638,7 +623,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
638
623
|
}, _callee10, this);
|
|
639
624
|
}));
|
|
640
625
|
|
|
641
|
-
function appendChunksToUpload(
|
|
626
|
+
function appendChunksToUpload(_x32, _x33, _x34, _x35) {
|
|
642
627
|
return _appendChunksToUpload.apply(this, arguments);
|
|
643
628
|
}
|
|
644
629
|
|
|
@@ -730,7 +715,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
730
715
|
}, _callee11, this);
|
|
731
716
|
}));
|
|
732
717
|
|
|
733
|
-
function request(
|
|
718
|
+
function request(_x36) {
|
|
734
719
|
return _request2.apply(this, arguments);
|
|
735
720
|
}
|
|
736
721
|
|
|
@@ -45,28 +45,24 @@ var createProbingFunction = function createProbingFunction(store, deferredUpload
|
|
|
45
45
|
case 0:
|
|
46
46
|
_context2.t0 = store;
|
|
47
47
|
_context2.t1 = hashedChunks(chunks);
|
|
48
|
-
_context2.
|
|
49
|
-
_context2.next = 5;
|
|
48
|
+
_context2.next = 4;
|
|
50
49
|
return deferredUploadId;
|
|
51
50
|
|
|
52
|
-
case
|
|
53
|
-
_context2.
|
|
54
|
-
_context2.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
_context2.t5 = traceContext;
|
|
59
|
-
_context2.next = 10;
|
|
60
|
-
return _context2.t0.probeChunks.call(_context2.t0, _context2.t1, _context2.t4, _context2.t5);
|
|
51
|
+
case 4:
|
|
52
|
+
_context2.t2 = _context2.sent;
|
|
53
|
+
_context2.t3 = collectionName;
|
|
54
|
+
_context2.t4 = traceContext;
|
|
55
|
+
_context2.next = 9;
|
|
56
|
+
return _context2.t0.probeChunks.call(_context2.t0, _context2.t1, _context2.t2, _context2.t3, _context2.t4);
|
|
61
57
|
|
|
62
|
-
case
|
|
58
|
+
case 9:
|
|
63
59
|
response = _context2.sent;
|
|
64
60
|
results = response.data.results;
|
|
65
61
|
return _context2.abrupt("return", Object.values(results).map(function (result) {
|
|
66
62
|
return result.exists;
|
|
67
63
|
}));
|
|
68
64
|
|
|
69
|
-
case
|
|
65
|
+
case 12:
|
|
70
66
|
case "end":
|
|
71
67
|
return _context2.stop();
|
|
72
68
|
}
|
|
@@ -90,26 +86,21 @@ var createUploadingFunction = function createUploadingFunction(store, deferredUp
|
|
|
90
86
|
_context3.t0 = store;
|
|
91
87
|
_context3.t1 = chunk.hash;
|
|
92
88
|
_context3.t2 = chunk.blob;
|
|
93
|
-
_context3.
|
|
94
|
-
_context3.t4 = chunk.partNumber;
|
|
95
|
-
_context3.next = 7;
|
|
89
|
+
_context3.next = 5;
|
|
96
90
|
return deferredUploadId;
|
|
97
91
|
|
|
98
|
-
case
|
|
99
|
-
_context3.
|
|
100
|
-
_context3.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
_context3.t7 = traceContext;
|
|
106
|
-
_context3.next = 12;
|
|
107
|
-
return _context3.t0.uploadChunk.call(_context3.t0, _context3.t1, _context3.t2, _context3.t6, _context3.t7);
|
|
92
|
+
case 5:
|
|
93
|
+
_context3.t3 = _context3.sent;
|
|
94
|
+
_context3.t4 = chunk.partNumber;
|
|
95
|
+
_context3.t5 = collectionName;
|
|
96
|
+
_context3.t6 = traceContext;
|
|
97
|
+
_context3.next = 11;
|
|
98
|
+
return _context3.t0.uploadChunk.call(_context3.t0, _context3.t1, _context3.t2, _context3.t3, _context3.t4, _context3.t5, _context3.t6);
|
|
108
99
|
|
|
109
|
-
case
|
|
100
|
+
case 11:
|
|
110
101
|
return _context3.abrupt("return", _context3.sent);
|
|
111
102
|
|
|
112
|
-
case
|
|
103
|
+
case 12:
|
|
113
104
|
case "end":
|
|
114
105
|
return _context3.stop();
|
|
115
106
|
}
|
package/dist/esm/version.json
CHANGED
|
@@ -8,7 +8,7 @@ import { MediaFileArtifacts } from '../../models/artifacts';
|
|
|
8
8
|
import { UploadController } from '../../upload-controller';
|
|
9
9
|
import { MediaSubscribable } from '../../utils/mediaSubscribable';
|
|
10
10
|
import { Dimensions } from '../../utils/getDimensionsFromBlob';
|
|
11
|
-
import { MediaTraceContext } from '@atlaskit/media-common';
|
|
11
|
+
import { MediaFeatureFlags, MediaTraceContext } from '@atlaskit/media-common';
|
|
12
12
|
export type { FileFetcherErrorAttributes, FileFetcherErrorReason, } from './error';
|
|
13
13
|
export { isFileFetcherError, FileFetcherError } from './error';
|
|
14
14
|
export interface CopySourceFile {
|
|
@@ -41,8 +41,9 @@ export interface FileFetcher {
|
|
|
41
41
|
}
|
|
42
42
|
export declare class FileFetcherImpl implements FileFetcher {
|
|
43
43
|
private readonly mediaStore;
|
|
44
|
+
private readonly featureFlags?;
|
|
44
45
|
private readonly dataloader;
|
|
45
|
-
constructor(mediaStore: MediaStore);
|
|
46
|
+
constructor(mediaStore: MediaStore, featureFlags?: MediaFeatureFlags | undefined);
|
|
46
47
|
getFileState(id: string, options?: GetFileOptions): MediaSubscribable<FileState>;
|
|
47
48
|
getCurrentState(id: string, options?: GetFileOptions): Promise<FileState>;
|
|
48
49
|
getArtifactURL(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string): Promise<string>;
|
|
@@ -51,6 +52,9 @@ export declare class FileFetcherImpl implements FileFetcher {
|
|
|
51
52
|
touchFiles(descriptors: TouchFileDescriptor[], collection?: string, traceContext?: MediaTraceContext): Promise<TouchedFiles>;
|
|
52
53
|
private generateUploadableFileUpfrontIds;
|
|
53
54
|
uploadExternal(url: string, collection?: string, traceContext?: MediaTraceContext): Promise<ExternalUploadPayload>;
|
|
55
|
+
private getUploadingFileStateBase;
|
|
56
|
+
private uploadAwlaysPullFileStates;
|
|
57
|
+
private uploadConditionallyPullFileStates;
|
|
54
58
|
upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds, traceContext?: MediaTraceContext): MediaSubscribable<FileState>;
|
|
55
59
|
downloadBinary(id: string, name?: string, collectionName?: string): Promise<void>;
|
|
56
60
|
copyFile(source: CopySourceFile, destination: CopyDestination, options?: CopyFileOptions, traceContext?: MediaTraceContext): Promise<MediaFile>;
|
|
@@ -12,15 +12,8 @@ export declare class MediaStore {
|
|
|
12
12
|
getCollectionItems(collectionName: string, params?: MediaStoreGetCollectionItemsParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaCollectionItems>>;
|
|
13
13
|
removeCollectionFile(id: string, collectionName: string, occurrenceKey?: string, traceContext?: MediaTraceContext): Promise<void>;
|
|
14
14
|
createUpload(createUpTo?: number, collectionName?: string, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaUpload[]>>;
|
|
15
|
-
uploadChunk(etag: string, blob: Blob,
|
|
16
|
-
|
|
17
|
-
uploadId?: string;
|
|
18
|
-
partNumber?: number;
|
|
19
|
-
}, traceContext?: MediaTraceContext): Promise<void>;
|
|
20
|
-
probeChunks(chunks: string[], { collectionName, uploadId, }?: {
|
|
21
|
-
collectionName?: string;
|
|
22
|
-
uploadId?: string;
|
|
23
|
-
}, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaChunksProbe>>;
|
|
15
|
+
uploadChunk(etag: string, blob: Blob, uploadId: string, partNumber: number, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
|
|
16
|
+
probeChunks(chunks: string[], uploadId: string, collectionName?: string, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaChunksProbe>>;
|
|
24
17
|
createFileFromUpload(body: MediaStoreCreateFileFromUploadBody, params?: MediaStoreCreateFileFromUploadParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaFile>>;
|
|
25
18
|
touchFiles(body: MediaStoreTouchFileBody, params?: MediaStoreTouchFileParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<TouchedFiles>>;
|
|
26
19
|
getFile(fileId: string, params?: MediaStoreGetFileParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaFile>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/media-client",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "20.0.1",
|
|
4
4
|
"description": "Media API Web Client Library",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@atlaskit/chunkinator": "^4.1.0",
|
|
31
|
-
"@atlaskit/media-common": "^2.
|
|
31
|
+
"@atlaskit/media-common": "^2.19.0",
|
|
32
32
|
"@babel/runtime": "^7.0.0",
|
|
33
33
|
"dataloader": "^2.0.0",
|
|
34
34
|
"deep-equal": "^1.0.1",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@atlaskit/button": "^16.5.0",
|
|
51
51
|
"@atlaskit/docs": "*",
|
|
52
|
-
"@atlaskit/media-card": "^74.
|
|
52
|
+
"@atlaskit/media-card": "^74.5.0",
|
|
53
53
|
"@atlaskit/media-core": "^34.0.0",
|
|
54
54
|
"@atlaskit/media-test-helpers": "^30.1.0",
|
|
55
55
|
"@atlaskit/ssr": "*",
|
package/report.api.md
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
### Table of contents
|
|
9
9
|
|
|
10
10
|
- [Main Entry Types](#main-entry-types)
|
|
11
|
+
- [Peer Dependencies](#peer-dependencies)
|
|
11
12
|
|
|
12
13
|
### Main Entry Types
|
|
13
14
|
|
|
@@ -360,7 +361,10 @@ export type FileFetcherErrorReason =
|
|
|
360
361
|
|
|
361
362
|
// @public (undocumented)
|
|
362
363
|
export class FileFetcherImpl implements FileFetcher {
|
|
363
|
-
constructor(
|
|
364
|
+
constructor(
|
|
365
|
+
mediaStore: MediaStore,
|
|
366
|
+
featureFlags?: MediaFeatureFlags | undefined,
|
|
367
|
+
);
|
|
364
368
|
// (undocumented)
|
|
365
369
|
copyFile(
|
|
366
370
|
source: CopySourceFile,
|
|
@@ -1024,13 +1028,8 @@ export class MediaStore {
|
|
|
1024
1028
|
// (undocumented)
|
|
1025
1029
|
probeChunks(
|
|
1026
1030
|
chunks: string[],
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
uploadId,
|
|
1030
|
-
}?: {
|
|
1031
|
-
collectionName?: string;
|
|
1032
|
-
uploadId?: string;
|
|
1033
|
-
},
|
|
1031
|
+
uploadId: string,
|
|
1032
|
+
collectionName?: string,
|
|
1034
1033
|
traceContext?: MediaTraceContext,
|
|
1035
1034
|
): Promise<MediaStoreResponse<MediaChunksProbe>>;
|
|
1036
1035
|
// (undocumented)
|
|
@@ -1060,15 +1059,9 @@ export class MediaStore {
|
|
|
1060
1059
|
uploadChunk(
|
|
1061
1060
|
etag: string,
|
|
1062
1061
|
blob: Blob,
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
partNumber,
|
|
1067
|
-
}?: {
|
|
1068
|
-
collectionName?: string;
|
|
1069
|
-
uploadId?: string;
|
|
1070
|
-
partNumber?: number;
|
|
1071
|
-
},
|
|
1062
|
+
uploadId: string,
|
|
1063
|
+
partNumber: number,
|
|
1064
|
+
collectionName?: string,
|
|
1072
1065
|
traceContext?: MediaTraceContext,
|
|
1073
1066
|
): Promise<void>;
|
|
1074
1067
|
}
|
|
@@ -1718,3 +1711,17 @@ export type WithMediaClientFunction = <P extends WithMediaClient>(
|
|
|
1718
1711
|
```
|
|
1719
1712
|
|
|
1720
1713
|
<!--SECTION END: Main Entry Types-->
|
|
1714
|
+
|
|
1715
|
+
### Peer Dependencies
|
|
1716
|
+
|
|
1717
|
+
<!--SECTION START: Peer Dependencies-->
|
|
1718
|
+
|
|
1719
|
+
```json
|
|
1720
|
+
{
|
|
1721
|
+
"@atlaskit/media-core": "^34.0.1",
|
|
1722
|
+
"@emotion/react": "^11.7.1",
|
|
1723
|
+
"react": "^16.8.0"
|
|
1724
|
+
}
|
|
1725
|
+
```
|
|
1726
|
+
|
|
1727
|
+
<!--SECTION END: Peer Dependencies-->
|