@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
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { videoURI, videoPreviewURI } from '@atlaskit/media-common/test-helpers';
|
|
2
|
+
import { defaultCollectionName as collectionName, onlyAnimatedGifsCollectionName } from './collectionNames';
|
|
3
|
+
const fileType = 'file';
|
|
4
|
+
|
|
5
|
+
// === FILE ===
|
|
6
|
+
|
|
7
|
+
export const genericFileId = {
|
|
8
|
+
id: '2dfcc12d-04d7-46e7-9fdf-3715ff00ba40',
|
|
9
|
+
mediaItemType: fileType,
|
|
10
|
+
collectionName: collectionName
|
|
11
|
+
};
|
|
12
|
+
export const audioFileId = {
|
|
13
|
+
id: 'a965c8df-1d64-4db8-9de5-16dfa8fd2e12',
|
|
14
|
+
// mp3 audio
|
|
15
|
+
mediaItemType: fileType,
|
|
16
|
+
collectionName: collectionName
|
|
17
|
+
};
|
|
18
|
+
export const audioNoCoverFileId = {
|
|
19
|
+
id: '7a5698bb-919c-4200-8699-6041e7913b11',
|
|
20
|
+
// mp3 audio
|
|
21
|
+
mediaItemType: fileType,
|
|
22
|
+
collectionName: collectionName
|
|
23
|
+
};
|
|
24
|
+
export const videoFileId = {
|
|
25
|
+
id: '1b01a476-83b4-4f44-8192-f83b2d00913a',
|
|
26
|
+
// mp4 video
|
|
27
|
+
mediaItemType: fileType,
|
|
28
|
+
collectionName: collectionName
|
|
29
|
+
};
|
|
30
|
+
export const videoHorizontalFileId = {
|
|
31
|
+
id: '2afaf845-4385-431f-9a15-3e21520cf896',
|
|
32
|
+
// .mov video
|
|
33
|
+
mediaItemType: fileType,
|
|
34
|
+
collectionName: collectionName
|
|
35
|
+
};
|
|
36
|
+
export const videoLargeFileId = {
|
|
37
|
+
id: '3291050e-6b66-4296-94c6-12088ef6fbad',
|
|
38
|
+
mediaItemType: fileType,
|
|
39
|
+
collectionName: collectionName
|
|
40
|
+
};
|
|
41
|
+
export const videoSquareFileId = {
|
|
42
|
+
id: 'cdff20d6-2c0a-4d0d-b2a9-22cc728a0368',
|
|
43
|
+
mediaItemType: fileType,
|
|
44
|
+
collectionName: collectionName
|
|
45
|
+
};
|
|
46
|
+
export const videoProcessingFailedId = {
|
|
47
|
+
id: 'e558199f-f982-4d23-93eb-313be5998d1b',
|
|
48
|
+
mediaItemType: fileType,
|
|
49
|
+
collectionName: collectionName
|
|
50
|
+
};
|
|
51
|
+
export const imageFileId = {
|
|
52
|
+
id: '5556346b-b081-482b-bc4a-4faca8ecd2de',
|
|
53
|
+
// jpg image
|
|
54
|
+
mediaItemType: fileType,
|
|
55
|
+
collectionName: collectionName
|
|
56
|
+
};
|
|
57
|
+
export const emptyImageFileId = {
|
|
58
|
+
id: 'aa7f7a63-2b1a-4405-b585-62e375a3b40a',
|
|
59
|
+
// jpg image
|
|
60
|
+
mediaItemType: fileType,
|
|
61
|
+
collectionName: collectionName
|
|
62
|
+
};
|
|
63
|
+
export const smallImageFileId = {
|
|
64
|
+
id: 'f251bd05-4b2d-485d-a088-57d112ca7945',
|
|
65
|
+
mediaItemType: fileType,
|
|
66
|
+
collectionName: collectionName
|
|
67
|
+
};
|
|
68
|
+
export const wideImageFileId = {
|
|
69
|
+
id: '3b6621a2-5b72-400e-ad95-447610dbb770',
|
|
70
|
+
mediaItemType: fileType,
|
|
71
|
+
collectionName: collectionName
|
|
72
|
+
};
|
|
73
|
+
export const largeImageFileId = {
|
|
74
|
+
id: '0607a6a8-b2ec-49a7-b6d3-d767cb49e844',
|
|
75
|
+
mediaItemType: fileType,
|
|
76
|
+
collectionName: collectionName
|
|
77
|
+
};
|
|
78
|
+
export const verticalImageFileId = {
|
|
79
|
+
id: 'f9235f5a-d582-4740-8611-ebf3feaf28b6',
|
|
80
|
+
mediaItemType: fileType,
|
|
81
|
+
collectionName: collectionName
|
|
82
|
+
};
|
|
83
|
+
export const docFileId = {
|
|
84
|
+
id: '71cd7e7d-4e86-4b89-a0b4-7f6ffe013c94',
|
|
85
|
+
mediaItemType: fileType,
|
|
86
|
+
collectionName: collectionName
|
|
87
|
+
};
|
|
88
|
+
export const bigDocFileId = {
|
|
89
|
+
id: 'd22f7a80-a661-4518-8b0e-eba02b6dfaca',
|
|
90
|
+
mediaItemType: fileType,
|
|
91
|
+
collectionName: collectionName
|
|
92
|
+
};
|
|
93
|
+
export const largePdfFileId = {
|
|
94
|
+
id: '0a510b7f-4168-44d8-b4d7-f5639ecefa2c',
|
|
95
|
+
mediaItemType: fileType,
|
|
96
|
+
collectionName: collectionName
|
|
97
|
+
};
|
|
98
|
+
export const passwordProtectedPdfFileId = {
|
|
99
|
+
id: 'c0e5bfa5-013d-4cbc-9b87-17d7f63bcc30',
|
|
100
|
+
mediaItemType: fileType,
|
|
101
|
+
collectionName: collectionName
|
|
102
|
+
};
|
|
103
|
+
export const codeFileId = {
|
|
104
|
+
id: '4bc95dd5-a7a2-4cbd-ac46-f9b9f0e0941a',
|
|
105
|
+
mediaItemType: fileType,
|
|
106
|
+
collectionName: collectionName
|
|
107
|
+
};
|
|
108
|
+
export const emailFileId = {
|
|
109
|
+
id: '79bb7327-fa6c-4e6f-8a7a-4ebd3607f481',
|
|
110
|
+
mediaItemType: fileType,
|
|
111
|
+
collectionName: collectionName
|
|
112
|
+
};
|
|
113
|
+
export const emailUnsupportedFileId = {
|
|
114
|
+
id: '3a2ae022-212a-4dca-a7d3-86eb016a0ed2',
|
|
115
|
+
mediaItemType: fileType,
|
|
116
|
+
collectionName: collectionName
|
|
117
|
+
};
|
|
118
|
+
export const archiveFileId = {
|
|
119
|
+
id: '1abbae6b-f507-4b4f-b181-21016bf3b7cc',
|
|
120
|
+
mediaItemType: fileType,
|
|
121
|
+
collectionName: collectionName
|
|
122
|
+
};
|
|
123
|
+
export const zipJiraArchiveFileId = {
|
|
124
|
+
id: 'aa99969c-6f0e-4cdc-8a57-9d38c43b2af8',
|
|
125
|
+
mediaItemType: fileType,
|
|
126
|
+
collectionName: collectionName
|
|
127
|
+
};
|
|
128
|
+
export const zipFileWithNestedFolderId = {
|
|
129
|
+
id: 'd1730520-316c-482a-a8c8-2b34acbea00b',
|
|
130
|
+
mediaItemType: fileType,
|
|
131
|
+
collectionName: collectionName
|
|
132
|
+
};
|
|
133
|
+
export const zipFileId = {
|
|
134
|
+
id: '3822aff2-9297-4ad9-93fd-ab1709f400ad',
|
|
135
|
+
mediaItemType: fileType,
|
|
136
|
+
collectionName: collectionName
|
|
137
|
+
};
|
|
138
|
+
export const zipItemMultipleFoldersAtRootId = {
|
|
139
|
+
id: 'b2c4623b-bd84-4d90-a2ed-61d50b0bd5f4',
|
|
140
|
+
mediaItemType: fileType,
|
|
141
|
+
collectionName: collectionName
|
|
142
|
+
};
|
|
143
|
+
export const zipItemLargeInnerFileId = {
|
|
144
|
+
id: '36b7957c-2d73-4cd5-8541-103daa2619ce',
|
|
145
|
+
mediaItemType: fileType,
|
|
146
|
+
collectionName: collectionName
|
|
147
|
+
};
|
|
148
|
+
export const zipEncryptedFileId = {
|
|
149
|
+
id: 'd1569d0f-936d-46f3-b974-a285696016c0',
|
|
150
|
+
mediaItemType: fileType,
|
|
151
|
+
collectionName: collectionName
|
|
152
|
+
};
|
|
153
|
+
export const unknownFileId = {
|
|
154
|
+
id: 'e0652e68-c596-4800-8a91-1920e6b8a585',
|
|
155
|
+
mediaItemType: fileType,
|
|
156
|
+
collectionName: collectionName
|
|
157
|
+
};
|
|
158
|
+
export const errorFileId = {
|
|
159
|
+
id: 'error-file-id',
|
|
160
|
+
mediaItemType: fileType,
|
|
161
|
+
collectionName: collectionName
|
|
162
|
+
};
|
|
163
|
+
export const gifFileId = {
|
|
164
|
+
id: '26adc5af-3af4-42a8-9c24-62b6ce0f9369',
|
|
165
|
+
mediaItemType: fileType,
|
|
166
|
+
collectionName: collectionName
|
|
167
|
+
};
|
|
168
|
+
export const noMetadataFileId = {
|
|
169
|
+
id: '1adaf6f9-37f6-4171-ab6b-455ec3115381',
|
|
170
|
+
mediaItemType: fileType,
|
|
171
|
+
collectionName: collectionName
|
|
172
|
+
};
|
|
173
|
+
export const animatedFileId = {
|
|
174
|
+
id: 'af637c7a-75c3-4254-b074-d16e6ae2e04b',
|
|
175
|
+
mediaItemType: fileType,
|
|
176
|
+
collectionName: onlyAnimatedGifsCollectionName
|
|
177
|
+
};
|
|
178
|
+
// === EXTERNAL IMAGE ===
|
|
179
|
+
|
|
180
|
+
export const atlassianLogoUrl = 'https://wac-cdn.atlassian.com/assets/img/favicons/atlassian/apple-touch-icon-152x152.png';
|
|
181
|
+
export const externalImageIdentifier = {
|
|
182
|
+
mediaItemType: 'external-image',
|
|
183
|
+
dataURI: atlassianLogoUrl
|
|
184
|
+
};
|
|
185
|
+
export const externalSmallImageIdentifier = {
|
|
186
|
+
mediaItemType: 'external-image',
|
|
187
|
+
dataURI: 'https://aui-cdn.atlassian.com/media/files-icon.png'
|
|
188
|
+
};
|
|
189
|
+
export const externaBrokenlIdentifier = {
|
|
190
|
+
mediaItemType: 'external-image',
|
|
191
|
+
dataURI: 'https://some-uri'
|
|
192
|
+
};
|
|
193
|
+
export const 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 const imageFileDetails = {
|
|
228
|
+
id: 'some-id',
|
|
229
|
+
mediaType: 'image',
|
|
230
|
+
name: 'image_file.jpg',
|
|
231
|
+
size: 2958464
|
|
232
|
+
};
|
|
233
|
+
export const videoFileDetails = {
|
|
234
|
+
id: 'some-id',
|
|
235
|
+
mediaType: 'video',
|
|
236
|
+
name: 'video_file.mp4',
|
|
237
|
+
size: 29584640
|
|
238
|
+
};
|
|
239
|
+
export const audioFileDetails = {
|
|
240
|
+
id: 'some-id',
|
|
241
|
+
mediaType: 'audio',
|
|
242
|
+
name: 'audio_file.mp3',
|
|
243
|
+
size: 2958464
|
|
244
|
+
};
|
|
245
|
+
export const docFileDetails = {
|
|
246
|
+
id: 'some-id',
|
|
247
|
+
mediaType: 'doc',
|
|
248
|
+
name: 'doc_file.pdf',
|
|
249
|
+
size: 2958464
|
|
250
|
+
};
|
|
251
|
+
export const unknownFileDetails = {
|
|
252
|
+
id: 'some-id',
|
|
253
|
+
mediaType: 'unknown',
|
|
254
|
+
name: 'doc_file.pdf',
|
|
255
|
+
size: 2958464
|
|
256
|
+
};
|
|
257
|
+
export const 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 const 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
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { MediaClient } from '../';
|
|
2
|
+
import { asMock, getJest } from '@atlaskit/media-common/test-helpers';
|
|
3
|
+
const jest = getJest();
|
|
4
|
+
export const getDefaultMediaClientConfig = () => ({
|
|
5
|
+
authProvider: jest.fn().mockReturnValue(Promise.resolve({
|
|
6
|
+
clientId: 'some-client-id',
|
|
7
|
+
token: 'some-token',
|
|
8
|
+
baseUrl: 'some-service-host'
|
|
9
|
+
}))
|
|
10
|
+
});
|
|
11
|
+
export const fakeMediaClient = (config = getDefaultMediaClientConfig()) => {
|
|
12
|
+
if (jest && jest.genMockFromModule) {
|
|
13
|
+
const {
|
|
14
|
+
MediaClient: MockMediaClient,
|
|
15
|
+
FileFetcherImpl,
|
|
16
|
+
MediaStore: MockMediaStore,
|
|
17
|
+
StargateClient
|
|
18
|
+
} = jest.genMockFromModule('@atlaskit/media-client');
|
|
19
|
+
const mediaClient = new MockMediaClient();
|
|
20
|
+
const fileFetcher = new FileFetcherImpl();
|
|
21
|
+
const mockMediaStore = new MockMediaStore({
|
|
22
|
+
authProvider: config.authProvider
|
|
23
|
+
});
|
|
24
|
+
const stargateClient = new StargateClient();
|
|
25
|
+
mediaClient.file = fileFetcher;
|
|
26
|
+
mediaClient.stargate = stargateClient;
|
|
27
|
+
mediaClient.config = config; // <- deprecated
|
|
28
|
+
mediaClient.mediaClientConfig = config;
|
|
29
|
+
mediaClient.mediaStore = mockMediaStore;
|
|
30
|
+
mediaClient.mediaStore.getItems = jest.fn().mockResolvedValue({
|
|
31
|
+
data: {
|
|
32
|
+
items: []
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
asMock(mediaClient.getImageUrl).mockResolvedValue('some-image-url');
|
|
36
|
+
asMock(mediaClient.getImageUrlSync).mockReturnValue('some-image-url');
|
|
37
|
+
asMock(mediaClient.getImage).mockImplementation(mockMediaStore.getImage);
|
|
38
|
+
asMock(mediaClient.file.copyFile).mockReturnValue({
|
|
39
|
+
id: 'copied-file-id'
|
|
40
|
+
});
|
|
41
|
+
asMock(mediaClient.file.getCurrentState).mockReturnValue(Promise.resolve({
|
|
42
|
+
id: 'file-id',
|
|
43
|
+
status: 'processed',
|
|
44
|
+
mediaType: 'image',
|
|
45
|
+
name: 'file_name'
|
|
46
|
+
}));
|
|
47
|
+
asMock(mediaClient.file.getFileState).mockImplementation(() => ({
|
|
48
|
+
subscribe: jest.fn()
|
|
49
|
+
}));
|
|
50
|
+
asMock(mediaClient.stargate.fetchToken).mockImplementation(() => Promise.resolve({
|
|
51
|
+
data: {
|
|
52
|
+
clientId: 'some-client-id-from-smart-edge',
|
|
53
|
+
token: 'some-token-from-smart-edge',
|
|
54
|
+
baseUrl: 'some-base-url-from-smart-edge',
|
|
55
|
+
expiresIn: 34000,
|
|
56
|
+
iat: new Date().getTime() / 1000
|
|
57
|
+
}
|
|
58
|
+
}));
|
|
59
|
+
return mediaClient;
|
|
60
|
+
} else {
|
|
61
|
+
return new MediaClient(config);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
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 const authProviderBaseURL = 'https://media.dev.atl-paas.net';
|
|
6
|
+
export { mediaPickerAuthProvider, defaultMediaPickerAuthProvider } from './mediaPickerAuthProvider';
|
|
7
|
+
export { fakeMediaClient } from './fakeMediaClient';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { MediaClient } from '../';
|
|
2
|
+
import { StoryBookAuthProvider } from './authProvider';
|
|
3
|
+
import { collectionNames } from './collectionNames';
|
|
4
|
+
import { mediaPickerAuthProvider } from './mediaPickerAuthProvider';
|
|
5
|
+
export const defaultBaseUrl = 'https://media.dev.atl-paas.net';
|
|
6
|
+
export const defaultParams = {
|
|
7
|
+
clientId: '5a9812fc-d029-4a39-8a46-d3cc36eed7ab',
|
|
8
|
+
asapIssuer: 'micros/media-playground',
|
|
9
|
+
baseUrl: defaultBaseUrl
|
|
10
|
+
};
|
|
11
|
+
const 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 const createStorybookMediaClient = (authParameter = defaultAuthParameter) => {
|
|
22
|
+
return new MediaClient(createStorybookMediaClientConfig(authParameter));
|
|
23
|
+
};
|
|
24
|
+
export const createStorybookMediaClientConfig = (authParameter = defaultAuthParameter) => {
|
|
25
|
+
const scopes = {
|
|
26
|
+
'urn:filestore:file:*': ['read'],
|
|
27
|
+
'urn:filestore:chunk:*': ['read']
|
|
28
|
+
};
|
|
29
|
+
collectionNames.forEach(c => {
|
|
30
|
+
scopes[`urn:filestore:collection:${c}`] = ['read', 'update'];
|
|
31
|
+
});
|
|
32
|
+
const isAsapEnvironment = authParameter.authType === 'asap';
|
|
33
|
+
const authProvider = StoryBookAuthProvider.create(isAsapEnvironment, scopes);
|
|
34
|
+
return {
|
|
35
|
+
authProvider
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export const createUploadMediaClient = () => new MediaClient(createUploadMediaClientConfig());
|
|
39
|
+
export const createUploadMediaClientConfig = (stargateBaseUrl, env) => ({
|
|
40
|
+
authProvider: mediaPickerAuthProvider('asap', env),
|
|
41
|
+
stargateBaseUrl
|
|
42
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { defaultCollectionName } from './collectionNames';
|
|
2
|
+
export const authProviderBaseURL = 'https://media.dev.atl-paas.net';
|
|
3
|
+
const cachedAuths = {};
|
|
4
|
+
const accessUrns = {
|
|
5
|
+
MediaServicesSample: {
|
|
6
|
+
'urn:filestore:collection:MediaServicesSample': ['read', 'insert'],
|
|
7
|
+
'urn:filestore:chunk:*': ['create', 'read'],
|
|
8
|
+
'urn:filestore:upload': ['create'],
|
|
9
|
+
'urn:filestore:upload:*': ['read', 'update'],
|
|
10
|
+
'urn:filestore:file': ['create'],
|
|
11
|
+
'urn:filestore:file:*': ['read', 'update']
|
|
12
|
+
},
|
|
13
|
+
'mediapicker-test': {
|
|
14
|
+
'urn:filestore:collection': ['create'],
|
|
15
|
+
'urn:filestore:collection:mediapicker-test': ['read', 'insert'],
|
|
16
|
+
'urn:filestore:chunk:*': ['create', 'read'],
|
|
17
|
+
'urn:filestore:upload': ['create'],
|
|
18
|
+
'urn:filestore:upload:*': ['read', 'update'],
|
|
19
|
+
'urn:filestore:file': ['create'],
|
|
20
|
+
'urn:filestore:file:*': ['read', 'update']
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const requestAuthProvider = async (authEnvironment, collectionName, env = 'dev') => {
|
|
24
|
+
const url = `https://media-playground.${env}.atl-paas.net/token/tenant?environment=${authEnvironment}`;
|
|
25
|
+
const body = JSON.stringify({
|
|
26
|
+
access: accessUrns[collectionName] || {}
|
|
27
|
+
});
|
|
28
|
+
const headers = new Headers();
|
|
29
|
+
headers.append('Content-Type', 'application/json; charset=utf-8');
|
|
30
|
+
headers.append('Accept', 'text/plain, */*; q=0.01');
|
|
31
|
+
const response = await fetch(url, {
|
|
32
|
+
method: 'POST',
|
|
33
|
+
body,
|
|
34
|
+
headers
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// We leverage the fact, that our internal /toke/tenant API returns data in the same format as Auth
|
|
38
|
+
return response.json();
|
|
39
|
+
};
|
|
40
|
+
export const mediaPickerAuthProvider = (authEnvironment = 'asap', env) => context => {
|
|
41
|
+
const collectionName = context && context.collectionName || defaultCollectionName;
|
|
42
|
+
authEnvironment = authEnvironment === 'asap' ? 'asap' : '';
|
|
43
|
+
const cacheKey = `${collectionName}:${authEnvironment}`;
|
|
44
|
+
if (!cachedAuths[cacheKey]) {
|
|
45
|
+
cachedAuths[cacheKey] = requestAuthProvider(authEnvironment, collectionName, env);
|
|
46
|
+
}
|
|
47
|
+
return cachedAuths[cacheKey];
|
|
48
|
+
};
|
|
49
|
+
export const defaultMediaPickerAuthProvider = () => () => {
|
|
50
|
+
const auth = {
|
|
51
|
+
clientId: 'a89be2a1-f91f-485c-9962-a8fb25ccfa13',
|
|
52
|
+
token: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhODliZTJhMS1mOTFmLTQ4NWMtOTk2Mi1hOGZiMjVjY2ZhMTMiLCJ1bnNhZmUiOnRydWUsImlhdCI6MTQ3MzIyNTEzNn0.6Isj5jKgKzWDnPqfoMLiC_LVIlGM8kg_wxG6eGGwhTw',
|
|
53
|
+
baseUrl: authProviderBaseURL
|
|
54
|
+
};
|
|
55
|
+
return Promise.resolve(auth);
|
|
56
|
+
};
|
|
@@ -2,8 +2,8 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
|
2
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
4
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
5
|
-
function ownKeys(
|
|
6
|
-
function _objectSpread(
|
|
5
|
+
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; }
|
|
6
|
+
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; }
|
|
7
7
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
8
|
import { Subscription } from 'rxjs/Subscription';
|
|
9
9
|
import { map } from 'rxjs/operators/map';
|
|
@@ -3,8 +3,8 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
|
3
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
4
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
5
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
|
-
function ownKeys(
|
|
7
|
-
function _objectSpread(
|
|
6
|
+
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; }
|
|
7
|
+
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; }
|
|
8
8
|
import { getRandomHex } from '@atlaskit/media-common';
|
|
9
9
|
import { FILE_CACHE_MAX_AGE, MAX_RESOLUTION } from '../../constants';
|
|
10
10
|
import { getArtifactUrl } from '../../models/artifacts';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
function ownKeys(
|
|
3
|
-
function _objectSpread(
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
4
4
|
export var isUploadingFileState = function isUploadingFileState(fileState) {
|
|
5
5
|
return fileState.status === 'uploading';
|
|
6
6
|
};
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
}();
|
|
@@ -0,0 +1,5 @@
|
|
|
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];
|