@atlaskit/media-client 26.3.0 → 27.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1044 -683
- package/dist/cjs/client/file-fetcher/index.js +2 -1
- package/dist/es2019/client/file-fetcher/index.js +2 -1
- package/dist/esm/client/file-fetcher/index.js +2 -1
- package/dist/types/client/file-fetcher/index.d.ts +11 -11
- package/dist/types-ts4.5/client/file-fetcher/index.d.ts +11 -11
- package/example-helpers/styles.ts +73 -74
- package/package.json +11 -4
- package/dist/cjs/test-helpers/MockedMediaApi/MockedMediaApi.js +0 -455
- package/dist/cjs/test-helpers/MockedMediaApi/helpers.js +0 -184
- package/dist/cjs/test-helpers/MockedMediaApi/index.js +0 -55
- package/dist/cjs/test-helpers/_numbers.js +0 -9
- package/dist/cjs/test-helpers/authProvider.js +0 -70
- package/dist/cjs/test-helpers/collectionNames.js +0 -11
- package/dist/cjs/test-helpers/exampleMediaItems.js +0 -274
- package/dist/cjs/test-helpers/fakeMediaClient.js +0 -75
- package/dist/cjs/test-helpers/index.js +0 -422
- package/dist/cjs/test-helpers/mediaClientProvider.js +0 -54
- package/dist/cjs/test-helpers/mediaPickerAuthProvider.js +0 -92
- package/dist/es2019/test-helpers/MockedMediaApi/MockedMediaApi.js +0 -166
- package/dist/es2019/test-helpers/MockedMediaApi/helpers.js +0 -167
- package/dist/es2019/test-helpers/MockedMediaApi/index.js +0 -2
- package/dist/es2019/test-helpers/_numbers.js +0 -3
- package/dist/es2019/test-helpers/authProvider.js +0 -34
- package/dist/es2019/test-helpers/collectionNames.js +0 -5
- package/dist/es2019/test-helpers/exampleMediaItems.js +0 -268
- package/dist/es2019/test-helpers/fakeMediaClient.js +0 -63
- package/dist/es2019/test-helpers/index.js +0 -8
- package/dist/es2019/test-helpers/mediaClientProvider.js +0 -42
- package/dist/es2019/test-helpers/mediaPickerAuthProvider.js +0 -56
- package/dist/esm/test-helpers/MockedMediaApi/MockedMediaApi.js +0 -448
- package/dist/esm/test-helpers/MockedMediaApi/helpers.js +0 -177
- package/dist/esm/test-helpers/MockedMediaApi/index.js +0 -2
- package/dist/esm/test-helpers/_numbers.js +0 -3
- package/dist/esm/test-helpers/authProvider.js +0 -63
- package/dist/esm/test-helpers/collectionNames.js +0 -5
- package/dist/esm/test-helpers/exampleMediaItems.js +0 -268
- package/dist/esm/test-helpers/fakeMediaClient.js +0 -69
- package/dist/esm/test-helpers/index.js +0 -8
- package/dist/esm/test-helpers/mediaClientProvider.js +0 -48
- package/dist/esm/test-helpers/mediaPickerAuthProvider.js +0 -85
- package/dist/types/test-helpers/MockedMediaApi/MockedMediaApi.d.ts +0 -16
- package/dist/types/test-helpers/MockedMediaApi/helpers.d.ts +0 -23
- package/dist/types/test-helpers/MockedMediaApi/index.d.ts +0 -3
- package/dist/types/test-helpers/_numbers.d.ts +0 -1
- package/dist/types/test-helpers/authProvider.d.ts +0 -6
- package/dist/types/test-helpers/collectionNames.d.ts +0 -5
- package/dist/types/test-helpers/exampleMediaItems.d.ts +0 -53
- package/dist/types/test-helpers/fakeMediaClient.d.ts +0 -4
- package/dist/types/test-helpers/index.d.ts +0 -9
- package/dist/types/test-helpers/mediaClientProvider.d.ts +0 -23
- package/dist/types/test-helpers/mediaPickerAuthProvider.d.ts +0 -5
- package/dist/types-ts4.5/test-helpers/MockedMediaApi/MockedMediaApi.d.ts +0 -16
- package/dist/types-ts4.5/test-helpers/MockedMediaApi/helpers.d.ts +0 -23
- package/dist/types-ts4.5/test-helpers/MockedMediaApi/index.d.ts +0 -3
- package/dist/types-ts4.5/test-helpers/_numbers.d.ts +0 -1
- package/dist/types-ts4.5/test-helpers/authProvider.d.ts +0 -6
- package/dist/types-ts4.5/test-helpers/collectionNames.d.ts +0 -5
- package/dist/types-ts4.5/test-helpers/exampleMediaItems.d.ts +0 -53
- package/dist/types-ts4.5/test-helpers/fakeMediaClient.d.ts +0 -4
- package/dist/types-ts4.5/test-helpers/index.d.ts +0 -9
- package/dist/types-ts4.5/test-helpers/mediaClientProvider.d.ts +0 -23
- package/dist/types-ts4.5/test-helpers/mediaPickerAuthProvider.d.ts +0 -5
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
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; }
|
|
4
|
-
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) { _defineProperty(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; }
|
|
5
|
-
import uuid from 'uuid/v4';
|
|
6
|
-
// --------------------------------------------------------
|
|
7
|
-
// Factory Utils
|
|
8
|
-
// --------------------------------------------------------
|
|
9
|
-
|
|
10
|
-
export var normaliseInput = function normaliseInput(input) {
|
|
11
|
-
return !input ? [] : input instanceof Array ? input : [input];
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
// --------------------------------------------------------
|
|
15
|
-
// Utils for the main class
|
|
16
|
-
// --------------------------------------------------------
|
|
17
|
-
|
|
18
|
-
export var getMediaFile = function getMediaFile(fileItem) {
|
|
19
|
-
return _objectSpread({
|
|
20
|
-
id: fileItem.id
|
|
21
|
-
}, fileItem.details);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
// --------------------------------------------------------
|
|
25
|
-
// Utils for creating file descriptors for tests
|
|
26
|
-
// --------------------------------------------------------
|
|
27
|
-
|
|
28
|
-
export var createEmptyFileItem = function createEmptyFileItem(id, collection) {
|
|
29
|
-
var emptyFileItem = {
|
|
30
|
-
type: 'file',
|
|
31
|
-
id: id,
|
|
32
|
-
details: {
|
|
33
|
-
mediaType: 'unknown',
|
|
34
|
-
mimeType: 'binary/octet-stream',
|
|
35
|
-
name: '',
|
|
36
|
-
size: 0,
|
|
37
|
-
processingStatus: 'pending',
|
|
38
|
-
artifacts: {},
|
|
39
|
-
representations: {},
|
|
40
|
-
createdAt: 1699488941974
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
if (collection) {
|
|
44
|
-
emptyFileItem.collection = collection;
|
|
45
|
-
}
|
|
46
|
-
return emptyFileItem;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Simulates the processing of the file by updating the processing status of the artifacts by a percentage
|
|
51
|
-
* Percent must be between 0 and 1
|
|
52
|
-
*/
|
|
53
|
-
export var createProcessingFileItem = function createProcessingFileItem(fileItem, percent) {
|
|
54
|
-
if (percent < 0 || percent > 1) {
|
|
55
|
-
throw new Error('Error createProcessingFileItem: percent must be between 0 and 1');
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* This behaviour has to be confirmed
|
|
60
|
-
* Artifacts show up immediately after processed or they have a
|
|
61
|
-
* "processing time"?
|
|
62
|
-
*/
|
|
63
|
-
|
|
64
|
-
if (percent === 1) {
|
|
65
|
-
return fileItem;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// No artifacts for 0% processing
|
|
69
|
-
if (percent === 0) {
|
|
70
|
-
return _objectSpread(_objectSpread({}, fileItem), {}, {
|
|
71
|
-
details: _objectSpread(_objectSpread({}, fileItem.details), {}, {
|
|
72
|
-
processingStatus: 'pending',
|
|
73
|
-
artifacts: {},
|
|
74
|
-
// The preview will only be ready at 100% -> TODO verify against backend
|
|
75
|
-
representations: {}
|
|
76
|
-
})
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
var artifactsKeys = Object.keys(fileItem.details.artifacts);
|
|
80
|
-
var artifactsEntries = Object.entries(_objectSpread({}, fileItem.details.artifacts));
|
|
81
|
-
|
|
82
|
-
// Get a % of the total artifacts to be set as processed
|
|
83
|
-
var processedArtifactKeys = artifactsKeys.slice(0, Math.ceil(artifactsKeys.length * percent));
|
|
84
|
-
var processedArtifactEntries = artifactsEntries.map(function (_ref) {
|
|
85
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
86
|
-
key = _ref2[0],
|
|
87
|
-
artifact = _ref2[1];
|
|
88
|
-
return [key, _objectSpread(_objectSpread({}, artifact), {}, {
|
|
89
|
-
processingStatus: processedArtifactKeys.includes(key) ? 'succeeded' : 'pending'
|
|
90
|
-
})];
|
|
91
|
-
});
|
|
92
|
-
var artifactsProcessingPercent = Object.fromEntries(processedArtifactEntries);
|
|
93
|
-
return _objectSpread(_objectSpread({}, fileItem), {}, {
|
|
94
|
-
details: _objectSpread(_objectSpread({}, fileItem.details), {}, {
|
|
95
|
-
processingStatus: 'pending',
|
|
96
|
-
artifacts: artifactsProcessingPercent,
|
|
97
|
-
// The preview will only be ready at 100% -> TODO verify against backend
|
|
98
|
-
representations: {}
|
|
99
|
-
})
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Makes a copy of the provided file item with a random file id
|
|
105
|
-
* */
|
|
106
|
-
export var copy = function copy(fileItem) {
|
|
107
|
-
return JSON.parse(JSON.stringify(fileItem).replace(new RegExp(fileItem.id, 'g'), uuid()));
|
|
108
|
-
};
|
|
109
|
-
/**
|
|
110
|
-
* Extracts the file identifier from the provided file item
|
|
111
|
-
*/
|
|
112
|
-
export var getIdentifier = function getIdentifier(fileItem) {
|
|
113
|
-
return {
|
|
114
|
-
mediaItemType: 'file',
|
|
115
|
-
id: fileItem.id,
|
|
116
|
-
collectionName: fileItem.collection
|
|
117
|
-
};
|
|
118
|
-
};
|
|
119
|
-
export var createFileState = function createFileState(_ref3) {
|
|
120
|
-
var id = _ref3.id,
|
|
121
|
-
_ref3$details = _ref3.details,
|
|
122
|
-
name = _ref3$details.name,
|
|
123
|
-
size = _ref3$details.size,
|
|
124
|
-
mediaType = _ref3$details.mediaType,
|
|
125
|
-
mimeType = _ref3$details.mimeType,
|
|
126
|
-
createdAt = _ref3$details.createdAt,
|
|
127
|
-
processingStatus = _ref3$details.processingStatus,
|
|
128
|
-
artifacts = _ref3$details.artifacts,
|
|
129
|
-
representations = _ref3$details.representations;
|
|
130
|
-
return {
|
|
131
|
-
status: processingStatus === 'succeeded' ? 'processed' : 'processing',
|
|
132
|
-
id: id,
|
|
133
|
-
name: name,
|
|
134
|
-
size: size,
|
|
135
|
-
mediaType: mediaType,
|
|
136
|
-
mimeType: mimeType,
|
|
137
|
-
createdAt: createdAt,
|
|
138
|
-
artifacts: artifacts,
|
|
139
|
-
representations: representations
|
|
140
|
-
};
|
|
141
|
-
};
|
|
142
|
-
export var createUploadingFileState = function createUploadingFileState(_ref4, progress, binary) {
|
|
143
|
-
var id = _ref4.id,
|
|
144
|
-
_ref4$details = _ref4.details,
|
|
145
|
-
name = _ref4$details.name,
|
|
146
|
-
size = _ref4$details.size,
|
|
147
|
-
mediaType = _ref4$details.mediaType,
|
|
148
|
-
mimeType = _ref4$details.mimeType,
|
|
149
|
-
createdAt = _ref4$details.createdAt;
|
|
150
|
-
return {
|
|
151
|
-
status: 'uploading',
|
|
152
|
-
progress: progress,
|
|
153
|
-
id: id,
|
|
154
|
-
name: name,
|
|
155
|
-
size: size,
|
|
156
|
-
mediaType: mediaType,
|
|
157
|
-
mimeType: mimeType,
|
|
158
|
-
createdAt: createdAt,
|
|
159
|
-
preview: {
|
|
160
|
-
value: binary || new Blob(['some-content'], {
|
|
161
|
-
type: mimeType
|
|
162
|
-
})
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
};
|
|
166
|
-
export var createErrorFileState = function createErrorFileState(_ref5) {
|
|
167
|
-
var id = _ref5.id;
|
|
168
|
-
return {
|
|
169
|
-
status: 'error',
|
|
170
|
-
id: id,
|
|
171
|
-
reason: 'a random error',
|
|
172
|
-
message: 'a random error message',
|
|
173
|
-
details: {
|
|
174
|
-
some: 'mocked error detail'
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
|
-
import { defaultCollectionName } from './collectionNames';
|
|
6
|
-
var cachedAuths = {};
|
|
7
|
-
var authProviderBaseURL = 'https://media-playground.dev.atl-paas.net/';
|
|
8
|
-
export var StoryBookAuthProvider = /*#__PURE__*/function () {
|
|
9
|
-
function StoryBookAuthProvider() {
|
|
10
|
-
_classCallCheck(this, StoryBookAuthProvider);
|
|
11
|
-
}
|
|
12
|
-
_createClass(StoryBookAuthProvider, null, [{
|
|
13
|
-
key: "create",
|
|
14
|
-
value: function create(isAsapEnvironment, access) {
|
|
15
|
-
var loadTenatAuth = /*#__PURE__*/function () {
|
|
16
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(collectionName) {
|
|
17
|
-
var environment, headers, config, url, response;
|
|
18
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
19
|
-
while (1) switch (_context.prev = _context.next) {
|
|
20
|
-
case 0:
|
|
21
|
-
environment = isAsapEnvironment ? 'asap' : '';
|
|
22
|
-
headers = new Headers();
|
|
23
|
-
headers.append('Content-Type', 'application/json; charset=utf-8');
|
|
24
|
-
headers.append('Accept', 'text/plain, */*; q=0.01');
|
|
25
|
-
config = {
|
|
26
|
-
method: 'POST',
|
|
27
|
-
headers: headers,
|
|
28
|
-
body: access ? JSON.stringify({
|
|
29
|
-
access: access
|
|
30
|
-
}) : undefined
|
|
31
|
-
};
|
|
32
|
-
url = "".concat(authProviderBaseURL, "/token/tenant?collection=").concat(collectionName, "&environment=").concat(environment);
|
|
33
|
-
response = fetch(url, config); // We leverage the fact, that our internal /toke/tenant API returns data in the same format as Auth
|
|
34
|
-
_context.next = 9;
|
|
35
|
-
return response;
|
|
36
|
-
case 9:
|
|
37
|
-
_context.next = 11;
|
|
38
|
-
return _context.sent.json();
|
|
39
|
-
case 11:
|
|
40
|
-
return _context.abrupt("return", _context.sent);
|
|
41
|
-
case 12:
|
|
42
|
-
case "end":
|
|
43
|
-
return _context.stop();
|
|
44
|
-
}
|
|
45
|
-
}, _callee);
|
|
46
|
-
}));
|
|
47
|
-
return function loadTenatAuth(_x) {
|
|
48
|
-
return _ref.apply(this, arguments);
|
|
49
|
-
};
|
|
50
|
-
}();
|
|
51
|
-
return function (authContext) {
|
|
52
|
-
var collectionName = authContext && authContext.collectionName || defaultCollectionName;
|
|
53
|
-
var accessStr = access ? JSON.stringify(access) : '';
|
|
54
|
-
var cacheKey = "".concat(collectionName, "-").concat(accessStr, "-").concat(isAsapEnvironment);
|
|
55
|
-
if (!cachedAuths[cacheKey]) {
|
|
56
|
-
cachedAuths[cacheKey] = loadTenatAuth(collectionName);
|
|
57
|
-
}
|
|
58
|
-
return cachedAuths[cacheKey];
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
}]);
|
|
62
|
-
return StoryBookAuthProvider;
|
|
63
|
-
}();
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export var defaultCollectionName = 'MediaServicesSample';
|
|
2
|
-
export var onlyAnimatedGifsCollectionName = 'only-animated-gifs';
|
|
3
|
-
export var fileCollectionName = "".concat(defaultCollectionName, "Files");
|
|
4
|
-
export var defaultMediaPickerCollectionName = 'mediapicker-test';
|
|
5
|
-
export var collectionNames = [defaultCollectionName, 'MediaServicesSampleAtlaskit', 'MediaServicesSampleHulk', 'MediaServicesSampleFabric', fileCollectionName, onlyAnimatedGifsCollectionName, defaultMediaPickerCollectionName];
|
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
import { videoURI, videoPreviewURI } from '@atlaskit/media-common/test-helpers';
|
|
2
|
-
import { defaultCollectionName as collectionName, onlyAnimatedGifsCollectionName } from './collectionNames';
|
|
3
|
-
var fileType = 'file';
|
|
4
|
-
|
|
5
|
-
// === FILE ===
|
|
6
|
-
|
|
7
|
-
export var genericFileId = {
|
|
8
|
-
id: '2dfcc12d-04d7-46e7-9fdf-3715ff00ba40',
|
|
9
|
-
mediaItemType: fileType,
|
|
10
|
-
collectionName: collectionName
|
|
11
|
-
};
|
|
12
|
-
export var audioFileId = {
|
|
13
|
-
id: 'a965c8df-1d64-4db8-9de5-16dfa8fd2e12',
|
|
14
|
-
// mp3 audio
|
|
15
|
-
mediaItemType: fileType,
|
|
16
|
-
collectionName: collectionName
|
|
17
|
-
};
|
|
18
|
-
export var audioNoCoverFileId = {
|
|
19
|
-
id: '7a5698bb-919c-4200-8699-6041e7913b11',
|
|
20
|
-
// mp3 audio
|
|
21
|
-
mediaItemType: fileType,
|
|
22
|
-
collectionName: collectionName
|
|
23
|
-
};
|
|
24
|
-
export var videoFileId = {
|
|
25
|
-
id: '1b01a476-83b4-4f44-8192-f83b2d00913a',
|
|
26
|
-
// mp4 video
|
|
27
|
-
mediaItemType: fileType,
|
|
28
|
-
collectionName: collectionName
|
|
29
|
-
};
|
|
30
|
-
export var videoHorizontalFileId = {
|
|
31
|
-
id: '2afaf845-4385-431f-9a15-3e21520cf896',
|
|
32
|
-
// .mov video
|
|
33
|
-
mediaItemType: fileType,
|
|
34
|
-
collectionName: collectionName
|
|
35
|
-
};
|
|
36
|
-
export var videoLargeFileId = {
|
|
37
|
-
id: '3291050e-6b66-4296-94c6-12088ef6fbad',
|
|
38
|
-
mediaItemType: fileType,
|
|
39
|
-
collectionName: collectionName
|
|
40
|
-
};
|
|
41
|
-
export var videoSquareFileId = {
|
|
42
|
-
id: 'cdff20d6-2c0a-4d0d-b2a9-22cc728a0368',
|
|
43
|
-
mediaItemType: fileType,
|
|
44
|
-
collectionName: collectionName
|
|
45
|
-
};
|
|
46
|
-
export var videoProcessingFailedId = {
|
|
47
|
-
id: 'e558199f-f982-4d23-93eb-313be5998d1b',
|
|
48
|
-
mediaItemType: fileType,
|
|
49
|
-
collectionName: collectionName
|
|
50
|
-
};
|
|
51
|
-
export var imageFileId = {
|
|
52
|
-
id: '5556346b-b081-482b-bc4a-4faca8ecd2de',
|
|
53
|
-
// jpg image
|
|
54
|
-
mediaItemType: fileType,
|
|
55
|
-
collectionName: collectionName
|
|
56
|
-
};
|
|
57
|
-
export var emptyImageFileId = {
|
|
58
|
-
id: 'aa7f7a63-2b1a-4405-b585-62e375a3b40a',
|
|
59
|
-
// jpg image
|
|
60
|
-
mediaItemType: fileType,
|
|
61
|
-
collectionName: collectionName
|
|
62
|
-
};
|
|
63
|
-
export var smallImageFileId = {
|
|
64
|
-
id: 'f251bd05-4b2d-485d-a088-57d112ca7945',
|
|
65
|
-
mediaItemType: fileType,
|
|
66
|
-
collectionName: collectionName
|
|
67
|
-
};
|
|
68
|
-
export var wideImageFileId = {
|
|
69
|
-
id: '3b6621a2-5b72-400e-ad95-447610dbb770',
|
|
70
|
-
mediaItemType: fileType,
|
|
71
|
-
collectionName: collectionName
|
|
72
|
-
};
|
|
73
|
-
export var largeImageFileId = {
|
|
74
|
-
id: '0607a6a8-b2ec-49a7-b6d3-d767cb49e844',
|
|
75
|
-
mediaItemType: fileType,
|
|
76
|
-
collectionName: collectionName
|
|
77
|
-
};
|
|
78
|
-
export var verticalImageFileId = {
|
|
79
|
-
id: 'f9235f5a-d582-4740-8611-ebf3feaf28b6',
|
|
80
|
-
mediaItemType: fileType,
|
|
81
|
-
collectionName: collectionName
|
|
82
|
-
};
|
|
83
|
-
export var docFileId = {
|
|
84
|
-
id: '71cd7e7d-4e86-4b89-a0b4-7f6ffe013c94',
|
|
85
|
-
mediaItemType: fileType,
|
|
86
|
-
collectionName: collectionName
|
|
87
|
-
};
|
|
88
|
-
export var bigDocFileId = {
|
|
89
|
-
id: 'd22f7a80-a661-4518-8b0e-eba02b6dfaca',
|
|
90
|
-
mediaItemType: fileType,
|
|
91
|
-
collectionName: collectionName
|
|
92
|
-
};
|
|
93
|
-
export var largePdfFileId = {
|
|
94
|
-
id: '0a510b7f-4168-44d8-b4d7-f5639ecefa2c',
|
|
95
|
-
mediaItemType: fileType,
|
|
96
|
-
collectionName: collectionName
|
|
97
|
-
};
|
|
98
|
-
export var passwordProtectedPdfFileId = {
|
|
99
|
-
id: 'c0e5bfa5-013d-4cbc-9b87-17d7f63bcc30',
|
|
100
|
-
mediaItemType: fileType,
|
|
101
|
-
collectionName: collectionName
|
|
102
|
-
};
|
|
103
|
-
export var codeFileId = {
|
|
104
|
-
id: '4bc95dd5-a7a2-4cbd-ac46-f9b9f0e0941a',
|
|
105
|
-
mediaItemType: fileType,
|
|
106
|
-
collectionName: collectionName
|
|
107
|
-
};
|
|
108
|
-
export var emailFileId = {
|
|
109
|
-
id: '79bb7327-fa6c-4e6f-8a7a-4ebd3607f481',
|
|
110
|
-
mediaItemType: fileType,
|
|
111
|
-
collectionName: collectionName
|
|
112
|
-
};
|
|
113
|
-
export var emailUnsupportedFileId = {
|
|
114
|
-
id: '3a2ae022-212a-4dca-a7d3-86eb016a0ed2',
|
|
115
|
-
mediaItemType: fileType,
|
|
116
|
-
collectionName: collectionName
|
|
117
|
-
};
|
|
118
|
-
export var archiveFileId = {
|
|
119
|
-
id: '1abbae6b-f507-4b4f-b181-21016bf3b7cc',
|
|
120
|
-
mediaItemType: fileType,
|
|
121
|
-
collectionName: collectionName
|
|
122
|
-
};
|
|
123
|
-
export var zipJiraArchiveFileId = {
|
|
124
|
-
id: 'aa99969c-6f0e-4cdc-8a57-9d38c43b2af8',
|
|
125
|
-
mediaItemType: fileType,
|
|
126
|
-
collectionName: collectionName
|
|
127
|
-
};
|
|
128
|
-
export var zipFileWithNestedFolderId = {
|
|
129
|
-
id: 'd1730520-316c-482a-a8c8-2b34acbea00b',
|
|
130
|
-
mediaItemType: fileType,
|
|
131
|
-
collectionName: collectionName
|
|
132
|
-
};
|
|
133
|
-
export var zipFileId = {
|
|
134
|
-
id: '3822aff2-9297-4ad9-93fd-ab1709f400ad',
|
|
135
|
-
mediaItemType: fileType,
|
|
136
|
-
collectionName: collectionName
|
|
137
|
-
};
|
|
138
|
-
export var zipItemMultipleFoldersAtRootId = {
|
|
139
|
-
id: 'b2c4623b-bd84-4d90-a2ed-61d50b0bd5f4',
|
|
140
|
-
mediaItemType: fileType,
|
|
141
|
-
collectionName: collectionName
|
|
142
|
-
};
|
|
143
|
-
export var zipItemLargeInnerFileId = {
|
|
144
|
-
id: '36b7957c-2d73-4cd5-8541-103daa2619ce',
|
|
145
|
-
mediaItemType: fileType,
|
|
146
|
-
collectionName: collectionName
|
|
147
|
-
};
|
|
148
|
-
export var zipEncryptedFileId = {
|
|
149
|
-
id: 'd1569d0f-936d-46f3-b974-a285696016c0',
|
|
150
|
-
mediaItemType: fileType,
|
|
151
|
-
collectionName: collectionName
|
|
152
|
-
};
|
|
153
|
-
export var unknownFileId = {
|
|
154
|
-
id: 'e0652e68-c596-4800-8a91-1920e6b8a585',
|
|
155
|
-
mediaItemType: fileType,
|
|
156
|
-
collectionName: collectionName
|
|
157
|
-
};
|
|
158
|
-
export var errorFileId = {
|
|
159
|
-
id: 'error-file-id',
|
|
160
|
-
mediaItemType: fileType,
|
|
161
|
-
collectionName: collectionName
|
|
162
|
-
};
|
|
163
|
-
export var gifFileId = {
|
|
164
|
-
id: '26adc5af-3af4-42a8-9c24-62b6ce0f9369',
|
|
165
|
-
mediaItemType: fileType,
|
|
166
|
-
collectionName: collectionName
|
|
167
|
-
};
|
|
168
|
-
export var noMetadataFileId = {
|
|
169
|
-
id: '1adaf6f9-37f6-4171-ab6b-455ec3115381',
|
|
170
|
-
mediaItemType: fileType,
|
|
171
|
-
collectionName: collectionName
|
|
172
|
-
};
|
|
173
|
-
export var animatedFileId = {
|
|
174
|
-
id: 'af637c7a-75c3-4254-b074-d16e6ae2e04b',
|
|
175
|
-
mediaItemType: fileType,
|
|
176
|
-
collectionName: onlyAnimatedGifsCollectionName
|
|
177
|
-
};
|
|
178
|
-
// === EXTERNAL IMAGE ===
|
|
179
|
-
|
|
180
|
-
export var atlassianLogoUrl = 'https://wac-cdn.atlassian.com/assets/img/favicons/atlassian/apple-touch-icon-152x152.png';
|
|
181
|
-
export var externalImageIdentifier = {
|
|
182
|
-
mediaItemType: 'external-image',
|
|
183
|
-
dataURI: atlassianLogoUrl
|
|
184
|
-
};
|
|
185
|
-
export var externalSmallImageIdentifier = {
|
|
186
|
-
mediaItemType: 'external-image',
|
|
187
|
-
dataURI: 'https://aui-cdn.atlassian.com/media/files-icon.png'
|
|
188
|
-
};
|
|
189
|
-
export var externaBrokenlIdentifier = {
|
|
190
|
-
mediaItemType: 'external-image',
|
|
191
|
-
dataURI: 'https://some-uri'
|
|
192
|
-
};
|
|
193
|
-
export var genericFileDetails = {
|
|
194
|
-
id: 'fd4c4672-323a-4b6c-8326-223169e2a13e',
|
|
195
|
-
mediaType: 'image',
|
|
196
|
-
mimeType: 'image/gif',
|
|
197
|
-
name: 'picker-thread-leaking.gif',
|
|
198
|
-
size: 2958464,
|
|
199
|
-
processingStatus: 'succeeded',
|
|
200
|
-
artifacts: {
|
|
201
|
-
'thumb_320.jpg': {
|
|
202
|
-
url: '/file/fd4c4672-323a-4b6c-8326-223169e2a13e/artifact/thumb_320.jpg/binary',
|
|
203
|
-
processingStatus: 'succeeded'
|
|
204
|
-
},
|
|
205
|
-
'thumb_large.jpg': {
|
|
206
|
-
url: '/file/fd4c4672-323a-4b6c-8326-223169e2a13e/artifact/thumb_320.jpg/binary',
|
|
207
|
-
processingStatus: 'succeeded'
|
|
208
|
-
},
|
|
209
|
-
'thumb_120.jpg': {
|
|
210
|
-
url: '/file/fd4c4672-323a-4b6c-8326-223169e2a13e/artifact/thumb_120.jpg/binary',
|
|
211
|
-
processingStatus: 'succeeded'
|
|
212
|
-
},
|
|
213
|
-
'thumb.jpg': {
|
|
214
|
-
url: '/file/fd4c4672-323a-4b6c-8326-223169e2a13e/artifact/thumb_120.jpg/binary',
|
|
215
|
-
processingStatus: 'succeeded'
|
|
216
|
-
},
|
|
217
|
-
'meta.json': {
|
|
218
|
-
url: '/file/fd4c4672-323a-4b6c-8326-223169e2a13e/artifact/meta.json/binary',
|
|
219
|
-
processingStatus: 'succeeded'
|
|
220
|
-
},
|
|
221
|
-
'image.jpg': {
|
|
222
|
-
url: '/file/fd4c4672-323a-4b6c-8326-223169e2a13e/artifact/image.jpg/binary',
|
|
223
|
-
processingStatus: 'succeeded'
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
export var imageFileDetails = {
|
|
228
|
-
id: 'some-id',
|
|
229
|
-
mediaType: 'image',
|
|
230
|
-
name: 'image_file.jpg',
|
|
231
|
-
size: 2958464
|
|
232
|
-
};
|
|
233
|
-
export var videoFileDetails = {
|
|
234
|
-
id: 'some-id',
|
|
235
|
-
mediaType: 'video',
|
|
236
|
-
name: 'video_file.mp4',
|
|
237
|
-
size: 29584640
|
|
238
|
-
};
|
|
239
|
-
export var audioFileDetails = {
|
|
240
|
-
id: 'some-id',
|
|
241
|
-
mediaType: 'audio',
|
|
242
|
-
name: 'audio_file.mp3',
|
|
243
|
-
size: 2958464
|
|
244
|
-
};
|
|
245
|
-
export var docFileDetails = {
|
|
246
|
-
id: 'some-id',
|
|
247
|
-
mediaType: 'doc',
|
|
248
|
-
name: 'doc_file.pdf',
|
|
249
|
-
size: 2958464
|
|
250
|
-
};
|
|
251
|
-
export var unknownFileDetails = {
|
|
252
|
-
id: 'some-id',
|
|
253
|
-
mediaType: 'unknown',
|
|
254
|
-
name: 'doc_file.pdf',
|
|
255
|
-
size: 2958464
|
|
256
|
-
};
|
|
257
|
-
export 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==';
|
|
258
|
-
|
|
259
|
-
// === VR test ids ===
|
|
260
|
-
|
|
261
|
-
export var vrVideoDetails = {
|
|
262
|
-
id: '0c3c64b9-65ad-4592-89d0-f838beebd81e',
|
|
263
|
-
name: 'video.mp4',
|
|
264
|
-
dataUri: videoURI,
|
|
265
|
-
previewDataUri: videoPreviewURI,
|
|
266
|
-
mediaType: 'video',
|
|
267
|
-
mimeType: 'video/mp4'
|
|
268
|
-
};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { MediaClient } from '../';
|
|
2
|
-
import { asMock, getJest } from '@atlaskit/media-common/test-helpers';
|
|
3
|
-
var jest = getJest();
|
|
4
|
-
export var getDefaultMediaClientConfig = function getDefaultMediaClientConfig() {
|
|
5
|
-
return {
|
|
6
|
-
authProvider: jest.fn().mockReturnValue(Promise.resolve({
|
|
7
|
-
clientId: 'some-client-id',
|
|
8
|
-
token: 'some-token',
|
|
9
|
-
baseUrl: 'some-service-host'
|
|
10
|
-
}))
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
export var fakeMediaClient = function fakeMediaClient() {
|
|
14
|
-
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getDefaultMediaClientConfig();
|
|
15
|
-
if (jest && jest.genMockFromModule) {
|
|
16
|
-
var _jest$genMockFromModu = jest.genMockFromModule('@atlaskit/media-client'),
|
|
17
|
-
MockMediaClient = _jest$genMockFromModu.MediaClient,
|
|
18
|
-
FileFetcherImpl = _jest$genMockFromModu.FileFetcherImpl,
|
|
19
|
-
MockMediaStore = _jest$genMockFromModu.MediaStore,
|
|
20
|
-
StargateClient = _jest$genMockFromModu.StargateClient;
|
|
21
|
-
var mediaClient = new MockMediaClient();
|
|
22
|
-
var fileFetcher = new FileFetcherImpl();
|
|
23
|
-
var mockMediaStore = new MockMediaStore({
|
|
24
|
-
authProvider: config.authProvider
|
|
25
|
-
});
|
|
26
|
-
var stargateClient = new StargateClient();
|
|
27
|
-
mediaClient.file = fileFetcher;
|
|
28
|
-
mediaClient.stargate = stargateClient;
|
|
29
|
-
mediaClient.config = config; // <- deprecated
|
|
30
|
-
mediaClient.mediaClientConfig = config;
|
|
31
|
-
mediaClient.mediaStore = mockMediaStore;
|
|
32
|
-
mediaClient.mediaStore.getItems = jest.fn().mockResolvedValue({
|
|
33
|
-
data: {
|
|
34
|
-
items: []
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
asMock(mediaClient.getImageUrl).mockResolvedValue('some-image-url');
|
|
38
|
-
asMock(mediaClient.getImageUrlSync).mockReturnValue('some-image-url');
|
|
39
|
-
asMock(mediaClient.getImage).mockImplementation(mockMediaStore.getImage);
|
|
40
|
-
asMock(mediaClient.file.copyFile).mockReturnValue({
|
|
41
|
-
id: 'copied-file-id'
|
|
42
|
-
});
|
|
43
|
-
asMock(mediaClient.file.getCurrentState).mockReturnValue(Promise.resolve({
|
|
44
|
-
id: 'file-id',
|
|
45
|
-
status: 'processed',
|
|
46
|
-
mediaType: 'image',
|
|
47
|
-
name: 'file_name'
|
|
48
|
-
}));
|
|
49
|
-
asMock(mediaClient.file.getFileState).mockImplementation(function () {
|
|
50
|
-
return {
|
|
51
|
-
subscribe: jest.fn()
|
|
52
|
-
};
|
|
53
|
-
});
|
|
54
|
-
asMock(mediaClient.stargate.fetchToken).mockImplementation(function () {
|
|
55
|
-
return Promise.resolve({
|
|
56
|
-
data: {
|
|
57
|
-
clientId: 'some-client-id-from-smart-edge',
|
|
58
|
-
token: 'some-token-from-smart-edge',
|
|
59
|
-
baseUrl: 'some-base-url-from-smart-edge',
|
|
60
|
-
expiresIn: 34000,
|
|
61
|
-
iat: new Date().getTime() / 1000
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
return mediaClient;
|
|
66
|
-
} else {
|
|
67
|
-
return new MediaClient(config);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { StoryBookAuthProvider } from './authProvider';
|
|
2
|
-
export { createStorybookMediaClient, createStorybookMediaClientConfig, createUploadMediaClient, createUploadMediaClientConfig, defaultBaseUrl, defaultParams } from './mediaClientProvider';
|
|
3
|
-
export { collectionNames, defaultCollectionName, defaultMediaPickerCollectionName, fileCollectionName, onlyAnimatedGifsCollectionName } from './collectionNames';
|
|
4
|
-
export { animatedFileId, archiveFileId, atlassianLogoUrl, audioFileDetails, audioFileId, audioNoCoverFileId, bigDocFileId, docFileDetails, docFileId, emptyImageFileId, errorFileId, externalImageIdentifier, externalSmallImageIdentifier, externaBrokenlIdentifier, genericDataURI, genericFileDetails, genericFileId, gifFileId, imageFileDetails, imageFileId, largeImageFileId, largePdfFileId, noMetadataFileId, passwordProtectedPdfFileId, smallImageFileId, unknownFileDetails, unknownFileId, verticalImageFileId, videoFileDetails, videoFileId, videoHorizontalFileId, videoLargeFileId, videoProcessingFailedId, videoSquareFileId, wideImageFileId, zipFileId, zipFileWithNestedFolderId, zipItemLargeInnerFileId, zipItemMultipleFoldersAtRootId, zipJiraArchiveFileId, zipEncryptedFileId, codeFileId, emailFileId, emailUnsupportedFileId, vrVideoDetails } from './exampleMediaItems';
|
|
5
|
-
export var authProviderBaseURL = 'https://media.dev.atl-paas.net';
|
|
6
|
-
export { mediaPickerAuthProvider, defaultMediaPickerAuthProvider } from './mediaPickerAuthProvider';
|
|
7
|
-
export { fakeMediaClient } from './fakeMediaClient';
|
|
8
|
-
export { createMockedMediaApi, copy, getIdentifier, createProcessingFileItem, createEmptyFileItem, createUploadingFileState, createFileState, createErrorFileState } from './MockedMediaApi';
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { MediaClient } from '../';
|
|
2
|
-
import { StoryBookAuthProvider } from './authProvider';
|
|
3
|
-
import { collectionNames } from './collectionNames';
|
|
4
|
-
import { mediaPickerAuthProvider } from './mediaPickerAuthProvider';
|
|
5
|
-
export var defaultBaseUrl = 'https://media.dev.atl-paas.net';
|
|
6
|
-
export var defaultParams = {
|
|
7
|
-
clientId: '5a9812fc-d029-4a39-8a46-d3cc36eed7ab',
|
|
8
|
-
asapIssuer: 'micros/media-playground',
|
|
9
|
-
baseUrl: defaultBaseUrl
|
|
10
|
-
};
|
|
11
|
-
var defaultAuthParameter = {
|
|
12
|
-
authType: 'client'
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Creates and returns `MediaClient` (from `media-client`) based on the data provided in parameter object.
|
|
17
|
-
*
|
|
18
|
-
* @param {AuthParameter} authParameter specifies serviceName and whatever auth should be done with clientId or asapIssuer
|
|
19
|
-
* @returns {Context}
|
|
20
|
-
*/
|
|
21
|
-
export var createStorybookMediaClient = function createStorybookMediaClient() {
|
|
22
|
-
var authParameter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultAuthParameter;
|
|
23
|
-
return new MediaClient(createStorybookMediaClientConfig(authParameter));
|
|
24
|
-
};
|
|
25
|
-
export var createStorybookMediaClientConfig = function createStorybookMediaClientConfig() {
|
|
26
|
-
var authParameter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultAuthParameter;
|
|
27
|
-
var scopes = {
|
|
28
|
-
'urn:filestore:file:*': ['read'],
|
|
29
|
-
'urn:filestore:chunk:*': ['read']
|
|
30
|
-
};
|
|
31
|
-
collectionNames.forEach(function (c) {
|
|
32
|
-
scopes["urn:filestore:collection:".concat(c)] = ['read', 'update'];
|
|
33
|
-
});
|
|
34
|
-
var isAsapEnvironment = authParameter.authType === 'asap';
|
|
35
|
-
var authProvider = StoryBookAuthProvider.create(isAsapEnvironment, scopes);
|
|
36
|
-
return {
|
|
37
|
-
authProvider: authProvider
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
export var createUploadMediaClient = function createUploadMediaClient() {
|
|
41
|
-
return new MediaClient(createUploadMediaClientConfig());
|
|
42
|
-
};
|
|
43
|
-
export var createUploadMediaClientConfig = function createUploadMediaClientConfig(stargateBaseUrl, env) {
|
|
44
|
-
return {
|
|
45
|
-
authProvider: mediaPickerAuthProvider('asap', env),
|
|
46
|
-
stargateBaseUrl: stargateBaseUrl
|
|
47
|
-
};
|
|
48
|
-
};
|