@atlaskit/media-client 23.1.2 → 23.2.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 +16 -0
- package/dist/cjs/client/file-fetcher/index.js +2 -2
- package/dist/cjs/client/media-store/index.js +2 -2
- package/dist/cjs/models/file-state.js +2 -2
- package/dist/cjs/test-helpers/_numbers.js +9 -0
- package/dist/cjs/test-helpers/authProvider.js +71 -0
- package/dist/cjs/test-helpers/collectionNames.js +16 -0
- package/dist/cjs/test-helpers/exampleMediaItems.js +317 -0
- package/dist/cjs/test-helpers/fakeMediaClient.js +77 -0
- package/dist/cjs/test-helpers/index.js +374 -0
- package/dist/cjs/test-helpers/mediaClientProvider.js +60 -0
- package/dist/cjs/test-helpers/mediaPickerAuthProvider.js +95 -0
- package/dist/cjs/utils/createFileDataLoader.js +2 -2
- package/dist/cjs/utils/mobileUpload/stateMachine/states/uploading.js +2 -2
- package/dist/cjs/utils/polling/index.js +2 -2
- package/dist/cjs/utils/request/helpers.js +2 -2
- package/dist/cjs/utils/url.js +2 -2
- package/dist/es2019/test-helpers/_numbers.js +3 -0
- package/dist/es2019/test-helpers/authProvider.js +34 -0
- package/dist/es2019/test-helpers/collectionNames.js +5 -0
- package/dist/es2019/test-helpers/exampleMediaItems.js +268 -0
- package/dist/es2019/test-helpers/fakeMediaClient.js +63 -0
- package/dist/es2019/test-helpers/index.js +7 -0
- package/dist/es2019/test-helpers/mediaClientProvider.js +42 -0
- package/dist/es2019/test-helpers/mediaPickerAuthProvider.js +56 -0
- package/dist/esm/client/file-fetcher/index.js +2 -2
- package/dist/esm/client/media-store/index.js +2 -2
- package/dist/esm/models/file-state.js +2 -2
- package/dist/esm/test-helpers/_numbers.js +3 -0
- package/dist/esm/test-helpers/authProvider.js +63 -0
- package/dist/esm/test-helpers/collectionNames.js +5 -0
- package/dist/esm/test-helpers/exampleMediaItems.js +268 -0
- package/dist/esm/test-helpers/fakeMediaClient.js +69 -0
- package/dist/esm/test-helpers/index.js +7 -0
- package/dist/esm/test-helpers/mediaClientProvider.js +48 -0
- package/dist/esm/test-helpers/mediaPickerAuthProvider.js +85 -0
- package/dist/esm/utils/createFileDataLoader.js +2 -2
- package/dist/esm/utils/mobileUpload/stateMachine/states/uploading.js +2 -2
- package/dist/esm/utils/polling/index.js +2 -2
- package/dist/esm/utils/request/helpers.js +2 -2
- package/dist/esm/utils/url.js +2 -2
- package/dist/types/models/artifacts.d.ts +3 -0
- package/dist/types/test-helpers/_numbers.d.ts +1 -0
- package/dist/types/test-helpers/authProvider.d.ts +6 -0
- package/dist/types/test-helpers/collectionNames.d.ts +5 -0
- package/dist/types/test-helpers/exampleMediaItems.d.ts +53 -0
- package/dist/types/test-helpers/fakeMediaClient.d.ts +4 -0
- package/dist/types/test-helpers/index.d.ts +7 -0
- package/dist/types/test-helpers/mediaClientProvider.d.ts +23 -0
- package/dist/types/test-helpers/mediaPickerAuthProvider.d.ts +5 -0
- package/dist/types-ts4.5/models/artifacts.d.ts +3 -0
- package/dist/types-ts4.5/test-helpers/_numbers.d.ts +1 -0
- package/dist/types-ts4.5/test-helpers/authProvider.d.ts +6 -0
- package/dist/types-ts4.5/test-helpers/collectionNames.d.ts +5 -0
- package/dist/types-ts4.5/test-helpers/exampleMediaItems.d.ts +53 -0
- package/dist/types-ts4.5/test-helpers/fakeMediaClient.d.ts +4 -0
- package/dist/types-ts4.5/test-helpers/index.d.ts +7 -0
- package/dist/types-ts4.5/test-helpers/mediaClientProvider.d.ts +23 -0
- package/dist/types-ts4.5/test-helpers/mediaPickerAuthProvider.d.ts +5 -0
- package/package.json +11 -4
- package/report.api.md +7 -0
- package/tmp/api-report-tmp.d.ts +6 -0
- package/dist/cjs/version.json +0 -5
- package/dist/es2019/version.json +0 -5
- package/dist/esm/version.json +0 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/media-client
|
|
2
2
|
|
|
3
|
+
## 23.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`ede6ee7aaab`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ede6ee7aaab) - Updated tests, examples and moving towards /test-helper export in packages to prevent circular dependancies
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 23.1.3
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 23.1.2
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -47,8 +47,8 @@ var _mediaTypeUtils = require("@atlaskit/media-common/mediaTypeUtils");
|
|
|
47
47
|
var _shouldFetchRemoteFileStates = require("../../utils/shouldFetchRemoteFileStates");
|
|
48
48
|
var _polling = require("../../utils/polling");
|
|
49
49
|
var _detectEmptyFile = require("../../utils/detectEmptyFile");
|
|
50
|
-
function ownKeys(
|
|
51
|
-
function _objectSpread(
|
|
50
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
51
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } // import setimmediate to temporary fix dataloader 2.0.0 bug
|
|
52
52
|
// @see https://github.com/graphql/dataloader/issues/249
|
|
53
53
|
var FileFetcherImpl = /*#__PURE__*/function () {
|
|
54
54
|
function FileFetcherImpl(mediaStore) {
|
|
@@ -30,8 +30,8 @@ var _request3 = require("../../utils/request");
|
|
|
30
30
|
var _helpers = require("../../utils/request/helpers");
|
|
31
31
|
var _resolveAuth = require("./resolveAuth");
|
|
32
32
|
var _error = require("./error");
|
|
33
|
-
function ownKeys(
|
|
34
|
-
function _objectSpread(
|
|
33
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
34
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
35
35
|
var MEDIA_API_REGION = 'media-api-region';
|
|
36
36
|
var MEDIA_API_ENVIRONMENT = 'media-api-environment';
|
|
37
37
|
var defaultImageOptions = {
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.mapMediaItemToFileState = exports.mapMediaFileToFileState = exports.isUploadingFileState = exports.isProcessingFileState = exports.isProcessedFileState = exports.isPreviewableFileState = exports.isImageRepresentationReady = exports.isFinalFileState = exports.isErrorFileState = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
function ownKeys(
|
|
10
|
-
function _objectSpread(
|
|
9
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
11
|
var isUploadingFileState = function isUploadingFileState(fileState) {
|
|
12
12
|
return fileState.status === 'uploading';
|
|
13
13
|
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.StoryBookAuthProvider = void 0;
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
|
+
var _collectionNames = require("./collectionNames");
|
|
13
|
+
var cachedAuths = {};
|
|
14
|
+
var authProviderBaseURL = 'https://media-playground.dev.atl-paas.net/';
|
|
15
|
+
var StoryBookAuthProvider = /*#__PURE__*/function () {
|
|
16
|
+
function StoryBookAuthProvider() {
|
|
17
|
+
(0, _classCallCheck2.default)(this, StoryBookAuthProvider);
|
|
18
|
+
}
|
|
19
|
+
(0, _createClass2.default)(StoryBookAuthProvider, null, [{
|
|
20
|
+
key: "create",
|
|
21
|
+
value: function create(isAsapEnvironment, access) {
|
|
22
|
+
var loadTenatAuth = /*#__PURE__*/function () {
|
|
23
|
+
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(collectionName) {
|
|
24
|
+
var environment, headers, config, url, response;
|
|
25
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
26
|
+
while (1) switch (_context.prev = _context.next) {
|
|
27
|
+
case 0:
|
|
28
|
+
environment = isAsapEnvironment ? 'asap' : '';
|
|
29
|
+
headers = new Headers();
|
|
30
|
+
headers.append('Content-Type', 'application/json; charset=utf-8');
|
|
31
|
+
headers.append('Accept', 'text/plain, */*; q=0.01');
|
|
32
|
+
config = {
|
|
33
|
+
method: 'POST',
|
|
34
|
+
headers: headers,
|
|
35
|
+
body: access ? JSON.stringify({
|
|
36
|
+
access: access
|
|
37
|
+
}) : undefined
|
|
38
|
+
};
|
|
39
|
+
url = "".concat(authProviderBaseURL, "/token/tenant?collection=").concat(collectionName, "&environment=").concat(environment);
|
|
40
|
+
response = fetch(url, config); // We leverage the fact, that our internal /toke/tenant API returns data in the same format as Auth
|
|
41
|
+
_context.next = 9;
|
|
42
|
+
return response;
|
|
43
|
+
case 9:
|
|
44
|
+
_context.next = 11;
|
|
45
|
+
return _context.sent.json();
|
|
46
|
+
case 11:
|
|
47
|
+
return _context.abrupt("return", _context.sent);
|
|
48
|
+
case 12:
|
|
49
|
+
case "end":
|
|
50
|
+
return _context.stop();
|
|
51
|
+
}
|
|
52
|
+
}, _callee);
|
|
53
|
+
}));
|
|
54
|
+
return function loadTenatAuth(_x) {
|
|
55
|
+
return _ref.apply(this, arguments);
|
|
56
|
+
};
|
|
57
|
+
}();
|
|
58
|
+
return function (authContext) {
|
|
59
|
+
var collectionName = authContext && authContext.collectionName || _collectionNames.defaultCollectionName;
|
|
60
|
+
var accessStr = access ? JSON.stringify(access) : '';
|
|
61
|
+
var cacheKey = "".concat(collectionName, "-").concat(accessStr, "-").concat(isAsapEnvironment);
|
|
62
|
+
if (!cachedAuths[cacheKey]) {
|
|
63
|
+
cachedAuths[cacheKey] = loadTenatAuth(collectionName);
|
|
64
|
+
}
|
|
65
|
+
return cachedAuths[cacheKey];
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}]);
|
|
69
|
+
return StoryBookAuthProvider;
|
|
70
|
+
}();
|
|
71
|
+
exports.StoryBookAuthProvider = StoryBookAuthProvider;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.onlyAnimatedGifsCollectionName = exports.fileCollectionName = exports.defaultMediaPickerCollectionName = exports.defaultCollectionName = exports.collectionNames = void 0;
|
|
7
|
+
var defaultCollectionName = 'MediaServicesSample';
|
|
8
|
+
exports.defaultCollectionName = defaultCollectionName;
|
|
9
|
+
var onlyAnimatedGifsCollectionName = 'only-animated-gifs';
|
|
10
|
+
exports.onlyAnimatedGifsCollectionName = onlyAnimatedGifsCollectionName;
|
|
11
|
+
var fileCollectionName = "".concat(defaultCollectionName, "Files");
|
|
12
|
+
exports.fileCollectionName = fileCollectionName;
|
|
13
|
+
var defaultMediaPickerCollectionName = 'mediapicker-test';
|
|
14
|
+
exports.defaultMediaPickerCollectionName = defaultMediaPickerCollectionName;
|
|
15
|
+
var collectionNames = [defaultCollectionName, 'MediaServicesSampleAtlaskit', 'MediaServicesSampleHulk', 'MediaServicesSampleFabric', fileCollectionName, onlyAnimatedGifsCollectionName, defaultMediaPickerCollectionName];
|
|
16
|
+
exports.collectionNames = collectionNames;
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.zipJiraArchiveFileId = exports.zipItemMultipleFoldersAtRootId = exports.zipItemLargeInnerFileId = exports.zipFileWithNestedFolderId = exports.zipFileId = exports.zipEncryptedFileId = exports.wideImageFileId = exports.vrVideoDetails = exports.videoSquareFileId = exports.videoProcessingFailedId = exports.videoLargeFileId = exports.videoHorizontalFileId = exports.videoFileId = exports.videoFileDetails = exports.verticalImageFileId = exports.unknownFileId = exports.unknownFileDetails = exports.smallImageFileId = exports.passwordProtectedPdfFileId = exports.noMetadataFileId = exports.largePdfFileId = exports.largeImageFileId = exports.imageFileId = exports.imageFileDetails = exports.gifFileId = exports.genericFileId = exports.genericFileDetails = exports.genericDataURI = exports.externalSmallImageIdentifier = exports.externalImageIdentifier = exports.externaBrokenlIdentifier = exports.errorFileId = exports.emptyImageFileId = exports.emailUnsupportedFileId = exports.emailFileId = exports.docFileId = exports.docFileDetails = exports.codeFileId = exports.bigDocFileId = exports.audioNoCoverFileId = exports.audioFileId = exports.audioFileDetails = exports.atlassianLogoUrl = exports.archiveFileId = exports.animatedFileId = void 0;
|
|
7
|
+
var _testHelpers = require("@atlaskit/media-common/test-helpers");
|
|
8
|
+
var _collectionNames = require("./collectionNames");
|
|
9
|
+
var fileType = 'file';
|
|
10
|
+
|
|
11
|
+
// === FILE ===
|
|
12
|
+
|
|
13
|
+
var genericFileId = {
|
|
14
|
+
id: '2dfcc12d-04d7-46e7-9fdf-3715ff00ba40',
|
|
15
|
+
mediaItemType: fileType,
|
|
16
|
+
collectionName: _collectionNames.defaultCollectionName
|
|
17
|
+
};
|
|
18
|
+
exports.genericFileId = genericFileId;
|
|
19
|
+
var audioFileId = {
|
|
20
|
+
id: 'a965c8df-1d64-4db8-9de5-16dfa8fd2e12',
|
|
21
|
+
// mp3 audio
|
|
22
|
+
mediaItemType: fileType,
|
|
23
|
+
collectionName: _collectionNames.defaultCollectionName
|
|
24
|
+
};
|
|
25
|
+
exports.audioFileId = audioFileId;
|
|
26
|
+
var audioNoCoverFileId = {
|
|
27
|
+
id: '7a5698bb-919c-4200-8699-6041e7913b11',
|
|
28
|
+
// mp3 audio
|
|
29
|
+
mediaItemType: fileType,
|
|
30
|
+
collectionName: _collectionNames.defaultCollectionName
|
|
31
|
+
};
|
|
32
|
+
exports.audioNoCoverFileId = audioNoCoverFileId;
|
|
33
|
+
var videoFileId = {
|
|
34
|
+
id: '1b01a476-83b4-4f44-8192-f83b2d00913a',
|
|
35
|
+
// mp4 video
|
|
36
|
+
mediaItemType: fileType,
|
|
37
|
+
collectionName: _collectionNames.defaultCollectionName
|
|
38
|
+
};
|
|
39
|
+
exports.videoFileId = videoFileId;
|
|
40
|
+
var videoHorizontalFileId = {
|
|
41
|
+
id: '2afaf845-4385-431f-9a15-3e21520cf896',
|
|
42
|
+
// .mov video
|
|
43
|
+
mediaItemType: fileType,
|
|
44
|
+
collectionName: _collectionNames.defaultCollectionName
|
|
45
|
+
};
|
|
46
|
+
exports.videoHorizontalFileId = videoHorizontalFileId;
|
|
47
|
+
var videoLargeFileId = {
|
|
48
|
+
id: '3291050e-6b66-4296-94c6-12088ef6fbad',
|
|
49
|
+
mediaItemType: fileType,
|
|
50
|
+
collectionName: _collectionNames.defaultCollectionName
|
|
51
|
+
};
|
|
52
|
+
exports.videoLargeFileId = videoLargeFileId;
|
|
53
|
+
var videoSquareFileId = {
|
|
54
|
+
id: 'cdff20d6-2c0a-4d0d-b2a9-22cc728a0368',
|
|
55
|
+
mediaItemType: fileType,
|
|
56
|
+
collectionName: _collectionNames.defaultCollectionName
|
|
57
|
+
};
|
|
58
|
+
exports.videoSquareFileId = videoSquareFileId;
|
|
59
|
+
var videoProcessingFailedId = {
|
|
60
|
+
id: 'e558199f-f982-4d23-93eb-313be5998d1b',
|
|
61
|
+
mediaItemType: fileType,
|
|
62
|
+
collectionName: _collectionNames.defaultCollectionName
|
|
63
|
+
};
|
|
64
|
+
exports.videoProcessingFailedId = videoProcessingFailedId;
|
|
65
|
+
var imageFileId = {
|
|
66
|
+
id: '5556346b-b081-482b-bc4a-4faca8ecd2de',
|
|
67
|
+
// jpg image
|
|
68
|
+
mediaItemType: fileType,
|
|
69
|
+
collectionName: _collectionNames.defaultCollectionName
|
|
70
|
+
};
|
|
71
|
+
exports.imageFileId = imageFileId;
|
|
72
|
+
var emptyImageFileId = {
|
|
73
|
+
id: 'aa7f7a63-2b1a-4405-b585-62e375a3b40a',
|
|
74
|
+
// jpg image
|
|
75
|
+
mediaItemType: fileType,
|
|
76
|
+
collectionName: _collectionNames.defaultCollectionName
|
|
77
|
+
};
|
|
78
|
+
exports.emptyImageFileId = emptyImageFileId;
|
|
79
|
+
var smallImageFileId = {
|
|
80
|
+
id: 'f251bd05-4b2d-485d-a088-57d112ca7945',
|
|
81
|
+
mediaItemType: fileType,
|
|
82
|
+
collectionName: _collectionNames.defaultCollectionName
|
|
83
|
+
};
|
|
84
|
+
exports.smallImageFileId = smallImageFileId;
|
|
85
|
+
var wideImageFileId = {
|
|
86
|
+
id: '3b6621a2-5b72-400e-ad95-447610dbb770',
|
|
87
|
+
mediaItemType: fileType,
|
|
88
|
+
collectionName: _collectionNames.defaultCollectionName
|
|
89
|
+
};
|
|
90
|
+
exports.wideImageFileId = wideImageFileId;
|
|
91
|
+
var largeImageFileId = {
|
|
92
|
+
id: '0607a6a8-b2ec-49a7-b6d3-d767cb49e844',
|
|
93
|
+
mediaItemType: fileType,
|
|
94
|
+
collectionName: _collectionNames.defaultCollectionName
|
|
95
|
+
};
|
|
96
|
+
exports.largeImageFileId = largeImageFileId;
|
|
97
|
+
var verticalImageFileId = {
|
|
98
|
+
id: 'f9235f5a-d582-4740-8611-ebf3feaf28b6',
|
|
99
|
+
mediaItemType: fileType,
|
|
100
|
+
collectionName: _collectionNames.defaultCollectionName
|
|
101
|
+
};
|
|
102
|
+
exports.verticalImageFileId = verticalImageFileId;
|
|
103
|
+
var docFileId = {
|
|
104
|
+
id: '71cd7e7d-4e86-4b89-a0b4-7f6ffe013c94',
|
|
105
|
+
mediaItemType: fileType,
|
|
106
|
+
collectionName: _collectionNames.defaultCollectionName
|
|
107
|
+
};
|
|
108
|
+
exports.docFileId = docFileId;
|
|
109
|
+
var bigDocFileId = {
|
|
110
|
+
id: 'd22f7a80-a661-4518-8b0e-eba02b6dfaca',
|
|
111
|
+
mediaItemType: fileType,
|
|
112
|
+
collectionName: _collectionNames.defaultCollectionName
|
|
113
|
+
};
|
|
114
|
+
exports.bigDocFileId = bigDocFileId;
|
|
115
|
+
var largePdfFileId = {
|
|
116
|
+
id: '0a510b7f-4168-44d8-b4d7-f5639ecefa2c',
|
|
117
|
+
mediaItemType: fileType,
|
|
118
|
+
collectionName: _collectionNames.defaultCollectionName
|
|
119
|
+
};
|
|
120
|
+
exports.largePdfFileId = largePdfFileId;
|
|
121
|
+
var passwordProtectedPdfFileId = {
|
|
122
|
+
id: 'c0e5bfa5-013d-4cbc-9b87-17d7f63bcc30',
|
|
123
|
+
mediaItemType: fileType,
|
|
124
|
+
collectionName: _collectionNames.defaultCollectionName
|
|
125
|
+
};
|
|
126
|
+
exports.passwordProtectedPdfFileId = passwordProtectedPdfFileId;
|
|
127
|
+
var codeFileId = {
|
|
128
|
+
id: '4bc95dd5-a7a2-4cbd-ac46-f9b9f0e0941a',
|
|
129
|
+
mediaItemType: fileType,
|
|
130
|
+
collectionName: _collectionNames.defaultCollectionName
|
|
131
|
+
};
|
|
132
|
+
exports.codeFileId = codeFileId;
|
|
133
|
+
var emailFileId = {
|
|
134
|
+
id: '79bb7327-fa6c-4e6f-8a7a-4ebd3607f481',
|
|
135
|
+
mediaItemType: fileType,
|
|
136
|
+
collectionName: _collectionNames.defaultCollectionName
|
|
137
|
+
};
|
|
138
|
+
exports.emailFileId = emailFileId;
|
|
139
|
+
var emailUnsupportedFileId = {
|
|
140
|
+
id: '3a2ae022-212a-4dca-a7d3-86eb016a0ed2',
|
|
141
|
+
mediaItemType: fileType,
|
|
142
|
+
collectionName: _collectionNames.defaultCollectionName
|
|
143
|
+
};
|
|
144
|
+
exports.emailUnsupportedFileId = emailUnsupportedFileId;
|
|
145
|
+
var archiveFileId = {
|
|
146
|
+
id: '1abbae6b-f507-4b4f-b181-21016bf3b7cc',
|
|
147
|
+
mediaItemType: fileType,
|
|
148
|
+
collectionName: _collectionNames.defaultCollectionName
|
|
149
|
+
};
|
|
150
|
+
exports.archiveFileId = archiveFileId;
|
|
151
|
+
var zipJiraArchiveFileId = {
|
|
152
|
+
id: 'aa99969c-6f0e-4cdc-8a57-9d38c43b2af8',
|
|
153
|
+
mediaItemType: fileType,
|
|
154
|
+
collectionName: _collectionNames.defaultCollectionName
|
|
155
|
+
};
|
|
156
|
+
exports.zipJiraArchiveFileId = zipJiraArchiveFileId;
|
|
157
|
+
var zipFileWithNestedFolderId = {
|
|
158
|
+
id: 'd1730520-316c-482a-a8c8-2b34acbea00b',
|
|
159
|
+
mediaItemType: fileType,
|
|
160
|
+
collectionName: _collectionNames.defaultCollectionName
|
|
161
|
+
};
|
|
162
|
+
exports.zipFileWithNestedFolderId = zipFileWithNestedFolderId;
|
|
163
|
+
var zipFileId = {
|
|
164
|
+
id: '3822aff2-9297-4ad9-93fd-ab1709f400ad',
|
|
165
|
+
mediaItemType: fileType,
|
|
166
|
+
collectionName: _collectionNames.defaultCollectionName
|
|
167
|
+
};
|
|
168
|
+
exports.zipFileId = zipFileId;
|
|
169
|
+
var zipItemMultipleFoldersAtRootId = {
|
|
170
|
+
id: 'b2c4623b-bd84-4d90-a2ed-61d50b0bd5f4',
|
|
171
|
+
mediaItemType: fileType,
|
|
172
|
+
collectionName: _collectionNames.defaultCollectionName
|
|
173
|
+
};
|
|
174
|
+
exports.zipItemMultipleFoldersAtRootId = zipItemMultipleFoldersAtRootId;
|
|
175
|
+
var zipItemLargeInnerFileId = {
|
|
176
|
+
id: '36b7957c-2d73-4cd5-8541-103daa2619ce',
|
|
177
|
+
mediaItemType: fileType,
|
|
178
|
+
collectionName: _collectionNames.defaultCollectionName
|
|
179
|
+
};
|
|
180
|
+
exports.zipItemLargeInnerFileId = zipItemLargeInnerFileId;
|
|
181
|
+
var zipEncryptedFileId = {
|
|
182
|
+
id: 'd1569d0f-936d-46f3-b974-a285696016c0',
|
|
183
|
+
mediaItemType: fileType,
|
|
184
|
+
collectionName: _collectionNames.defaultCollectionName
|
|
185
|
+
};
|
|
186
|
+
exports.zipEncryptedFileId = zipEncryptedFileId;
|
|
187
|
+
var unknownFileId = {
|
|
188
|
+
id: 'e0652e68-c596-4800-8a91-1920e6b8a585',
|
|
189
|
+
mediaItemType: fileType,
|
|
190
|
+
collectionName: _collectionNames.defaultCollectionName
|
|
191
|
+
};
|
|
192
|
+
exports.unknownFileId = unknownFileId;
|
|
193
|
+
var errorFileId = {
|
|
194
|
+
id: 'error-file-id',
|
|
195
|
+
mediaItemType: fileType,
|
|
196
|
+
collectionName: _collectionNames.defaultCollectionName
|
|
197
|
+
};
|
|
198
|
+
exports.errorFileId = errorFileId;
|
|
199
|
+
var gifFileId = {
|
|
200
|
+
id: '26adc5af-3af4-42a8-9c24-62b6ce0f9369',
|
|
201
|
+
mediaItemType: fileType,
|
|
202
|
+
collectionName: _collectionNames.defaultCollectionName
|
|
203
|
+
};
|
|
204
|
+
exports.gifFileId = gifFileId;
|
|
205
|
+
var noMetadataFileId = {
|
|
206
|
+
id: '1adaf6f9-37f6-4171-ab6b-455ec3115381',
|
|
207
|
+
mediaItemType: fileType,
|
|
208
|
+
collectionName: _collectionNames.defaultCollectionName
|
|
209
|
+
};
|
|
210
|
+
exports.noMetadataFileId = noMetadataFileId;
|
|
211
|
+
var animatedFileId = {
|
|
212
|
+
id: 'af637c7a-75c3-4254-b074-d16e6ae2e04b',
|
|
213
|
+
mediaItemType: fileType,
|
|
214
|
+
collectionName: _collectionNames.onlyAnimatedGifsCollectionName
|
|
215
|
+
};
|
|
216
|
+
// === EXTERNAL IMAGE ===
|
|
217
|
+
exports.animatedFileId = animatedFileId;
|
|
218
|
+
var atlassianLogoUrl = 'https://wac-cdn.atlassian.com/assets/img/favicons/atlassian/apple-touch-icon-152x152.png';
|
|
219
|
+
exports.atlassianLogoUrl = atlassianLogoUrl;
|
|
220
|
+
var externalImageIdentifier = {
|
|
221
|
+
mediaItemType: 'external-image',
|
|
222
|
+
dataURI: atlassianLogoUrl
|
|
223
|
+
};
|
|
224
|
+
exports.externalImageIdentifier = externalImageIdentifier;
|
|
225
|
+
var externalSmallImageIdentifier = {
|
|
226
|
+
mediaItemType: 'external-image',
|
|
227
|
+
dataURI: 'https://aui-cdn.atlassian.com/media/files-icon.png'
|
|
228
|
+
};
|
|
229
|
+
exports.externalSmallImageIdentifier = externalSmallImageIdentifier;
|
|
230
|
+
var externaBrokenlIdentifier = {
|
|
231
|
+
mediaItemType: 'external-image',
|
|
232
|
+
dataURI: 'https://some-uri'
|
|
233
|
+
};
|
|
234
|
+
exports.externaBrokenlIdentifier = externaBrokenlIdentifier;
|
|
235
|
+
var genericFileDetails = {
|
|
236
|
+
id: 'fd4c4672-323a-4b6c-8326-223169e2a13e',
|
|
237
|
+
mediaType: 'image',
|
|
238
|
+
mimeType: 'image/gif',
|
|
239
|
+
name: 'picker-thread-leaking.gif',
|
|
240
|
+
size: 2958464,
|
|
241
|
+
processingStatus: 'succeeded',
|
|
242
|
+
artifacts: {
|
|
243
|
+
'thumb_320.jpg': {
|
|
244
|
+
url: '/file/fd4c4672-323a-4b6c-8326-223169e2a13e/artifact/thumb_320.jpg/binary',
|
|
245
|
+
processingStatus: 'succeeded'
|
|
246
|
+
},
|
|
247
|
+
'thumb_large.jpg': {
|
|
248
|
+
url: '/file/fd4c4672-323a-4b6c-8326-223169e2a13e/artifact/thumb_320.jpg/binary',
|
|
249
|
+
processingStatus: 'succeeded'
|
|
250
|
+
},
|
|
251
|
+
'thumb_120.jpg': {
|
|
252
|
+
url: '/file/fd4c4672-323a-4b6c-8326-223169e2a13e/artifact/thumb_120.jpg/binary',
|
|
253
|
+
processingStatus: 'succeeded'
|
|
254
|
+
},
|
|
255
|
+
'thumb.jpg': {
|
|
256
|
+
url: '/file/fd4c4672-323a-4b6c-8326-223169e2a13e/artifact/thumb_120.jpg/binary',
|
|
257
|
+
processingStatus: 'succeeded'
|
|
258
|
+
},
|
|
259
|
+
'meta.json': {
|
|
260
|
+
url: '/file/fd4c4672-323a-4b6c-8326-223169e2a13e/artifact/meta.json/binary',
|
|
261
|
+
processingStatus: 'succeeded'
|
|
262
|
+
},
|
|
263
|
+
'image.jpg': {
|
|
264
|
+
url: '/file/fd4c4672-323a-4b6c-8326-223169e2a13e/artifact/image.jpg/binary',
|
|
265
|
+
processingStatus: 'succeeded'
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
exports.genericFileDetails = genericFileDetails;
|
|
270
|
+
var imageFileDetails = {
|
|
271
|
+
id: 'some-id',
|
|
272
|
+
mediaType: 'image',
|
|
273
|
+
name: 'image_file.jpg',
|
|
274
|
+
size: 2958464
|
|
275
|
+
};
|
|
276
|
+
exports.imageFileDetails = imageFileDetails;
|
|
277
|
+
var videoFileDetails = {
|
|
278
|
+
id: 'some-id',
|
|
279
|
+
mediaType: 'video',
|
|
280
|
+
name: 'video_file.mp4',
|
|
281
|
+
size: 29584640
|
|
282
|
+
};
|
|
283
|
+
exports.videoFileDetails = videoFileDetails;
|
|
284
|
+
var audioFileDetails = {
|
|
285
|
+
id: 'some-id',
|
|
286
|
+
mediaType: 'audio',
|
|
287
|
+
name: 'audio_file.mp3',
|
|
288
|
+
size: 2958464
|
|
289
|
+
};
|
|
290
|
+
exports.audioFileDetails = audioFileDetails;
|
|
291
|
+
var docFileDetails = {
|
|
292
|
+
id: 'some-id',
|
|
293
|
+
mediaType: 'doc',
|
|
294
|
+
name: 'doc_file.pdf',
|
|
295
|
+
size: 2958464
|
|
296
|
+
};
|
|
297
|
+
exports.docFileDetails = docFileDetails;
|
|
298
|
+
var unknownFileDetails = {
|
|
299
|
+
id: 'some-id',
|
|
300
|
+
mediaType: 'unknown',
|
|
301
|
+
name: 'doc_file.pdf',
|
|
302
|
+
size: 2958464
|
|
303
|
+
};
|
|
304
|
+
exports.unknownFileDetails = unknownFileDetails;
|
|
305
|
+
var genericDataURI = 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAZABkAAD/4QCMRXhpZgAATU0AKgAAAAgABQESAAMAAAABAAEAAAEaAAUAAAABAAAASgEbAAUAAAABAAAAUgEoAAMAAAABAAIAAIdpAAQAAAABAAAAWgAAAAAAAABkAAAAAQAAAGQAAAABAAOgAQADAAAAAQABAACgAgAEAAAAAQAAAAKgAwAEAAAAAQAAAAIAAAAA/+0AOFBob3Rvc2hvcCAzLjAAOEJJTQQEAAAAAAAAOEJJTQQlAAAAAAAQ1B2M2Y8AsgTpgAmY7PhCfv/AABEIAAIAAgMBEQACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQICAQECAQEBAgICAgICAgICAQICAgICAgICAgL/2wBDAQEBAQEBAQEBAQECAQEBAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgL/3QAEAAH/2gAMAwEAAhEDEQA/AP0U8M2NmPDfh8C0tgBomkgAW8OAPsFvwK/lh7s+5u+/4n//2Q==';
|
|
306
|
+
|
|
307
|
+
// === VR test ids ===
|
|
308
|
+
exports.genericDataURI = genericDataURI;
|
|
309
|
+
var vrVideoDetails = {
|
|
310
|
+
id: '0c3c64b9-65ad-4592-89d0-f838beebd81e',
|
|
311
|
+
name: 'video.mp4',
|
|
312
|
+
dataUri: _testHelpers.videoURI,
|
|
313
|
+
previewDataUri: _testHelpers.videoPreviewURI,
|
|
314
|
+
mediaType: 'video',
|
|
315
|
+
mimeType: 'video/mp4'
|
|
316
|
+
};
|
|
317
|
+
exports.vrVideoDetails = vrVideoDetails;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getDefaultMediaClientConfig = exports.fakeMediaClient = void 0;
|
|
7
|
+
var _ = require("../");
|
|
8
|
+
var _testHelpers = require("@atlaskit/media-common/test-helpers");
|
|
9
|
+
var jest = (0, _testHelpers.getJest)();
|
|
10
|
+
var getDefaultMediaClientConfig = function getDefaultMediaClientConfig() {
|
|
11
|
+
return {
|
|
12
|
+
authProvider: jest.fn().mockReturnValue(Promise.resolve({
|
|
13
|
+
clientId: 'some-client-id',
|
|
14
|
+
token: 'some-token',
|
|
15
|
+
baseUrl: 'some-service-host'
|
|
16
|
+
}))
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
exports.getDefaultMediaClientConfig = getDefaultMediaClientConfig;
|
|
20
|
+
var fakeMediaClient = function fakeMediaClient() {
|
|
21
|
+
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getDefaultMediaClientConfig();
|
|
22
|
+
if (jest && jest.genMockFromModule) {
|
|
23
|
+
var _jest$genMockFromModu = jest.genMockFromModule('@atlaskit/media-client'),
|
|
24
|
+
MockMediaClient = _jest$genMockFromModu.MediaClient,
|
|
25
|
+
FileFetcherImpl = _jest$genMockFromModu.FileFetcherImpl,
|
|
26
|
+
MockMediaStore = _jest$genMockFromModu.MediaStore,
|
|
27
|
+
StargateClient = _jest$genMockFromModu.StargateClient;
|
|
28
|
+
var mediaClient = new MockMediaClient();
|
|
29
|
+
var fileFetcher = new FileFetcherImpl();
|
|
30
|
+
var mockMediaStore = new MockMediaStore({
|
|
31
|
+
authProvider: config.authProvider
|
|
32
|
+
});
|
|
33
|
+
var stargateClient = new StargateClient();
|
|
34
|
+
mediaClient.file = fileFetcher;
|
|
35
|
+
mediaClient.stargate = stargateClient;
|
|
36
|
+
mediaClient.config = config; // <- deprecated
|
|
37
|
+
mediaClient.mediaClientConfig = config;
|
|
38
|
+
mediaClient.mediaStore = mockMediaStore;
|
|
39
|
+
mediaClient.mediaStore.getItems = jest.fn().mockResolvedValue({
|
|
40
|
+
data: {
|
|
41
|
+
items: []
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
(0, _testHelpers.asMock)(mediaClient.getImageUrl).mockResolvedValue('some-image-url');
|
|
45
|
+
(0, _testHelpers.asMock)(mediaClient.getImageUrlSync).mockReturnValue('some-image-url');
|
|
46
|
+
(0, _testHelpers.asMock)(mediaClient.getImage).mockImplementation(mockMediaStore.getImage);
|
|
47
|
+
(0, _testHelpers.asMock)(mediaClient.file.copyFile).mockReturnValue({
|
|
48
|
+
id: 'copied-file-id'
|
|
49
|
+
});
|
|
50
|
+
(0, _testHelpers.asMock)(mediaClient.file.getCurrentState).mockReturnValue(Promise.resolve({
|
|
51
|
+
id: 'file-id',
|
|
52
|
+
status: 'processed',
|
|
53
|
+
mediaType: 'image',
|
|
54
|
+
name: 'file_name'
|
|
55
|
+
}));
|
|
56
|
+
(0, _testHelpers.asMock)(mediaClient.file.getFileState).mockImplementation(function () {
|
|
57
|
+
return {
|
|
58
|
+
subscribe: jest.fn()
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
(0, _testHelpers.asMock)(mediaClient.stargate.fetchToken).mockImplementation(function () {
|
|
62
|
+
return Promise.resolve({
|
|
63
|
+
data: {
|
|
64
|
+
clientId: 'some-client-id-from-smart-edge',
|
|
65
|
+
token: 'some-token-from-smart-edge',
|
|
66
|
+
baseUrl: 'some-base-url-from-smart-edge',
|
|
67
|
+
expiresIn: 34000,
|
|
68
|
+
iat: new Date().getTime() / 1000
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
return mediaClient;
|
|
73
|
+
} else {
|
|
74
|
+
return new _.MediaClient(config);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
exports.fakeMediaClient = fakeMediaClient;
|