@atlaskit/media-client 17.1.3 → 17.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +0 -20
- package/constants/package.json +1 -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 +70 -44
- package/dist/cjs/client/media-store/resolveAuth.js +1 -1
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/uploader/index.js +22 -20
- package/dist/cjs/utils/request/helpers.js +50 -26
- package/dist/cjs/utils/request/index.js +3 -2
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/client/file-fetcher/index.js +16 -14
- package/dist/es2019/client/media-client.js +2 -2
- package/dist/es2019/client/media-store/index.js +52 -35
- package/dist/es2019/client/media-store/resolveAuth.js +1 -1
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/uploader/index.js +14 -14
- package/dist/es2019/utils/request/helpers.js +33 -12
- package/dist/es2019/utils/request/index.js +4 -3
- package/dist/es2019/version.json +1 -1
- package/dist/esm/client/file-fetcher/index.js +40 -36
- package/dist/esm/client/media-client.js +2 -2
- package/dist/esm/client/media-store/index.js +71 -45
- package/dist/esm/client/media-store/resolveAuth.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/uploader/index.js +23 -21
- package/dist/esm/utils/request/helpers.js +45 -24
- package/dist/esm/utils/request/index.js +4 -3
- package/dist/esm/version.json +1 -1
- package/dist/types/client/file-fetcher/index.d.ts +9 -8
- package/dist/types/client/media-client.d.ts +2 -1
- package/dist/types/client/media-store/index.d.ts +15 -14
- package/dist/types/index.d.ts +3 -3
- package/dist/types/uploader/index.d.ts +2 -1
- package/dist/types/utils/request/helpers.d.ts +11 -3
- package/dist/types/utils/request/types.d.ts +5 -0
- package/package.json +5 -12
- 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 -90
- 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
|
@@ -31,7 +31,25 @@ export function isFetchNetworkError(err) {
|
|
|
31
31
|
export function isRateLimitedError(error) {
|
|
32
32
|
return !!error && isRequestError(error) && error.attributes.statusCode === 429 || !!error && !!error.message && error.message.includes('429');
|
|
33
33
|
}
|
|
34
|
+
export var ZipkinHeaderKeys = {
|
|
35
|
+
traceId: 'x-b3-traceid',
|
|
36
|
+
spanId: 'x-b3-spanid',
|
|
37
|
+
parentSpanId: 'x-b3-parentspanid',
|
|
38
|
+
sampled: 'x-b3-sampled',
|
|
39
|
+
flags: 'x-b3-flags'
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
var mapTraceIdToRequestHeaders = function mapTraceIdToRequestHeaders(traceContext) {
|
|
43
|
+
var _ref;
|
|
44
|
+
|
|
45
|
+
return traceContext ? (_ref = {}, _defineProperty(_ref, ZipkinHeaderKeys.traceId, traceContext.traceId), _defineProperty(_ref, ZipkinHeaderKeys.spanId, traceContext.spanId), _ref) : {};
|
|
46
|
+
};
|
|
47
|
+
|
|
34
48
|
export function mapAuthToRequestHeaders(auth) {
|
|
49
|
+
if (!auth) {
|
|
50
|
+
return {};
|
|
51
|
+
}
|
|
52
|
+
|
|
35
53
|
if (isClientBasedAuth(auth)) {
|
|
36
54
|
return {
|
|
37
55
|
'X-Client-Id': auth.clientId,
|
|
@@ -44,18 +62,18 @@ export function mapAuthToRequestHeaders(auth) {
|
|
|
44
62
|
Authorization: "Bearer ".concat(auth.token)
|
|
45
63
|
};
|
|
46
64
|
}
|
|
47
|
-
export function createUrl(url,
|
|
48
|
-
var params =
|
|
49
|
-
auth =
|
|
65
|
+
export function createUrl(url, _ref2) {
|
|
66
|
+
var params = _ref2.params,
|
|
67
|
+
auth = _ref2.auth;
|
|
50
68
|
var parsedUrl = new URL(url);
|
|
51
69
|
var authParams = auth && mapAuthToQueryParameters(auth) || {};
|
|
52
70
|
|
|
53
71
|
var paramsToAppend = _objectSpread(_objectSpread({}, params), authParams);
|
|
54
72
|
|
|
55
|
-
Object.entries(paramsToAppend).filter(function (
|
|
56
|
-
var
|
|
57
|
-
_ =
|
|
58
|
-
value =
|
|
73
|
+
Object.entries(paramsToAppend).filter(function (_ref3) {
|
|
74
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
75
|
+
_ = _ref4[0],
|
|
76
|
+
value = _ref4[1];
|
|
59
77
|
|
|
60
78
|
return value != null;
|
|
61
79
|
}).forEach(function (pair) {
|
|
@@ -66,14 +84,12 @@ export function createUrl(url, _ref) {
|
|
|
66
84
|
parsedUrl.searchParams.sort();
|
|
67
85
|
return parsedUrl.toString();
|
|
68
86
|
}
|
|
69
|
-
export function
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
87
|
+
export function extendHeaders(headers, auth, traceContext) {
|
|
88
|
+
if (!auth && !traceContext && !headers) {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
74
91
|
|
|
75
|
-
|
|
76
|
-
};
|
|
92
|
+
return _objectSpread(_objectSpread(_objectSpread({}, headers !== null && headers !== void 0 ? headers : {}), mapAuthToRequestHeaders(auth)), mapTraceIdToRequestHeaders(traceContext));
|
|
77
93
|
}
|
|
78
94
|
/**
|
|
79
95
|
* @deprecated Helper is deprecated and will be removed in the next major version.
|
|
@@ -108,7 +124,7 @@ function _mapResponseToJson() {
|
|
|
108
124
|
_context3.t0 = _context3["catch"](1);
|
|
109
125
|
throw new RequestError('serverInvalidBody', {
|
|
110
126
|
statusCode: response.status
|
|
111
|
-
}, _context3.t0
|
|
127
|
+
}, _context3.t0);
|
|
112
128
|
|
|
113
129
|
case 10:
|
|
114
130
|
case "end":
|
|
@@ -148,7 +164,7 @@ function _mapResponseToBlob() {
|
|
|
148
164
|
_context4.t0 = _context4["catch"](1);
|
|
149
165
|
throw new RequestError('serverInvalidBody', {
|
|
150
166
|
statusCode: response.status
|
|
151
|
-
}, _context4.t0
|
|
167
|
+
}, _context4.t0);
|
|
152
168
|
|
|
153
169
|
case 10:
|
|
154
170
|
case "end":
|
|
@@ -167,7 +183,7 @@ export function mapResponseToVoid() {
|
|
|
167
183
|
}
|
|
168
184
|
export function createMapResponseToJson(metadata) {
|
|
169
185
|
return /*#__PURE__*/function () {
|
|
170
|
-
var
|
|
186
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(response) {
|
|
171
187
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
172
188
|
while (1) {
|
|
173
189
|
switch (_context.prev = _context.next) {
|
|
@@ -184,7 +200,7 @@ export function createMapResponseToJson(metadata) {
|
|
|
184
200
|
_context.t0 = _context["catch"](0);
|
|
185
201
|
throw new RequestError('serverInvalidBody', _objectSpread(_objectSpread(_objectSpread({}, metadata), extractMediaHeaders(response)), {}, {
|
|
186
202
|
statusCode: response.status
|
|
187
|
-
}), _context.t0
|
|
203
|
+
}), _context.t0);
|
|
188
204
|
|
|
189
205
|
case 9:
|
|
190
206
|
case "end":
|
|
@@ -195,13 +211,13 @@ export function createMapResponseToJson(metadata) {
|
|
|
195
211
|
}));
|
|
196
212
|
|
|
197
213
|
return function (_x3) {
|
|
198
|
-
return
|
|
214
|
+
return _ref5.apply(this, arguments);
|
|
199
215
|
};
|
|
200
216
|
}();
|
|
201
217
|
}
|
|
202
218
|
export function createMapResponseToBlob(metadata) {
|
|
203
219
|
return /*#__PURE__*/function () {
|
|
204
|
-
var
|
|
220
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(response) {
|
|
205
221
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
206
222
|
while (1) {
|
|
207
223
|
switch (_context2.prev = _context2.next) {
|
|
@@ -218,7 +234,7 @@ export function createMapResponseToBlob(metadata) {
|
|
|
218
234
|
_context2.t0 = _context2["catch"](0);
|
|
219
235
|
throw new RequestError('serverInvalidBody', _objectSpread(_objectSpread(_objectSpread({}, metadata), extractMediaHeaders(response)), {}, {
|
|
220
236
|
statusCode: response.status
|
|
221
|
-
}), _context2.t0
|
|
237
|
+
}), _context2.t0);
|
|
222
238
|
|
|
223
239
|
case 9:
|
|
224
240
|
case "end":
|
|
@@ -229,7 +245,7 @@ export function createMapResponseToBlob(metadata) {
|
|
|
229
245
|
}));
|
|
230
246
|
|
|
231
247
|
return function (_x4) {
|
|
232
|
-
return
|
|
248
|
+
return _ref6.apply(this, arguments);
|
|
233
249
|
};
|
|
234
250
|
}();
|
|
235
251
|
}
|
|
@@ -274,7 +290,7 @@ function _fetchRetry() {
|
|
|
274
290
|
timeoutInMs = startTimeoutInMs;
|
|
275
291
|
|
|
276
292
|
waitAndBumpTimeout = /*#__PURE__*/function () {
|
|
277
|
-
var
|
|
293
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
278
294
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
279
295
|
while (1) {
|
|
280
296
|
switch (_context5.prev = _context5.next) {
|
|
@@ -295,7 +311,7 @@ function _fetchRetry() {
|
|
|
295
311
|
}));
|
|
296
312
|
|
|
297
313
|
return function waitAndBumpTimeout() {
|
|
298
|
-
return
|
|
314
|
+
return _ref7.apply(this, arguments);
|
|
299
315
|
};
|
|
300
316
|
}();
|
|
301
317
|
|
|
@@ -419,4 +435,9 @@ export function extractMediaHeaders(response) {
|
|
|
419
435
|
mediaRegion: mediaRegion,
|
|
420
436
|
mediaEnv: mediaEnv
|
|
421
437
|
};
|
|
438
|
+
}
|
|
439
|
+
export function getRandomHex(size) {
|
|
440
|
+
return _toConsumableArray(Array(size)).map(function () {
|
|
441
|
+
return Math.floor(Math.random() * 16).toString(16);
|
|
442
|
+
}).join('');
|
|
422
443
|
}
|
|
@@ -2,7 +2,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
3
|
export { RequestError, isRequestError } from './errors';
|
|
4
4
|
export { isRateLimitedError } from './helpers';
|
|
5
|
-
import { createUrl, fetchRetry, createProcessFetchResponse,
|
|
5
|
+
import { createUrl, fetchRetry, createProcessFetchResponse, extendHeaders } from './helpers';
|
|
6
6
|
export function request(_x) {
|
|
7
7
|
return _request.apply(this, arguments);
|
|
8
8
|
}
|
|
@@ -20,6 +20,7 @@ function _request() {
|
|
|
20
20
|
body,
|
|
21
21
|
_options$clientOption,
|
|
22
22
|
clientOptions,
|
|
23
|
+
traceContext,
|
|
23
24
|
retryOptions,
|
|
24
25
|
metadata,
|
|
25
26
|
doFetch,
|
|
@@ -31,7 +32,7 @@ function _request() {
|
|
|
31
32
|
case 0:
|
|
32
33
|
options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
33
34
|
controller = _args.length > 2 ? _args[2] : undefined;
|
|
34
|
-
_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;
|
|
35
|
+
_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;
|
|
35
36
|
retryOptions = clientOptions.retryOptions;
|
|
36
37
|
metadata = {
|
|
37
38
|
method: method,
|
|
@@ -44,7 +45,7 @@ function _request() {
|
|
|
44
45
|
}), {
|
|
45
46
|
method: method,
|
|
46
47
|
body: body,
|
|
47
|
-
headers:
|
|
48
|
+
headers: extendHeaders(headers, auth, traceContext),
|
|
48
49
|
signal: controller && controller.signal
|
|
49
50
|
}).then(createProcessFetchResponse(metadata));
|
|
50
51
|
};
|
package/dist/esm/version.json
CHANGED
|
@@ -8,6 +8,7 @@ import { MediaFileArtifacts } from '../../models/artifacts';
|
|
|
8
8
|
import { UploadController } from '../../upload-controller';
|
|
9
9
|
import { MediaSubscribable } from '../../utils/mediaSubscribable';
|
|
10
10
|
import { Dimensions } from '../../utils/getDimensionsFromBlob';
|
|
11
|
+
import { MediaTraceContext } from '../../utils/request/types';
|
|
11
12
|
export type { FileFetcherErrorAttributes, FileFetcherErrorReason, } from './error';
|
|
12
13
|
export { isFileFetcherError, FileFetcherError } from './error';
|
|
13
14
|
export interface CopySourceFile {
|
|
@@ -30,12 +31,12 @@ export declare type ExternalUploadPayload = {
|
|
|
30
31
|
export interface FileFetcher {
|
|
31
32
|
getFileState(id: string, options?: GetFileOptions): MediaSubscribable<FileState>;
|
|
32
33
|
getArtifactURL(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string): Promise<string>;
|
|
33
|
-
touchFiles(descriptors: TouchFileDescriptor[], collection?: string): Promise<TouchedFiles>;
|
|
34
|
-
upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds): MediaSubscribable<FileState>;
|
|
35
|
-
uploadExternal(url: string, collection?: string): Promise<ExternalUploadPayload>;
|
|
34
|
+
touchFiles(descriptors: TouchFileDescriptor[], collection?: string, traceContext?: MediaTraceContext): Promise<TouchedFiles>;
|
|
35
|
+
upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds, traceContext?: MediaTraceContext): MediaSubscribable<FileState>;
|
|
36
|
+
uploadExternal(url: string, collection?: string, traceContext?: MediaTraceContext): Promise<ExternalUploadPayload>;
|
|
36
37
|
downloadBinary(id: string, name?: string, collectionName?: string): Promise<void>;
|
|
37
38
|
getCurrentState(id: string, options?: GetFileOptions): Promise<FileState>;
|
|
38
|
-
copyFile(source: CopySourceFile, destination: CopyDestination, options?: CopyFileOptions): Promise<MediaFile>;
|
|
39
|
+
copyFile(source: CopySourceFile, destination: CopyDestination, options?: CopyFileOptions, traceContext?: MediaTraceContext): Promise<MediaFile>;
|
|
39
40
|
getFileBinaryURL(id: string, collectionName?: string): Promise<string>;
|
|
40
41
|
}
|
|
41
42
|
export declare class FileFetcherImpl implements FileFetcher {
|
|
@@ -47,10 +48,10 @@ export declare class FileFetcherImpl implements FileFetcher {
|
|
|
47
48
|
getArtifactURL(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string): Promise<string>;
|
|
48
49
|
getFileBinaryURL(id: string, collectionName?: string): Promise<string>;
|
|
49
50
|
private createDownloadFileStream;
|
|
50
|
-
touchFiles(descriptors: TouchFileDescriptor[], collection?: string): Promise<TouchedFiles>;
|
|
51
|
+
touchFiles(descriptors: TouchFileDescriptor[], collection?: string, traceContext?: MediaTraceContext): Promise<TouchedFiles>;
|
|
51
52
|
private generateUploadableFileUpfrontIds;
|
|
52
|
-
uploadExternal(url: string, collection?: string): Promise<ExternalUploadPayload>;
|
|
53
|
-
upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds): MediaSubscribable<FileState>;
|
|
53
|
+
uploadExternal(url: string, collection?: string, traceContext?: MediaTraceContext): Promise<ExternalUploadPayload>;
|
|
54
|
+
upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds, traceContext?: MediaTraceContext): MediaSubscribable<FileState>;
|
|
54
55
|
downloadBinary(id: string, name?: string, collectionName?: string): Promise<void>;
|
|
55
|
-
copyFile(source: CopySourceFile, destination: CopyDestination, options?: CopyFileOptions): Promise<MediaFile>;
|
|
56
|
+
copyFile(source: CopySourceFile, destination: CopyDestination, options?: CopyFileOptions, traceContext?: MediaTraceContext): Promise<MediaFile>;
|
|
56
57
|
}
|
|
@@ -6,6 +6,7 @@ import { FileFetcher } from './file-fetcher';
|
|
|
6
6
|
import { UploadEventPayloadMap, EventPayloadListener } from './events';
|
|
7
7
|
import { StargateClient } from './stargate-client';
|
|
8
8
|
import { MobileUpload } from '../models/mobile-upload';
|
|
9
|
+
import { MediaTraceContext } from '../utils/request/types';
|
|
9
10
|
export declare class MediaClient {
|
|
10
11
|
readonly mediaClientConfig: MediaClientConfig;
|
|
11
12
|
readonly featureFlags?: MediaFeatureFlags | undefined;
|
|
@@ -17,7 +18,7 @@ export declare class MediaClient {
|
|
|
17
18
|
private mobileUpload?;
|
|
18
19
|
readonly config: MediaClientConfig;
|
|
19
20
|
constructor(mediaClientConfig: MediaClientConfig, featureFlags?: MediaFeatureFlags | undefined);
|
|
20
|
-
getImage(id: string, params?: MediaStoreGetFileImageParams, controller?: AbortController, fetchMaxRes?: boolean): Promise<Blob>;
|
|
21
|
+
getImage(id: string, params?: MediaStoreGetFileImageParams, controller?: AbortController, fetchMaxRes?: boolean, traceContext?: MediaTraceContext): Promise<Blob>;
|
|
21
22
|
getImageUrl(id: string, params?: MediaStoreGetFileImageParams): Promise<string>;
|
|
22
23
|
getImageUrlSync(id: string, params?: MediaStoreGetFileImageParams): string;
|
|
23
24
|
getImageMetadata(id: string, params?: MediaStoreGetFileImageParams): Promise<ImageMetadata>;
|
|
@@ -2,40 +2,40 @@ import { AsapBasedAuth, AuthContext, ClientAltBasedAuth, MediaApiConfig, Auth }
|
|
|
2
2
|
import { MediaFeatureFlags } from '@atlaskit/media-common';
|
|
3
3
|
import { MediaFileArtifacts } from '../../models/artifacts';
|
|
4
4
|
import { MediaChunksProbe, MediaCollectionItemFullDetails, MediaCollectionItems, MediaFile, MediaUpload } from '../../models/media';
|
|
5
|
-
import { ClientOptions, RequestHeaders, RequestMethod, RequestParams, RequestMetadata } from '../../utils/request/types';
|
|
5
|
+
import { ClientOptions, RequestHeaders, RequestMethod, RequestParams, RequestMetadata, MediaTraceContext } from '../../utils/request/types';
|
|
6
6
|
export type { MediaStoreErrorReason, MediaStoreErrorAttributes } from './error';
|
|
7
7
|
export { MediaStoreError, isMediaStoreError } from './error';
|
|
8
8
|
export declare class MediaStore {
|
|
9
9
|
private readonly config;
|
|
10
10
|
readonly featureFlags?: MediaFeatureFlags | undefined;
|
|
11
11
|
constructor(config: MediaApiConfig, featureFlags?: MediaFeatureFlags | undefined);
|
|
12
|
-
getCollectionItems(collectionName: string, params?: MediaStoreGetCollectionItemsParams): Promise<MediaStoreResponse<MediaCollectionItems>>;
|
|
13
|
-
removeCollectionFile(id: string, collectionName: string, occurrenceKey?: string): Promise<void>;
|
|
14
|
-
createUpload(createUpTo?: number, collectionName?: string): Promise<MediaStoreResponse<MediaUpload[]>>;
|
|
12
|
+
getCollectionItems(collectionName: string, params?: MediaStoreGetCollectionItemsParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaCollectionItems>>;
|
|
13
|
+
removeCollectionFile(id: string, collectionName: string, occurrenceKey?: string, traceContext?: MediaTraceContext): Promise<void>;
|
|
14
|
+
createUpload(createUpTo?: number, collectionName?: string, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaUpload[]>>;
|
|
15
15
|
uploadChunk(etag: string, blob: Blob, { collectionName, uploadId, partNumber, }?: {
|
|
16
16
|
collectionName?: string;
|
|
17
17
|
uploadId?: string;
|
|
18
18
|
partNumber?: number;
|
|
19
|
-
}): Promise<void>;
|
|
19
|
+
}, traceContext?: MediaTraceContext): Promise<void>;
|
|
20
20
|
probeChunks(chunks: string[], { collectionName, uploadId, }?: {
|
|
21
21
|
collectionName?: string;
|
|
22
22
|
uploadId?: string;
|
|
23
|
-
}): Promise<MediaStoreResponse<MediaChunksProbe>>;
|
|
24
|
-
createFileFromUpload(body: MediaStoreCreateFileFromUploadBody, params?: MediaStoreCreateFileFromUploadParams): Promise<MediaStoreResponse<MediaFile>>;
|
|
25
|
-
touchFiles(body: MediaStoreTouchFileBody, params?: MediaStoreTouchFileParams): Promise<MediaStoreResponse<TouchedFiles>>;
|
|
26
|
-
getFile(fileId: string, params?: MediaStoreGetFileParams): Promise<MediaStoreResponse<MediaFile>>;
|
|
23
|
+
}, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaChunksProbe>>;
|
|
24
|
+
createFileFromUpload(body: MediaStoreCreateFileFromUploadBody, params?: MediaStoreCreateFileFromUploadParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaFile>>;
|
|
25
|
+
touchFiles(body: MediaStoreTouchFileBody, params?: MediaStoreTouchFileParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<TouchedFiles>>;
|
|
26
|
+
getFile(fileId: string, params?: MediaStoreGetFileParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaFile>>;
|
|
27
27
|
getFileImageURL(id: string, params?: MediaStoreGetFileImageParams): Promise<string>;
|
|
28
28
|
getFileImageURLSync(id: string, params?: MediaStoreGetFileImageParams): string;
|
|
29
29
|
private createFileImageURL;
|
|
30
30
|
getFileBinaryURL(id: string, collectionName?: string): Promise<string>;
|
|
31
31
|
getArtifactURL(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string): Promise<string>;
|
|
32
|
-
getImage(id: string, params?: MediaStoreGetFileImageParams, controller?: AbortController, fetchMaxRes?: boolean): Promise<Blob>;
|
|
33
|
-
getItems(ids: string[], collectionName?: string): Promise<MediaStoreResponse<ItemsPayload>>;
|
|
34
|
-
getImageMetadata(id: string, params?: MediaStoreGetFileImageParams): Promise<{
|
|
32
|
+
getImage(id: string, params?: MediaStoreGetFileImageParams, controller?: AbortController, fetchMaxRes?: boolean, traceContext?: MediaTraceContext): Promise<Blob>;
|
|
33
|
+
getItems(ids: string[], collectionName?: string, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<ItemsPayload>>;
|
|
34
|
+
getImageMetadata(id: string, params?: MediaStoreGetFileImageParams, traceContext?: MediaTraceContext): Promise<{
|
|
35
35
|
metadata: ImageMetadata;
|
|
36
36
|
}>;
|
|
37
|
-
appendChunksToUpload(uploadId: string, body: AppendChunksToUploadRequestBody, collectionName?: string): Promise<void>;
|
|
38
|
-
copyFileWithToken(body: MediaStoreCopyFileWithTokenBody, params: MediaStoreCopyFileWithTokenParams): Promise<MediaStoreResponse<MediaFile>>;
|
|
37
|
+
appendChunksToUpload(uploadId: string, body: AppendChunksToUploadRequestBody, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
|
|
38
|
+
copyFileWithToken(body: MediaStoreCopyFileWithTokenBody, params: MediaStoreCopyFileWithTokenParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaFile>>;
|
|
39
39
|
request(path: string, options?: MediaStoreRequestOptions, controller?: AbortController): Promise<Response>;
|
|
40
40
|
resolveAuth: (authContext?: AuthContext | undefined) => Promise<Auth>;
|
|
41
41
|
resolveInitialAuth: () => Auth;
|
|
@@ -72,6 +72,7 @@ export declare type MediaStoreRequestOptions = RequestMetadata & {
|
|
|
72
72
|
readonly headers?: RequestHeaders;
|
|
73
73
|
readonly body?: any;
|
|
74
74
|
readonly clientOptions?: ClientOptions;
|
|
75
|
+
readonly traceContext?: MediaTraceContext;
|
|
75
76
|
};
|
|
76
77
|
export declare type MediaStoreCreateFileFromUploadParams = {
|
|
77
78
|
readonly collection?: string;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -12,17 +12,17 @@ export { isMediaClientError, getMediaClientErrorReason } from './models/errors';
|
|
|
12
12
|
export type { MediaClientError, MediaClientErrorReason, MediaClientErrorAttributes, } from './models/errors';
|
|
13
13
|
export { isUploadingFileState, isProcessingFileState, isProcessedFileState, isErrorFileState, isPreviewableFileState, isFinalFileState, isImageRepresentationReady, mapMediaFileToFileState, mapMediaItemToFileState, } from './models/file-state';
|
|
14
14
|
export type { FileStatus, FilePreview, PreviewOptions, GetFileOptions, UploadingFileState, ProcessingFileState, ProcessedFileState, ProcessingFailedState, ErrorFileState, NonErrorFileState, PreviewableFileState, FileState, } from './models/file-state';
|
|
15
|
-
export type {
|
|
15
|
+
export type { MobileUploadStartEvent, MobileUploadProgressEvent, MobileUploadEndEvent, MobileUploadErrorEvent, } from './models/mobile-upload';
|
|
16
16
|
export { StreamsCache } from './file-streams-cache';
|
|
17
17
|
export { uploadFile } from './uploader';
|
|
18
18
|
export type { UploadableFile, UploadableFileUpfrontIds, UploadFileCallbacks, UploadFileResult, } from './uploader';
|
|
19
19
|
export { request, RequestError, isRequestError, isRateLimitedError, } from './utils/request';
|
|
20
20
|
export type { RequestErrorReason, RequestErrorMetadata, RequestErrorAttributes, } from './utils/request';
|
|
21
|
-
export { isAbortedRequestError, mapResponseToJson, mapResponseToBlob, mapResponseToVoid, createUrl, } from './utils/request/helpers';
|
|
21
|
+
export { isAbortedRequestError, mapResponseToJson, mapResponseToBlob, mapResponseToVoid, createUrl, getRandomHex, } from './utils/request/helpers';
|
|
22
22
|
export { PollingFunction } from './utils/polling';
|
|
23
23
|
export { isPollingError, PollingError } from './utils/polling/errors';
|
|
24
24
|
export type { Executor, PollingErrorAttributes, PollingErrorReason, } from './utils/polling/types';
|
|
25
|
-
export type { RequestMethod, RequestParams, RequestHeaders, RetryOptions, ClientOptions, RequestMetadata, RequestOptions, CreateUrlOptions, } from './utils/request/types';
|
|
25
|
+
export type { RequestMethod, RequestParams, RequestHeaders, RetryOptions, ClientOptions, RequestMetadata, RequestOptions, CreateUrlOptions, MediaTraceContext, } from './utils/request/types';
|
|
26
26
|
export type { ImageResizeMode } from './utils/imageResizeModeToFileImageMode';
|
|
27
27
|
export { imageResizeModeToFileImageMode } from './utils/imageResizeModeToFileImageMode';
|
|
28
28
|
export { FileFetcherImpl, FileFetcherError, isFileFetcherError, } from './client/file-fetcher';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ChunkinatorFile } from '@atlaskit/chunkinator';
|
|
2
2
|
import { MediaStore } from '../client/media-store';
|
|
3
|
+
import { MediaTraceContext } from '../utils/request/types';
|
|
3
4
|
export declare type UploadableFile = {
|
|
4
5
|
content: ChunkinatorFile;
|
|
5
6
|
name?: string;
|
|
@@ -18,4 +19,4 @@ export declare type UploadFileCallbacks = {
|
|
|
18
19
|
export interface UploadFileResult {
|
|
19
20
|
cancel: () => void;
|
|
20
21
|
}
|
|
21
|
-
export declare const uploadFile: (file: UploadableFile, store: MediaStore, uploadableFileUpfrontIds: UploadableFileUpfrontIds, callbacks?: UploadFileCallbacks | undefined) => UploadFileResult;
|
|
22
|
+
export declare const uploadFile: (file: UploadableFile, store: MediaStore, uploadableFileUpfrontIds: UploadableFileUpfrontIds, callbacks?: UploadFileCallbacks | undefined, traceContext?: MediaTraceContext | undefined) => UploadFileResult;
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import { Auth } from '@atlaskit/media-core';
|
|
2
2
|
import { RequestError } from './errors';
|
|
3
|
-
import { CreateUrlOptions, RequestErrorReason, RequestErrorMetadata, RequestHeaders, RequestMetadata, RetryOptions } from './types';
|
|
3
|
+
import { CreateUrlOptions, RequestErrorReason, RequestErrorMetadata, RequestHeaders, RequestMetadata, RetryOptions, MediaTraceContext } from './types';
|
|
4
4
|
export declare function clientTimeoutPromise(timeout: number): Promise<Response>;
|
|
5
5
|
export declare function waitPromise(timeout: number): Promise<void>;
|
|
6
6
|
export declare function isAbortedRequestError(err: any): boolean;
|
|
7
7
|
export declare function isFetchNetworkError(err: any): err is TypeError;
|
|
8
8
|
export declare function isRateLimitedError(error: Error | undefined): boolean;
|
|
9
|
-
export declare
|
|
9
|
+
export declare const ZipkinHeaderKeys: {
|
|
10
|
+
traceId: string;
|
|
11
|
+
spanId: string;
|
|
12
|
+
parentSpanId: string;
|
|
13
|
+
sampled: string;
|
|
14
|
+
flags: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function mapAuthToRequestHeaders(auth?: Auth): RequestHeaders;
|
|
10
17
|
export declare function createUrl(url: string, { params, auth }: CreateUrlOptions): string;
|
|
11
|
-
export declare function
|
|
18
|
+
export declare function extendHeaders(headers?: RequestHeaders, auth?: Auth, traceContext?: Required<MediaTraceContext>): RequestHeaders | undefined;
|
|
12
19
|
/**
|
|
13
20
|
* @deprecated Helper is deprecated and will be removed in the next major version.
|
|
14
21
|
* TODO: https://product-fabric.atlassian.net/browse/BMPT-1354
|
|
@@ -36,3 +43,4 @@ export declare function extractMediaHeaders(response: Response): {
|
|
|
36
43
|
mediaRegion: string;
|
|
37
44
|
mediaEnv: string;
|
|
38
45
|
};
|
|
46
|
+
export declare function getRandomHex(size: number): string;
|
|
@@ -23,6 +23,7 @@ export declare type RequestMetadata = {
|
|
|
23
23
|
};
|
|
24
24
|
export declare type RequestOptions = RequestMetadata & {
|
|
25
25
|
readonly auth?: Auth;
|
|
26
|
+
readonly traceContext?: Required<MediaTraceContext>;
|
|
26
27
|
readonly params?: RequestParams;
|
|
27
28
|
readonly headers?: RequestHeaders;
|
|
28
29
|
readonly body?: any;
|
|
@@ -41,3 +42,7 @@ export declare type RequestErrorMetadata = RequestMetadata & {
|
|
|
41
42
|
export declare type RequestErrorAttributes = RequestErrorMetadata & {
|
|
42
43
|
readonly reason: RequestErrorReason;
|
|
43
44
|
};
|
|
45
|
+
export declare type MediaTraceContext = {
|
|
46
|
+
traceId: string;
|
|
47
|
+
spanId?: string;
|
|
48
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/media-client",
|
|
3
|
-
"version": "17.1.
|
|
3
|
+
"version": "17.1.4",
|
|
4
4
|
"description": "Media API Web Client Library",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -12,13 +12,6 @@
|
|
|
12
12
|
"module": "dist/esm/index.js",
|
|
13
13
|
"module:es2019": "dist/es2019/index.js",
|
|
14
14
|
"types": "dist/types/index.d.ts",
|
|
15
|
-
"typesVersions": {
|
|
16
|
-
">=4.0 <4.5": {
|
|
17
|
-
"*": [
|
|
18
|
-
"dist/types-ts4.0/*"
|
|
19
|
-
]
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
15
|
"sideEffects": false,
|
|
23
16
|
"atlaskit:src": "src/index.ts",
|
|
24
17
|
"af:exports": {
|
|
@@ -35,7 +28,7 @@
|
|
|
35
28
|
},
|
|
36
29
|
"dependencies": {
|
|
37
30
|
"@atlaskit/chunkinator": "^4.1.0",
|
|
38
|
-
"@atlaskit/media-common": "^2.
|
|
31
|
+
"@atlaskit/media-common": "^2.15.0",
|
|
39
32
|
"@babel/runtime": "^7.0.0",
|
|
40
33
|
"dataloader": "^2.0.0",
|
|
41
34
|
"deep-equal": "^1.0.1",
|
|
@@ -50,14 +43,14 @@
|
|
|
50
43
|
"xstate": "^4.20.0"
|
|
51
44
|
},
|
|
52
45
|
"peerDependencies": {
|
|
53
|
-
"@atlaskit/media-core": "^33.0.
|
|
46
|
+
"@atlaskit/media-core": "^33.0.1",
|
|
54
47
|
"@emotion/react": "^11.7.1",
|
|
55
48
|
"react": "^16.8.0"
|
|
56
49
|
},
|
|
57
50
|
"devDependencies": {
|
|
58
51
|
"@atlaskit/button": "^16.3.0",
|
|
59
52
|
"@atlaskit/docs": "*",
|
|
60
|
-
"@atlaskit/media-card": "^74.
|
|
53
|
+
"@atlaskit/media-card": "^74.0.0",
|
|
61
54
|
"@atlaskit/media-core": "^33.0.0",
|
|
62
55
|
"@atlaskit/media-test-helpers": "^30.0.0",
|
|
63
56
|
"@atlaskit/ssr": "*",
|
|
@@ -69,7 +62,7 @@
|
|
|
69
62
|
"fetch-mock": "^8.0.0",
|
|
70
63
|
"react": "^16.8.0",
|
|
71
64
|
"react-dom": "^16.8.0",
|
|
72
|
-
"typescript": "4.
|
|
65
|
+
"typescript": "4.2.4"
|
|
73
66
|
},
|
|
74
67
|
"resolutions": {
|
|
75
68
|
"lru-fast": "0.2.2"
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/// <reference types="jest" />
|
|
2
|
-
export declare class FileFetcher {
|
|
3
|
-
constructor();
|
|
4
|
-
getFileState: jest.Mock<any, any>;
|
|
5
|
-
getCurrentState: jest.Mock<any, any>;
|
|
6
|
-
getArtifactURL: jest.Mock<any, any>;
|
|
7
|
-
touchFiles: jest.Mock<any, any>;
|
|
8
|
-
upload: jest.Mock<any, any>;
|
|
9
|
-
downloadBinary: jest.Mock<any, any>;
|
|
10
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/// <reference types="jest" />
|
|
2
|
-
import { MediaClientConfig } from '@atlaskit/media-core';
|
|
3
|
-
import { CollectionFetcher } from '../collection-fetcher';
|
|
4
|
-
import { FileFetcher } from '../file-fetcher';
|
|
5
|
-
export declare class MediaClient {
|
|
6
|
-
readonly config: MediaClientConfig;
|
|
7
|
-
readonly collection: CollectionFetcher;
|
|
8
|
-
readonly file: FileFetcher;
|
|
9
|
-
constructor(config: MediaClientConfig);
|
|
10
|
-
getImage: jest.Mock<any, any>;
|
|
11
|
-
getImageUrl: jest.Mock<any, any>;
|
|
12
|
-
getImageMetadata: jest.Mock<any, any>;
|
|
13
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { ReplaySubject } from 'rxjs/ReplaySubject';
|
|
2
|
-
import { FileDetails, FileItem } from '../models/item';
|
|
3
|
-
import { MediaCollectionItem } from '../models/media';
|
|
4
|
-
import { MediaStore, MediaStoreGetCollectionItemsParams } from './media-store';
|
|
5
|
-
import { MediaSubscribable } from '../utils/mediaSubscribable';
|
|
6
|
-
export interface MediaCollectionFileItemDetails extends FileDetails {
|
|
7
|
-
occurrenceKey: string;
|
|
8
|
-
}
|
|
9
|
-
export interface MediaCollectionFileItem extends FileItem {
|
|
10
|
-
details: MediaCollectionFileItemDetails;
|
|
11
|
-
}
|
|
12
|
-
export interface MediaCollection {
|
|
13
|
-
id: string;
|
|
14
|
-
items: Array<MediaCollectionItem>;
|
|
15
|
-
}
|
|
16
|
-
export interface CollectionCacheEntry {
|
|
17
|
-
items: MediaCollectionItem[];
|
|
18
|
-
subject: ReplaySubject<MediaCollectionItem[]>;
|
|
19
|
-
isLoadingNextPage: boolean;
|
|
20
|
-
nextInclusiveStartKey?: string;
|
|
21
|
-
}
|
|
22
|
-
export declare type CollectionCache = {
|
|
23
|
-
[collectionName: string]: CollectionCacheEntry;
|
|
24
|
-
};
|
|
25
|
-
export declare const collectionCache: CollectionCache;
|
|
26
|
-
export declare class CollectionFetcher {
|
|
27
|
-
readonly mediaStore: MediaStore;
|
|
28
|
-
constructor(mediaStore: MediaStore);
|
|
29
|
-
private createFileStateObserver;
|
|
30
|
-
private populateCache;
|
|
31
|
-
private removeFromCache;
|
|
32
|
-
getItems(collectionName: string, params?: MediaStoreGetCollectionItemsParams): MediaSubscribable<MediaCollectionItem[]>;
|
|
33
|
-
removeFile(id: string, collectionName: string, occurrenceKey?: string): Promise<void>;
|
|
34
|
-
loadNextPage(collectionName: string, params?: MediaStoreGetCollectionItemsParams): Promise<void>;
|
|
35
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { FileState } from '../models/file-state';
|
|
2
|
-
export declare type EventPayloadMap<P> = {
|
|
3
|
-
readonly [event: string]: P;
|
|
4
|
-
};
|
|
5
|
-
export declare type EventPayloadListener<M extends EventPayloadMap<P>, E extends keyof M, P = any> = (payload: M[E]) => void;
|
|
6
|
-
export interface MediaViewedEventPayload {
|
|
7
|
-
fileId: string;
|
|
8
|
-
viewingLevel: 'minimal' | 'full' | 'download';
|
|
9
|
-
isUserCollection?: boolean;
|
|
10
|
-
}
|
|
11
|
-
export declare type UploadEventPayloadMap = {
|
|
12
|
-
'file-added': FileState;
|
|
13
|
-
'media-viewed': MediaViewedEventPayload;
|
|
14
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { BaseMediaClientError } from '../../models/errors';
|
|
2
|
-
export declare type FileFetcherErrorReason = 'invalidFileId' | 'emptyItems' | 'zeroVersionFile';
|
|
3
|
-
export declare type FileFetcherErrorAttributes = {
|
|
4
|
-
readonly reason: FileFetcherErrorReason;
|
|
5
|
-
readonly id: string;
|
|
6
|
-
readonly metadata?: {
|
|
7
|
-
readonly collectionName?: string;
|
|
8
|
-
readonly occurrenceKey?: string;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
export declare class FileFetcherError extends BaseMediaClientError<FileFetcherErrorAttributes> {
|
|
12
|
-
readonly reason: FileFetcherErrorReason;
|
|
13
|
-
readonly id: string;
|
|
14
|
-
readonly metadata?: {
|
|
15
|
-
readonly collectionName?: string | undefined;
|
|
16
|
-
readonly occurrenceKey?: string | undefined;
|
|
17
|
-
} | undefined;
|
|
18
|
-
constructor(reason: FileFetcherErrorReason, id: string, metadata?: {
|
|
19
|
-
readonly collectionName?: string | undefined;
|
|
20
|
-
readonly occurrenceKey?: string | undefined;
|
|
21
|
-
} | undefined);
|
|
22
|
-
get attributes(): {
|
|
23
|
-
reason: FileFetcherErrorReason;
|
|
24
|
-
id: string;
|
|
25
|
-
collectionName: string | undefined;
|
|
26
|
-
occurrenceKey: string | undefined;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
export declare function isFileFetcherError(err: Error): err is FileFetcherError;
|