@atlaskit/media-client 18.1.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 +10 -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 +69 -52
- package/dist/cjs/uploader/index.js +22 -20
- 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 +50 -41
- package/dist/es2019/uploader/index.js +13 -13
- 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 +68 -50
- package/dist/esm/uploader/index.js +22 -20
- 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 -21
- package/dist/types/uploader/index.d.ts +2 -1
- package/dist/types/utils/request/helpers.d.ts +10 -2
- package/dist/types/utils/request/types.d.ts +2 -0
- package/package.json +4 -12
- package/report.api.md +101 -70
- 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 -174
- 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 -5
- 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) {
|
|
@@ -32,13 +32,6 @@ const jsonHeaders = {
|
|
|
32
32
|
Accept: 'application/json',
|
|
33
33
|
'Content-Type': 'application/json'
|
|
34
34
|
};
|
|
35
|
-
export const ZipkinHeaderKeys = {
|
|
36
|
-
traceId: 'x-b3-traceid',
|
|
37
|
-
spanId: 'x-b3-spanid',
|
|
38
|
-
parentSpanId: 'x-b3-parentspanid',
|
|
39
|
-
sampled: 'x-b3-sampled',
|
|
40
|
-
flags: 'x-b3-flags'
|
|
41
|
-
};
|
|
42
35
|
export class MediaStore {
|
|
43
36
|
constructor(config, featureFlags) {
|
|
44
37
|
_defineProperty(this, "resolveAuth", authContext => resolveAuth(this.config.authProvider, authContext));
|
|
@@ -49,7 +42,7 @@ export class MediaStore {
|
|
|
49
42
|
this.featureFlags = featureFlags;
|
|
50
43
|
}
|
|
51
44
|
|
|
52
|
-
async getCollectionItems(collectionName, params) {
|
|
45
|
+
async getCollectionItems(collectionName, params, traceContext) {
|
|
53
46
|
const metadata = {
|
|
54
47
|
method: 'GET',
|
|
55
48
|
endpoint: '/collection/{collectionName}/items'
|
|
@@ -63,7 +56,8 @@ export class MediaStore {
|
|
|
63
56
|
},
|
|
64
57
|
headers: {
|
|
65
58
|
Accept: 'application/json'
|
|
66
|
-
}
|
|
59
|
+
},
|
|
60
|
+
traceContext
|
|
67
61
|
};
|
|
68
62
|
const response = await this.request(`/collection/${collectionName}/items`, options);
|
|
69
63
|
const {
|
|
@@ -83,7 +77,7 @@ export class MediaStore {
|
|
|
83
77
|
};
|
|
84
78
|
}
|
|
85
79
|
|
|
86
|
-
async removeCollectionFile(id, collectionName, occurrenceKey) {
|
|
80
|
+
async removeCollectionFile(id, collectionName, occurrenceKey, traceContext) {
|
|
87
81
|
const metadata = {
|
|
88
82
|
method: 'PUT',
|
|
89
83
|
endpoint: '/collection/{collectionName}'
|
|
@@ -106,12 +100,13 @@ export class MediaStore {
|
|
|
106
100
|
Accept: 'application/json',
|
|
107
101
|
'Content-Type': 'application/json'
|
|
108
102
|
},
|
|
109
|
-
body: JSON.stringify(body)
|
|
103
|
+
body: JSON.stringify(body),
|
|
104
|
+
traceContext
|
|
110
105
|
};
|
|
111
106
|
await this.request(`/collection/${collectionName}`, options);
|
|
112
107
|
}
|
|
113
108
|
|
|
114
|
-
createUpload(createUpTo = 1, collectionName) {
|
|
109
|
+
createUpload(createUpTo = 1, collectionName, traceContext) {
|
|
115
110
|
const metadata = {
|
|
116
111
|
method: 'POST',
|
|
117
112
|
endpoint: '/upload'
|
|
@@ -125,7 +120,8 @@ export class MediaStore {
|
|
|
125
120
|
},
|
|
126
121
|
headers: {
|
|
127
122
|
Accept: 'application/json'
|
|
128
|
-
}
|
|
123
|
+
},
|
|
124
|
+
traceContext
|
|
129
125
|
};
|
|
130
126
|
return this.request(`/upload`, options).then(createMapResponseToJson(metadata));
|
|
131
127
|
}
|
|
@@ -134,7 +130,7 @@ export class MediaStore {
|
|
|
134
130
|
collectionName,
|
|
135
131
|
uploadId,
|
|
136
132
|
partNumber
|
|
137
|
-
} = {}) {
|
|
133
|
+
} = {}, traceContext) {
|
|
138
134
|
const metadata = {
|
|
139
135
|
method: 'PUT',
|
|
140
136
|
endpoint: '/chunk/{etag}'
|
|
@@ -147,7 +143,8 @@ export class MediaStore {
|
|
|
147
143
|
authContext: {
|
|
148
144
|
collectionName
|
|
149
145
|
},
|
|
150
|
-
body: blob
|
|
146
|
+
body: blob,
|
|
147
|
+
traceContext
|
|
151
148
|
};
|
|
152
149
|
await this.request(`/chunk/${etag}`, options);
|
|
153
150
|
}
|
|
@@ -155,7 +152,7 @@ export class MediaStore {
|
|
|
155
152
|
probeChunks(chunks, {
|
|
156
153
|
collectionName,
|
|
157
154
|
uploadId
|
|
158
|
-
} = {}) {
|
|
155
|
+
} = {}, traceContext) {
|
|
159
156
|
const metadata = {
|
|
160
157
|
method: 'POST',
|
|
161
158
|
endpoint: '/chunk/probe'
|
|
@@ -170,12 +167,13 @@ export class MediaStore {
|
|
|
170
167
|
headers: jsonHeaders,
|
|
171
168
|
body: JSON.stringify({
|
|
172
169
|
chunks
|
|
173
|
-
})
|
|
170
|
+
}),
|
|
171
|
+
traceContext
|
|
174
172
|
};
|
|
175
173
|
return this.request(`/chunk/probe`, options).then(createMapResponseToJson(metadata));
|
|
176
174
|
}
|
|
177
175
|
|
|
178
|
-
createFileFromUpload(body, params = {}) {
|
|
176
|
+
createFileFromUpload(body, params = {}, traceContext) {
|
|
179
177
|
const metadata = {
|
|
180
178
|
method: 'POST',
|
|
181
179
|
endpoint: '/file/upload'
|
|
@@ -186,12 +184,13 @@ export class MediaStore {
|
|
|
186
184
|
},
|
|
187
185
|
params,
|
|
188
186
|
headers: jsonHeaders,
|
|
189
|
-
body: JSON.stringify(body)
|
|
187
|
+
body: JSON.stringify(body),
|
|
188
|
+
traceContext
|
|
190
189
|
};
|
|
191
190
|
return this.request('/file/upload', options).then(createMapResponseToJson(metadata));
|
|
192
191
|
}
|
|
193
192
|
|
|
194
|
-
touchFiles(body, params = {}) {
|
|
193
|
+
touchFiles(body, params = {}, traceContext) {
|
|
195
194
|
const metadata = {
|
|
196
195
|
method: 'POST',
|
|
197
196
|
endpoint: '/upload/createWithFiles'
|
|
@@ -201,12 +200,13 @@ export class MediaStore {
|
|
|
201
200
|
collectionName: params.collection
|
|
202
201
|
},
|
|
203
202
|
headers: jsonHeaders,
|
|
204
|
-
body: JSON.stringify(body)
|
|
203
|
+
body: JSON.stringify(body),
|
|
204
|
+
traceContext
|
|
205
205
|
};
|
|
206
206
|
return this.request('/upload/createWithFiles', options).then(createMapResponseToJson(metadata));
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
-
getFile(fileId, params = {}) {
|
|
209
|
+
getFile(fileId, params = {}, traceContext) {
|
|
210
210
|
const metadata = {
|
|
211
211
|
method: 'GET',
|
|
212
212
|
endpoint: '/file/{fileId}'
|
|
@@ -215,7 +215,8 @@ export class MediaStore {
|
|
|
215
215
|
authContext: {
|
|
216
216
|
collectionName: params.collection
|
|
217
217
|
},
|
|
218
|
-
params
|
|
218
|
+
params,
|
|
219
|
+
traceContext
|
|
219
220
|
};
|
|
220
221
|
return this.request(`/file/${fileId}`, options).then(createMapResponseToJson(metadata));
|
|
221
222
|
}
|
|
@@ -228,7 +229,8 @@ export class MediaStore {
|
|
|
228
229
|
collectionName
|
|
229
230
|
});
|
|
230
231
|
return this.createFileImageURL(id, auth, params);
|
|
231
|
-
}
|
|
232
|
+
} // TODO Create ticket in case Trace Id can be supported through query params
|
|
233
|
+
|
|
232
234
|
|
|
233
235
|
getFileImageURLSync(id, params) {
|
|
234
236
|
const auth = this.resolveInitialAuth();
|
|
@@ -278,13 +280,10 @@ export class MediaStore {
|
|
|
278
280
|
return createUrl(`${auth.baseUrl}${artifactUrl}`, options);
|
|
279
281
|
}
|
|
280
282
|
|
|
281
|
-
async getImage(id, params, controller, fetchMaxRes,
|
|
283
|
+
async getImage(id, params, controller, fetchMaxRes, traceContext) {
|
|
282
284
|
// TODO add checkWebpSupport() back https://product-fabric.atlassian.net/browse/MPT-584
|
|
283
285
|
const isWebpSupported = false;
|
|
284
|
-
|
|
285
|
-
[ZipkinHeaderKeys.traceId]: traceId,
|
|
286
|
-
[ZipkinHeaderKeys.spanId]: getRandomHex(16)
|
|
287
|
-
} : {};
|
|
286
|
+
const headers = {};
|
|
288
287
|
|
|
289
288
|
if (isWebpSupported) {
|
|
290
289
|
headers.accept = 'image/webp,image/*,*/*;q=0.8';
|
|
@@ -299,12 +298,13 @@ export class MediaStore {
|
|
|
299
298
|
collectionName: params && params.collection
|
|
300
299
|
},
|
|
301
300
|
params: extendImageParams(params, fetchMaxRes),
|
|
302
|
-
headers
|
|
301
|
+
headers,
|
|
302
|
+
traceContext
|
|
303
303
|
};
|
|
304
304
|
return this.request(`/file/${id}/image`, options, controller).then(createMapResponseToBlob(metadata));
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
-
async getItems(ids, collectionName) {
|
|
307
|
+
async getItems(ids, collectionName, traceContext) {
|
|
308
308
|
const descriptors = ids.map(id => ({
|
|
309
309
|
type: 'file',
|
|
310
310
|
id,
|
|
@@ -321,12 +321,13 @@ export class MediaStore {
|
|
|
321
321
|
headers: jsonHeaders,
|
|
322
322
|
body: JSON.stringify({
|
|
323
323
|
descriptors
|
|
324
|
-
})
|
|
324
|
+
}),
|
|
325
|
+
traceContext
|
|
325
326
|
};
|
|
326
327
|
return this.request('/items', options).then(createMapResponseToJson(metadata));
|
|
327
328
|
}
|
|
328
329
|
|
|
329
|
-
async getImageMetadata(id, params) {
|
|
330
|
+
async getImageMetadata(id, params, traceContext) {
|
|
330
331
|
const metadata = {
|
|
331
332
|
method: 'GET',
|
|
332
333
|
endpoint: '/file/{fileId}/image/metadata'
|
|
@@ -335,12 +336,13 @@ export class MediaStore {
|
|
|
335
336
|
authContext: {
|
|
336
337
|
collectionName: params && params.collection
|
|
337
338
|
},
|
|
338
|
-
params
|
|
339
|
+
params,
|
|
340
|
+
traceContext
|
|
339
341
|
};
|
|
340
342
|
return this.request(`/file/${id}/image/metadata`, options).then(createMapResponseToJson(metadata));
|
|
341
343
|
}
|
|
342
344
|
|
|
343
|
-
async appendChunksToUpload(uploadId, body, collectionName) {
|
|
345
|
+
async appendChunksToUpload(uploadId, body, collectionName, traceContext) {
|
|
344
346
|
const metadata = {
|
|
345
347
|
method: 'PUT',
|
|
346
348
|
endpoint: '/upload/{uploadId}/chunks'
|
|
@@ -350,12 +352,13 @@ export class MediaStore {
|
|
|
350
352
|
collectionName
|
|
351
353
|
},
|
|
352
354
|
headers: jsonHeaders,
|
|
353
|
-
body: JSON.stringify(body)
|
|
355
|
+
body: JSON.stringify(body),
|
|
356
|
+
traceContext
|
|
354
357
|
};
|
|
355
358
|
await this.request(`/upload/${uploadId}/chunks`, options);
|
|
356
359
|
}
|
|
357
360
|
|
|
358
|
-
copyFileWithToken(body, params) {
|
|
361
|
+
copyFileWithToken(body, params, traceContext) {
|
|
359
362
|
const metadata = {
|
|
360
363
|
method: 'POST',
|
|
361
364
|
endpoint: '/file/copy/withToken'
|
|
@@ -368,8 +371,9 @@ export class MediaStore {
|
|
|
368
371
|
params,
|
|
369
372
|
// Contains collection name to write to
|
|
370
373
|
headers: jsonHeaders,
|
|
371
|
-
body: JSON.stringify(body)
|
|
372
|
-
|
|
374
|
+
body: JSON.stringify(body),
|
|
375
|
+
// Contains collection name to read from
|
|
376
|
+
traceContext
|
|
373
377
|
};
|
|
374
378
|
return this.request('/file/copy/withToken', options).then(createMapResponseToJson(metadata));
|
|
375
379
|
}
|
|
@@ -386,9 +390,13 @@ export class MediaStore {
|
|
|
386
390
|
params,
|
|
387
391
|
headers,
|
|
388
392
|
body,
|
|
389
|
-
clientOptions
|
|
393
|
+
clientOptions,
|
|
394
|
+
traceContext
|
|
390
395
|
} = options;
|
|
391
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;
|
|
392
400
|
const response = await request(`${auth.baseUrl}${path}`, {
|
|
393
401
|
method,
|
|
394
402
|
endpoint,
|
|
@@ -396,7 +404,8 @@ export class MediaStore {
|
|
|
396
404
|
params,
|
|
397
405
|
headers,
|
|
398
406
|
body,
|
|
399
|
-
clientOptions
|
|
407
|
+
clientOptions,
|
|
408
|
+
traceContext: extendedTraceContext
|
|
400
409
|
}, controller);
|
|
401
410
|
setKeyValueInSessionStorage(MEDIA_API_REGION, response.headers.get('x-media-region'));
|
|
402
411
|
setKeyValueInSessionStorage(MEDIA_API_ENVIRONMENT, response.headers.get('x-media-env'));
|