@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.
Files changed (115) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/cjs/client/collection-fetcher.js +8 -8
  3. package/dist/cjs/client/file-fetcher/index.js +40 -36
  4. package/dist/cjs/client/media-client.js +2 -2
  5. package/dist/cjs/client/media-store/index.js +72 -44
  6. package/dist/cjs/uploader/index.js +22 -20
  7. package/dist/cjs/utils/getVideoDimensionsFromBlob.js +23 -19
  8. package/dist/cjs/utils/request/helpers.js +39 -22
  9. package/dist/cjs/utils/request/index.js +3 -2
  10. package/dist/cjs/version.json +1 -1
  11. package/dist/es2019/client/collection-fetcher.js +6 -6
  12. package/dist/es2019/client/file-fetcher/index.js +16 -14
  13. package/dist/es2019/client/media-client.js +2 -2
  14. package/dist/es2019/client/media-store/index.js +52 -34
  15. package/dist/es2019/uploader/index.js +13 -13
  16. package/dist/es2019/utils/getVideoDimensionsFromBlob.js +21 -7
  17. package/dist/es2019/utils/request/helpers.js +26 -8
  18. package/dist/es2019/utils/request/index.js +4 -3
  19. package/dist/es2019/version.json +1 -1
  20. package/dist/esm/client/collection-fetcher.js +8 -8
  21. package/dist/esm/client/file-fetcher/index.js +40 -36
  22. package/dist/esm/client/media-client.js +2 -2
  23. package/dist/esm/client/media-store/index.js +71 -44
  24. package/dist/esm/uploader/index.js +22 -20
  25. package/dist/esm/utils/getVideoDimensionsFromBlob.js +21 -16
  26. package/dist/esm/utils/request/helpers.js +36 -20
  27. package/dist/esm/utils/request/index.js +4 -3
  28. package/dist/esm/version.json +1 -1
  29. package/dist/types/client/collection-fetcher.d.ts +4 -3
  30. package/dist/types/client/file-fetcher/index.d.ts +9 -8
  31. package/dist/types/client/media-client.d.ts +2 -2
  32. package/dist/types/client/media-store/index.d.ts +15 -14
  33. package/dist/types/uploader/index.d.ts +2 -1
  34. package/dist/types/utils/getVideoDimensionsFromBlob.d.ts +3 -4
  35. package/dist/types/utils/request/helpers.d.ts +10 -2
  36. package/dist/types/utils/request/types.d.ts +2 -0
  37. package/example-helpers/styles.ts +9 -8
  38. package/package.json +8 -12
  39. package/report.api.md +892 -555
  40. package/dist/types-ts4.0/client/__mocks__/collection-fetcher.d.ts +0 -8
  41. package/dist/types-ts4.0/client/__mocks__/file-fetcher.d.ts +0 -10
  42. package/dist/types-ts4.0/client/__mocks__/media-client.d.ts +0 -13
  43. package/dist/types-ts4.0/client/collection-fetcher.d.ts +0 -35
  44. package/dist/types-ts4.0/client/events.d.ts +0 -14
  45. package/dist/types-ts4.0/client/file-fetcher/error.d.ts +0 -29
  46. package/dist/types-ts4.0/client/file-fetcher/index.d.ts +0 -56
  47. package/dist/types-ts4.0/client/media-client.d.ts +0 -28
  48. package/dist/types-ts4.0/client/media-store/error.d.ts +0 -16
  49. package/dist/types-ts4.0/client/media-store/index.d.ts +0 -167
  50. package/dist/types-ts4.0/client/media-store/resolveAuth.d.ts +0 -4
  51. package/dist/types-ts4.0/client/mobile-upload.d.ts +0 -11
  52. package/dist/types-ts4.0/client/stargate-client.d.ts +0 -15
  53. package/dist/types-ts4.0/constants.d.ts +0 -6
  54. package/dist/types-ts4.0/file-streams-cache.d.ts +0 -15
  55. package/dist/types-ts4.0/globalMediaEventEmitter.d.ts +0 -6
  56. package/dist/types-ts4.0/identifier.d.ts +0 -15
  57. package/dist/types-ts4.0/index.d.ts +0 -89
  58. package/dist/types-ts4.0/models/artifacts.d.ts +0 -12
  59. package/dist/types-ts4.0/models/auth-headers.d.ts +0 -11
  60. package/dist/types-ts4.0/models/auth-query-parameters.d.ts +0 -11
  61. package/dist/types-ts4.0/models/errors/helpers.d.ts +0 -6
  62. package/dist/types-ts4.0/models/errors/index.d.ts +0 -11
  63. package/dist/types-ts4.0/models/errors/types.d.ts +0 -15
  64. package/dist/types-ts4.0/models/file-state.d.ts +0 -91
  65. package/dist/types-ts4.0/models/item.d.ts +0 -25
  66. package/dist/types-ts4.0/models/media-subscribable.d.ts +0 -3
  67. package/dist/types-ts4.0/models/media.d.ts +0 -66
  68. package/dist/types-ts4.0/models/mobile-upload.d.ts +0 -28
  69. package/dist/types-ts4.0/upload-controller.d.ts +0 -7
  70. package/dist/types-ts4.0/uploader/calculateChunkSize.d.ts +0 -11
  71. package/dist/types-ts4.0/uploader/error.d.ts +0 -29
  72. package/dist/types-ts4.0/uploader/index.d.ts +0 -21
  73. package/dist/types-ts4.0/utils/checkWebpSupport.d.ts +0 -1
  74. package/dist/types-ts4.0/utils/convertBase64ToBlob.d.ts +0 -1
  75. package/dist/types-ts4.0/utils/createFileDataLoader.d.ts +0 -30
  76. package/dist/types-ts4.0/utils/createMediaSubject.d.ts +0 -3
  77. package/dist/types-ts4.0/utils/detectEmptyFile.d.ts +0 -16
  78. package/dist/types-ts4.0/utils/getDimensionsFromBlob.d.ts +0 -6
  79. package/dist/types-ts4.0/utils/getImageDimensionsFromBlob.d.ts +0 -5
  80. package/dist/types-ts4.0/utils/getMediaTypeFromUploadableFile.d.ts +0 -3
  81. package/dist/types-ts4.0/utils/getVideoDimensionsFromBlob.d.ts +0 -6
  82. package/dist/types-ts4.0/utils/hashing/hasher.d.ts +0 -3
  83. package/dist/types-ts4.0/utils/hashing/hasherCreator.d.ts +0 -3
  84. package/dist/types-ts4.0/utils/hashing/simpleHasher.d.ts +0 -4
  85. package/dist/types-ts4.0/utils/hashing/workerHasher.d.ts +0 -16
  86. package/dist/types-ts4.0/utils/imageResizeModeToFileImageMode.d.ts +0 -3
  87. package/dist/types-ts4.0/utils/isImageRemote.d.ts +0 -1
  88. package/dist/types-ts4.0/utils/mediaSubscribable/fromObservable.d.ts +0 -5
  89. package/dist/types-ts4.0/utils/mediaSubscribable/index.d.ts +0 -3
  90. package/dist/types-ts4.0/utils/mediaSubscribable/toPromise.d.ts +0 -10
  91. package/dist/types-ts4.0/utils/mediaSubscribable/types.d.ts +0 -16
  92. package/dist/types-ts4.0/utils/mobileUpload/error.d.ts +0 -29
  93. package/dist/types-ts4.0/utils/mobileUpload/helpers.d.ts +0 -8
  94. package/dist/types-ts4.0/utils/mobileUpload/index.d.ts +0 -5
  95. package/dist/types-ts4.0/utils/mobileUpload/servicesCache.d.ts +0 -4
  96. package/dist/types-ts4.0/utils/mobileUpload/stateMachine/index.d.ts +0 -7
  97. package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/error.d.ts +0 -3
  98. package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/processed.d.ts +0 -3
  99. package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/processing.d.ts +0 -3
  100. package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/processingFailed.d.ts +0 -3
  101. package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/uploading.d.ts +0 -3
  102. package/dist/types-ts4.0/utils/mobileUpload/stateMachine/types.d.ts +0 -69
  103. package/dist/types-ts4.0/utils/overrideMediaTypeIfUnknown.d.ts +0 -5
  104. package/dist/types-ts4.0/utils/polling/errors.d.ts +0 -12
  105. package/dist/types-ts4.0/utils/polling/index.d.ts +0 -33
  106. package/dist/types-ts4.0/utils/polling/types.d.ts +0 -7
  107. package/dist/types-ts4.0/utils/request/errors.d.ts +0 -20
  108. package/dist/types-ts4.0/utils/request/helpers.d.ts +0 -38
  109. package/dist/types-ts4.0/utils/request/index.d.ts +0 -5
  110. package/dist/types-ts4.0/utils/request/types.d.ts +0 -43
  111. package/dist/types-ts4.0/utils/safeUnsubscribe.d.ts +0 -2
  112. package/dist/types-ts4.0/utils/setTimeoutPromise.d.ts +0 -2
  113. package/dist/types-ts4.0/utils/shouldFetchRemoteFileStates.d.ts +0 -16
  114. package/dist/types-ts4.0/utils/url.d.ts +0 -17
  115. package/dist/types-ts4.0/utils/with-media-client-hoc.d.ts +0 -16
