@atlaskit/media-client 17.1.2 → 17.1.4
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 +0 -13
- package/dist/cjs/client/file-fetcher/index.js +40 -36
- package/dist/cjs/client/media-client.js +2 -2
- package/dist/cjs/client/media-store/index.js +70 -44
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/uploader/index.js +22 -20
- package/dist/cjs/utils/request/helpers.js +46 -22
- package/dist/cjs/utils/request/index.js +3 -2
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/client/file-fetcher/index.js +16 -14
- package/dist/es2019/client/media-client.js +2 -2
- package/dist/es2019/client/media-store/index.js +52 -35
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/uploader/index.js +14 -14
- package/dist/es2019/utils/request/helpers.js +29 -8
- package/dist/es2019/utils/request/index.js +4 -3
- package/dist/es2019/version.json +1 -1
- package/dist/esm/client/file-fetcher/index.js +40 -36
- package/dist/esm/client/media-client.js +2 -2
- package/dist/esm/client/media-store/index.js +71 -45
- package/dist/esm/index.js +1 -1
- package/dist/esm/uploader/index.js +23 -21
- package/dist/esm/utils/request/helpers.js +41 -20
- package/dist/esm/utils/request/index.js +4 -3
- package/dist/esm/version.json +1 -1
- package/dist/types/client/file-fetcher/index.d.ts +9 -8
- package/dist/types/client/media-client.d.ts +2 -1
- package/dist/types/client/media-store/index.d.ts +15 -14
- package/dist/types/index.d.ts +3 -3
- package/dist/types/uploader/index.d.ts +2 -1
- package/dist/types/utils/request/helpers.d.ts +11 -3
- package/dist/types/utils/request/types.d.ts +5 -0
- package/package.json +5 -5
|
@@ -11,7 +11,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
11
11
|
import { FILE_CACHE_MAX_AGE, MAX_RESOLUTION } from '../../constants';
|
|
12
12
|
import { getArtifactUrl } from '../../models/artifacts';
|
|
13
13
|
import { request as _request } from '../../utils/request';
|
|
14
|
-
import { createUrl, createMapResponseToJson, createMapResponseToBlob } from '../../utils/request/helpers';
|
|
14
|
+
import { createUrl, createMapResponseToJson, createMapResponseToBlob, getRandomHex } from '../../utils/request/helpers';
|
|
15
15
|
import { resolveAuth, resolveInitialAuth } from './resolveAuth';
|
|
16
16
|
export { MediaStoreError, isMediaStoreError } from './error';
|
|
17
17
|
var MEDIA_API_REGION = 'media-api-region';
|
|
@@ -59,7 +59,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
59
59
|
_createClass(MediaStore, [{
|
|
60
60
|
key: "getCollectionItems",
|
|
61
61
|
value: function () {
|
|
62
|
-
var _getCollectionItems = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(collectionName, params) {
|
|
62
|
+
var _getCollectionItems = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(collectionName, params, traceContext) {
|
|
63
63
|
var metadata, options, response, _yield$createMapRespo, _yield$createMapRespo2, contents, nextInclusiveStartKey, contentsWithoutEmptyFiles;
|
|
64
64
|
|
|
65
65
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
@@ -77,7 +77,8 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
77
77
|
params: _objectSpread(_objectSpread({}, defaultGetCollectionItems), params),
|
|
78
78
|
headers: {
|
|
79
79
|
Accept: 'application/json'
|
|
80
|
-
}
|
|
80
|
+
},
|
|
81
|
+
traceContext: traceContext
|
|
81
82
|
});
|
|
82
83
|
_context.next = 4;
|
|
83
84
|
return this.request("/collection/".concat(collectionName, "/items"), options);
|
|
@@ -112,7 +113,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
112
113
|
}, _callee, this);
|
|
113
114
|
}));
|
|
114
115
|
|
|
115
|
-
function getCollectionItems(_x, _x2) {
|
|
116
|
+
function getCollectionItems(_x, _x2, _x3) {
|
|
116
117
|
return _getCollectionItems.apply(this, arguments);
|
|
117
118
|
}
|
|
118
119
|
|
|
@@ -121,7 +122,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
121
122
|
}, {
|
|
122
123
|
key: "removeCollectionFile",
|
|
123
124
|
value: function () {
|
|
124
|
-
var _removeCollectionFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(id, collectionName, occurrenceKey) {
|
|
125
|
+
var _removeCollectionFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(id, collectionName, occurrenceKey, traceContext) {
|
|
125
126
|
var metadata, body, options;
|
|
126
127
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
127
128
|
while (1) {
|
|
@@ -149,7 +150,8 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
149
150
|
Accept: 'application/json',
|
|
150
151
|
'Content-Type': 'application/json'
|
|
151
152
|
},
|
|
152
|
-
body: JSON.stringify(body)
|
|
153
|
+
body: JSON.stringify(body),
|
|
154
|
+
traceContext: traceContext
|
|
153
155
|
});
|
|
154
156
|
_context2.next = 5;
|
|
155
157
|
return this.request("/collection/".concat(collectionName), options);
|
|
@@ -162,7 +164,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
162
164
|
}, _callee2, this);
|
|
163
165
|
}));
|
|
164
166
|
|
|
165
|
-
function removeCollectionFile(
|
|
167
|
+
function removeCollectionFile(_x4, _x5, _x6, _x7) {
|
|
166
168
|
return _removeCollectionFile.apply(this, arguments);
|
|
167
169
|
}
|
|
168
170
|
|
|
@@ -173,6 +175,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
173
175
|
value: function createUpload() {
|
|
174
176
|
var createUpTo = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
175
177
|
var collectionName = arguments.length > 1 ? arguments[1] : undefined;
|
|
178
|
+
var traceContext = arguments.length > 2 ? arguments[2] : undefined;
|
|
176
179
|
var metadata = {
|
|
177
180
|
method: 'POST',
|
|
178
181
|
endpoint: '/upload'
|
|
@@ -187,7 +190,8 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
187
190
|
},
|
|
188
191
|
headers: {
|
|
189
192
|
Accept: 'application/json'
|
|
190
|
-
}
|
|
193
|
+
},
|
|
194
|
+
traceContext: traceContext
|
|
191
195
|
});
|
|
192
196
|
|
|
193
197
|
return this.request("/upload", options).then(createMapResponseToJson(metadata));
|
|
@@ -200,6 +204,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
200
204
|
collectionName,
|
|
201
205
|
uploadId,
|
|
202
206
|
partNumber,
|
|
207
|
+
traceContext,
|
|
203
208
|
metadata,
|
|
204
209
|
options,
|
|
205
210
|
_args3 = arguments;
|
|
@@ -209,6 +214,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
209
214
|
switch (_context3.prev = _context3.next) {
|
|
210
215
|
case 0:
|
|
211
216
|
_ref = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : {}, collectionName = _ref.collectionName, uploadId = _ref.uploadId, partNumber = _ref.partNumber;
|
|
217
|
+
traceContext = _args3.length > 3 ? _args3[3] : undefined;
|
|
212
218
|
metadata = {
|
|
213
219
|
method: 'PUT',
|
|
214
220
|
endpoint: '/chunk/{etag}'
|
|
@@ -221,12 +227,13 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
221
227
|
authContext: {
|
|
222
228
|
collectionName: collectionName
|
|
223
229
|
},
|
|
224
|
-
body: blob
|
|
230
|
+
body: blob,
|
|
231
|
+
traceContext: traceContext
|
|
225
232
|
});
|
|
226
|
-
_context3.next =
|
|
233
|
+
_context3.next = 6;
|
|
227
234
|
return this.request("/chunk/".concat(etag), options);
|
|
228
235
|
|
|
229
|
-
case
|
|
236
|
+
case 6:
|
|
230
237
|
case "end":
|
|
231
238
|
return _context3.stop();
|
|
232
239
|
}
|
|
@@ -234,7 +241,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
234
241
|
}, _callee3, this);
|
|
235
242
|
}));
|
|
236
243
|
|
|
237
|
-
function uploadChunk(
|
|
244
|
+
function uploadChunk(_x8, _x9) {
|
|
238
245
|
return _uploadChunk.apply(this, arguments);
|
|
239
246
|
}
|
|
240
247
|
|
|
@@ -247,6 +254,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
247
254
|
collectionName = _ref2.collectionName,
|
|
248
255
|
uploadId = _ref2.uploadId;
|
|
249
256
|
|
|
257
|
+
var traceContext = arguments.length > 2 ? arguments[2] : undefined;
|
|
250
258
|
var metadata = {
|
|
251
259
|
method: 'POST',
|
|
252
260
|
endpoint: '/chunk/probe'
|
|
@@ -262,7 +270,8 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
262
270
|
headers: jsonHeaders,
|
|
263
271
|
body: JSON.stringify({
|
|
264
272
|
chunks: chunks
|
|
265
|
-
})
|
|
273
|
+
}),
|
|
274
|
+
traceContext: traceContext
|
|
266
275
|
});
|
|
267
276
|
|
|
268
277
|
return this.request("/chunk/probe", options).then(createMapResponseToJson(metadata));
|
|
@@ -271,6 +280,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
271
280
|
key: "createFileFromUpload",
|
|
272
281
|
value: function createFileFromUpload(body) {
|
|
273
282
|
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
283
|
+
var traceContext = arguments.length > 2 ? arguments[2] : undefined;
|
|
274
284
|
var metadata = {
|
|
275
285
|
method: 'POST',
|
|
276
286
|
endpoint: '/file/upload'
|
|
@@ -282,7 +292,8 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
282
292
|
},
|
|
283
293
|
params: params,
|
|
284
294
|
headers: jsonHeaders,
|
|
285
|
-
body: JSON.stringify(body)
|
|
295
|
+
body: JSON.stringify(body),
|
|
296
|
+
traceContext: traceContext
|
|
286
297
|
});
|
|
287
298
|
|
|
288
299
|
return this.request('/file/upload', options).then(createMapResponseToJson(metadata));
|
|
@@ -291,6 +302,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
291
302
|
key: "touchFiles",
|
|
292
303
|
value: function touchFiles(body) {
|
|
293
304
|
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
305
|
+
var traceContext = arguments.length > 2 ? arguments[2] : undefined;
|
|
294
306
|
var metadata = {
|
|
295
307
|
method: 'POST',
|
|
296
308
|
endpoint: '/upload/createWithFiles'
|
|
@@ -301,7 +313,8 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
301
313
|
collectionName: params.collection
|
|
302
314
|
},
|
|
303
315
|
headers: jsonHeaders,
|
|
304
|
-
body: JSON.stringify(body)
|
|
316
|
+
body: JSON.stringify(body),
|
|
317
|
+
traceContext: traceContext
|
|
305
318
|
});
|
|
306
319
|
|
|
307
320
|
return this.request('/upload/createWithFiles', options).then(createMapResponseToJson(metadata));
|
|
@@ -310,6 +323,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
310
323
|
key: "getFile",
|
|
311
324
|
value: function getFile(fileId) {
|
|
312
325
|
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
326
|
+
var traceContext = arguments.length > 2 ? arguments[2] : undefined;
|
|
313
327
|
var metadata = {
|
|
314
328
|
method: 'GET',
|
|
315
329
|
endpoint: '/file/{fileId}'
|
|
@@ -319,7 +333,8 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
319
333
|
authContext: {
|
|
320
334
|
collectionName: params.collection
|
|
321
335
|
},
|
|
322
|
-
params: params
|
|
336
|
+
params: params,
|
|
337
|
+
traceContext: traceContext
|
|
323
338
|
});
|
|
324
339
|
|
|
325
340
|
return this.request("/file/".concat(fileId), options).then(createMapResponseToJson(metadata));
|
|
@@ -352,12 +367,13 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
352
367
|
}, _callee4, this);
|
|
353
368
|
}));
|
|
354
369
|
|
|
355
|
-
function getFileImageURL(
|
|
370
|
+
function getFileImageURL(_x10, _x11) {
|
|
356
371
|
return _getFileImageURL.apply(this, arguments);
|
|
357
372
|
}
|
|
358
373
|
|
|
359
374
|
return getFileImageURL;
|
|
360
|
-
}()
|
|
375
|
+
}() // TODO Create ticket in case Trace Id can be supported through query params
|
|
376
|
+
|
|
361
377
|
}, {
|
|
362
378
|
key: "getFileImageURLSync",
|
|
363
379
|
value: function getFileImageURLSync(id, params) {
|
|
@@ -407,7 +423,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
407
423
|
}, _callee5, this);
|
|
408
424
|
}));
|
|
409
425
|
|
|
410
|
-
function getFileBinaryURL(
|
|
426
|
+
function getFileBinaryURL(_x12, _x13) {
|
|
411
427
|
return _getFileBinaryURL.apply(this, arguments);
|
|
412
428
|
}
|
|
413
429
|
|
|
@@ -456,7 +472,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
456
472
|
}, _callee6, this);
|
|
457
473
|
}));
|
|
458
474
|
|
|
459
|
-
function getArtifactURL(
|
|
475
|
+
function getArtifactURL(_x14, _x15, _x16) {
|
|
460
476
|
return _getArtifactURL.apply(this, arguments);
|
|
461
477
|
}
|
|
462
478
|
|
|
@@ -465,7 +481,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
465
481
|
}, {
|
|
466
482
|
key: "getImage",
|
|
467
483
|
value: function () {
|
|
468
|
-
var _getImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(id, params, controller, fetchMaxRes) {
|
|
484
|
+
var _getImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(id, params, controller, fetchMaxRes, traceContext) {
|
|
469
485
|
var isWebpSupported, headers, metadata, options;
|
|
470
486
|
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
471
487
|
while (1) {
|
|
@@ -473,11 +489,10 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
473
489
|
case 0:
|
|
474
490
|
// TODO add checkWebpSupport() back https://product-fabric.atlassian.net/browse/MPT-584
|
|
475
491
|
isWebpSupported = false;
|
|
492
|
+
headers = {};
|
|
476
493
|
|
|
477
494
|
if (isWebpSupported) {
|
|
478
|
-
headers =
|
|
479
|
-
accept: 'image/webp,image/*,*/*;q=0.8'
|
|
480
|
-
};
|
|
495
|
+
headers.accept = 'image/webp,image/*,*/*;q=0.8';
|
|
481
496
|
}
|
|
482
497
|
|
|
483
498
|
metadata = {
|
|
@@ -489,11 +504,12 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
489
504
|
collectionName: params && params.collection
|
|
490
505
|
},
|
|
491
506
|
params: extendImageParams(params, fetchMaxRes),
|
|
492
|
-
headers: headers
|
|
507
|
+
headers: headers,
|
|
508
|
+
traceContext: traceContext
|
|
493
509
|
});
|
|
494
510
|
return _context7.abrupt("return", this.request("/file/".concat(id, "/image"), options, controller).then(createMapResponseToBlob(metadata)));
|
|
495
511
|
|
|
496
|
-
case
|
|
512
|
+
case 6:
|
|
497
513
|
case "end":
|
|
498
514
|
return _context7.stop();
|
|
499
515
|
}
|
|
@@ -501,7 +517,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
501
517
|
}, _callee7, this);
|
|
502
518
|
}));
|
|
503
519
|
|
|
504
|
-
function getImage(
|
|
520
|
+
function getImage(_x17, _x18, _x19, _x20, _x21) {
|
|
505
521
|
return _getImage.apply(this, arguments);
|
|
506
522
|
}
|
|
507
523
|
|
|
@@ -510,7 +526,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
510
526
|
}, {
|
|
511
527
|
key: "getItems",
|
|
512
528
|
value: function () {
|
|
513
|
-
var _getItems = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(ids, collectionName) {
|
|
529
|
+
var _getItems = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(ids, collectionName, traceContext) {
|
|
514
530
|
var descriptors, metadata, options;
|
|
515
531
|
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
516
532
|
while (1) {
|
|
@@ -534,7 +550,8 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
534
550
|
headers: jsonHeaders,
|
|
535
551
|
body: JSON.stringify({
|
|
536
552
|
descriptors: descriptors
|
|
537
|
-
})
|
|
553
|
+
}),
|
|
554
|
+
traceContext: traceContext
|
|
538
555
|
});
|
|
539
556
|
return _context8.abrupt("return", this.request('/items', options).then(createMapResponseToJson(metadata)));
|
|
540
557
|
|
|
@@ -546,7 +563,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
546
563
|
}, _callee8, this);
|
|
547
564
|
}));
|
|
548
565
|
|
|
549
|
-
function getItems(
|
|
566
|
+
function getItems(_x22, _x23, _x24) {
|
|
550
567
|
return _getItems.apply(this, arguments);
|
|
551
568
|
}
|
|
552
569
|
|
|
@@ -555,7 +572,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
555
572
|
}, {
|
|
556
573
|
key: "getImageMetadata",
|
|
557
574
|
value: function () {
|
|
558
|
-
var _getImageMetadata = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(id, params) {
|
|
575
|
+
var _getImageMetadata = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(id, params, traceContext) {
|
|
559
576
|
var metadata, options;
|
|
560
577
|
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
561
578
|
while (1) {
|
|
@@ -569,7 +586,8 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
569
586
|
authContext: {
|
|
570
587
|
collectionName: params && params.collection
|
|
571
588
|
},
|
|
572
|
-
params: params
|
|
589
|
+
params: params,
|
|
590
|
+
traceContext: traceContext
|
|
573
591
|
});
|
|
574
592
|
return _context9.abrupt("return", this.request("/file/".concat(id, "/image/metadata"), options).then(createMapResponseToJson(metadata)));
|
|
575
593
|
|
|
@@ -581,7 +599,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
581
599
|
}, _callee9, this);
|
|
582
600
|
}));
|
|
583
601
|
|
|
584
|
-
function getImageMetadata(
|
|
602
|
+
function getImageMetadata(_x25, _x26, _x27) {
|
|
585
603
|
return _getImageMetadata.apply(this, arguments);
|
|
586
604
|
}
|
|
587
605
|
|
|
@@ -590,7 +608,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
590
608
|
}, {
|
|
591
609
|
key: "appendChunksToUpload",
|
|
592
610
|
value: function () {
|
|
593
|
-
var _appendChunksToUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(uploadId, body, collectionName) {
|
|
611
|
+
var _appendChunksToUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(uploadId, body, collectionName, traceContext) {
|
|
594
612
|
var metadata, options;
|
|
595
613
|
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
596
614
|
while (1) {
|
|
@@ -605,7 +623,8 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
605
623
|
collectionName: collectionName
|
|
606
624
|
},
|
|
607
625
|
headers: jsonHeaders,
|
|
608
|
-
body: JSON.stringify(body)
|
|
626
|
+
body: JSON.stringify(body),
|
|
627
|
+
traceContext: traceContext
|
|
609
628
|
});
|
|
610
629
|
_context10.next = 4;
|
|
611
630
|
return this.request("/upload/".concat(uploadId, "/chunks"), options);
|
|
@@ -618,7 +637,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
618
637
|
}, _callee10, this);
|
|
619
638
|
}));
|
|
620
639
|
|
|
621
|
-
function appendChunksToUpload(
|
|
640
|
+
function appendChunksToUpload(_x28, _x29, _x30, _x31) {
|
|
622
641
|
return _appendChunksToUpload.apply(this, arguments);
|
|
623
642
|
}
|
|
624
643
|
|
|
@@ -626,7 +645,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
626
645
|
}()
|
|
627
646
|
}, {
|
|
628
647
|
key: "copyFileWithToken",
|
|
629
|
-
value: function copyFileWithToken(body, params) {
|
|
648
|
+
value: function copyFileWithToken(body, params, traceContext) {
|
|
630
649
|
var metadata = {
|
|
631
650
|
method: 'POST',
|
|
632
651
|
endpoint: '/file/copy/withToken'
|
|
@@ -640,8 +659,9 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
640
659
|
params: params,
|
|
641
660
|
// Contains collection name to write to
|
|
642
661
|
headers: jsonHeaders,
|
|
643
|
-
body: JSON.stringify(body)
|
|
644
|
-
|
|
662
|
+
body: JSON.stringify(body),
|
|
663
|
+
// Contains collection name to read from
|
|
664
|
+
traceContext: traceContext
|
|
645
665
|
});
|
|
646
666
|
|
|
647
667
|
return this.request('/file/copy/withToken', options).then(createMapResponseToJson(metadata));
|
|
@@ -659,7 +679,9 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
659
679
|
headers,
|
|
660
680
|
body,
|
|
661
681
|
clientOptions,
|
|
682
|
+
traceContext,
|
|
662
683
|
auth,
|
|
684
|
+
extendedTraceContext,
|
|
663
685
|
response,
|
|
664
686
|
_args11 = arguments;
|
|
665
687
|
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
@@ -672,13 +694,16 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
672
694
|
authContext: {}
|
|
673
695
|
};
|
|
674
696
|
controller = _args11.length > 2 ? _args11[2] : undefined;
|
|
675
|
-
method = options.method, endpoint = options.endpoint, authContext = options.authContext, params = options.params, headers = options.headers, body = options.body, clientOptions = options.clientOptions;
|
|
697
|
+
method = options.method, endpoint = options.endpoint, authContext = options.authContext, params = options.params, headers = options.headers, body = options.body, clientOptions = options.clientOptions, traceContext = options.traceContext;
|
|
676
698
|
_context11.next = 5;
|
|
677
699
|
return this.resolveAuth(authContext);
|
|
678
700
|
|
|
679
701
|
case 5:
|
|
680
702
|
auth = _context11.sent;
|
|
681
|
-
|
|
703
|
+
extendedTraceContext = traceContext ? _objectSpread(_objectSpread({}, traceContext), {}, {
|
|
704
|
+
spanId: (traceContext === null || traceContext === void 0 ? void 0 : traceContext.spanId) || getRandomHex(16)
|
|
705
|
+
}) : undefined;
|
|
706
|
+
_context11.next = 9;
|
|
682
707
|
return _request("".concat(auth.baseUrl).concat(path), {
|
|
683
708
|
method: method,
|
|
684
709
|
endpoint: endpoint,
|
|
@@ -686,16 +711,17 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
686
711
|
params: params,
|
|
687
712
|
headers: headers,
|
|
688
713
|
body: body,
|
|
689
|
-
clientOptions: clientOptions
|
|
714
|
+
clientOptions: clientOptions,
|
|
715
|
+
traceContext: extendedTraceContext
|
|
690
716
|
}, controller);
|
|
691
717
|
|
|
692
|
-
case
|
|
718
|
+
case 9:
|
|
693
719
|
response = _context11.sent;
|
|
694
720
|
setKeyValueInSessionStorage(MEDIA_API_REGION, response.headers.get('x-media-region'));
|
|
695
721
|
setKeyValueInSessionStorage(MEDIA_API_ENVIRONMENT, response.headers.get('x-media-env'));
|
|
696
722
|
return _context11.abrupt("return", response);
|
|
697
723
|
|
|
698
|
-
case
|
|
724
|
+
case 13:
|
|
699
725
|
case "end":
|
|
700
726
|
return _context11.stop();
|
|
701
727
|
}
|
|
@@ -703,7 +729,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
703
729
|
}, _callee11, this);
|
|
704
730
|
}));
|
|
705
731
|
|
|
706
|
-
function request(
|
|
732
|
+
function request(_x32) {
|
|
707
733
|
return _request2.apply(this, arguments);
|
|
708
734
|
}
|
|
709
735
|
|
package/dist/esm/index.js
CHANGED
|
@@ -8,7 +8,7 @@ export { isUploadingFileState, isProcessingFileState, isProcessedFileState, isEr
|
|
|
8
8
|
export { StreamsCache } from './file-streams-cache';
|
|
9
9
|
export { uploadFile } from './uploader';
|
|
10
10
|
export { request, RequestError, isRequestError, isRateLimitedError } from './utils/request';
|
|
11
|
-
export { isAbortedRequestError, mapResponseToJson, mapResponseToBlob, mapResponseToVoid, createUrl } from './utils/request/helpers';
|
|
11
|
+
export { isAbortedRequestError, mapResponseToJson, mapResponseToBlob, mapResponseToVoid, createUrl, getRandomHex } from './utils/request/helpers';
|
|
12
12
|
export { PollingFunction } from './utils/polling';
|
|
13
13
|
export { isPollingError, PollingError } from './utils/polling/errors';
|
|
14
14
|
export { imageResizeModeToFileImageMode } from './utils/imageResizeModeToFileImageMode';
|
|
@@ -13,7 +13,7 @@ import { createHasher } from '../utils/hashing/hasherCreator';
|
|
|
13
13
|
import { UploaderError } from './error';
|
|
14
14
|
import { CHUNK_SIZE, PROCESSING_BATCH_SIZE } from '../constants';
|
|
15
15
|
import { calculateChunkSize, fileSizeError } from './calculateChunkSize';
|
|
16
|
-
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
16
|
+
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
17
17
|
|
|
18
18
|
var hashingFunction = /*#__PURE__*/function () {
|
|
19
19
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(blob) {
|
|
@@ -42,7 +42,7 @@ var hashingFunction = /*#__PURE__*/function () {
|
|
|
42
42
|
};
|
|
43
43
|
}();
|
|
44
44
|
|
|
45
|
-
var createProbingFunction = function createProbingFunction(store, deferredUploadId, collectionName) {
|
|
45
|
+
var createProbingFunction = function createProbingFunction(store, deferredUploadId, collectionName, traceContext) {
|
|
46
46
|
return /*#__PURE__*/function () {
|
|
47
47
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(chunks) {
|
|
48
48
|
var response, results;
|
|
@@ -76,17 +76,18 @@ var createProbingFunction = function createProbingFunction(store, deferredUpload
|
|
|
76
76
|
collectionName: _context2.t2,
|
|
77
77
|
uploadId: _context2.t4
|
|
78
78
|
};
|
|
79
|
-
_context2.
|
|
80
|
-
|
|
79
|
+
_context2.t6 = traceContext;
|
|
80
|
+
_context2.next = 15;
|
|
81
|
+
return _context2.t0.probeChunks.call(_context2.t0, _context2.t1, _context2.t5, _context2.t6);
|
|
81
82
|
|
|
82
|
-
case
|
|
83
|
+
case 15:
|
|
83
84
|
response = _context2.sent;
|
|
84
85
|
results = response.data.results;
|
|
85
86
|
return _context2.abrupt("return", Object.values(results).map(function (result) {
|
|
86
87
|
return result.exists;
|
|
87
88
|
}));
|
|
88
89
|
|
|
89
|
-
case
|
|
90
|
+
case 18:
|
|
90
91
|
case "end":
|
|
91
92
|
return _context2.stop();
|
|
92
93
|
}
|
|
@@ -100,7 +101,7 @@ var createProbingFunction = function createProbingFunction(store, deferredUpload
|
|
|
100
101
|
}();
|
|
101
102
|
};
|
|
102
103
|
|
|
103
|
-
var createUploadingFunction = function createUploadingFunction(store, deferredUploadId, collectionName) {
|
|
104
|
+
var createUploadingFunction = function createUploadingFunction(store, deferredUploadId, collectionName, traceContext) {
|
|
104
105
|
return /*#__PURE__*/function () {
|
|
105
106
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(chunk) {
|
|
106
107
|
var options;
|
|
@@ -134,7 +135,7 @@ var createUploadingFunction = function createUploadingFunction(store, deferredUp
|
|
|
134
135
|
_context3.next = 12;
|
|
135
136
|
return store.uploadChunk(chunk.hash, chunk.blob, _objectSpread({
|
|
136
137
|
collectionName: collectionName
|
|
137
|
-
}, options));
|
|
138
|
+
}, options), traceContext);
|
|
138
139
|
|
|
139
140
|
case 12:
|
|
140
141
|
return _context3.abrupt("return", _context3.sent);
|
|
@@ -153,7 +154,7 @@ var createUploadingFunction = function createUploadingFunction(store, deferredUp
|
|
|
153
154
|
}();
|
|
154
155
|
};
|
|
155
156
|
|
|
156
|
-
var createProcessingFunction = function createProcessingFunction(store, deferredUploadId, collection) {
|
|
157
|
+
var createProcessingFunction = function createProcessingFunction(store, deferredUploadId, collection, traceContext) {
|
|
157
158
|
var offset = 0;
|
|
158
159
|
return /*#__PURE__*/function () {
|
|
159
160
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(chunks) {
|
|
@@ -172,13 +173,14 @@ var createProcessingFunction = function createProcessingFunction(store, deferred
|
|
|
172
173
|
offset: offset
|
|
173
174
|
};
|
|
174
175
|
_context4.t3 = collection;
|
|
175
|
-
_context4.
|
|
176
|
-
|
|
176
|
+
_context4.t4 = traceContext;
|
|
177
|
+
_context4.next = 9;
|
|
178
|
+
return _context4.t0.appendChunksToUpload.call(_context4.t0, _context4.t1, _context4.t2, _context4.t3, _context4.t4);
|
|
177
179
|
|
|
178
|
-
case
|
|
180
|
+
case 9:
|
|
179
181
|
offset += chunks.length;
|
|
180
182
|
|
|
181
|
-
case
|
|
183
|
+
case 10:
|
|
182
184
|
case "end":
|
|
183
185
|
return _context4.stop();
|
|
184
186
|
}
|
|
@@ -193,7 +195,7 @@ var createProcessingFunction = function createProcessingFunction(store, deferred
|
|
|
193
195
|
};
|
|
194
196
|
|
|
195
197
|
var createFileFromUpload = /*#__PURE__*/function () {
|
|
196
|
-
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(file, store, uploadableFileUpfrontIds, uploadId) {
|
|
198
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(file, store, uploadableFileUpfrontIds, uploadId, traceContext) {
|
|
197
199
|
var collection, name, mimeType, id, occurrenceKey;
|
|
198
200
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
199
201
|
while (1) {
|
|
@@ -209,7 +211,7 @@ var createFileFromUpload = /*#__PURE__*/function () {
|
|
|
209
211
|
occurrenceKey: occurrenceKey,
|
|
210
212
|
collection: collection,
|
|
211
213
|
replaceFileId: id
|
|
212
|
-
}));
|
|
214
|
+
}, traceContext));
|
|
213
215
|
|
|
214
216
|
case 3:
|
|
215
217
|
case "end":
|
|
@@ -219,12 +221,12 @@ var createFileFromUpload = /*#__PURE__*/function () {
|
|
|
219
221
|
}, _callee5);
|
|
220
222
|
}));
|
|
221
223
|
|
|
222
|
-
return function createFileFromUpload(_x5, _x6, _x7, _x8) {
|
|
224
|
+
return function createFileFromUpload(_x5, _x6, _x7, _x8, _x9) {
|
|
223
225
|
return _ref5.apply(this, arguments);
|
|
224
226
|
};
|
|
225
227
|
}();
|
|
226
228
|
|
|
227
|
-
export var uploadFile = function uploadFile(file, store, uploadableFileUpfrontIds, callbacks) {
|
|
229
|
+
export var uploadFile = function uploadFile(file, store, uploadableFileUpfrontIds, callbacks, traceContext) {
|
|
228
230
|
var content = file.content,
|
|
229
231
|
collection = file.collection;
|
|
230
232
|
var deferredUploadId = uploadableFileUpfrontIds.deferredUploadId,
|
|
@@ -257,10 +259,10 @@ export var uploadFile = function uploadFile(file, store, uploadableFileUpfrontId
|
|
|
257
259
|
probingBatchSize: 100,
|
|
258
260
|
chunkSize: chunkSize,
|
|
259
261
|
uploadingConcurrency: 3,
|
|
260
|
-
uploadingFunction: createUploadingFunction(store, deferredUploadId, collection),
|
|
261
|
-
probingFunction: createProbingFunction(store, deferredUploadId, collection),
|
|
262
|
+
uploadingFunction: createUploadingFunction(store, deferredUploadId, collection, traceContext),
|
|
263
|
+
probingFunction: createProbingFunction(store, deferredUploadId, collection, traceContext),
|
|
262
264
|
processingBatchSize: PROCESSING_BATCH_SIZE,
|
|
263
|
-
processingFunction: createProcessingFunction(store, deferredUploadId, collection)
|
|
265
|
+
processingFunction: createProcessingFunction(store, deferredUploadId, collection, traceContext)
|
|
264
266
|
}, {
|
|
265
267
|
onProgress: function onProgress(progress) {
|
|
266
268
|
if (callbacks) {
|
|
@@ -273,7 +275,7 @@ export var uploadFile = function uploadFile(file, store, uploadableFileUpfrontId
|
|
|
273
275
|
|
|
274
276
|
var subscription = from(deferredUploadId).pipe(concatMap(function (uploadId) {
|
|
275
277
|
return chunkinatorObservable.pipe(concatMap(function () {
|
|
276
|
-
return from(createFileFromUpload(file, store, uploadableFileUpfrontIds, uploadId));
|
|
278
|
+
return from(createFileFromUpload(file, store, uploadableFileUpfrontIds, uploadId, traceContext));
|
|
277
279
|
}));
|
|
278
280
|
})).subscribe({
|
|
279
281
|
error: function error(err) {
|