@atlaskit/media-client 25.1.0 → 26.1.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 +19 -0
- package/dist/cjs/client/media-store/MediaStore.js +0 -22
- package/dist/cjs/test-helpers/MockedMediaApi/MockedMediaApi.js +101 -118
- package/dist/cjs/test-helpers/MockedMediaApi/helpers.js +2 -2
- package/dist/cjs/uploader/index.js +36 -72
- package/dist/es2019/client/media-store/MediaStore.js +0 -21
- package/dist/es2019/test-helpers/MockedMediaApi/MockedMediaApi.js +13 -16
- package/dist/es2019/test-helpers/MockedMediaApi/helpers.js +2 -2
- package/dist/es2019/uploader/index.js +0 -7
- package/dist/esm/client/media-store/MediaStore.js +0 -22
- package/dist/esm/test-helpers/MockedMediaApi/MockedMediaApi.js +101 -118
- package/dist/esm/test-helpers/MockedMediaApi/helpers.js +2 -2
- package/dist/esm/uploader/index.js +36 -72
- package/dist/types/client/media-store/MediaStore.d.ts +1 -2
- package/dist/types/client/media-store/types.d.ts +1 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/models/media.d.ts +0 -7
- package/dist/types/test-helpers/MockedMediaApi/MockedMediaApi.d.ts +5 -5
- package/dist/types/test-helpers/MockedMediaApi/helpers.d.ts +1 -1
- package/dist/types/test-helpers/MockedMediaApi/index.d.ts +1 -1
- package/dist/types/test-helpers/index.d.ts +1 -1
- package/dist/types-ts4.5/client/media-store/MediaStore.d.ts +1 -2
- package/dist/types-ts4.5/client/media-store/types.d.ts +1 -2
- package/dist/types-ts4.5/index.d.ts +2 -2
- package/dist/types-ts4.5/models/media.d.ts +0 -7
- package/dist/types-ts4.5/test-helpers/MockedMediaApi/MockedMediaApi.d.ts +5 -5
- package/dist/types-ts4.5/test-helpers/MockedMediaApi/helpers.d.ts +1 -1
- package/dist/types-ts4.5/test-helpers/MockedMediaApi/index.d.ts +1 -1
- package/dist/types-ts4.5/test-helpers/index.d.ts +1 -1
- package/package.json +3 -3
- package/tmp/api-report-tmp.d.ts +0 -1199
|
@@ -37,29 +37,26 @@ var hashingFunction = /*#__PURE__*/function () {
|
|
|
37
37
|
return _ref.apply(this, arguments);
|
|
38
38
|
};
|
|
39
39
|
}();
|
|
40
|
-
var
|
|
40
|
+
var createUploadingFunction = function createUploadingFunction(store, deferredUploadId, collectionName, traceContext) {
|
|
41
41
|
return /*#__PURE__*/function () {
|
|
42
|
-
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(
|
|
43
|
-
var response, results;
|
|
42
|
+
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(chunk) {
|
|
44
43
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
45
44
|
while (1) switch (_context2.prev = _context2.next) {
|
|
46
45
|
case 0:
|
|
47
46
|
_context2.t0 = store;
|
|
48
|
-
_context2.t1 =
|
|
49
|
-
_context2.
|
|
47
|
+
_context2.t1 = chunk.hash;
|
|
48
|
+
_context2.t2 = chunk.blob;
|
|
49
|
+
_context2.next = 5;
|
|
50
50
|
return deferredUploadId;
|
|
51
|
-
case
|
|
52
|
-
_context2.
|
|
53
|
-
_context2.
|
|
54
|
-
_context2.
|
|
55
|
-
_context2.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return _context2.abrupt("return", Object.values(results).map(function (result) {
|
|
61
|
-
return result.exists;
|
|
62
|
-
}));
|
|
51
|
+
case 5:
|
|
52
|
+
_context2.t3 = _context2.sent;
|
|
53
|
+
_context2.t4 = chunk.partNumber;
|
|
54
|
+
_context2.t5 = collectionName;
|
|
55
|
+
_context2.t6 = traceContext;
|
|
56
|
+
_context2.next = 11;
|
|
57
|
+
return _context2.t0.uploadChunk.call(_context2.t0, _context2.t1, _context2.t2, _context2.t3, _context2.t4, _context2.t5, _context2.t6);
|
|
58
|
+
case 11:
|
|
59
|
+
return _context2.abrupt("return", _context2.sent);
|
|
63
60
|
case 12:
|
|
64
61
|
case "end":
|
|
65
62
|
return _context2.stop();
|
|
@@ -71,75 +68,44 @@ var createProbingFunction = function createProbingFunction(store, deferredUpload
|
|
|
71
68
|
};
|
|
72
69
|
}();
|
|
73
70
|
};
|
|
74
|
-
var
|
|
71
|
+
var createProcessingFunction = function createProcessingFunction(store, deferredUploadId, collection, traceContext) {
|
|
72
|
+
var offset = 0;
|
|
75
73
|
return /*#__PURE__*/function () {
|
|
76
|
-
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(
|
|
74
|
+
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(chunks) {
|
|
77
75
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
78
76
|
while (1) switch (_context3.prev = _context3.next) {
|
|
79
77
|
case 0:
|
|
80
78
|
_context3.t0 = store;
|
|
81
|
-
_context3.
|
|
82
|
-
_context3.t2 = chunk.blob;
|
|
83
|
-
_context3.next = 5;
|
|
84
|
-
return deferredUploadId;
|
|
85
|
-
case 5:
|
|
86
|
-
_context3.t3 = _context3.sent;
|
|
87
|
-
_context3.t4 = chunk.partNumber;
|
|
88
|
-
_context3.t5 = collectionName;
|
|
89
|
-
_context3.t6 = traceContext;
|
|
90
|
-
_context3.next = 11;
|
|
91
|
-
return _context3.t0.uploadChunk.call(_context3.t0, _context3.t1, _context3.t2, _context3.t3, _context3.t4, _context3.t5, _context3.t6);
|
|
92
|
-
case 11:
|
|
93
|
-
return _context3.abrupt("return", _context3.sent);
|
|
94
|
-
case 12:
|
|
95
|
-
case "end":
|
|
96
|
-
return _context3.stop();
|
|
97
|
-
}
|
|
98
|
-
}, _callee3);
|
|
99
|
-
}));
|
|
100
|
-
return function (_x3) {
|
|
101
|
-
return _ref3.apply(this, arguments);
|
|
102
|
-
};
|
|
103
|
-
}();
|
|
104
|
-
};
|
|
105
|
-
var createProcessingFunction = function createProcessingFunction(store, deferredUploadId, collection, traceContext) {
|
|
106
|
-
var offset = 0;
|
|
107
|
-
return /*#__PURE__*/function () {
|
|
108
|
-
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(chunks) {
|
|
109
|
-
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
110
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
111
|
-
case 0:
|
|
112
|
-
_context4.t0 = store;
|
|
113
|
-
_context4.next = 3;
|
|
79
|
+
_context3.next = 3;
|
|
114
80
|
return deferredUploadId;
|
|
115
81
|
case 3:
|
|
116
|
-
|
|
117
|
-
|
|
82
|
+
_context3.t1 = _context3.sent;
|
|
83
|
+
_context3.t2 = {
|
|
118
84
|
chunks: hashedChunks(chunks),
|
|
119
85
|
offset: offset
|
|
120
86
|
};
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
return
|
|
87
|
+
_context3.t3 = collection;
|
|
88
|
+
_context3.t4 = traceContext;
|
|
89
|
+
_context3.next = 9;
|
|
90
|
+
return _context3.t0.appendChunksToUpload.call(_context3.t0, _context3.t1, _context3.t2, _context3.t3, _context3.t4);
|
|
125
91
|
case 9:
|
|
126
92
|
offset += chunks.length;
|
|
127
93
|
case 10:
|
|
128
94
|
case "end":
|
|
129
|
-
return
|
|
95
|
+
return _context3.stop();
|
|
130
96
|
}
|
|
131
|
-
},
|
|
97
|
+
}, _callee3);
|
|
132
98
|
}));
|
|
133
|
-
return function (
|
|
134
|
-
return
|
|
99
|
+
return function (_x3) {
|
|
100
|
+
return _ref3.apply(this, arguments);
|
|
135
101
|
};
|
|
136
102
|
}();
|
|
137
103
|
};
|
|
138
104
|
var createFileFromUpload = /*#__PURE__*/function () {
|
|
139
|
-
var
|
|
105
|
+
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(file, store, uploadableFileUpfrontIds, uploadId, traceContext) {
|
|
140
106
|
var collection, name, mimeType, id, occurrenceKey, body;
|
|
141
|
-
return _regenerator.default.wrap(function
|
|
142
|
-
while (1) switch (
|
|
107
|
+
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
108
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
143
109
|
case 0:
|
|
144
110
|
collection = file.collection, name = file.name, mimeType = file.mimeType;
|
|
145
111
|
id = uploadableFileUpfrontIds.id, occurrenceKey = uploadableFileUpfrontIds.occurrenceKey;
|
|
@@ -155,19 +121,19 @@ var createFileFromUpload = /*#__PURE__*/function () {
|
|
|
155
121
|
name: name,
|
|
156
122
|
mimeType: mimeType
|
|
157
123
|
};
|
|
158
|
-
return
|
|
124
|
+
return _context4.abrupt("return", store.createFileFromUpload(body, {
|
|
159
125
|
occurrenceKey: occurrenceKey,
|
|
160
126
|
collection: collection,
|
|
161
127
|
replaceFileId: id
|
|
162
128
|
}, traceContext));
|
|
163
129
|
case 4:
|
|
164
130
|
case "end":
|
|
165
|
-
return
|
|
131
|
+
return _context4.stop();
|
|
166
132
|
}
|
|
167
|
-
},
|
|
133
|
+
}, _callee4);
|
|
168
134
|
}));
|
|
169
|
-
return function createFileFromUpload(_x5, _x6, _x7, _x8
|
|
170
|
-
return
|
|
135
|
+
return function createFileFromUpload(_x4, _x5, _x6, _x7, _x8) {
|
|
136
|
+
return _ref4.apply(this, arguments);
|
|
171
137
|
};
|
|
172
138
|
}();
|
|
173
139
|
var uploadFile = exports.uploadFile = function uploadFile(file, store, uploadableFileUpfrontIds, callbacks, traceContext) {
|
|
@@ -197,11 +163,9 @@ var uploadFile = exports.uploadFile = function uploadFile(file, store, uploadabl
|
|
|
197
163
|
var chunkinatorObservable = (0, _chunkinator.chunkinator)(content, {
|
|
198
164
|
hashingFunction: hashingFunction,
|
|
199
165
|
hashingConcurrency: 5,
|
|
200
|
-
probingBatchSize: 100,
|
|
201
166
|
chunkSize: chunkSize,
|
|
202
167
|
uploadingConcurrency: 3,
|
|
203
168
|
uploadingFunction: createUploadingFunction(store, deferredUploadId, collection, traceContext),
|
|
204
|
-
probingFunction: createProbingFunction(store, deferredUploadId, collection, traceContext),
|
|
205
169
|
processingBatchSize: _constants.PROCESSING_BATCH_SIZE,
|
|
206
170
|
processingFunction: createProcessingFunction(store, deferredUploadId, collection, traceContext)
|
|
207
171
|
}, {
|
|
@@ -100,27 +100,6 @@ export class MediaStore {
|
|
|
100
100
|
};
|
|
101
101
|
await this.request(`/chunk/${etag}`, options);
|
|
102
102
|
}
|
|
103
|
-
probeChunks(chunks, uploadId, collectionName, traceContext) {
|
|
104
|
-
const metadata = {
|
|
105
|
-
method: 'POST',
|
|
106
|
-
endpoint: '/chunk/probe'
|
|
107
|
-
};
|
|
108
|
-
const options = {
|
|
109
|
-
...metadata,
|
|
110
|
-
params: {
|
|
111
|
-
uploadId
|
|
112
|
-
},
|
|
113
|
-
authContext: {
|
|
114
|
-
collectionName
|
|
115
|
-
},
|
|
116
|
-
headers: jsonHeaders,
|
|
117
|
-
body: JSON.stringify({
|
|
118
|
-
chunks
|
|
119
|
-
}),
|
|
120
|
-
traceContext
|
|
121
|
-
};
|
|
122
|
-
return this.request(`/chunk/probe`, options).then(createMapResponseToJson(metadata));
|
|
123
|
-
}
|
|
124
103
|
createFileFromUpload(body, params = {}, traceContext) {
|
|
125
104
|
const metadata = {
|
|
126
105
|
method: 'POST',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getMediaFile, normaliseInput } from './helpers';
|
|
2
2
|
const getMediaApi = ({
|
|
3
|
-
|
|
3
|
+
getItem
|
|
4
4
|
}) => ({
|
|
5
5
|
// --------------------------------------------------------
|
|
6
6
|
// UPLOAD ENDPOINTS - None is supported
|
|
@@ -11,9 +11,6 @@ const getMediaApi = ({
|
|
|
11
11
|
}) => {
|
|
12
12
|
throw new Error('500 - MockedMediaApi.touchFiles: method not implemented');
|
|
13
13
|
},
|
|
14
|
-
probeChunks: async (...args) => {
|
|
15
|
-
throw new Error('500 - MockedMediaApi.probeChunks: method not implemented');
|
|
16
|
-
},
|
|
17
14
|
uploadChunk: async (_etag, _blob, uploadId) => {
|
|
18
15
|
throw new Error('500 - MockedMediaApi.uploadChunk: method not implemented');
|
|
19
16
|
},
|
|
@@ -40,7 +37,7 @@ const getMediaApi = ({
|
|
|
40
37
|
// --------------------------------------------------------
|
|
41
38
|
|
|
42
39
|
getFile: async fileId => {
|
|
43
|
-
const fileItem =
|
|
40
|
+
const fileItem = getItem(fileId);
|
|
44
41
|
if (!fileItem) {
|
|
45
42
|
throw new Error('404 - MockedMediaApi.getFile: file not found');
|
|
46
43
|
}
|
|
@@ -49,7 +46,7 @@ const getMediaApi = ({
|
|
|
49
46
|
};
|
|
50
47
|
},
|
|
51
48
|
getItems: async ids => {
|
|
52
|
-
const items = ids.map(id =>
|
|
49
|
+
const items = ids.map(id => getItem(id)).filter(fileState => !!fileState);
|
|
53
50
|
return {
|
|
54
51
|
data: {
|
|
55
52
|
items
|
|
@@ -73,7 +70,7 @@ const getMediaApi = ({
|
|
|
73
70
|
throw new Error('500 - MockedMediaApi.getFileImageURLSync: method not implemented');
|
|
74
71
|
},
|
|
75
72
|
getFileBinaryURL: async id => {
|
|
76
|
-
const fileItem =
|
|
73
|
+
const fileItem = getItem(id);
|
|
77
74
|
if (!fileItem) {
|
|
78
75
|
throw new Error('404 - MockedMediaApi.getFileBinaryURL: file not found');
|
|
79
76
|
}
|
|
@@ -95,7 +92,7 @@ const getMediaApi = ({
|
|
|
95
92
|
// BINARY ENDPOINTS
|
|
96
93
|
// --------------------------------------------------------
|
|
97
94
|
getImage: async fileId => {
|
|
98
|
-
const fileItem =
|
|
95
|
+
const fileItem = getItem(fileId);
|
|
99
96
|
if (!fileItem) {
|
|
100
97
|
throw new Error('404 - MockedMediaApi.getImage: file not found');
|
|
101
98
|
}
|
|
@@ -113,7 +110,7 @@ const getMediaApi = ({
|
|
|
113
110
|
// TODO
|
|
114
111
|
copyFileWithToken: async body => {
|
|
115
112
|
const fileId = body.sourceFile.id;
|
|
116
|
-
const fileItem =
|
|
113
|
+
const fileItem = getItem(fileId);
|
|
117
114
|
if (!fileItem) {
|
|
118
115
|
throw new Error('404 - MockedMediaApi.copyFileWithToken: file not found');
|
|
119
116
|
}
|
|
@@ -144,21 +141,21 @@ const getMediaApi = ({
|
|
|
144
141
|
*/
|
|
145
142
|
export const createMockedMediaApi = initialFileItems => {
|
|
146
143
|
const storedFileItems = new Map();
|
|
147
|
-
const
|
|
148
|
-
const
|
|
144
|
+
const getItem = fileId => storedFileItems.get(fileId);
|
|
145
|
+
const setItems = fileItems => {
|
|
149
146
|
const normalised = normaliseInput(fileItems);
|
|
150
147
|
normalised.forEach(fileItem => storedFileItems.set(fileItem.id, fileItem));
|
|
151
148
|
};
|
|
152
149
|
if (initialFileItems) {
|
|
153
|
-
|
|
150
|
+
setItems(initialFileItems);
|
|
154
151
|
}
|
|
155
152
|
const mediaApi = getMediaApi({
|
|
156
|
-
|
|
157
|
-
|
|
153
|
+
setItems,
|
|
154
|
+
getItem
|
|
158
155
|
});
|
|
159
156
|
return {
|
|
160
|
-
|
|
161
|
-
|
|
157
|
+
setItems,
|
|
158
|
+
getItem,
|
|
162
159
|
mediaApi
|
|
163
160
|
};
|
|
164
161
|
};
|
|
@@ -138,7 +138,7 @@ export const createUploadingFileState = ({
|
|
|
138
138
|
mimeType,
|
|
139
139
|
createdAt
|
|
140
140
|
}
|
|
141
|
-
}, progress) => ({
|
|
141
|
+
}, progress, binary) => ({
|
|
142
142
|
status: 'uploading',
|
|
143
143
|
progress,
|
|
144
144
|
id,
|
|
@@ -148,7 +148,7 @@ export const createUploadingFileState = ({
|
|
|
148
148
|
mimeType,
|
|
149
149
|
createdAt,
|
|
150
150
|
preview: {
|
|
151
|
-
value: new Blob(['some-content'], {
|
|
151
|
+
value: binary || new Blob(['some-content'], {
|
|
152
152
|
type: mimeType
|
|
153
153
|
})
|
|
154
154
|
}
|
|
@@ -12,11 +12,6 @@ const hashingFunction = async blob => {
|
|
|
12
12
|
const hasher = await createHasher();
|
|
13
13
|
return hasher.hash(blob);
|
|
14
14
|
};
|
|
15
|
-
const createProbingFunction = (store, deferredUploadId, collectionName, traceContext) => async chunks => {
|
|
16
|
-
const response = await store.probeChunks(hashedChunks(chunks), await deferredUploadId, collectionName, traceContext);
|
|
17
|
-
const results = response.data.results;
|
|
18
|
-
return Object.values(results).map(result => result.exists);
|
|
19
|
-
};
|
|
20
15
|
const createUploadingFunction = (store, deferredUploadId, collectionName, traceContext) => async chunk => {
|
|
21
16
|
return await store.uploadChunk(chunk.hash, chunk.blob, await deferredUploadId, chunk.partNumber, collectionName, traceContext);
|
|
22
17
|
};
|
|
@@ -89,11 +84,9 @@ export const uploadFile = (file, store, uploadableFileUpfrontIds, callbacks, tra
|
|
|
89
84
|
const chunkinatorObservable = chunkinator(content, {
|
|
90
85
|
hashingFunction,
|
|
91
86
|
hashingConcurrency: 5,
|
|
92
|
-
probingBatchSize: 100,
|
|
93
87
|
chunkSize,
|
|
94
88
|
uploadingConcurrency: 3,
|
|
95
89
|
uploadingFunction: createUploadingFunction(store, deferredUploadId, collection, traceContext),
|
|
96
|
-
probingFunction: createProbingFunction(store, deferredUploadId, collection, traceContext),
|
|
97
90
|
processingBatchSize: PROCESSING_BATCH_SIZE,
|
|
98
91
|
processingFunction: createProcessingFunction(store, deferredUploadId, collection, traceContext)
|
|
99
92
|
}, {
|
|
@@ -147,28 +147,6 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
147
147
|
}
|
|
148
148
|
return uploadChunk;
|
|
149
149
|
}()
|
|
150
|
-
}, {
|
|
151
|
-
key: "probeChunks",
|
|
152
|
-
value: function probeChunks(chunks, uploadId, collectionName, traceContext) {
|
|
153
|
-
var metadata = {
|
|
154
|
-
method: 'POST',
|
|
155
|
-
endpoint: '/chunk/probe'
|
|
156
|
-
};
|
|
157
|
-
var options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
158
|
-
params: {
|
|
159
|
-
uploadId: uploadId
|
|
160
|
-
},
|
|
161
|
-
authContext: {
|
|
162
|
-
collectionName: collectionName
|
|
163
|
-
},
|
|
164
|
-
headers: jsonHeaders,
|
|
165
|
-
body: JSON.stringify({
|
|
166
|
-
chunks: chunks
|
|
167
|
-
}),
|
|
168
|
-
traceContext: traceContext
|
|
169
|
-
});
|
|
170
|
-
return this.request("/chunk/probe", options).then(createMapResponseToJson(metadata));
|
|
171
|
-
}
|
|
172
150
|
}, {
|
|
173
151
|
key: "createFileFromUpload",
|
|
174
152
|
value: function createFileFromUpload(body) {
|