@@ -12,16 +12,16 @@ const hashingFunction = async blob => {
12
12
  return hasher.hash(blob);
13
13
  };
14
14
 
15
- const createProbingFunction = (store, deferredUploadId, collectionName) => async chunks => {
15
+ const createProbingFunction = (store, deferredUploadId, collectionName, traceContext) => async chunks => {
16
16
  const response = await store.probeChunks(hashedChunks(chunks), {
17
17
  collectionName,
18
18
  uploadId: getMediaFeatureFlag('mediaUploadApiV2', store.featureFlags) ? await deferredUploadId : undefined
19
- });
19
+ }, traceContext);
20
20
  const results = response.data.results;
21
21
  return Object.values(results).map(result => result.exists);
22
22
  };
23
23
 
24
- const createUploadingFunction = (store, deferredUploadId, collectionName) => async chunk => {
24
+ const createUploadingFunction = (store, deferredUploadId, collectionName, traceContext) => async chunk => {
25
25
  const options = getMediaFeatureFlag('mediaUploadApiV2', store.featureFlags) ? {
26
26
  partNumber: chunk.partNumber,
27
27
  uploadId: await deferredUploadId
@@ -29,21 +29,21 @@ const createUploadingFunction = (store, deferredUploadId, collectionName) => asy
29
29
  return await store.uploadChunk(chunk.hash, chunk.blob, {
30
30
  collectionName,
31
31
  ...options
32
- });
32
+ }, traceContext);
33
33
  };
