@atlaskit/media-client 18.0.0 → 19.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 +21 -0
- package/dist/cjs/client/collection-fetcher.js +8 -8
- 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 +72 -44
- package/dist/cjs/uploader/index.js +22 -20
- package/dist/cjs/utils/getVideoDimensionsFromBlob.js +23 -19
- package/dist/cjs/utils/request/helpers.js +39 -22
- package/dist/cjs/utils/request/index.js +3 -2
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/client/collection-fetcher.js +6 -6
- 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 -34
- package/dist/es2019/uploader/index.js +13 -13
- package/dist/es2019/utils/getVideoDimensionsFromBlob.js +21 -7
- package/dist/es2019/utils/request/helpers.js +26 -8
- package/dist/es2019/utils/request/index.js +4 -3
- package/dist/es2019/version.json +1 -1
- package/dist/esm/client/collection-fetcher.js +8 -8
- 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 -44
- package/dist/esm/uploader/index.js +22 -20
- package/dist/esm/utils/getVideoDimensionsFromBlob.js +21 -16
- package/dist/esm/utils/request/helpers.js +36 -20
- package/dist/esm/utils/request/index.js +4 -3
- package/dist/esm/version.json +1 -1
- package/dist/types/client/collection-fetcher.d.ts +4 -3
- package/dist/types/client/file-fetcher/index.d.ts +9 -8
- package/dist/types/client/media-client.d.ts +2 -2
- package/dist/types/client/media-store/index.d.ts +15 -14
- package/dist/types/uploader/index.d.ts +2 -1
- package/dist/types/utils/getVideoDimensionsFromBlob.d.ts +3 -4
- package/dist/types/utils/request/helpers.d.ts +10 -2
- package/dist/types/utils/request/types.d.ts +2 -0
- package/example-helpers/styles.ts +9 -8
- package/package.json +8 -12
- package/report.api.md +892 -555
- package/dist/types-ts4.0/client/__mocks__/collection-fetcher.d.ts +0 -8
- package/dist/types-ts4.0/client/__mocks__/file-fetcher.d.ts +0 -10
- package/dist/types-ts4.0/client/__mocks__/media-client.d.ts +0 -13
- package/dist/types-ts4.0/client/collection-fetcher.d.ts +0 -35
- package/dist/types-ts4.0/client/events.d.ts +0 -14
- package/dist/types-ts4.0/client/file-fetcher/error.d.ts +0 -29
- package/dist/types-ts4.0/client/file-fetcher/index.d.ts +0 -56
- package/dist/types-ts4.0/client/media-client.d.ts +0 -28
- package/dist/types-ts4.0/client/media-store/error.d.ts +0 -16
- package/dist/types-ts4.0/client/media-store/index.d.ts +0 -167
- package/dist/types-ts4.0/client/media-store/resolveAuth.d.ts +0 -4
- package/dist/types-ts4.0/client/mobile-upload.d.ts +0 -11
- package/dist/types-ts4.0/client/stargate-client.d.ts +0 -15
- package/dist/types-ts4.0/constants.d.ts +0 -6
- package/dist/types-ts4.0/file-streams-cache.d.ts +0 -15
- package/dist/types-ts4.0/globalMediaEventEmitter.d.ts +0 -6
- package/dist/types-ts4.0/identifier.d.ts +0 -15
- package/dist/types-ts4.0/index.d.ts +0 -89
- package/dist/types-ts4.0/models/artifacts.d.ts +0 -12
- package/dist/types-ts4.0/models/auth-headers.d.ts +0 -11
- package/dist/types-ts4.0/models/auth-query-parameters.d.ts +0 -11
- package/dist/types-ts4.0/models/errors/helpers.d.ts +0 -6
- package/dist/types-ts4.0/models/errors/index.d.ts +0 -11
- package/dist/types-ts4.0/models/errors/types.d.ts +0 -15
- package/dist/types-ts4.0/models/file-state.d.ts +0 -91
- package/dist/types-ts4.0/models/item.d.ts +0 -25
- package/dist/types-ts4.0/models/media-subscribable.d.ts +0 -3
- package/dist/types-ts4.0/models/media.d.ts +0 -66
- package/dist/types-ts4.0/models/mobile-upload.d.ts +0 -28
- package/dist/types-ts4.0/upload-controller.d.ts +0 -7
- package/dist/types-ts4.0/uploader/calculateChunkSize.d.ts +0 -11
- package/dist/types-ts4.0/uploader/error.d.ts +0 -29
- package/dist/types-ts4.0/uploader/index.d.ts +0 -21
- package/dist/types-ts4.0/utils/checkWebpSupport.d.ts +0 -1
- package/dist/types-ts4.0/utils/convertBase64ToBlob.d.ts +0 -1
- package/dist/types-ts4.0/utils/createFileDataLoader.d.ts +0 -30
- package/dist/types-ts4.0/utils/createMediaSubject.d.ts +0 -3
- package/dist/types-ts4.0/utils/detectEmptyFile.d.ts +0 -16
- package/dist/types-ts4.0/utils/getDimensionsFromBlob.d.ts +0 -6
- package/dist/types-ts4.0/utils/getImageDimensionsFromBlob.d.ts +0 -5
- package/dist/types-ts4.0/utils/getMediaTypeFromUploadableFile.d.ts +0 -3
- package/dist/types-ts4.0/utils/getVideoDimensionsFromBlob.d.ts +0 -6
- package/dist/types-ts4.0/utils/hashing/hasher.d.ts +0 -3
- package/dist/types-ts4.0/utils/hashing/hasherCreator.d.ts +0 -3
- package/dist/types-ts4.0/utils/hashing/simpleHasher.d.ts +0 -4
- package/dist/types-ts4.0/utils/hashing/workerHasher.d.ts +0 -16
- package/dist/types-ts4.0/utils/imageResizeModeToFileImageMode.d.ts +0 -3
- package/dist/types-ts4.0/utils/isImageRemote.d.ts +0 -1
- package/dist/types-ts4.0/utils/mediaSubscribable/fromObservable.d.ts +0 -5
- package/dist/types-ts4.0/utils/mediaSubscribable/index.d.ts +0 -3
- package/dist/types-ts4.0/utils/mediaSubscribable/toPromise.d.ts +0 -10
- package/dist/types-ts4.0/utils/mediaSubscribable/types.d.ts +0 -16
- package/dist/types-ts4.0/utils/mobileUpload/error.d.ts +0 -29
- package/dist/types-ts4.0/utils/mobileUpload/helpers.d.ts +0 -8
- package/dist/types-ts4.0/utils/mobileUpload/index.d.ts +0 -5
- package/dist/types-ts4.0/utils/mobileUpload/servicesCache.d.ts +0 -4
- package/dist/types-ts4.0/utils/mobileUpload/stateMachine/index.d.ts +0 -7
- package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/error.d.ts +0 -3
- package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/processed.d.ts +0 -3
- package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/processing.d.ts +0 -3
- package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/processingFailed.d.ts +0 -3
- package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/uploading.d.ts +0 -3
- package/dist/types-ts4.0/utils/mobileUpload/stateMachine/types.d.ts +0 -69
- package/dist/types-ts4.0/utils/overrideMediaTypeIfUnknown.d.ts +0 -5
- package/dist/types-ts4.0/utils/polling/errors.d.ts +0 -12
- package/dist/types-ts4.0/utils/polling/index.d.ts +0 -33
- package/dist/types-ts4.0/utils/polling/types.d.ts +0 -7
- package/dist/types-ts4.0/utils/request/errors.d.ts +0 -20
- package/dist/types-ts4.0/utils/request/helpers.d.ts +0 -38
- package/dist/types-ts4.0/utils/request/index.d.ts +0 -5
- package/dist/types-ts4.0/utils/request/types.d.ts +0 -43
- package/dist/types-ts4.0/utils/safeUnsubscribe.d.ts +0 -2
- package/dist/types-ts4.0/utils/setTimeoutPromise.d.ts +0 -2
- package/dist/types-ts4.0/utils/shouldFetchRemoteFileStates.d.ts +0 -16
- package/dist/types-ts4.0/utils/url.d.ts +0 -17
- package/dist/types-ts4.0/utils/with-media-client-hoc.d.ts +0 -16
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.DEFAULT_RETRY_OPTIONS = void 0;
|
|
8
|
+
exports.ZipkinHeaderKeys = exports.DEFAULT_RETRY_OPTIONS = void 0;
|
|
9
9
|
exports.clientTimeoutPromise = clientTimeoutPromise;
|
|
10
10
|
exports.cloneRequestError = cloneRequestError;
|
|
11
11
|
exports.createMapResponseToBlob = createMapResponseToBlob;
|
|
@@ -14,6 +14,7 @@ exports.createProcessFetchResponse = createProcessFetchResponse;
|
|
|
14
14
|
exports.createRequestErrorFromResponse = createRequestErrorFromResponse;
|
|
15
15
|
exports.createRequestErrorReason = createRequestErrorReason;
|
|
16
16
|
exports.createUrl = createUrl;
|
|
17
|
+
exports.extendHeaders = extendHeaders;
|
|
17
18
|
exports.extractMediaHeaders = extractMediaHeaders;
|
|
18
19
|
exports.fetchRetry = fetchRetry;
|
|
19
20
|
exports.isAbortedRequestError = isAbortedRequestError;
|
|
@@ -24,7 +25,6 @@ exports.mapResponseToBlob = mapResponseToBlob;
|
|
|
24
25
|
exports.mapResponseToJson = mapResponseToJson;
|
|
25
26
|
exports.mapResponseToVoid = mapResponseToVoid;
|
|
26
27
|
exports.waitPromise = waitPromise;
|
|
27
|
-
exports.withAuth = withAuth;
|
|
28
28
|
|
|
29
29
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
30
30
|
|
|
@@ -71,7 +71,26 @@ function isRateLimitedError(error) {
|
|
|
71
71
|
return !!error && (0, _errors.isRequestError)(error) && error.attributes.statusCode === 429 || !!error && !!error.message && error.message.includes('429');
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
var ZipkinHeaderKeys = {
|
|
75
|
+
traceId: 'x-b3-traceid',
|
|
76
|
+
spanId: 'x-b3-spanid',
|
|
77
|
+
parentSpanId: 'x-b3-parentspanid',
|
|
78
|
+
sampled: 'x-b3-sampled',
|
|
79
|
+
flags: 'x-b3-flags'
|
|
80
|
+
};
|
|
81
|
+
exports.ZipkinHeaderKeys = ZipkinHeaderKeys;
|
|
82
|
+
|
|
83
|
+
var mapTraceIdToRequestHeaders = function mapTraceIdToRequestHeaders(traceContext) {
|
|
84
|
+
var _ref;
|
|
85
|
+
|
|
86
|
+
return traceContext ? (_ref = {}, (0, _defineProperty2.default)(_ref, ZipkinHeaderKeys.traceId, traceContext.traceId), (0, _defineProperty2.default)(_ref, ZipkinHeaderKeys.spanId, traceContext.spanId), _ref) : {};
|
|
87
|
+
};
|
|
88
|
+
|
|
74
89
|
function mapAuthToRequestHeaders(auth) {
|
|
90
|
+
if (!auth) {
|
|
91
|
+
return {};
|
|
92
|
+
}
|
|
93
|
+
|
|
75
94
|
if ((0, _mediaCore.isClientBasedAuth)(auth)) {
|
|
76
95
|
return {
|
|
77
96
|
'X-Client-Id': auth.clientId,
|
|
@@ -85,18 +104,18 @@ function mapAuthToRequestHeaders(auth) {
|
|
|
85
104
|
};
|
|
86
105
|
}
|
|
87
106
|
|
|
88
|
-
function createUrl(url,
|
|
89
|
-
var params =
|
|
90
|
-
auth =
|
|
107
|
+
function createUrl(url, _ref2) {
|
|
108
|
+
var params = _ref2.params,
|
|
109
|
+
auth = _ref2.auth;
|
|
91
110
|
var parsedUrl = new URL(url);
|
|
92
111
|
var authParams = auth && (0, _authQueryParameters.mapAuthToQueryParameters)(auth) || {};
|
|
93
112
|
|
|
94
113
|
var paramsToAppend = _objectSpread(_objectSpread({}, params), authParams);
|
|
95
114
|
|
|
96
|
-
Object.entries(paramsToAppend).filter(function (
|
|
97
|
-
var
|
|
98
|
-
_ =
|
|
99
|
-
value =
|
|
115
|
+
Object.entries(paramsToAppend).filter(function (_ref3) {
|
|
116
|
+
var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
|
|
117
|
+
_ = _ref4[0],
|
|
118
|
+
value = _ref4[1];
|
|
100
119
|
|
|
101
120
|
return value != null;
|
|
102
121
|
}).forEach(function (pair) {
|
|
@@ -108,14 +127,12 @@ function createUrl(url, _ref) {
|
|
|
108
127
|
return parsedUrl.toString();
|
|
109
128
|
}
|
|
110
129
|
|
|
111
|
-
function
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
130
|
+
function extendHeaders(headers, auth, traceContext) {
|
|
131
|
+
if (!auth && !traceContext && !headers) {
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
116
134
|
|
|
117
|
-
|
|
118
|
-
};
|
|
135
|
+
return _objectSpread(_objectSpread(_objectSpread({}, headers !== null && headers !== void 0 ? headers : {}), mapAuthToRequestHeaders(auth)), mapTraceIdToRequestHeaders(traceContext));
|
|
119
136
|
}
|
|
120
137
|
/**
|
|
121
138
|
* @deprecated Helper is deprecated and will be removed in the next major version.
|
|
@@ -213,7 +230,7 @@ function mapResponseToVoid() {
|
|
|
213
230
|
|
|
214
231
|
function createMapResponseToJson(metadata) {
|
|
215
232
|
return /*#__PURE__*/function () {
|
|
216
|
-
var
|
|
233
|
+
var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(response) {
|
|
217
234
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
218
235
|
while (1) {
|
|
219
236
|
switch (_context.prev = _context.next) {
|
|
@@ -241,14 +258,14 @@ function createMapResponseToJson(metadata) {
|
|
|
241
258
|
}));
|
|
242
259
|
|
|
243
260
|
return function (_x3) {
|
|
244
|
-
return
|
|
261
|
+
return _ref5.apply(this, arguments);
|
|
245
262
|
};
|
|
246
263
|
}();
|
|
247
264
|
}
|
|
248
265
|
|
|
249
266
|
function createMapResponseToBlob(metadata) {
|
|
250
267
|
return /*#__PURE__*/function () {
|
|
251
|
-
var
|
|
268
|
+
var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(response) {
|
|
252
269
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
253
270
|
while (1) {
|
|
254
271
|
switch (_context2.prev = _context2.next) {
|
|
@@ -276,7 +293,7 @@ function createMapResponseToBlob(metadata) {
|
|
|
276
293
|
}));
|
|
277
294
|
|
|
278
295
|
return function (_x4) {
|
|
279
|
-
return
|
|
296
|
+
return _ref6.apply(this, arguments);
|
|
280
297
|
};
|
|
281
298
|
}();
|
|
282
299
|
}
|
|
@@ -325,7 +342,7 @@ function _fetchRetry() {
|
|
|
325
342
|
timeoutInMs = startTimeoutInMs;
|
|
326
343
|
|
|
327
344
|
waitAndBumpTimeout = /*#__PURE__*/function () {
|
|
328
|
-
var
|
|
345
|
+
var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
|
|
329
346
|
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
330
347
|
while (1) {
|
|
331
348
|
switch (_context5.prev = _context5.next) {
|
|
@@ -346,7 +363,7 @@ function _fetchRetry() {
|
|
|
346
363
|
}));
|
|
347
364
|
|
|
348
365
|
return function waitAndBumpTimeout() {
|
|
349
|
-
return
|
|
366
|
+
return _ref7.apply(this, arguments);
|
|
350
367
|
};
|
|
351
368
|
}();
|
|
352
369
|
|
|
@@ -50,6 +50,7 @@ function _request() {
|
|
|
50
50
|
body,
|
|
51
51
|
_options$clientOption,
|
|
52
52
|
clientOptions,
|
|
53
|
+
traceContext,
|
|
53
54
|
retryOptions,
|
|
54
55
|
metadata,
|
|
55
56
|
doFetch,
|
|
@@ -61,7 +62,7 @@ function _request() {
|
|
|
61
62
|
case 0:
|
|
62
63
|
options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
63
64
|
controller = _args.length > 2 ? _args[2] : undefined;
|
|
64
|
-
_options$method = options.method, method = _options$method === void 0 ? 'GET' : _options$method, endpoint = options.endpoint, auth = options.auth, params = options.params, headers = options.headers, body = options.body, _options$clientOption = options.clientOptions, clientOptions = _options$clientOption === void 0 ? {} : _options$clientOption;
|
|
65
|
+
_options$method = options.method, method = _options$method === void 0 ? 'GET' : _options$method, endpoint = options.endpoint, auth = options.auth, params = options.params, headers = options.headers, body = options.body, _options$clientOption = options.clientOptions, clientOptions = _options$clientOption === void 0 ? {} : _options$clientOption, traceContext = options.traceContext;
|
|
65
66
|
retryOptions = clientOptions.retryOptions;
|
|
66
67
|
metadata = {
|
|
67
68
|
method: method,
|
|
@@ -74,7 +75,7 @@ function _request() {
|
|
|
74
75
|
}), {
|
|
75
76
|
method: method,
|
|
76
77
|
body: body,
|
|
77
|
-
headers: (0, _helpers.
|
|
78
|
+
headers: (0, _helpers.extendHeaders)(headers, auth, traceContext),
|
|
78
79
|
signal: controller && controller.signal
|
|
79
80
|
}).then((0, _helpers.createProcessFetchResponse)(metadata));
|
|
80
81
|
};
|
package/dist/cjs/version.json
CHANGED
|
@@ -46,7 +46,7 @@ export class CollectionFetcher {
|
|
|
46
46
|
collectionCache[collectionName].items.splice(collectionCacheIndex, 1);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
getItems(collectionName, params) {
|
|
49
|
+
getItems(collectionName, params, traceContext) {
|
|
50
50
|
if (!collectionCache[collectionName]) {
|
|
51
51
|
collectionCache[collectionName] = createCacheEntry();
|
|
52
52
|
}
|
|
@@ -55,7 +55,7 @@ export class CollectionFetcher {
|
|
|
55
55
|
const subject = collection.subject;
|
|
56
56
|
this.mediaStore.getCollectionItems(collectionName, { ...params,
|
|
57
57
|
details: 'full'
|
|
58
|
-
}).then(items => {
|
|
58
|
+
}, traceContext).then(items => {
|
|
59
59
|
const {
|
|
60
60
|
contents,
|
|
61
61
|
nextInclusiveStartKey
|
|
@@ -70,14 +70,14 @@ export class CollectionFetcher {
|
|
|
70
70
|
return fromObservable(subject);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
async removeFile(id, collectionName, occurrenceKey) {
|
|
74
|
-
await this.mediaStore.removeCollectionFile(id, collectionName, occurrenceKey);
|
|
73
|
+
async removeFile(id, collectionName, occurrenceKey, traceContext) {
|
|
74
|
+
await this.mediaStore.removeCollectionFile(id, collectionName, occurrenceKey, traceContext);
|
|
75
75
|
this.removeFromCache(id, collectionName);
|
|
76
76
|
const collection = collectionCache[collectionName];
|
|
77
77
|
collection.subject.next(collection.items);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
async loadNextPage(collectionName, params) {
|
|
80
|
+
async loadNextPage(collectionName, params, traceContext) {
|
|
81
81
|
const collection = collectionCache[collectionName];
|
|
82
82
|
const isLoading = collection ? collection.isLoadingNextPage : false;
|
|
83
83
|
|
|
@@ -94,7 +94,7 @@ export class CollectionFetcher {
|
|
|
94
94
|
const response = await this.mediaStore.getCollectionItems(collectionName, { ...params,
|
|
95
95
|
inclusiveStartKey,
|
|
96
96
|
details: 'full'
|
|
97
|
-
});
|
|
97
|
+
}, traceContext);
|
|
98
98
|
const {
|
|
99
99
|
contents,
|
|
100
100
|
nextInclusiveStartKey
|
|
@@ -106,19 +106,20 @@ export class FileFetcherImpl {
|
|
|
106
106
|
|
|
107
107
|
getFileBinaryURL(id, collectionName) {
|
|
108
108
|
return this.mediaStore.getFileBinaryURL(id, collectionName);
|
|
109
|
-
}
|
|
109
|
+
} // TODO: ----- ADD TICKET TO PASS TRACE ID to this.dataloader.load
|
|
110
|
+
|
|
110
111
|
|
|
111
|
-
touchFiles(descriptors, collection) {
|
|
112
|
+
touchFiles(descriptors, collection, traceContext) {
|
|
112
113
|
return this.mediaStore.touchFiles({
|
|
113
114
|
descriptors
|
|
114
115
|
}, {
|
|
115
116
|
collection
|
|
116
|
-
}).then(({
|
|
117
|
+
}, traceContext).then(({
|
|
117
118
|
data
|
|
118
119
|
}) => data);
|
|
119
120
|
}
|
|
120
121
|
|
|
121
|
-
generateUploadableFileUpfrontIds(collection) {
|
|
122
|
+
generateUploadableFileUpfrontIds(collection, traceContext) {
|
|
122
123
|
const id = uuid();
|
|
123
124
|
const occurrenceKey = uuid();
|
|
124
125
|
const touchFileDescriptor = {
|
|
@@ -126,7 +127,7 @@ export class FileFetcherImpl {
|
|
|
126
127
|
occurrenceKey,
|
|
127
128
|
collection
|
|
128
129
|
};
|
|
129
|
-
const deferredUploadId = this.touchFiles([touchFileDescriptor], collection).then(touchedFiles => touchedFiles.created[0].uploadId);
|
|
130
|
+
const deferredUploadId = this.touchFiles([touchFileDescriptor], collection, traceContext).then(touchedFiles => touchedFiles.created[0].uploadId);
|
|
130
131
|
return {
|
|
131
132
|
id,
|
|
132
133
|
occurrenceKey,
|
|
@@ -134,8 +135,8 @@ export class FileFetcherImpl {
|
|
|
134
135
|
};
|
|
135
136
|
}
|
|
136
137
|
|
|
137
|
-
async uploadExternal(url, collection) {
|
|
138
|
-
const uploadableFileUpfrontIds = this.generateUploadableFileUpfrontIds(collection);
|
|
138
|
+
async uploadExternal(url, collection, traceContext) {
|
|
139
|
+
const uploadableFileUpfrontIds = this.generateUploadableFileUpfrontIds(collection, traceContext);
|
|
139
140
|
const {
|
|
140
141
|
id,
|
|
141
142
|
occurrenceKey
|
|
@@ -199,7 +200,7 @@ export class FileFetcherImpl {
|
|
|
199
200
|
preview
|
|
200
201
|
}); // we don't want to wait for the file to be upload
|
|
201
202
|
|
|
202
|
-
this.upload(file, undefined, uploadableFileUpfrontIds);
|
|
203
|
+
this.upload(file, undefined, uploadableFileUpfrontIds, traceContext);
|
|
203
204
|
const dimensions = await getDimensionsFromBlob(mediaType, blob);
|
|
204
205
|
resolve({
|
|
205
206
|
dimensions,
|
|
@@ -208,7 +209,7 @@ export class FileFetcherImpl {
|
|
|
208
209
|
});
|
|
209
210
|
}
|
|
210
211
|
|
|
211
|
-
upload(file, controller, uploadableFileUpfrontIds) {
|
|
212
|
+
upload(file, controller, uploadableFileUpfrontIds, traceContext) {
|
|
212
213
|
if (typeof file.content === 'string') {
|
|
213
214
|
file.content = convertBase64ToBlob(file.content);
|
|
214
215
|
}
|
|
@@ -221,7 +222,7 @@ export class FileFetcherImpl {
|
|
|
221
222
|
} = file;
|
|
222
223
|
|
|
223
224
|
if (!uploadableFileUpfrontIds) {
|
|
224
|
-
uploadableFileUpfrontIds = this.generateUploadableFileUpfrontIds(collection);
|
|
225
|
+
uploadableFileUpfrontIds = this.generateUploadableFileUpfrontIds(collection, traceContext);
|
|
225
226
|
}
|
|
226
227
|
|
|
227
228
|
const id = uploadableFileUpfrontIds.id;
|
|
@@ -291,7 +292,7 @@ export class FileFetcherImpl {
|
|
|
291
292
|
} = uploadFile(file, this.mediaStore, uploadableFileUpfrontIds, {
|
|
292
293
|
onUploadFinish,
|
|
293
294
|
onProgress
|
|
294
|
-
});
|
|
295
|
+
}, traceContext);
|
|
295
296
|
getFileStreamsCache().set(id, subject); // We should report progress asynchronously, since this is what consumer expects
|
|
296
297
|
// (otherwise in newUploadService file-converting event will be emitted before files-added)
|
|
297
298
|
|
|
@@ -307,7 +308,8 @@ export class FileFetcherImpl {
|
|
|
307
308
|
}
|
|
308
309
|
|
|
309
310
|
return fromObservable(subject);
|
|
310
|
-
}
|
|
311
|
+
} // TODO: ----- ADD TICKET
|
|
312
|
+
|
|
311
313
|
|
|
312
314
|
async downloadBinary(id, name = 'download', collectionName) {
|
|
313
315
|
const url = await this.mediaStore.getFileBinaryURL(id, collectionName);
|
|
@@ -321,7 +323,7 @@ export class FileFetcherImpl {
|
|
|
321
323
|
});
|
|
322
324
|
}
|
|
323
325
|
|
|
324
|
-
async copyFile(source, destination, options = {}) {
|
|
326
|
+
async copyFile(source, destination, options = {}, traceContext) {
|
|
325
327
|
const {
|
|
326
328
|
authProvider,
|
|
327
329
|
collection: sourceCollection,
|
|
@@ -361,7 +363,7 @@ export class FileFetcherImpl {
|
|
|
361
363
|
try {
|
|
362
364
|
const {
|
|
363
365
|
data: copiedFile
|
|
364
|
-
} = await mediaStore.copyFileWithToken(body, params); // if we were passed a "mimeType", we propagate it into copiedFileWithMimeType
|
|
366
|
+
} = await mediaStore.copyFileWithToken(body, params, traceContext); // if we were passed a "mimeType", we propagate it into copiedFileWithMimeType
|
|
365
367
|
|
|
366
368
|
const copiedFileWithMimeType = { ...copiedFile,
|
|
367
369
|
...(mimeType ? {
|
|
@@ -20,8 +20,8 @@ export class MediaClient {
|
|
|
20
20
|
this.stargate = new StargateClient(mediaClientConfig.stargateBaseUrl);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
getImage(id, params, controller, fetchMaxRes) {
|
|
24
|
-
return this.mediaStore.getImage(id, params, controller, fetchMaxRes);
|
|
23
|
+
getImage(id, params, controller, fetchMaxRes, traceContext) {
|
|
24
|
+
return this.mediaStore.getImage(id, params, controller, fetchMaxRes, traceContext);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
getImageUrl(id, params) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import { getRandomHex } from '@atlaskit/media-common';
|
|
2
3
|
import { FILE_CACHE_MAX_AGE, MAX_RESOLUTION } from '../../constants';
|
|
3
4
|
import { getArtifactUrl } from '../../models/artifacts';
|
|
4
5
|
import { request } from '../../utils/request';
|
|
@@ -41,7 +42,7 @@ export class MediaStore {
|
|
|
41
42
|
this.featureFlags = featureFlags;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
async getCollectionItems(collectionName, params) {
|
|
45
|
+
async getCollectionItems(collectionName, params, traceContext) {
|
|
45
46
|
const metadata = {
|
|
46
47
|
method: 'GET',
|
|
47
48
|
endpoint: '/collection/{collectionName}/items'
|
|
@@ -55,7 +56,8 @@ export class MediaStore {
|
|
|
55
56
|
},
|
|
56
57
|
headers: {
|
|
57
58
|
Accept: 'application/json'
|
|
58
|
-
}
|
|
59
|
+
},
|
|
60
|
+
traceContext
|
|
59
61
|
};
|
|
60
62
|
const response = await this.request(`/collection/${collectionName}/items`, options);
|
|
61
63
|
const {
|
|
@@ -75,7 +77,7 @@ export class MediaStore {
|
|
|
75
77
|
};
|
|
76
78
|
}
|
|
77
79
|
|
|
78
|
-
async removeCollectionFile(id, collectionName, occurrenceKey) {
|
|
80
|
+
async removeCollectionFile(id, collectionName, occurrenceKey, traceContext) {
|
|
79
81
|
const metadata = {
|
|
80
82
|
method: 'PUT',
|
|
81
83
|
endpoint: '/collection/{collectionName}'
|
|
@@ -98,12 +100,13 @@ export class MediaStore {
|
|
|
98
100
|
Accept: 'application/json',
|
|
99
101
|
'Content-Type': 'application/json'
|
|
100
102
|
},
|
|
101
|
-
body: JSON.stringify(body)
|
|
103
|
+
body: JSON.stringify(body),
|
|
104
|
+
traceContext
|
|
102
105
|
};
|
|
103
106
|
await this.request(`/collection/${collectionName}`, options);
|
|
104
107
|
}
|
|
105
108
|
|
|
106
|
-
createUpload(createUpTo = 1, collectionName) {
|
|
109
|
+
createUpload(createUpTo = 1, collectionName, traceContext) {
|
|
107
110
|
const metadata = {
|
|
108
111
|
method: 'POST',
|
|
109
112
|
endpoint: '/upload'
|
|
@@ -117,7 +120,8 @@ export class MediaStore {
|
|
|
117
120
|
},
|
|
118
121
|
headers: {
|
|
119
122
|
Accept: 'application/json'
|
|
120
|
-
}
|
|
123
|
+
},
|
|
124
|
+
traceContext
|
|
121
125
|
};
|
|
122
126
|
return this.request(`/upload`, options).then(createMapResponseToJson(metadata));
|
|
123
127
|
}
|
|
@@ -126,7 +130,7 @@ export class MediaStore {
|
|
|
126
130
|
collectionName,
|
|
127
131
|
uploadId,
|
|
128
132
|
partNumber
|
|
129
|
-
} = {}) {
|
|
133
|
+
} = {}, traceContext) {
|
|
130
134
|
const metadata = {
|
|
131
135
|
method: 'PUT',
|
|
132
136
|
endpoint: '/chunk/{etag}'
|
|
@@ -139,7 +143,8 @@ export class MediaStore {
|
|
|
139
143
|
authContext: {
|
|
140
144
|
collectionName
|
|
141
145
|
},
|
|
142
|
-
body: blob
|
|
146
|
+
body: blob,
|
|
147
|
+
traceContext
|
|
143
148
|
};
|
|
144
149
|
await this.request(`/chunk/${etag}`, options);
|
|
145
150
|
}
|
|
@@ -147,7 +152,7 @@ export class MediaStore {
|
|
|
147
152
|
probeChunks(chunks, {
|
|
148
153
|
collectionName,
|
|
149
154
|
uploadId
|
|
150
|
-
} = {}) {
|
|
155
|
+
} = {}, traceContext) {
|
|
151
156
|
const metadata = {
|
|
152
157
|
method: 'POST',
|
|
153
158
|
endpoint: '/chunk/probe'
|
|
@@ -162,12 +167,13 @@ export class MediaStore {
|
|
|
162
167
|
headers: jsonHeaders,
|
|
163
168
|
body: JSON.stringify({
|
|
164
169
|
chunks
|
|
165
|
-
})
|
|
170
|
+
}),
|
|
171
|
+
traceContext
|
|
166
172
|
};
|
|
167
173
|
return this.request(`/chunk/probe`, options).then(createMapResponseToJson(metadata));
|
|
168
174
|
}
|
|
169
175
|
|
|
170
|
-
createFileFromUpload(body, params = {}) {
|
|
176
|
+
createFileFromUpload(body, params = {}, traceContext) {
|
|
171
177
|
const metadata = {
|
|
172
178
|
method: 'POST',
|
|
173
179
|
endpoint: '/file/upload'
|
|
@@ -178,12 +184,13 @@ export class MediaStore {
|
|
|
178
184
|
},
|
|
179
185
|
params,
|
|
180
186
|
headers: jsonHeaders,
|
|
181
|
-
body: JSON.stringify(body)
|
|
187
|
+
body: JSON.stringify(body),
|
|
188
|
+
traceContext
|
|
182
189
|
};
|
|
183
190
|
return this.request('/file/upload', options).then(createMapResponseToJson(metadata));
|
|
184
191
|
}
|
|
185
192
|
|
|
186
|
-
touchFiles(body, params = {}) {
|
|
193
|
+
touchFiles(body, params = {}, traceContext) {
|
|
187
194
|
const metadata = {
|
|
188
195
|
method: 'POST',
|
|
189
196
|
endpoint: '/upload/createWithFiles'
|
|
@@ -193,12 +200,13 @@ export class MediaStore {
|
|
|
193
200
|
collectionName: params.collection
|
|
194
201
|
},
|
|
195
202
|
headers: jsonHeaders,
|
|
196
|
-
body: JSON.stringify(body)
|
|
203
|
+
body: JSON.stringify(body),
|
|
204
|
+
traceContext
|
|
197
205
|
};
|
|
198
206
|
return this.request('/upload/createWithFiles', options).then(createMapResponseToJson(metadata));
|
|
199
207
|
}
|
|
200
208
|
|
|
201
|
-
getFile(fileId, params = {}) {
|
|
209
|
+
getFile(fileId, params = {}, traceContext) {
|
|
202
210
|
const metadata = {
|
|
203
211
|
method: 'GET',
|
|
204
212
|
endpoint: '/file/{fileId}'
|
|
@@ -207,7 +215,8 @@ export class MediaStore {
|
|
|
207
215
|
authContext: {
|
|
208
216
|
collectionName: params.collection
|
|
209
217
|
},
|
|
210
|
-
params
|
|
218
|
+
params,
|
|
219
|
+
traceContext
|
|
211
220
|
};
|
|
212
221
|
return this.request(`/file/${fileId}`, options).then(createMapResponseToJson(metadata));
|
|
213
222
|
}
|
|
@@ -220,7 +229,8 @@ export class MediaStore {
|
|
|
220
229
|
collectionName
|
|
221
230
|
});
|
|
222
231
|
return this.createFileImageURL(id, auth, params);
|
|
223
|
-
}
|
|
232
|
+
} // TODO Create ticket in case Trace Id can be supported through query params
|
|
233
|
+
|
|
224
234
|
|
|
225
235
|
getFileImageURLSync(id, params) {
|
|
226
236
|
const auth = this.resolveInitialAuth();
|
|
@@ -270,15 +280,13 @@ export class MediaStore {
|
|
|
270
280
|
return createUrl(`${auth.baseUrl}${artifactUrl}`, options);
|
|
271
281
|
}
|
|
272
282
|
|
|
273
|
-
async getImage(id, params, controller, fetchMaxRes) {
|
|
283
|
+
async getImage(id, params, controller, fetchMaxRes, traceContext) {
|
|
274
284
|
// TODO add checkWebpSupport() back https://product-fabric.atlassian.net/browse/MPT-584
|
|
275
285
|
const isWebpSupported = false;
|
|
276
|
-
|
|
286
|
+
const headers = {};
|
|
277
287
|
|
|
278
288
|
if (isWebpSupported) {
|
|
279
|
-
headers =
|
|
280
|
-
accept: 'image/webp,image/*,*/*;q=0.8'
|
|
281
|
-
};
|
|
289
|
+
headers.accept = 'image/webp,image/*,*/*;q=0.8';
|
|
282
290
|
}
|
|
283
291
|
|
|
284
292
|
const metadata = {
|
|
@@ -290,12 +298,13 @@ export class MediaStore {
|
|
|
290
298
|
collectionName: params && params.collection
|
|
291
299
|
},
|
|
292
300
|
params: extendImageParams(params, fetchMaxRes),
|
|
293
|
-
headers
|
|
301
|
+
headers,
|
|
302
|
+
traceContext
|
|
294
303
|
};
|
|
295
304
|
return this.request(`/file/${id}/image`, options, controller).then(createMapResponseToBlob(metadata));
|
|
296
305
|
}
|
|
297
306
|
|
|
298
|
-
async getItems(ids, collectionName) {
|
|
307
|
+
async getItems(ids, collectionName, traceContext) {
|
|
299
308
|
const descriptors = ids.map(id => ({
|
|
300
309
|
type: 'file',
|
|
301
310
|
id,
|
|
@@ -312,12 +321,13 @@ export class MediaStore {
|
|
|
312
321
|
headers: jsonHeaders,
|
|
313
322
|
body: JSON.stringify({
|
|
314
323
|
descriptors
|
|
315
|
-
})
|
|
324
|
+
}),
|
|
325
|
+
traceContext
|
|
316
326
|
};
|
|
317
327
|
return this.request('/items', options).then(createMapResponseToJson(metadata));
|
|
318
328
|
}
|
|
319
329
|
|
|
320
|
-
async getImageMetadata(id, params) {
|
|
330
|
+
async getImageMetadata(id, params, traceContext) {
|
|
321
331
|
const metadata = {
|
|
322
332
|
method: 'GET',
|
|
323
333
|
endpoint: '/file/{fileId}/image/metadata'
|
|
@@ -326,12 +336,13 @@ export class MediaStore {
|
|
|
326
336
|
authContext: {
|
|
327
337
|
collectionName: params && params.collection
|
|
328
338
|
},
|
|
329
|
-
params
|
|
339
|
+
params,
|
|
340
|
+
traceContext
|
|
330
341
|
};
|
|
331
342
|
return this.request(`/file/${id}/image/metadata`, options).then(createMapResponseToJson(metadata));
|
|
332
343
|
}
|
|
333
344
|
|
|
334
|
-
async appendChunksToUpload(uploadId, body, collectionName) {
|
|
345
|
+
async appendChunksToUpload(uploadId, body, collectionName, traceContext) {
|
|
335
346
|
const metadata = {
|
|
336
347
|
method: 'PUT',
|
|
337
348
|
endpoint: '/upload/{uploadId}/chunks'
|
|
@@ -341,12 +352,13 @@ export class MediaStore {
|
|
|
341
352
|
collectionName
|
|
342
353
|
},
|
|
343
354
|
headers: jsonHeaders,
|
|
344
|
-
body: JSON.stringify(body)
|
|
355
|
+
body: JSON.stringify(body),
|
|
356
|
+
traceContext
|
|
345
357
|
};
|
|
346
358
|
await this.request(`/upload/${uploadId}/chunks`, options);
|
|
347
359
|
}
|
|
348
360
|
|
|
349
|
-
copyFileWithToken(body, params) {
|
|
361
|
+
copyFileWithToken(body, params, traceContext) {
|
|
350
362
|
const metadata = {
|
|
351
363
|
method: 'POST',
|
|
352
364
|
endpoint: '/file/copy/withToken'
|
|
@@ -359,8 +371,9 @@ export class MediaStore {
|
|
|
359
371
|
params,
|
|
360
372
|
// Contains collection name to write to
|
|
361
373
|
headers: jsonHeaders,
|
|
362
|
-
body: JSON.stringify(body)
|
|
363
|
-
|
|
374
|
+
body: JSON.stringify(body),
|
|
375
|
+
// Contains collection name to read from
|
|
376
|
+
traceContext
|
|
364
377
|
};
|
|
365
378
|
return this.request('/file/copy/withToken', options).then(createMapResponseToJson(metadata));
|
|
366
379
|
}
|
|
@@ -377,9 +390,13 @@ export class MediaStore {
|
|
|
377
390
|
params,
|
|
378
391
|
headers,
|
|
379
392
|
body,
|
|
380
|
-
clientOptions
|
|
393
|
+
clientOptions,
|
|
394
|
+
traceContext
|
|
381
395
|
} = options;
|
|
382
396
|
const auth = await this.resolveAuth(authContext);
|
|
397
|
+
const extendedTraceContext = traceContext ? { ...traceContext,
|
|
398
|
+
spanId: (traceContext === null || traceContext === void 0 ? void 0 : traceContext.spanId) || getRandomHex(16)
|
|
399
|
+
} : undefined;
|
|
383
400
|
const response = await request(`${auth.baseUrl}${path}`, {
|
|
384
401
|
method,
|
|
385
402
|
endpoint,
|
|
@@ -387,7 +404,8 @@ export class MediaStore {
|
|
|
387
404
|
params,
|
|
388
405
|
headers,
|
|
389
406
|
body,
|
|
390
|
-
clientOptions
|
|
407
|
+
clientOptions,
|
|
408
|
+
traceContext: extendedTraceContext
|
|
391
409
|
}, controller);
|
|
392
410
|
setKeyValueInSessionStorage(MEDIA_API_REGION, response.headers.get('x-media-region'));
|
|
393
411
|
setKeyValueInSessionStorage(MEDIA_API_ENVIRONMENT, response.headers.get('x-media-env'));
|