@atlaskit/media-client 28.3.1 → 28.5.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 +6 -4
- package/dist/cjs/client/media-store/MediaStore.js +91 -29
- package/dist/cjs/models/file-state.js +3 -1
- package/dist/cjs/utils/createFileDataLoader.js +23 -15
- package/dist/es2019/client/file-fetcher/index.js +6 -4
- package/dist/es2019/client/media-store/MediaStore.js +44 -2
- package/dist/es2019/models/file-state.js +3 -1
- package/dist/es2019/utils/createFileDataLoader.js +9 -1
- package/dist/esm/client/file-fetcher/index.js +6 -4
- package/dist/esm/client/media-store/MediaStore.js +91 -29
- package/dist/esm/models/file-state.js +3 -1
- package/dist/esm/utils/createFileDataLoader.js +23 -15
- package/dist/types/client/media-store/MediaStore.d.ts +4 -2
- package/dist/types/client/media-store/types.d.ts +8 -1
- package/dist/types/models/file-state.d.ts +1 -0
- package/dist/types/models/media.d.ts +2 -0
- package/dist/types/utils/createFileDataLoader.d.ts +1 -0
- package/dist/types-ts4.5/client/media-store/MediaStore.d.ts +4 -2
- package/dist/types-ts4.5/client/media-store/types.d.ts +8 -1
- package/dist/types-ts4.5/models/file-state.d.ts +1 -0
- package/dist/types-ts4.5/models/media.d.ts +2 -0
- package/dist/types-ts4.5/utils/createFileDataLoader.d.ts +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/media-client
|
|
2
2
|
|
|
3
|
+
## 28.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#170974](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/170974)
|
|
8
|
+
[`215eb993c1ea3`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/215eb993c1ea3) -
|
|
9
|
+
Added `registerCopyIntents` and `copyFile` endpoints to meida client to enable cross client copy
|
|
10
|
+
and paste
|
|
11
|
+
|
|
12
|
+
## 28.4.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- [#170821](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/170821)
|
|
17
|
+
[`52532d238c0b6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/52532d238c0b6) -
|
|
18
|
+
Enabled the deduplication of files in media-filmstrip by passing includeHashForDuplicateFiles flag
|
|
19
|
+
to /items
|
|
20
|
+
|
|
3
21
|
## 28.3.1
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -86,7 +86,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
86
86
|
});
|
|
87
87
|
});
|
|
88
88
|
// TODO: ----- ADD TICKET TO PASS TRACE ID to this.dataloader.load
|
|
89
|
-
(0, _defineProperty2.default)(this, "createDownloadFileStream", function (id, collectionName, occurrenceKey) {
|
|
89
|
+
(0, _defineProperty2.default)(this, "createDownloadFileStream", function (id, collectionName, occurrenceKey, includeHashForDuplicateFiles) {
|
|
90
90
|
var subject = (0, _createMediaSubject.createMediaSubject)();
|
|
91
91
|
var poll = new _polling.PollingFunction();
|
|
92
92
|
|
|
@@ -102,7 +102,8 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
102
102
|
_context.next = 2;
|
|
103
103
|
return _this.dataloader.load({
|
|
104
104
|
id: id,
|
|
105
|
-
collectionName: collectionName
|
|
105
|
+
collectionName: collectionName,
|
|
106
|
+
includeHashForDuplicateFiles: includeHashForDuplicateFiles
|
|
106
107
|
});
|
|
107
108
|
case 2:
|
|
108
109
|
response = _context.sent;
|
|
@@ -189,7 +190,8 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
189
190
|
var _this2 = this;
|
|
190
191
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
191
192
|
var collectionName = options.collectionName,
|
|
192
|
-
occurrenceKey = options.occurrenceKey
|
|
193
|
+
occurrenceKey = options.occurrenceKey,
|
|
194
|
+
includeHashForDuplicateFiles = options.includeHashForDuplicateFiles;
|
|
193
195
|
if (!(0, _uuidValidate.default)(id)) {
|
|
194
196
|
var _err$attributes;
|
|
195
197
|
var subject = (0, _createMediaSubject.createMediaSubject)();
|
|
@@ -215,7 +217,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
215
217
|
return (0, _mediaSubscribable.fromObservable)(subject);
|
|
216
218
|
}
|
|
217
219
|
return (0, _mediaSubscribable.fromObservable)((0, _fileStreamsCache.getFileStreamsCache)().getOrInsert(id, function () {
|
|
218
|
-
var subject = _this2.createDownloadFileStream(id, collectionName);
|
|
220
|
+
var subject = _this2.createDownloadFileStream(id, collectionName, undefined, includeHashForDuplicateFiles);
|
|
219
221
|
subject.subscribe({
|
|
220
222
|
next: function next(fileState) {
|
|
221
223
|
_this2.setFileState(id, fileState);
|
|
@@ -469,7 +469,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
469
469
|
}, {
|
|
470
470
|
key: "getItems",
|
|
471
471
|
value: function () {
|
|
472
|
-
var _getItems = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(ids, collectionName, traceContext) {
|
|
472
|
+
var _getItems = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(ids, collectionName, traceContext, includeHashForDuplicateFiles) {
|
|
473
473
|
var descriptors, metadata, options;
|
|
474
474
|
return _regenerator.default.wrap(function _callee9$(_context9) {
|
|
475
475
|
while (1) switch (_context9.prev = _context9.next) {
|
|
@@ -491,7 +491,8 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
491
491
|
},
|
|
492
492
|
headers: jsonHeaders,
|
|
493
493
|
body: JSON.stringify({
|
|
494
|
-
descriptors: descriptors
|
|
494
|
+
descriptors: descriptors,
|
|
495
|
+
includeHashForDuplicateFiles: includeHashForDuplicateFiles
|
|
495
496
|
}),
|
|
496
497
|
traceContext: traceContext
|
|
497
498
|
});
|
|
@@ -502,7 +503,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
502
503
|
}
|
|
503
504
|
}, _callee9, this);
|
|
504
505
|
}));
|
|
505
|
-
function getItems(_x27, _x28, _x29) {
|
|
506
|
+
function getItems(_x27, _x28, _x29, _x30) {
|
|
506
507
|
return _getItems.apply(this, arguments);
|
|
507
508
|
}
|
|
508
509
|
return getItems;
|
|
@@ -533,7 +534,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
533
534
|
}
|
|
534
535
|
}, _callee10, this);
|
|
535
536
|
}));
|
|
536
|
-
function getImageMetadata(
|
|
537
|
+
function getImageMetadata(_x31, _x32, _x33) {
|
|
537
538
|
return _getImageMetadata.apply(this, arguments);
|
|
538
539
|
}
|
|
539
540
|
return getImageMetadata;
|
|
@@ -566,7 +567,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
566
567
|
}
|
|
567
568
|
}, _callee11, this);
|
|
568
569
|
}));
|
|
569
|
-
function appendChunksToUpload(
|
|
570
|
+
function appendChunksToUpload(_x34, _x35, _x36, _x37) {
|
|
570
571
|
return _appendChunksToUpload.apply(this, arguments);
|
|
571
572
|
}
|
|
572
573
|
return appendChunksToUpload;
|
|
@@ -592,10 +593,71 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
592
593
|
});
|
|
593
594
|
return this.request('/file/copy/withToken', options).then((0, _helpers.createMapResponseToJson)(metadata));
|
|
594
595
|
}
|
|
596
|
+
}, {
|
|
597
|
+
key: "copyFile",
|
|
598
|
+
value: function copyFile(id, params, traceContext) {
|
|
599
|
+
var metadata = {
|
|
600
|
+
method: 'POST',
|
|
601
|
+
endpoint: '/v2/file/copy'
|
|
602
|
+
};
|
|
603
|
+
var options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
604
|
+
authContext: {
|
|
605
|
+
collectionName: params.collection
|
|
606
|
+
},
|
|
607
|
+
params: params,
|
|
608
|
+
headers: jsonHeaders,
|
|
609
|
+
body: JSON.stringify({
|
|
610
|
+
id: id
|
|
611
|
+
}),
|
|
612
|
+
traceContext: traceContext
|
|
613
|
+
});
|
|
614
|
+
return this.request('/v2/file/copy', options).then((0, _helpers.createMapResponseToJson)(metadata));
|
|
615
|
+
}
|
|
616
|
+
}, {
|
|
617
|
+
key: "registerCopyIntents",
|
|
618
|
+
value: function () {
|
|
619
|
+
var _registerCopyIntents = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12(ids, collectionName, traceContext) {
|
|
620
|
+
var files, metadata, options;
|
|
621
|
+
return _regenerator.default.wrap(function _callee12$(_context12) {
|
|
622
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
623
|
+
case 0:
|
|
624
|
+
files = ids.map(function (id) {
|
|
625
|
+
return {
|
|
626
|
+
id: id,
|
|
627
|
+
collection: collectionName
|
|
628
|
+
};
|
|
629
|
+
});
|
|
630
|
+
metadata = {
|
|
631
|
+
method: 'POST',
|
|
632
|
+
endpoint: '/file/copy/intents'
|
|
633
|
+
};
|
|
634
|
+
options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
635
|
+
authContext: {
|
|
636
|
+
collectionName: collectionName
|
|
637
|
+
},
|
|
638
|
+
headers: jsonHeaders,
|
|
639
|
+
body: JSON.stringify({
|
|
640
|
+
files: files
|
|
641
|
+
}),
|
|
642
|
+
traceContext: traceContext
|
|
643
|
+
});
|
|
644
|
+
_context12.next = 5;
|
|
645
|
+
return this.request('/file/copy/intents', options);
|
|
646
|
+
case 5:
|
|
647
|
+
case "end":
|
|
648
|
+
return _context12.stop();
|
|
649
|
+
}
|
|
650
|
+
}, _callee12, this);
|
|
651
|
+
}));
|
|
652
|
+
function registerCopyIntents(_x38, _x39, _x40) {
|
|
653
|
+
return _registerCopyIntents.apply(this, arguments);
|
|
654
|
+
}
|
|
655
|
+
return registerCopyIntents;
|
|
656
|
+
}()
|
|
595
657
|
}, {
|
|
596
658
|
key: "request",
|
|
597
659
|
value: function () {
|
|
598
|
-
var _request2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
660
|
+
var _request2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13(path) {
|
|
599
661
|
var options,
|
|
600
662
|
controller,
|
|
601
663
|
useMediaCdn,
|
|
@@ -614,22 +676,22 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
614
676
|
extendedParams,
|
|
615
677
|
url,
|
|
616
678
|
response,
|
|
617
|
-
|
|
618
|
-
return _regenerator.default.wrap(function
|
|
619
|
-
while (1) switch (
|
|
679
|
+
_args13 = arguments;
|
|
680
|
+
return _regenerator.default.wrap(function _callee13$(_context13) {
|
|
681
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
620
682
|
case 0:
|
|
621
|
-
options =
|
|
683
|
+
options = _args13.length > 1 && _args13[1] !== undefined ? _args13[1] : {
|
|
622
684
|
method: 'GET',
|
|
623
685
|
endpoint: undefined,
|
|
624
686
|
authContext: {}
|
|
625
687
|
};
|
|
626
|
-
controller =
|
|
627
|
-
useMediaCdn =
|
|
688
|
+
controller = _args13.length > 2 ? _args13[2] : undefined;
|
|
689
|
+
useMediaCdn = _args13.length > 3 ? _args13[3] : undefined;
|
|
628
690
|
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;
|
|
629
|
-
|
|
691
|
+
_context13.next = 6;
|
|
630
692
|
return this.resolveAuth(authContext);
|
|
631
693
|
case 6:
|
|
632
|
-
auth =
|
|
694
|
+
auth = _context13.sent;
|
|
633
695
|
clientId = (0, _mediaCore.isClientBasedAuth)(auth) ? auth.clientId : undefined;
|
|
634
696
|
extendedTraceContext = (0, _helpers.extendTraceContext)(traceContext);
|
|
635
697
|
extendedParams = addMediaClientParam ? _objectSpread(_objectSpread({}, params), {}, {
|
|
@@ -639,7 +701,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
639
701
|
if (useMediaCdn) {
|
|
640
702
|
url = (0, _mediaCdn.mapToMediaCdnUrl)(url, auth.token);
|
|
641
703
|
}
|
|
642
|
-
|
|
704
|
+
_context13.next = 14;
|
|
643
705
|
return (0, _request3.request)(url, {
|
|
644
706
|
method: method,
|
|
645
707
|
endpoint: endpoint,
|
|
@@ -651,17 +713,17 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
651
713
|
traceContext: extendedTraceContext
|
|
652
714
|
}, controller);
|
|
653
715
|
case 14:
|
|
654
|
-
response =
|
|
716
|
+
response = _context13.sent;
|
|
655
717
|
setKeyValueInSessionStorage(MEDIA_API_REGION, response.headers.get('x-media-region'));
|
|
656
718
|
setKeyValueInSessionStorage(MEDIA_API_ENVIRONMENT, response.headers.get('x-media-env'));
|
|
657
|
-
return
|
|
719
|
+
return _context13.abrupt("return", response);
|
|
658
720
|
case 18:
|
|
659
721
|
case "end":
|
|
660
|
-
return
|
|
722
|
+
return _context13.stop();
|
|
661
723
|
}
|
|
662
|
-
},
|
|
724
|
+
}, _callee13, this);
|
|
663
725
|
}));
|
|
664
|
-
function request(
|
|
726
|
+
function request(_x41) {
|
|
665
727
|
return _request2.apply(this, arguments);
|
|
666
728
|
}
|
|
667
729
|
return request;
|
|
@@ -669,16 +731,16 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
669
731
|
}, {
|
|
670
732
|
key: "testUrl",
|
|
671
733
|
value: function () {
|
|
672
|
-
var _testUrl = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
734
|
+
var _testUrl = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14(url) {
|
|
673
735
|
var options,
|
|
674
736
|
traceContext,
|
|
675
|
-
|
|
676
|
-
return _regenerator.default.wrap(function
|
|
677
|
-
while (1) switch (
|
|
737
|
+
_args14 = arguments;
|
|
738
|
+
return _regenerator.default.wrap(function _callee14$(_context14) {
|
|
739
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
678
740
|
case 0:
|
|
679
|
-
options =
|
|
741
|
+
options = _args14.length > 1 && _args14[1] !== undefined ? _args14[1] : {};
|
|
680
742
|
traceContext = options.traceContext;
|
|
681
|
-
|
|
743
|
+
_context14.next = 4;
|
|
682
744
|
return (0, _request3.request)(url, {
|
|
683
745
|
method: 'HEAD',
|
|
684
746
|
traceContext: (0, _helpers.extendTraceContext)(traceContext),
|
|
@@ -690,11 +752,11 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
690
752
|
});
|
|
691
753
|
case 4:
|
|
692
754
|
case "end":
|
|
693
|
-
return
|
|
755
|
+
return _context14.stop();
|
|
694
756
|
}
|
|
695
|
-
},
|
|
757
|
+
}, _callee14);
|
|
696
758
|
}));
|
|
697
|
-
function testUrl(
|
|
759
|
+
function testUrl(_x42) {
|
|
698
760
|
return _testUrl.apply(this, arguments);
|
|
699
761
|
}
|
|
700
762
|
return testUrl;
|
|
@@ -47,7 +47,8 @@ var mapMediaFileToFileState = exports.mapMediaFileToFileState = function mapMedi
|
|
|
47
47
|
mimeType = _mediaFile$data.mimeType,
|
|
48
48
|
representations = _mediaFile$data.representations,
|
|
49
49
|
createdAt = _mediaFile$data.createdAt,
|
|
50
|
-
metadataTraceContext = _mediaFile$data.metadataTraceContext
|
|
50
|
+
metadataTraceContext = _mediaFile$data.metadataTraceContext,
|
|
51
|
+
hash = _mediaFile$data.hash;
|
|
51
52
|
var baseState = {
|
|
52
53
|
id: id,
|
|
53
54
|
name: name,
|
|
@@ -57,6 +58,7 @@ var mapMediaFileToFileState = exports.mapMediaFileToFileState = function mapMedi
|
|
|
57
58
|
artifacts: artifacts,
|
|
58
59
|
representations: representations,
|
|
59
60
|
createdAt: createdAt,
|
|
61
|
+
hash: hash,
|
|
60
62
|
metadataTraceContext: metadataTraceContext
|
|
61
63
|
};
|
|
62
64
|
switch (processingStatus) {
|
|
@@ -69,11 +69,18 @@ var getItemsFromKeys = exports.getItemsFromKeys = function getItemsFromKeys(data
|
|
|
69
69
|
function createBatchLoadingFunc(mediaStore) {
|
|
70
70
|
return /*#__PURE__*/function () {
|
|
71
71
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(keys) {
|
|
72
|
-
var nonCollectionName, fileIdsByCollection, items;
|
|
72
|
+
var nonCollectionName, includeHashByCollection, fileIdsByCollection, items;
|
|
73
73
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
74
74
|
while (1) switch (_context2.prev = _context2.next) {
|
|
75
75
|
case 0:
|
|
76
76
|
nonCollectionName = '__media-single-file-collection__';
|
|
77
|
+
includeHashByCollection = keys.reduce(function (acc, key) {
|
|
78
|
+
var collectionName = key.collectionName || nonCollectionName;
|
|
79
|
+
if (key.includeHashForDuplicateFiles) {
|
|
80
|
+
acc[collectionName] = key.includeHashForDuplicateFiles;
|
|
81
|
+
}
|
|
82
|
+
return acc;
|
|
83
|
+
}, {});
|
|
77
84
|
fileIdsByCollection = keys.reduce(function (acc, key) {
|
|
78
85
|
var collectionName = key.collectionName || nonCollectionName;
|
|
79
86
|
var fileIds = acc[collectionName] || [];
|
|
@@ -86,10 +93,10 @@ function createBatchLoadingFunc(mediaStore) {
|
|
|
86
93
|
return acc;
|
|
87
94
|
}, {});
|
|
88
95
|
items = [];
|
|
89
|
-
_context2.next =
|
|
96
|
+
_context2.next = 6;
|
|
90
97
|
return Promise.all(Object.keys(fileIdsByCollection).map( /*#__PURE__*/function () {
|
|
91
98
|
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(collectionNameKey) {
|
|
92
|
-
var metadataTraceContext, fileIds, collectionName, response, itemsWithMetadataTraceContext, itemsIds, fileIdsNotFound;
|
|
99
|
+
var metadataTraceContext, fileIds, includeHashForDuplicateFiles, collectionName, response, itemsWithMetadataTraceContext, itemsIds, fileIdsNotFound;
|
|
93
100
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
94
101
|
while (1) switch (_context.prev = _context.next) {
|
|
95
102
|
case 0:
|
|
@@ -98,11 +105,12 @@ function createBatchLoadingFunc(mediaStore) {
|
|
|
98
105
|
spanId: (0, _mediaCommon.getRandomHex)(8)
|
|
99
106
|
};
|
|
100
107
|
fileIds = fileIdsByCollection[collectionNameKey];
|
|
108
|
+
includeHashForDuplicateFiles = includeHashByCollection[collectionNameKey];
|
|
101
109
|
collectionName = collectionNameKey === nonCollectionName ? undefined : collectionNameKey;
|
|
102
|
-
_context.prev =
|
|
103
|
-
_context.next =
|
|
104
|
-
return mediaStore.getItems(fileIds, collectionName, metadataTraceContext);
|
|
105
|
-
case
|
|
110
|
+
_context.prev = 4;
|
|
111
|
+
_context.next = 7;
|
|
112
|
+
return mediaStore.getItems(fileIds, collectionName, metadataTraceContext, includeHashForDuplicateFiles);
|
|
113
|
+
case 7:
|
|
106
114
|
response = _context.sent;
|
|
107
115
|
itemsWithMetadataTraceContext = response.data.items.map(function (item) {
|
|
108
116
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
@@ -126,11 +134,11 @@ function createBatchLoadingFunc(mediaStore) {
|
|
|
126
134
|
metadataTraceContext: metadataTraceContext
|
|
127
135
|
});
|
|
128
136
|
});
|
|
129
|
-
_context.next =
|
|
137
|
+
_context.next = 18;
|
|
130
138
|
break;
|
|
131
|
-
case
|
|
132
|
-
_context.prev =
|
|
133
|
-
_context.t0 = _context["catch"](
|
|
139
|
+
case 15:
|
|
140
|
+
_context.prev = 15;
|
|
141
|
+
_context.t0 = _context["catch"](4);
|
|
134
142
|
fileIds.forEach(function (fileId) {
|
|
135
143
|
items.push({
|
|
136
144
|
id: fileId,
|
|
@@ -138,19 +146,19 @@ function createBatchLoadingFunc(mediaStore) {
|
|
|
138
146
|
error: _context.t0
|
|
139
147
|
});
|
|
140
148
|
});
|
|
141
|
-
case
|
|
149
|
+
case 18:
|
|
142
150
|
case "end":
|
|
143
151
|
return _context.stop();
|
|
144
152
|
}
|
|
145
|
-
}, _callee, null, [[
|
|
153
|
+
}, _callee, null, [[4, 15]]);
|
|
146
154
|
}));
|
|
147
155
|
return function (_x2) {
|
|
148
156
|
return _ref2.apply(this, arguments);
|
|
149
157
|
};
|
|
150
158
|
}()));
|
|
151
|
-
case 5:
|
|
152
|
-
return _context2.abrupt("return", getItemsFromKeys(keys, items));
|
|
153
159
|
case 6:
|
|
160
|
+
return _context2.abrupt("return", getItemsFromKeys(keys, items));
|
|
161
|
+
case 7:
|
|
154
162
|
case "end":
|
|
155
163
|
return _context2.stop();
|
|
156
164
|
}
|
|
@@ -60,7 +60,7 @@ export class FileFetcherImpl {
|
|
|
60
60
|
});
|
|
61
61
|
});
|
|
62
62
|
// TODO: ----- ADD TICKET TO PASS TRACE ID to this.dataloader.load
|
|
63
|
-
_defineProperty(this, "createDownloadFileStream", (id, collectionName, occurrenceKey) => {
|
|
63
|
+
_defineProperty(this, "createDownloadFileStream", (id, collectionName, occurrenceKey, includeHashForDuplicateFiles) => {
|
|
64
64
|
const subject = createMediaSubject();
|
|
65
65
|
const poll = new PollingFunction();
|
|
66
66
|
|
|
@@ -69,7 +69,8 @@ export class FileFetcherImpl {
|
|
|
69
69
|
poll.execute(async () => {
|
|
70
70
|
const response = await this.dataloader.load({
|
|
71
71
|
id,
|
|
72
|
-
collectionName
|
|
72
|
+
collectionName,
|
|
73
|
+
includeHashForDuplicateFiles
|
|
73
74
|
});
|
|
74
75
|
if (isNotFoundMediaItemDetails(response)) {
|
|
75
76
|
throw new FileFetcherError('emptyItems', id, {
|
|
@@ -142,7 +143,8 @@ export class FileFetcherImpl {
|
|
|
142
143
|
getFileState(id, options = {}) {
|
|
143
144
|
const {
|
|
144
145
|
collectionName,
|
|
145
|
-
occurrenceKey
|
|
146
|
+
occurrenceKey,
|
|
147
|
+
includeHashForDuplicateFiles
|
|
146
148
|
} = options;
|
|
147
149
|
if (!isValidId(id)) {
|
|
148
150
|
var _err$attributes;
|
|
@@ -173,7 +175,7 @@ export class FileFetcherImpl {
|
|
|
173
175
|
return fromObservable(subject);
|
|
174
176
|
}
|
|
175
177
|
return fromObservable(getFileStreamsCache().getOrInsert(id, () => {
|
|
176
|
-
const subject = this.createDownloadFileStream(id, collectionName);
|
|
178
|
+
const subject = this.createDownloadFileStream(id, collectionName, undefined, includeHashForDuplicateFiles);
|
|
177
179
|
subject.subscribe({
|
|
178
180
|
next: fileState => {
|
|
179
181
|
this.setFileState(id, fileState);
|
|
@@ -275,7 +275,7 @@ export class MediaStore {
|
|
|
275
275
|
};
|
|
276
276
|
return this.request(`/file/${id}/${imageEndpoint}`, options, controller, true).then(createMapResponseToBlob(metadata));
|
|
277
277
|
}
|
|
278
|
-
async getItems(ids, collectionName, traceContext) {
|
|
278
|
+
async getItems(ids, collectionName, traceContext, includeHashForDuplicateFiles) {
|
|
279
279
|
const descriptors = ids.map(id => ({
|
|
280
280
|
type: 'file',
|
|
281
281
|
id,
|
|
@@ -292,7 +292,8 @@ export class MediaStore {
|
|
|
292
292
|
},
|
|
293
293
|
headers: jsonHeaders,
|
|
294
294
|
body: JSON.stringify({
|
|
295
|
-
descriptors
|
|
295
|
+
descriptors,
|
|
296
|
+
includeHashForDuplicateFiles
|
|
296
297
|
}),
|
|
297
298
|
traceContext
|
|
298
299
|
};
|
|
@@ -349,6 +350,47 @@ export class MediaStore {
|
|
|
349
350
|
};
|
|
350
351
|
return this.request('/file/copy/withToken', options).then(createMapResponseToJson(metadata));
|
|
351
352
|
}
|
|
353
|
+
copyFile(id, params, traceContext) {
|
|
354
|
+
const metadata = {
|
|
355
|
+
method: 'POST',
|
|
356
|
+
endpoint: '/v2/file/copy'
|
|
357
|
+
};
|
|
358
|
+
const options = {
|
|
359
|
+
...metadata,
|
|
360
|
+
authContext: {
|
|
361
|
+
collectionName: params.collection
|
|
362
|
+
},
|
|
363
|
+
params,
|
|
364
|
+
headers: jsonHeaders,
|
|
365
|
+
body: JSON.stringify({
|
|
366
|
+
id
|
|
367
|
+
}),
|
|
368
|
+
traceContext
|
|
369
|
+
};
|
|
370
|
+
return this.request('/v2/file/copy', options).then(createMapResponseToJson(metadata));
|
|
371
|
+
}
|
|
372
|
+
async registerCopyIntents(ids, collectionName, traceContext) {
|
|
373
|
+
const files = ids.map(id => ({
|
|
374
|
+
id,
|
|
375
|
+
collection: collectionName
|
|
376
|
+
}));
|
|
377
|
+
const metadata = {
|
|
378
|
+
method: 'POST',
|
|
379
|
+
endpoint: '/file/copy/intents'
|
|
380
|
+
};
|
|
381
|
+
const options = {
|
|
382
|
+
...metadata,
|
|
383
|
+
authContext: {
|
|
384
|
+
collectionName
|
|
385
|
+
},
|
|
386
|
+
headers: jsonHeaders,
|
|
387
|
+
body: JSON.stringify({
|
|
388
|
+
files
|
|
389
|
+
}),
|
|
390
|
+
traceContext
|
|
391
|
+
};
|
|
392
|
+
await this.request('/file/copy/intents', options);
|
|
393
|
+
}
|
|
352
394
|
async request(path, options = {
|
|
353
395
|
method: 'GET',
|
|
354
396
|
endpoint: undefined,
|
|
@@ -25,7 +25,8 @@ export const mapMediaFileToFileState = mediaFile => {
|
|
|
25
25
|
mimeType,
|
|
26
26
|
representations,
|
|
27
27
|
createdAt,
|
|
28
|
-
metadataTraceContext
|
|
28
|
+
metadataTraceContext,
|
|
29
|
+
hash
|
|
29
30
|
} = mediaFile.data;
|
|
30
31
|
const baseState = {
|
|
31
32
|
id,
|
|
@@ -36,6 +37,7 @@ export const mapMediaFileToFileState = mediaFile => {
|
|
|
36
37
|
artifacts,
|
|
37
38
|
representations,
|
|
38
39
|
createdAt,
|
|
40
|
+
hash,
|
|
39
41
|
metadataTraceContext
|
|
40
42
|
};
|
|
41
43
|
switch (processingStatus) {
|
|
@@ -56,6 +56,13 @@ export const getItemsFromKeys = (dataloaderKeys, fileItems) => {
|
|
|
56
56
|
export function createBatchLoadingFunc(mediaStore) {
|
|
57
57
|
return async keys => {
|
|
58
58
|
const nonCollectionName = '__media-single-file-collection__';
|
|
59
|
+
const includeHashByCollection = keys.reduce((acc, key) => {
|
|
60
|
+
const collectionName = key.collectionName || nonCollectionName;
|
|
61
|
+
if (key.includeHashForDuplicateFiles) {
|
|
62
|
+
acc[collectionName] = key.includeHashForDuplicateFiles;
|
|
63
|
+
}
|
|
64
|
+
return acc;
|
|
65
|
+
}, {});
|
|
59
66
|
const fileIdsByCollection = keys.reduce((acc, key) => {
|
|
60
67
|
const collectionName = key.collectionName || nonCollectionName;
|
|
61
68
|
const fileIds = acc[collectionName] || [];
|
|
@@ -74,9 +81,10 @@ export function createBatchLoadingFunc(mediaStore) {
|
|
|
74
81
|
spanId: getRandomHex(8)
|
|
75
82
|
};
|
|
76
83
|
const fileIds = fileIdsByCollection[collectionNameKey];
|
|
84
|
+
const includeHashForDuplicateFiles = includeHashByCollection[collectionNameKey];
|
|
77
85
|
const collectionName = collectionNameKey === nonCollectionName ? undefined : collectionNameKey;
|
|
78
86
|
try {
|
|
79
|
-
const response = await mediaStore.getItems(fileIds, collectionName, metadataTraceContext);
|
|
87
|
+
const response = await mediaStore.getItems(fileIds, collectionName, metadataTraceContext, includeHashForDuplicateFiles);
|
|
80
88
|
const itemsWithMetadataTraceContext = response.data.items.map(item => ({
|
|
81
89
|
...item,
|
|
82
90
|
metadataTraceContext
|
|
@@ -68,7 +68,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
68
68
|
});
|
|
69
69
|
});
|
|
70
70
|
// TODO: ----- ADD TICKET TO PASS TRACE ID to this.dataloader.load
|
|
71
|
-
_defineProperty(this, "createDownloadFileStream", function (id, collectionName, occurrenceKey) {
|
|
71
|
+
_defineProperty(this, "createDownloadFileStream", function (id, collectionName, occurrenceKey, includeHashForDuplicateFiles) {
|
|
72
72
|
var subject = createMediaSubject();
|
|
73
73
|
var poll = new PollingFunction();
|
|
74
74
|
|
|
@@ -84,7 +84,8 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
84
84
|
_context.next = 2;
|
|
85
85
|
return _this.dataloader.load({
|
|
86
86
|
id: id,
|
|
87
|
-
collectionName: collectionName
|
|
87
|
+
collectionName: collectionName,
|
|
88
|
+
includeHashForDuplicateFiles: includeHashForDuplicateFiles
|
|
88
89
|
});
|
|
89
90
|
case 2:
|
|
90
91
|
response = _context.sent;
|
|
@@ -171,7 +172,8 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
171
172
|
var _this2 = this;
|
|
172
173
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
173
174
|
var collectionName = options.collectionName,
|
|
174
|
-
occurrenceKey = options.occurrenceKey
|
|
175
|
+
occurrenceKey = options.occurrenceKey,
|
|
176
|
+
includeHashForDuplicateFiles = options.includeHashForDuplicateFiles;
|
|
175
177
|
if (!isValidId(id)) {
|
|
176
178
|
var _err$attributes;
|
|
177
179
|
var subject = createMediaSubject();
|
|
@@ -197,7 +199,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
197
199
|
return fromObservable(subject);
|
|
198
200
|
}
|
|
199
201
|
return fromObservable(getFileStreamsCache().getOrInsert(id, function () {
|
|
200
|
-
var subject = _this2.createDownloadFileStream(id, collectionName);
|
|
202
|
+
var subject = _this2.createDownloadFileStream(id, collectionName, undefined, includeHashForDuplicateFiles);
|
|
201
203
|
subject.subscribe({
|
|
202
204
|
next: function next(fileState) {
|
|
203
205
|
_this2.setFileState(id, fileState);
|
|
@@ -463,7 +463,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
463
463
|
}, {
|
|
464
464
|
key: "getItems",
|
|
465
465
|
value: function () {
|
|
466
|
-
var _getItems = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(ids, collectionName, traceContext) {
|
|
466
|
+
var _getItems = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(ids, collectionName, traceContext, includeHashForDuplicateFiles) {
|
|
467
467
|
var descriptors, metadata, options;
|
|
468
468
|
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
469
469
|
while (1) switch (_context9.prev = _context9.next) {
|
|
@@ -485,7 +485,8 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
485
485
|
},
|
|
486
486
|
headers: jsonHeaders,
|
|
487
487
|
body: JSON.stringify({
|
|
488
|
-
descriptors: descriptors
|
|
488
|
+
descriptors: descriptors,
|
|
489
|
+
includeHashForDuplicateFiles: includeHashForDuplicateFiles
|
|
489
490
|
}),
|
|
490
491
|
traceContext: traceContext
|
|
491
492
|
});
|
|
@@ -496,7 +497,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
496
497
|
}
|
|
497
498
|
}, _callee9, this);
|
|
498
499
|
}));
|
|
499
|
-
function getItems(_x27, _x28, _x29) {
|
|
500
|
+
function getItems(_x27, _x28, _x29, _x30) {
|
|
500
501
|
return _getItems.apply(this, arguments);
|
|
501
502
|
}
|
|
502
503
|
return getItems;
|
|
@@ -527,7 +528,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
527
528
|
}
|
|
528
529
|
}, _callee10, this);
|
|
529
530
|
}));
|
|
530
|
-
function getImageMetadata(
|
|
531
|
+
function getImageMetadata(_x31, _x32, _x33) {
|
|
531
532
|
return _getImageMetadata.apply(this, arguments);
|
|
532
533
|
}
|
|
533
534
|
return getImageMetadata;
|
|
@@ -560,7 +561,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
560
561
|
}
|
|
561
562
|
}, _callee11, this);
|
|
562
563
|
}));
|
|
563
|
-
function appendChunksToUpload(
|
|
564
|
+
function appendChunksToUpload(_x34, _x35, _x36, _x37) {
|
|
564
565
|
return _appendChunksToUpload.apply(this, arguments);
|
|
565
566
|
}
|
|
566
567
|
return appendChunksToUpload;
|
|
@@ -586,10 +587,71 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
586
587
|
});
|
|
587
588
|
return this.request('/file/copy/withToken', options).then(createMapResponseToJson(metadata));
|
|
588
589
|
}
|
|
590
|
+
}, {
|
|
591
|
+
key: "copyFile",
|
|
592
|
+
value: function copyFile(id, params, traceContext) {
|
|
593
|
+
var metadata = {
|
|
594
|
+
method: 'POST',
|
|
595
|
+
endpoint: '/v2/file/copy'
|
|
596
|
+
};
|
|
597
|
+
var options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
598
|
+
authContext: {
|
|
599
|
+
collectionName: params.collection
|
|
600
|
+
},
|
|
601
|
+
params: params,
|
|
602
|
+
headers: jsonHeaders,
|
|
603
|
+
body: JSON.stringify({
|
|
604
|
+
id: id
|
|
605
|
+
}),
|
|
606
|
+
traceContext: traceContext
|
|
607
|
+
});
|
|
608
|
+
return this.request('/v2/file/copy', options).then(createMapResponseToJson(metadata));
|
|
609
|
+
}
|
|
610
|
+
}, {
|
|
611
|
+
key: "registerCopyIntents",
|
|
612
|
+
value: function () {
|
|
613
|
+
var _registerCopyIntents = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(ids, collectionName, traceContext) {
|
|
614
|
+
var files, metadata, options;
|
|
615
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
616
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
617
|
+
case 0:
|
|
618
|
+
files = ids.map(function (id) {
|
|
619
|
+
return {
|
|
620
|
+
id: id,
|
|
621
|
+
collection: collectionName
|
|
622
|
+
};
|
|
623
|
+
});
|
|
624
|
+
metadata = {
|
|
625
|
+
method: 'POST',
|
|
626
|
+
endpoint: '/file/copy/intents'
|
|
627
|
+
};
|
|
628
|
+
options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
629
|
+
authContext: {
|
|
630
|
+
collectionName: collectionName
|
|
631
|
+
},
|
|
632
|
+
headers: jsonHeaders,
|
|
633
|
+
body: JSON.stringify({
|
|
634
|
+
files: files
|
|
635
|
+
}),
|
|
636
|
+
traceContext: traceContext
|
|
637
|
+
});
|
|
638
|
+
_context12.next = 5;
|
|
639
|
+
return this.request('/file/copy/intents', options);
|
|
640
|
+
case 5:
|
|
641
|
+
case "end":
|
|
642
|
+
return _context12.stop();
|
|
643
|
+
}
|
|
644
|
+
}, _callee12, this);
|
|
645
|
+
}));
|
|
646
|
+
function registerCopyIntents(_x38, _x39, _x40) {
|
|
647
|
+
return _registerCopyIntents.apply(this, arguments);
|
|
648
|
+
}
|
|
649
|
+
return registerCopyIntents;
|
|
650
|
+
}()
|
|
589
651
|
}, {
|
|
590
652
|
key: "request",
|
|
591
653
|
value: function () {
|
|
592
|
-
var _request2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
654
|
+
var _request2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(path) {
|
|
593
655
|
var options,
|
|
594
656
|
controller,
|
|
595
657
|
useMediaCdn,
|
|
@@ -608,22 +670,22 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
608
670
|
extendedParams,
|
|
609
671
|
url,
|
|
610
672
|
response,
|
|
611
|
-
|
|
612
|
-
return _regeneratorRuntime.wrap(function
|
|
613
|
-
while (1) switch (
|
|
673
|
+
_args13 = arguments;
|
|
674
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
675
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
614
676
|
case 0:
|
|
615
|
-
options =
|
|
677
|
+
options = _args13.length > 1 && _args13[1] !== undefined ? _args13[1] : {
|
|
616
678
|
method: 'GET',
|
|
617
679
|
endpoint: undefined,
|
|
618
680
|
authContext: {}
|
|
619
681
|
};
|
|
620
|
-
controller =
|
|
621
|
-
useMediaCdn =
|
|
682
|
+
controller = _args13.length > 2 ? _args13[2] : undefined;
|
|
683
|
+
useMediaCdn = _args13.length > 3 ? _args13[3] : undefined;
|
|
622
684
|
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;
|
|
623
|
-
|
|
685
|
+
_context13.next = 6;
|
|
624
686
|
return this.resolveAuth(authContext);
|
|
625
687
|
case 6:
|
|
626
|
-
auth =
|
|
688
|
+
auth = _context13.sent;
|
|
627
689
|
clientId = isClientBasedAuth(auth) ? auth.clientId : undefined;
|
|
628
690
|
extendedTraceContext = extendTraceContext(traceContext);
|
|
629
691
|
extendedParams = addMediaClientParam ? _objectSpread(_objectSpread({}, params), {}, {
|
|
@@ -633,7 +695,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
633
695
|
if (useMediaCdn) {
|
|
634
696
|
url = mapToMediaCdnUrl(url, auth.token);
|
|
635
697
|
}
|
|
636
|
-
|
|
698
|
+
_context13.next = 14;
|
|
637
699
|
return _request(url, {
|
|
638
700
|
method: method,
|
|
639
701
|
endpoint: endpoint,
|
|
@@ -645,17 +707,17 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
645
707
|
traceContext: extendedTraceContext
|
|
646
708
|
}, controller);
|
|
647
709
|
case 14:
|
|
648
|
-
response =
|
|
710
|
+
response = _context13.sent;
|
|
649
711
|
setKeyValueInSessionStorage(MEDIA_API_REGION, response.headers.get('x-media-region'));
|
|
650
712
|
setKeyValueInSessionStorage(MEDIA_API_ENVIRONMENT, response.headers.get('x-media-env'));
|
|
651
|
-
return
|
|
713
|
+
return _context13.abrupt("return", response);
|
|
652
714
|
case 18:
|
|
653
715
|
case "end":
|
|
654
|
-
return
|
|
716
|
+
return _context13.stop();
|
|
655
717
|
}
|
|
656
|
-
},
|
|
718
|
+
}, _callee13, this);
|
|
657
719
|
}));
|
|
658
|
-
function request(
|
|
720
|
+
function request(_x41) {
|
|
659
721
|
return _request2.apply(this, arguments);
|
|
660
722
|
}
|
|
661
723
|
return request;
|
|
@@ -663,16 +725,16 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
663
725
|
}, {
|
|
664
726
|
key: "testUrl",
|
|
665
727
|
value: function () {
|
|
666
|
-
var _testUrl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
728
|
+
var _testUrl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(url) {
|
|
667
729
|
var options,
|
|
668
730
|
traceContext,
|
|
669
|
-
|
|
670
|
-
return _regeneratorRuntime.wrap(function
|
|
671
|
-
while (1) switch (
|
|
731
|
+
_args14 = arguments;
|
|
732
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
733
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
672
734
|
case 0:
|
|
673
|
-
options =
|
|
735
|
+
options = _args14.length > 1 && _args14[1] !== undefined ? _args14[1] : {};
|
|
674
736
|
traceContext = options.traceContext;
|
|
675
|
-
|
|
737
|
+
_context14.next = 4;
|
|
676
738
|
return _request(url, {
|
|
677
739
|
method: 'HEAD',
|
|
678
740
|
traceContext: extendTraceContext(traceContext),
|
|
@@ -684,11 +746,11 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
684
746
|
});
|
|
685
747
|
case 4:
|
|
686
748
|
case "end":
|
|
687
|
-
return
|
|
749
|
+
return _context14.stop();
|
|
688
750
|
}
|
|
689
|
-
},
|
|
751
|
+
}, _callee14);
|
|
690
752
|
}));
|
|
691
|
-
function testUrl(
|
|
753
|
+
function testUrl(_x42) {
|
|
692
754
|
return _testUrl.apply(this, arguments);
|
|
693
755
|
}
|
|
694
756
|
return testUrl;
|
|
@@ -40,7 +40,8 @@ export var mapMediaFileToFileState = function mapMediaFileToFileState(mediaFile)
|
|
|
40
40
|
mimeType = _mediaFile$data.mimeType,
|
|
41
41
|
representations = _mediaFile$data.representations,
|
|
42
42
|
createdAt = _mediaFile$data.createdAt,
|
|
43
|
-
metadataTraceContext = _mediaFile$data.metadataTraceContext
|
|
43
|
+
metadataTraceContext = _mediaFile$data.metadataTraceContext,
|
|
44
|
+
hash = _mediaFile$data.hash;
|
|
44
45
|
var baseState = {
|
|
45
46
|
id: id,
|
|
46
47
|
name: name,
|
|
@@ -50,6 +51,7 @@ export var mapMediaFileToFileState = function mapMediaFileToFileState(mediaFile)
|
|
|
50
51
|
artifacts: artifacts,
|
|
51
52
|
representations: representations,
|
|
52
53
|
createdAt: createdAt,
|
|
54
|
+
hash: hash,
|
|
53
55
|
metadataTraceContext: metadataTraceContext
|
|
54
56
|
};
|
|
55
57
|
switch (processingStatus) {
|
|
@@ -59,11 +59,18 @@ export var getItemsFromKeys = function getItemsFromKeys(dataloaderKeys, fileItem
|
|
|
59
59
|
export function createBatchLoadingFunc(mediaStore) {
|
|
60
60
|
return /*#__PURE__*/function () {
|
|
61
61
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(keys) {
|
|
62
|
-
var nonCollectionName, fileIdsByCollection, items;
|
|
62
|
+
var nonCollectionName, includeHashByCollection, fileIdsByCollection, items;
|
|
63
63
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
64
64
|
while (1) switch (_context2.prev = _context2.next) {
|
|
65
65
|
case 0:
|
|
66
66
|
nonCollectionName = '__media-single-file-collection__';
|
|
67
|
+
includeHashByCollection = keys.reduce(function (acc, key) {
|
|
68
|
+
var collectionName = key.collectionName || nonCollectionName;
|
|
69
|
+
if (key.includeHashForDuplicateFiles) {
|
|
70
|
+
acc[collectionName] = key.includeHashForDuplicateFiles;
|
|
71
|
+
}
|
|
72
|
+
return acc;
|
|
73
|
+
}, {});
|
|
67
74
|
fileIdsByCollection = keys.reduce(function (acc, key) {
|
|
68
75
|
var collectionName = key.collectionName || nonCollectionName;
|
|
69
76
|
var fileIds = acc[collectionName] || [];
|
|
@@ -76,10 +83,10 @@ export function createBatchLoadingFunc(mediaStore) {
|
|
|
76
83
|
return acc;
|
|
77
84
|
}, {});
|
|
78
85
|
items = [];
|
|
79
|
-
_context2.next =
|
|
86
|
+
_context2.next = 6;
|
|
80
87
|
return Promise.all(Object.keys(fileIdsByCollection).map( /*#__PURE__*/function () {
|
|
81
88
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(collectionNameKey) {
|
|
82
|
-
var metadataTraceContext, fileIds, collectionName, response, itemsWithMetadataTraceContext, itemsIds, fileIdsNotFound;
|
|
89
|
+
var metadataTraceContext, fileIds, includeHashForDuplicateFiles, collectionName, response, itemsWithMetadataTraceContext, itemsIds, fileIdsNotFound;
|
|
83
90
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
84
91
|
while (1) switch (_context.prev = _context.next) {
|
|
85
92
|
case 0:
|
|
@@ -88,11 +95,12 @@ export function createBatchLoadingFunc(mediaStore) {
|
|
|
88
95
|
spanId: getRandomHex(8)
|
|
89
96
|
};
|
|
90
97
|
fileIds = fileIdsByCollection[collectionNameKey];
|
|
98
|
+
includeHashForDuplicateFiles = includeHashByCollection[collectionNameKey];
|
|
91
99
|
collectionName = collectionNameKey === nonCollectionName ? undefined : collectionNameKey;
|
|
92
|
-
_context.prev =
|
|
93
|
-
_context.next =
|
|
94
|
-
return mediaStore.getItems(fileIds, collectionName, metadataTraceContext);
|
|
95
|
-
case
|
|
100
|
+
_context.prev = 4;
|
|
101
|
+
_context.next = 7;
|
|
102
|
+
return mediaStore.getItems(fileIds, collectionName, metadataTraceContext, includeHashForDuplicateFiles);
|
|
103
|
+
case 7:
|
|
96
104
|
response = _context.sent;
|
|
97
105
|
itemsWithMetadataTraceContext = response.data.items.map(function (item) {
|
|
98
106
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
@@ -116,11 +124,11 @@ export function createBatchLoadingFunc(mediaStore) {
|
|
|
116
124
|
metadataTraceContext: metadataTraceContext
|
|
117
125
|
});
|
|
118
126
|
});
|
|
119
|
-
_context.next =
|
|
127
|
+
_context.next = 18;
|
|
120
128
|
break;
|
|
121
|
-
case
|
|
122
|
-
_context.prev =
|
|
123
|
-
_context.t0 = _context["catch"](
|
|
129
|
+
case 15:
|
|
130
|
+
_context.prev = 15;
|
|
131
|
+
_context.t0 = _context["catch"](4);
|
|
124
132
|
fileIds.forEach(function (fileId) {
|
|
125
133
|
items.push({
|
|
126
134
|
id: fileId,
|
|
@@ -128,19 +136,19 @@ export function createBatchLoadingFunc(mediaStore) {
|
|
|
128
136
|
error: _context.t0
|
|
129
137
|
});
|
|
130
138
|
});
|
|
131
|
-
case
|
|
139
|
+
case 18:
|
|
132
140
|
case "end":
|
|
133
141
|
return _context.stop();
|
|
134
142
|
}
|
|
135
|
-
}, _callee, null, [[
|
|
143
|
+
}, _callee, null, [[4, 15]]);
|
|
136
144
|
}));
|
|
137
145
|
return function (_x2) {
|
|
138
146
|
return _ref2.apply(this, arguments);
|
|
139
147
|
};
|
|
140
148
|
}()));
|
|
141
|
-
case 5:
|
|
142
|
-
return _context2.abrupt("return", getItemsFromKeys(keys, items));
|
|
143
149
|
case 6:
|
|
150
|
+
return _context2.abrupt("return", getItemsFromKeys(keys, items));
|
|
151
|
+
case 7:
|
|
144
152
|
case "end":
|
|
145
153
|
return _context2.stop();
|
|
146
154
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type AuthContext, type MediaApiConfig, type Auth } from '@atlaskit/media-core';
|
|
2
2
|
import { type MediaTraceContext } from '@atlaskit/media-common';
|
|
3
3
|
import { type MediaFileArtifacts } from '@atlaskit/media-state';
|
|
4
|
-
import type { ItemsPayload, ImageMetadata, MediaStoreResponse, MediaStoreTouchFileParams, TouchFileDescriptor, MediaStoreTouchFileBody, RejectedTouchFile, MediaStoreRequestOptions, MediaStoreCreateFileFromUploadParams, MediaStoreCreateFileFromUploadBody, MediaStoreGetFileParams, MediaStoreGetFileImageParams, MediaStoreCopyFileWithTokenBody, MediaStoreCopyFileWithTokenParams, AppendChunksToUploadRequestBody, TouchedFiles, MediaApi } from './types';
|
|
4
|
+
import type { ItemsPayload, ImageMetadata, MediaStoreResponse, MediaStoreTouchFileParams, TouchFileDescriptor, MediaStoreTouchFileBody, RejectedTouchFile, MediaStoreRequestOptions, MediaStoreCreateFileFromUploadParams, MediaStoreCreateFileFromUploadBody, MediaStoreGetFileParams, MediaStoreGetFileImageParams, MediaStoreCopyFileWithTokenBody, MediaStoreCopyFileWithTokenParams, AppendChunksToUploadRequestBody, TouchedFiles, MediaApi, CopyFileParams } from './types';
|
|
5
5
|
import { type MediaFile, type MediaUpload } from '../../models/media';
|
|
6
6
|
import { ChunkHashAlgorithm } from '@atlaskit/media-core';
|
|
7
7
|
export declare class MediaStore implements MediaApi {
|
|
@@ -22,12 +22,14 @@ export declare class MediaStore implements MediaApi {
|
|
|
22
22
|
getFileBinaryURL(id: string, collectionName?: string, maxAge?: number): Promise<string>;
|
|
23
23
|
getArtifactURL(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string): Promise<string>;
|
|
24
24
|
getImage(id: string, params?: MediaStoreGetFileImageParams, controller?: AbortController, fetchMaxRes?: boolean, traceContext?: MediaTraceContext): Promise<Blob>;
|
|
25
|
-
getItems(ids: string[], collectionName?: string, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<ItemsPayload>>;
|
|
25
|
+
getItems(ids: string[], collectionName?: string, traceContext?: MediaTraceContext, includeHashForDuplicateFiles?: boolean): Promise<MediaStoreResponse<ItemsPayload>>;
|
|
26
26
|
getImageMetadata(id: string, params?: MediaStoreGetFileImageParams, traceContext?: MediaTraceContext): Promise<{
|
|
27
27
|
metadata: ImageMetadata;
|
|
28
28
|
}>;
|
|
29
29
|
appendChunksToUpload(uploadId: string, body: AppendChunksToUploadRequestBody, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
|
|
30
30
|
copyFileWithToken(body: MediaStoreCopyFileWithTokenBody, params: MediaStoreCopyFileWithTokenParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaFile>>;
|
|
31
|
+
copyFile(id: string, params: CopyFileParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaFile>>;
|
|
32
|
+
registerCopyIntents(ids: string[], collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
|
|
31
33
|
request(path: string, options?: MediaStoreRequestOptions, controller?: AbortController, useMediaCdn?: boolean): Promise<Response>;
|
|
32
34
|
testUrl(url: string, options?: {
|
|
33
35
|
traceContext?: MediaTraceContext;
|
|
@@ -113,6 +113,11 @@ export interface SourceFile {
|
|
|
113
113
|
export type MediaStoreCopyFileWithTokenBody = {
|
|
114
114
|
sourceFile: SourceFile;
|
|
115
115
|
};
|
|
116
|
+
export type CopyFileParams = {
|
|
117
|
+
sourceCollection?: string;
|
|
118
|
+
collection?: string;
|
|
119
|
+
replaceFileId?: string;
|
|
120
|
+
};
|
|
116
121
|
export type MediaStoreCopyFileWithTokenParams = {
|
|
117
122
|
readonly collection?: string;
|
|
118
123
|
readonly replaceFileId?: string;
|
|
@@ -160,12 +165,14 @@ export interface MediaApi {
|
|
|
160
165
|
getFileBinaryURL: (id: string, collectionName?: string) => Promise<string>;
|
|
161
166
|
getArtifactURL: (artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string) => Promise<string>;
|
|
162
167
|
getImage: (id: string, params?: MediaStoreGetFileImageParams, controller?: AbortController, fetchMaxRes?: boolean, traceContext?: MediaTraceContext) => Promise<Blob>;
|
|
163
|
-
getItems: (ids: string[], collectionName?: string, traceContext?: MediaTraceContext) => Promise<MediaStoreResponse<ItemsPayload>>;
|
|
168
|
+
getItems: (ids: string[], collectionName?: string, traceContext?: MediaTraceContext, includeHashForDuplicateFiles?: boolean) => Promise<MediaStoreResponse<ItemsPayload>>;
|
|
164
169
|
getImageMetadata: (id: string, params?: MediaStoreGetFileImageParams, traceContext?: MediaTraceContext) => Promise<{
|
|
165
170
|
metadata: ImageMetadata;
|
|
166
171
|
}>;
|
|
167
172
|
appendChunksToUpload: (uploadId: string, body: AppendChunksToUploadRequestBody, collectionName?: string, traceContext?: MediaTraceContext) => Promise<void>;
|
|
168
173
|
copyFileWithToken: (body: MediaStoreCopyFileWithTokenBody, params: MediaStoreCopyFileWithTokenParams, traceContext?: MediaTraceContext) => Promise<MediaStoreResponse<MediaFile>>;
|
|
174
|
+
copyFile: (id: string, params: CopyFileParams) => Promise<MediaStoreResponse<MediaFile>>;
|
|
175
|
+
registerCopyIntents: (ids: string[], collectionName: string) => Promise<void>;
|
|
169
176
|
request: (path: string, options: MediaStoreRequestOptions, controller?: AbortController) => Promise<Response>;
|
|
170
177
|
testUrl: (url: string, options?: {
|
|
171
178
|
traceContext?: MediaTraceContext;
|
|
@@ -13,6 +13,7 @@ export type MediaFile = {
|
|
|
13
13
|
readonly artifacts: MediaFileArtifacts;
|
|
14
14
|
readonly representations: MediaRepresentations;
|
|
15
15
|
readonly createdAt?: number;
|
|
16
|
+
readonly hash?: string;
|
|
16
17
|
readonly metadataTraceContext?: MediaTraceContext;
|
|
17
18
|
};
|
|
18
19
|
export type MediaItemDetails = {
|
|
@@ -24,6 +25,7 @@ export type MediaItemDetails = {
|
|
|
24
25
|
readonly artifacts: MediaFileArtifacts;
|
|
25
26
|
readonly representations: MediaRepresentations;
|
|
26
27
|
readonly createdAt?: number;
|
|
28
|
+
readonly hash?: string;
|
|
27
29
|
readonly metadataTraceContext?: MediaTraceContext;
|
|
28
30
|
};
|
|
29
31
|
export type NotFoundMediaItemDetails = {
|
|
@@ -5,6 +5,7 @@ export declare const MAX_BATCH_SIZE = 100;
|
|
|
5
5
|
export type DataloaderKey = {
|
|
6
6
|
readonly id: string;
|
|
7
7
|
readonly collectionName?: string;
|
|
8
|
+
readonly includeHashForDuplicateFiles?: boolean;
|
|
8
9
|
};
|
|
9
10
|
export type DataloaderResult = MediaItemDetails | NotFoundMediaItemDetails;
|
|
10
11
|
export type BatchLoadingErrorResult = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type AuthContext, type MediaApiConfig, type Auth } from '@atlaskit/media-core';
|
|
2
2
|
import { type MediaTraceContext } from '@atlaskit/media-common';
|
|
3
3
|
import { type MediaFileArtifacts } from '@atlaskit/media-state';
|
|
4
|
-
import type { ItemsPayload, ImageMetadata, MediaStoreResponse, MediaStoreTouchFileParams, TouchFileDescriptor, MediaStoreTouchFileBody, RejectedTouchFile, MediaStoreRequestOptions, MediaStoreCreateFileFromUploadParams, MediaStoreCreateFileFromUploadBody, MediaStoreGetFileParams, MediaStoreGetFileImageParams, MediaStoreCopyFileWithTokenBody, MediaStoreCopyFileWithTokenParams, AppendChunksToUploadRequestBody, TouchedFiles, MediaApi } from './types';
|
|
4
|
+
import type { ItemsPayload, ImageMetadata, MediaStoreResponse, MediaStoreTouchFileParams, TouchFileDescriptor, MediaStoreTouchFileBody, RejectedTouchFile, MediaStoreRequestOptions, MediaStoreCreateFileFromUploadParams, MediaStoreCreateFileFromUploadBody, MediaStoreGetFileParams, MediaStoreGetFileImageParams, MediaStoreCopyFileWithTokenBody, MediaStoreCopyFileWithTokenParams, AppendChunksToUploadRequestBody, TouchedFiles, MediaApi, CopyFileParams } from './types';
|
|
5
5
|
import { type MediaFile, type MediaUpload } from '../../models/media';
|
|
6
6
|
import { ChunkHashAlgorithm } from '@atlaskit/media-core';
|
|
7
7
|
export declare class MediaStore implements MediaApi {
|
|
@@ -22,12 +22,14 @@ export declare class MediaStore implements MediaApi {
|
|
|
22
22
|
getFileBinaryURL(id: string, collectionName?: string, maxAge?: number): Promise<string>;
|
|
23
23
|
getArtifactURL(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string): Promise<string>;
|
|
24
24
|
getImage(id: string, params?: MediaStoreGetFileImageParams, controller?: AbortController, fetchMaxRes?: boolean, traceContext?: MediaTraceContext): Promise<Blob>;
|
|
25
|
-
getItems(ids: string[], collectionName?: string, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<ItemsPayload>>;
|
|
25
|
+
getItems(ids: string[], collectionName?: string, traceContext?: MediaTraceContext, includeHashForDuplicateFiles?: boolean): Promise<MediaStoreResponse<ItemsPayload>>;
|
|
26
26
|
getImageMetadata(id: string, params?: MediaStoreGetFileImageParams, traceContext?: MediaTraceContext): Promise<{
|
|
27
27
|
metadata: ImageMetadata;
|
|
28
28
|
}>;
|
|
29
29
|
appendChunksToUpload(uploadId: string, body: AppendChunksToUploadRequestBody, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
|
|
30
30
|
copyFileWithToken(body: MediaStoreCopyFileWithTokenBody, params: MediaStoreCopyFileWithTokenParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaFile>>;
|
|
31
|
+
copyFile(id: string, params: CopyFileParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaFile>>;
|
|
32
|
+
registerCopyIntents(ids: string[], collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
|
|
31
33
|
request(path: string, options?: MediaStoreRequestOptions, controller?: AbortController, useMediaCdn?: boolean): Promise<Response>;
|
|
32
34
|
testUrl(url: string, options?: {
|
|
33
35
|
traceContext?: MediaTraceContext;
|
|
@@ -113,6 +113,11 @@ export interface SourceFile {
|
|
|
113
113
|
export type MediaStoreCopyFileWithTokenBody = {
|
|
114
114
|
sourceFile: SourceFile;
|
|
115
115
|
};
|
|
116
|
+
export type CopyFileParams = {
|
|
117
|
+
sourceCollection?: string;
|
|
118
|
+
collection?: string;
|
|
119
|
+
replaceFileId?: string;
|
|
120
|
+
};
|
|
116
121
|
export type MediaStoreCopyFileWithTokenParams = {
|
|
117
122
|
readonly collection?: string;
|
|
118
123
|
readonly replaceFileId?: string;
|
|
@@ -160,12 +165,14 @@ export interface MediaApi {
|
|
|
160
165
|
getFileBinaryURL: (id: string, collectionName?: string) => Promise<string>;
|
|
161
166
|
getArtifactURL: (artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string) => Promise<string>;
|
|
162
167
|
getImage: (id: string, params?: MediaStoreGetFileImageParams, controller?: AbortController, fetchMaxRes?: boolean, traceContext?: MediaTraceContext) => Promise<Blob>;
|
|
163
|
-
getItems: (ids: string[], collectionName?: string, traceContext?: MediaTraceContext) => Promise<MediaStoreResponse<ItemsPayload>>;
|
|
168
|
+
getItems: (ids: string[], collectionName?: string, traceContext?: MediaTraceContext, includeHashForDuplicateFiles?: boolean) => Promise<MediaStoreResponse<ItemsPayload>>;
|
|
164
169
|
getImageMetadata: (id: string, params?: MediaStoreGetFileImageParams, traceContext?: MediaTraceContext) => Promise<{
|
|
165
170
|
metadata: ImageMetadata;
|
|
166
171
|
}>;
|
|
167
172
|
appendChunksToUpload: (uploadId: string, body: AppendChunksToUploadRequestBody, collectionName?: string, traceContext?: MediaTraceContext) => Promise<void>;
|
|
168
173
|
copyFileWithToken: (body: MediaStoreCopyFileWithTokenBody, params: MediaStoreCopyFileWithTokenParams, traceContext?: MediaTraceContext) => Promise<MediaStoreResponse<MediaFile>>;
|
|
174
|
+
copyFile: (id: string, params: CopyFileParams) => Promise<MediaStoreResponse<MediaFile>>;
|
|
175
|
+
registerCopyIntents: (ids: string[], collectionName: string) => Promise<void>;
|
|
169
176
|
request: (path: string, options: MediaStoreRequestOptions, controller?: AbortController) => Promise<Response>;
|
|
170
177
|
testUrl: (url: string, options?: {
|
|
171
178
|
traceContext?: MediaTraceContext;
|
|
@@ -13,6 +13,7 @@ export type MediaFile = {
|
|
|
13
13
|
readonly artifacts: MediaFileArtifacts;
|
|
14
14
|
readonly representations: MediaRepresentations;
|
|
15
15
|
readonly createdAt?: number;
|
|
16
|
+
readonly hash?: string;
|
|
16
17
|
readonly metadataTraceContext?: MediaTraceContext;
|
|
17
18
|
};
|
|
18
19
|
export type MediaItemDetails = {
|
|
@@ -24,6 +25,7 @@ export type MediaItemDetails = {
|
|
|
24
25
|
readonly artifacts: MediaFileArtifacts;
|
|
25
26
|
readonly representations: MediaRepresentations;
|
|
26
27
|
readonly createdAt?: number;
|
|
28
|
+
readonly hash?: string;
|
|
27
29
|
readonly metadataTraceContext?: MediaTraceContext;
|
|
28
30
|
};
|
|
29
31
|
export type NotFoundMediaItemDetails = {
|
|
@@ -5,6 +5,7 @@ export declare const MAX_BATCH_SIZE = 100;
|
|
|
5
5
|
export type DataloaderKey = {
|
|
6
6
|
readonly id: string;
|
|
7
7
|
readonly collectionName?: string;
|
|
8
|
+
readonly includeHashForDuplicateFiles?: boolean;
|
|
8
9
|
};
|
|
9
10
|
export type DataloaderResult = MediaItemDetails | NotFoundMediaItemDetails;
|
|
10
11
|
export type BatchLoadingErrorResult = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/media-client",
|
|
3
|
-
"version": "28.
|
|
3
|
+
"version": "28.5.0",
|
|
4
4
|
"description": "Media API Web Client Library",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@atlaskit/media-core": "^34.3.0",
|
|
58
|
-
"@atlaskit/media-state": "^1.
|
|
58
|
+
"@atlaskit/media-state": "^1.2.0",
|
|
59
59
|
"@atlaskit/ssr": "*",
|
|
60
60
|
"@atlaskit/tokens": "^2.4.0",
|
|
61
61
|
"@atlassian/feature-flags-test-utils": "0.2.3",
|