34
34
 
35
- const createProcessingFunction = (store, deferredUploadId, collection) => {
35
+ const createProcessingFunction = (store, deferredUploadId, collection, traceContext) => {
36
36
  let offset = 0;
37
37
  return async chunks => {
38
38
  await store.appendChunksToUpload(await deferredUploadId, {
39
39
  chunks: hashedChunks(chunks),
40
40
  offset
41
- }, collection);
41
+ }, collection, traceContext);
42
42
  offset += chunks.length;
43
43
  };
44
44
  };
45
45
 
46
- const createFileFromUpload = async (file, store, uploadableFileUpfrontIds, uploadId) => {
46
+ const createFileFromUpload = async (file, store, uploadableFileUpfrontIds, uploadId, traceContext) => {
47
47
  const {
48
48
  collection,
49
49
  name,
@@ -61,10 +61,10 @@ const createFileFromUpload = async (file, store, uploadableFileUpfrontIds, uploa
61
61
  occurrenceKey,
62
62
  collection,
63
63
  replaceFileId: id
64
- });
64
+ }, traceContext);
65
65
  };
66
66
 
67
- export const uploadFile = (file, store, uploadableFileUpfrontIds, callbacks) => {
67
+ export const uploadFile = (file, store, uploadableFileUpfrontIds, callbacks, traceContext) => {
68
68
  const {
69
69
  content,
70
70
  collection
@@ -101,10 +101,10 @@ export const uploadFile = (file, store, uploadableFileUpfrontIds, callbacks) =>
101
101
  probingBatchSize: 100,
102
102
  chunkSize,
103
103
  uploadingConcurrency: 3,
104
- uploadingFunction: createUploadingFunction(store, deferredUploadId, collection),
105
- probingFunction: createProbingFunction(store, deferredUploadId, collection),
104
+ uploadingFunction: createUploadingFunction(store, deferredUploadId, collection, traceContext),
105
+ probingFunction: createProbingFunction(store, deferredUploadId, collection, traceContext),
106
106
  processingBatchSize: PROCESSING_BATCH_SIZE,
107
- processingFunction: createProcessingFunction(store, deferredUploadId, collection)
107
+ processingFunction: createProcessingFunction(store, deferredUploadId, collection, traceContext)
108
108
  }, {
109
109
  onProgress(progress) {
110
110
  if (callbacks) {
@@ -116,7 +116,7 @@ export const uploadFile = (file, store, uploadableFileUpfrontIds, callbacks) =>
116
116
 
117
117
  const onUploadFinish = callbacks && callbacks.onUploadFinish || (() => {});
118
118
 
119
- const subscription = from(deferredUploadId).pipe(concatMap(uploadId => chunkinatorObservable.pipe(concatMap(() => from(createFileFromUpload(file, store, uploadableFileUpfrontIds, uploadId)))))).subscribe({
119
+ const subscription = from(deferredUploadId).pipe(concatMap(uploadId => chunkinatorObservable.pipe(concatMap(() => from(createFileFromUpload(file, store, uploadableFileUpfrontIds, uploadId, traceContext)))))).subscribe({
120
120
  error: err => onUploadFinish(err),
121
121
  complete: () => onUploadFinish()
122
122
  });
@@ -1,8 +1,22 @@
1
- import VideoSnapshot from 'video-snapshot';
2
- export const getVideoDimensionsFromBlob = async (blob, snapshoter = new VideoSnapshot(blob)) => {
3
- try {
4
- return await snapshoter.getDimensions();
5
- } finally {
6
- snapshoter.end();
7
- }
1
+ export const getVideoDimensionsFromBlob = async blob => {
2
+ return new Promise((resolve, reject) => {
3
+ const url = URL.createObjectURL(blob);
4
+ const video = document.createElement('video');
5
+ video.preload = 'metadata';
6
+ video.src = url;
7
+ video.muted = true; // loadedmetadata, loadeddata, play, playing
8
+
9
+ video.addEventListener('loadedmetadata', function timeupdateHandler() {
10
+ video.removeEventListener('loadedmetadata', timeupdateHandler);
11
+ resolve({
12
+ width: video.videoWidth,
13
+ height: video.videoHeight
14
+ });
15
+ URL.revokeObjectURL(url);
16
+ });
17
+ video.addEventListener('error', () => {
18
+ reject(new Error('failed to load video'));
19
+ URL.revokeObjectURL(url);
20
+ });
21
+ });
8
22
  };
@@ -19,7 +19,26 @@ export function isFetchNetworkError(err) {
19
19
  export function isRateLimitedError(error) {
20
20
  return !!error && isRequestError(error) && error.attributes.statusCode === 429 || !!error && !!error.message && error.message.includes('429');
21
21
  }
22
+ export const ZipkinHeaderKeys = {
23
+ traceId: 'x-b3-traceid',
24
+ spanId: 'x-b3-spanid',
25
+ parentSpanId: 'x-b3-parentspanid',
26
+ sampled: 'x-b3-sampled',
27
+ flags: 'x-b3-flags'
28
+ };
29
+
30
+ const mapTraceIdToRequestHeaders = traceContext => {
31
+ return traceContext ? {
32
+ [ZipkinHeaderKeys.traceId]: traceContext.traceId,
33
+ [ZipkinHeaderKeys.spanId]: traceContext.spanId
34
+ } : {};
35
+ };
36
+
22
37
  export function mapAuthToRequestHeaders(auth) {
38
+ if (!auth) {
39
+ return {};
40
+ }
41
+
23
42
  if (isClientBasedAuth(auth)) {
24
43
  return {
25
44
  'X-Client-Id': auth.clientId,
@@ -47,15 +66,14 @@ export function createUrl(url, {
47
66
  parsedUrl.searchParams.sort();
48
67
  return parsedUrl.toString();
49
68
  }
50
- export function withAuth(auth) {
51
- return headers => {
52
- if (auth) {
53
- return { ...(headers || {}),
54
- ...mapAuthToRequestHeaders(auth)
55
- };
56
- }
69
+ export function extendHeaders(headers, auth, traceContext) {
70
+ if (!auth && !traceContext && !headers) {
71
+ return undefined;
72
+ }
57
73
 
58
- return headers;
74
+ return { ...(headers !== null && headers !== void 0 ? headers : {}),
75
+ ...mapAuthToRequestHeaders(auth),
76
+ ...mapTraceIdToRequestHeaders(traceContext)
59
77
  };
60
78
  }
61
79
  /**
@@ -1,6 +1,6 @@
1
1
  export { RequestError, isRequestError } from './errors';
2
2
  export { isRateLimitedError } from './helpers';
3
- import { createUrl, fetchRetry, createProcessFetchResponse, withAuth } from './helpers';
3
+ import { createUrl, fetchRetry, createProcessFetchResponse, extendHeaders } from './helpers';
4
4
  export async function request(url, options = {}, controller) {
5
5
  const {
6
6
  method = 'GET',
@@ -9,7 +9,8 @@ export async function request(url, options = {}, controller) {
9
9
  params,
10
10
  headers,
11
11
  body,
12
- clientOptions = {}
12
+ clientOptions = {},
13
+ traceContext
13
14
  } = options;
14
15
  const {
15
16
  retryOptions
@@ -24,7 +25,7 @@ export async function request(url, options = {}, controller) {
24
25
  }), {
25
26
  method,
26
27
  body,
27
- headers: withAuth(auth)(headers),
28
+ headers: extendHeaders(headers, auth, traceContext),
28
29
  signal: controller && controller.signal
29
30
  }).then(createProcessFetchResponse(metadata));
30
31
 
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/media-client",
3
- "version": "18.0.0",
3
+ "version": "19.0.0",
4
4
  "sideEffects": false
5
5
  }
@@ -72,7 +72,7 @@ export var CollectionFetcher = /*#__PURE__*/function () {
72
72
  }
73
73
  }, {
74
74
  key: "getItems",
75
- value: function getItems(collectionName, params) {
75
+ value: function getItems(collectionName, params, traceContext) {
76
76
  var _this2 = this;
77
77
 
78
78
  if (!collectionCache[collectionName]) {
@@ -83,7 +83,7 @@ export var CollectionFetcher = /*#__PURE__*/function () {
83
83
  var subject = collection.subject;
84
84
  this.mediaStore.getCollectionItems(collectionName, _objectSpread(_objectSpread({}, params), {}, {
85
85
  details: 'full'
86
- })).then(function (items) {
86
+ }), traceContext).then(function (items) {
87
87
  var _items$data = items.data,
88
88
  contents = _items$data.contents,
89
89
  nextInclusiveStartKey = _items$data.nextInclusiveStartKey;
@@ -103,14 +103,14 @@ export var CollectionFetcher = /*#__PURE__*/function () {
103
103
  }, {
104
104
  key: "removeFile",
105
105
  value: function () {
106
- var _removeFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(id, collectionName, occurrenceKey) {
106
+ var _removeFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(id, collectionName, occurrenceKey, traceContext) {
107
107
  var collection;
108
108
  return _regeneratorRuntime.wrap(function _callee$(_context) {
109
109
  while (1) {
110
110
  switch (_context.prev = _context.next) {
111
111
  case 0:
112
112
  _context.next = 2;
113
- return this.mediaStore.removeCollectionFile(id, collectionName, occurrenceKey);
113
+ return this.mediaStore.removeCollectionFile(id, collectionName, occurrenceKey, traceContext);
114
114
 
115
115
  case 2:
116
116
  this.removeFromCache(id, collectionName);
@@ -125,7 +125,7 @@ export var CollectionFetcher = /*#__PURE__*/function () {
125
125
  }, _callee, this);
126
126
  }));
127
127
 
128
- function removeFile(_x, _x2, _x3) {
128
+ function removeFile(_x, _x2, _x3, _x4) {
129
129
  return _removeFile.apply(this, arguments);
130
130
  }
131
131
 
@@ -134,7 +134,7 @@ export var CollectionFetcher = /*#__PURE__*/function () {
134
134
  }, {
135
135
  key: "loadNextPage",
136
136
  value: function () {
137
- var _loadNextPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(collectionName, params) {
137
+ var _loadNextPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(collectionName, params, traceContext) {
138
138
  var collection, isLoading, _collectionCache$coll, inclusiveStartKey, currentItems, subject, response, _response$data, contents, nextInclusiveStartKey, newItems, items;
139
139
 
140
140
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
@@ -158,7 +158,7 @@ export var CollectionFetcher = /*#__PURE__*/function () {
158
158
  return this.mediaStore.getCollectionItems(collectionName, _objectSpread(_objectSpread({}, params), {}, {
159
159
  inclusiveStartKey: inclusiveStartKey,
160
160
  details: 'full'
161
- }));
161
+ }), traceContext);
162
162
 
163
163
  case 8:
164
164
  response = _context2.sent;
@@ -182,7 +182,7 @@ export var CollectionFetcher = /*#__PURE__*/function () {
182
182
  }, _callee2, this);
183
183
  }));
184
184
 
185
- function loadNextPage(_x4, _x5) {
185
+ function loadNextPage(_x5, _x6, _x7) {
186
186
  return _loadNextPage.apply(this, arguments);
187
187
  }
188
188
 
@@ -154,22 +154,23 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
154
154
  key: "getFileBinaryURL",
155
155
  value: function getFileBinaryURL(id, collectionName) {
156
156
  return this.mediaStore.getFileBinaryURL(id, collectionName);
157
- }
157
+ } // TODO: ----- ADD TICKET TO PASS TRACE ID to this.dataloader.load
158
+
158
159
  }, {
159
160
  key: "touchFiles",
160
- value: function touchFiles(descriptors, collection) {
161
+ value: function touchFiles(descriptors, collection, traceContext) {
161
162
  return this.mediaStore.touchFiles({
162
163
  descriptors: descriptors
163
164
  }, {
164
165
  collection: collection
165
- }).then(function (_ref2) {
166
+ }, traceContext).then(function (_ref2) {
166
167
  var data = _ref2.data;
167
168
  return data;
168
169
  });
169
170
  }
170
171
  }, {
171
172
  key: "generateUploadableFileUpfrontIds",
172
- value: function generateUploadableFileUpfrontIds(collection) {
173
+ value: function generateUploadableFileUpfrontIds(collection, traceContext) {
173
174
  var id = uuid();
174
175
  var occurrenceKey = uuid();
175
176
  var touchFileDescriptor = {
@@ -177,7 +178,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
177
178
  occurrenceKey: occurrenceKey,
178
179
  collection: collection
179
180
  };
180
- var deferredUploadId = this.touchFiles([touchFileDescriptor], collection).then(function (touchedFiles) {
181
+ var deferredUploadId = this.touchFiles([touchFileDescriptor], collection, traceContext).then(function (touchedFiles) {
181
182
  return touchedFiles.created[0].uploadId;
182
183
  });
183
184
  return {
@@ -189,7 +190,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
189
190
  }, {
190
191
  key: "uploadExternal",
191
192
  value: function () {
192
- var _uploadExternal = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(url, collection) {
193
+ var _uploadExternal = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(url, collection, traceContext) {
193
194
  var _this3 = this;
194
195
 
195
196
  var uploadableFileUpfrontIds, id, occurrenceKey, subject, deferredBlob, preview, name, fileState;
@@ -197,7 +198,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
197
198
  while (1) {
198
199
  switch (_context4.prev = _context4.next) {
199
200
  case 0:
200
- uploadableFileUpfrontIds = this.generateUploadableFileUpfrontIds(collection);
201
+ uploadableFileUpfrontIds = this.generateUploadableFileUpfrontIds(collection, traceContext);
201
202
  id = uploadableFileUpfrontIds.id, occurrenceKey = uploadableFileUpfrontIds.occurrenceKey;
202
203
  subject = createMediaSubject();
203
204
  deferredBlob = fetch(url).then(function (response) {
@@ -235,7 +236,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
235
236
  }, _callee2);
236
237
  }));
237
238
 
238
- return function (_x3, _x4) {
239
+ return function (_x4, _x5) {
239
240
  return _ref3.apply(this, arguments);
240
241
  };
241
242
  }());
@@ -295,7 +296,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
295
296
  preview: preview
296
297
  }); // we don't want to wait for the file to be upload
297
298
 
298
- _this3.upload(file, undefined, uploadableFileUpfrontIds);
299
+ _this3.upload(file, undefined, uploadableFileUpfrontIds, traceContext);
299
300
 
300
301
  _context3.next = 12;
301
302
  return getDimensionsFromBlob(mediaType, blob);
@@ -315,7 +316,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
315
316
  }, _callee3);
316
317
  }));
317
318
 
318
- return function (_x5, _x6) {
319
+ return function (_x6, _x7) {
319
320
  return _ref4.apply(this, arguments);
320
321
  };
321
322
  }()));
@@ -328,7 +329,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
328
329
  }, _callee4, this);
329
330
  }));
330
331
 
331
- function uploadExternal(_x, _x2) {
332
+ function uploadExternal(_x, _x2, _x3) {
332
333
  return _uploadExternal.apply(this, arguments);
333
334
  }
334
335
 
@@ -336,7 +337,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
336
337
  }()
337
338
  }, {
338
339
  key: "upload",
339
- value: function upload(file, controller, uploadableFileUpfrontIds) {
340
+ value: function upload(file, controller, uploadableFileUpfrontIds, traceContext) {
340
341
  var _this4 = this;
341
342
 
342
343
  if (typeof file.content === 'string') {
@@ -349,7 +350,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
349
350
  collection = file.collection;
350
351
 
351
352
  if (!uploadableFileUpfrontIds) {
352
- uploadableFileUpfrontIds = this.generateUploadableFileUpfrontIds(collection);
353
+ uploadableFileUpfrontIds = this.generateUploadableFileUpfrontIds(collection, traceContext);
353
354
  }
354
355
 
355
356
  var id = uploadableFileUpfrontIds.id;
@@ -414,7 +415,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
414
415
  var _uploadFile = uploadFile(file, this.mediaStore, uploadableFileUpfrontIds, {
415
416
  onUploadFinish: onUploadFinish,
416
417
  onProgress: onProgress
417
- }),
418
+ }, traceContext),
418
419
  cancel = _uploadFile.cancel;
419
420
 
420
421
  getFileStreamsCache().set(id, subject); // We should report progress asynchronously, since this is what consumer expects
@@ -432,7 +433,8 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
432
433
  }
433
434
 
434
435
  return fromObservable(subject);
435
- }
436
+ } // TODO: ----- ADD TICKET
437
+
436
438
  }, {
437
439
  key: "downloadBinary",
438
440
  value: function () {
@@ -469,7 +471,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
469
471
  }, _callee5, this);
470
472
  }));
471
473
 
472
- function downloadBinary(_x7) {
474
+ function downloadBinary(_x8) {
473
475
  return _downloadBinary.apply(this, arguments);
474
476
  }
475
477
 
@@ -480,6 +482,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
480
482
  value: function () {
481
483
  var _copyFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(source, destination) {
482
484
  var options,
485
+ traceContext,
483
486
  authProvider,
484
487
  sourceCollection,
485
488
  id,
@@ -513,6 +516,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
513
516
  switch (_context6.prev = _context6.next) {
514
517
  case 0:
515
518
  options = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : {};
519
+ traceContext = _args6.length > 3 ? _args6[3] : undefined;
516
520
  authProvider = source.authProvider, sourceCollection = source.collection, id = source.id;
517
521
  destinationAuthProvider = destination.authProvider, destinationCollectionName = destination.collection, replaceFileId = destination.replaceFileId, occurrenceKey = destination.occurrenceKey;
518
522
  preview = options.preview, mimeType = options.mimeType;
@@ -520,12 +524,12 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
520
524
  authProvider: destinationAuthProvider
521
525
  });
522
526
  _context6.t0 = authToOwner;
523
- _context6.next = 8;
527
+ _context6.next = 9;
524
528
  return authProvider({
525
529
  collectionName: sourceCollection
526
530
  });
527
531
 
528
- case 8:
532
+ case 9:
529
533
  _context6.t1 = _context6.sent;
530
534
  owner = (0, _context6.t0)(_context6.t1);
531
535
  body = {
@@ -541,11 +545,11 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
541
545
  occurrenceKey: occurrenceKey
542
546
  };
543
547
  cache = getFileStreamsCache();
544
- _context6.prev = 13;
545
- _context6.next = 16;
546
- return mediaStore.copyFileWithToken(body, params);
548
+ _context6.prev = 14;
549
+ _context6.next = 17;
550
+ return mediaStore.copyFileWithToken(body, params, traceContext);
547
551
 
548
- case 16:
552
+ case 17:
549
553
  _yield$mediaStore$cop = _context6.sent;
550
554
  copiedFile = _yield$mediaStore$cop.data;
551
555
  // if we were passed a "mimeType", we propagate it into copiedFileWithMimeType
@@ -570,19 +574,19 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
570
574
  copiedMimeType;
571
575
 
572
576
  if (!_context6.t2) {
573
- _context6.next = 30;
577
+ _context6.next = 31;
574
578
  break;
575
579
  }
576
580
 
577
- _context6.next = 29;
581
+ _context6.next = 30;
578
582
  return shouldFetchRemoteFileStates(mediaType, copiedMimeType, preview);
579
583
 
580
- case 29:
584
+ case 30:
581
585
  _context6.t2 = _context6.sent;
582
586
 
583
- case 30:
587
+ case 31:
584
588
  if (!_context6.t2) {
585
- _context6.next = 35;
589
+ _context6.next = 36;
586
590
  break;
587
591
  }
588
592
 
@@ -598,24 +602,24 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
598
602
  return subject.complete();
599
603
  }
600
604
  });
601
- _context6.next = 36;
605
+ _context6.next = 37;
602
606
  break;
603
607
 
604
- case 35:
608
+ case 36:
605
609
  if (!isProcessingFileState(copiedFileState)) {
606
610
  subject.next(_objectSpread(_objectSpread({}, copiedFileState), !isErrorFileState(copiedFileState) && previewOverride));
607
611
  }
608
612
 
609
- case 36:
613
+ case 37:
610
614
  if (!cache.has(copiedId)) {
611
615
  getFileStreamsCache().set(copiedId, subject);
612
616
  }
613
617
 
614
618
  return _context6.abrupt("return", copiedFile);
615
619
 
616
- case 40:
617
- _context6.prev = 40;
618
- _context6.t3 = _context6["catch"](13);
620
+ case 41:
621
+ _context6.prev = 41;
622
+ _context6.t3 = _context6["catch"](14);
619
623
 
620
624
  if (processingSubscription) {
621
625
  processingSubscription.unsubscribe();
@@ -634,15 +638,15 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
634
638
 
635
639
  throw _context6.t3;
636
640
 
637
- case 45:
641
+ case 46:
638
642
  case "end":
639
643
  return _context6.stop();
640
644
  }
641
645
  }
642
- }, _callee6, this, [[13, 40]]);
646
+ }, _callee6, this, [[14, 41]]);
643
647
  }));
644
648
 
645
- function copyFile(_x8, _x9) {
649
+ function copyFile(_x9, _x10) {
646
650
  return _copyFile.apply(this, arguments);
647
651
  }
648
652
 
@@ -28,8 +28,8 @@ export var MediaClient = /*#__PURE__*/function () {
28
28
 
29
29
  _createClass(MediaClient, [{
30
30
  key: "getImage",
31
- value: function getImage(id, params, controller, fetchMaxRes) {
32
- return this.mediaStore.getImage(id, params, controller, fetchMaxRes);
31
+ value: function getImage(id, params, controller, fetchMaxRes, traceContext) {
32
+ return this.mediaStore.getImage(id, params, controller, fetchMaxRes, traceContext);
33
33
  }
34
34
  }, {
35
35
  key: "getImageUrl",