@atlaskit/media-client 28.5.0 → 28.6.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 +8 -0
- package/dist/cjs/client/file-fetcher/error.js +5 -7
- package/dist/cjs/client/file-fetcher/index.js +135 -71
- package/dist/cjs/client/media-client.js +1 -2
- package/dist/cjs/client/media-store/MediaStore.js +10 -3
- package/dist/cjs/client/media-store/error.js +5 -7
- package/dist/cjs/client/mobile-upload.js +1 -2
- package/dist/cjs/client/stargate-client.js +1 -2
- package/dist/cjs/file-streams-cache.js +1 -2
- package/dist/cjs/models/errors/index.js +6 -8
- package/dist/cjs/upload-controller.js +1 -2
- package/dist/cjs/uploader/error.js +5 -7
- package/dist/cjs/utils/hashing/sha256SimpleHasher.js +1 -2
- package/dist/cjs/utils/hashing/simpleHasher.js +1 -2
- package/dist/cjs/utils/hashing/workerHasher.js +1 -2
- package/dist/cjs/utils/mobileUpload/error.js +5 -7
- package/dist/cjs/utils/polling/errors.js +5 -7
- package/dist/cjs/utils/polling/index.js +1 -2
- package/dist/cjs/utils/request/errors.js +5 -7
- package/dist/cjs/utils/request/helpers.js +10 -4
- package/dist/es2019/client/file-fetcher/index.js +38 -8
- package/dist/es2019/client/media-store/MediaStore.js +11 -3
- package/dist/es2019/utils/request/helpers.js +7 -2
- package/dist/esm/client/file-fetcher/error.js +5 -7
- package/dist/esm/client/file-fetcher/index.js +135 -71
- package/dist/esm/client/media-client.js +1 -2
- package/dist/esm/client/media-store/MediaStore.js +12 -5
- package/dist/esm/client/media-store/error.js +5 -7
- package/dist/esm/client/mobile-upload.js +1 -2
- package/dist/esm/client/stargate-client.js +1 -2
- package/dist/esm/file-streams-cache.js +1 -2
- package/dist/esm/models/errors/index.js +6 -8
- package/dist/esm/upload-controller.js +1 -2
- package/dist/esm/uploader/error.js +5 -7
- package/dist/esm/utils/hashing/sha256SimpleHasher.js +1 -2
- package/dist/esm/utils/hashing/simpleHasher.js +1 -2
- package/dist/esm/utils/hashing/workerHasher.js +1 -2
- package/dist/esm/utils/mobileUpload/error.js +5 -7
- package/dist/esm/utils/polling/errors.js +5 -7
- package/dist/esm/utils/polling/index.js +1 -2
- package/dist/esm/utils/request/errors.js +5 -7
- package/dist/esm/utils/request/helpers.js +9 -4
- package/dist/types/client/file-fetcher/index.d.ts +4 -2
- package/dist/types/utils/request/helpers.d.ts +1 -0
- package/dist/types/utils/request/types.d.ts +1 -0
- package/dist/types-ts4.5/client/file-fetcher/index.d.ts +4 -2
- package/dist/types-ts4.5/utils/request/helpers.d.ts +1 -0
- package/dist/types-ts4.5/utils/request/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
3
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
4
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
-
|
|
5
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
7
7
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
8
8
|
import { BaseMediaClientError } from '../../models/errors';
|
|
9
9
|
export var PollingError = /*#__PURE__*/function (_BaseMediaClientError) {
|
|
10
|
-
_inherits(PollingError, _BaseMediaClientError);
|
|
11
|
-
var _super = _createSuper(PollingError);
|
|
12
10
|
function PollingError(reason, attempts) {
|
|
13
11
|
var _this;
|
|
14
12
|
_classCallCheck(this, PollingError);
|
|
15
|
-
_this =
|
|
13
|
+
_this = _callSuper(this, PollingError, [reason]);
|
|
16
14
|
_this.reason = reason;
|
|
17
15
|
_this.attempts = attempts;
|
|
18
16
|
return _this;
|
|
19
17
|
}
|
|
20
|
-
|
|
18
|
+
_inherits(PollingError, _BaseMediaClientError);
|
|
19
|
+
return _createClass(PollingError, [{
|
|
21
20
|
key: "attributes",
|
|
22
21
|
get: function get() {
|
|
23
22
|
var reason = this.reason,
|
|
@@ -28,7 +27,6 @@ export var PollingError = /*#__PURE__*/function (_BaseMediaClientError) {
|
|
|
28
27
|
};
|
|
29
28
|
}
|
|
30
29
|
}]);
|
|
31
|
-
return PollingError;
|
|
32
30
|
}(BaseMediaClientError);
|
|
33
31
|
export function isPollingError(err) {
|
|
34
32
|
return err instanceof PollingError;
|
|
@@ -36,7 +36,7 @@ export var PollingFunction = /*#__PURE__*/function () {
|
|
|
36
36
|
this.options = _objectSpread(_objectSpread({}, defaultPollingOptions), options);
|
|
37
37
|
this.poll_intervalMs = this.options.poll_intervalMs;
|
|
38
38
|
}
|
|
39
|
-
_createClass(PollingFunction, [{
|
|
39
|
+
return _createClass(PollingFunction, [{
|
|
40
40
|
key: "execute",
|
|
41
41
|
value: function () {
|
|
42
42
|
var _execute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(executor) {
|
|
@@ -123,5 +123,4 @@ export var PollingFunction = /*#__PURE__*/function () {
|
|
|
123
123
|
this.timeoutId = 0;
|
|
124
124
|
}
|
|
125
125
|
}]);
|
|
126
|
-
return PollingFunction;
|
|
127
126
|
}();
|
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
3
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
4
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
-
|
|
5
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
7
7
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
8
8
|
import { BaseMediaClientError } from '../../models/errors';
|
|
9
9
|
export var RequestError = /*#__PURE__*/function (_BaseMediaClientError) {
|
|
10
|
-
_inherits(RequestError, _BaseMediaClientError);
|
|
11
|
-
var _super = _createSuper(RequestError);
|
|
12
10
|
function RequestError(reason, metadata, innerError) {
|
|
13
11
|
var _this;
|
|
14
12
|
_classCallCheck(this, RequestError);
|
|
15
|
-
_this =
|
|
13
|
+
_this = _callSuper(this, RequestError, [reason]);
|
|
16
14
|
_this.reason = reason;
|
|
17
15
|
_this.metadata = metadata;
|
|
18
16
|
_this.innerError = innerError;
|
|
19
17
|
return _this;
|
|
20
18
|
}
|
|
21
|
-
|
|
19
|
+
_inherits(RequestError, _BaseMediaClientError);
|
|
20
|
+
return _createClass(RequestError, [{
|
|
22
21
|
key: "attributes",
|
|
23
22
|
get: function get() {
|
|
24
23
|
var reason = this.reason,
|
|
@@ -49,7 +48,6 @@ export var RequestError = /*#__PURE__*/function (_BaseMediaClientError) {
|
|
|
49
48
|
};
|
|
50
49
|
}
|
|
51
50
|
}]);
|
|
52
|
-
return RequestError;
|
|
53
51
|
}(BaseMediaClientError);
|
|
54
52
|
export function isRequestError(err) {
|
|
55
53
|
return err instanceof RequestError;
|
|
@@ -38,8 +38,7 @@ export var ZipkinHeaderKeys = {
|
|
|
38
38
|
flags: 'x-b3-flags'
|
|
39
39
|
};
|
|
40
40
|
var mapTraceIdToRequestHeaders = function mapTraceIdToRequestHeaders(traceContext) {
|
|
41
|
-
|
|
42
|
-
return traceContext ? (_ref = {}, _defineProperty(_ref, ZipkinHeaderKeys.traceId, traceContext.traceId), _defineProperty(_ref, ZipkinHeaderKeys.spanId, traceContext.spanId), _ref) : {};
|
|
41
|
+
return traceContext ? _defineProperty(_defineProperty({}, ZipkinHeaderKeys.traceId, traceContext.traceId), ZipkinHeaderKeys.spanId, traceContext.spanId) : {};
|
|
43
42
|
};
|
|
44
43
|
export function mapAuthToRequestHeaders(auth) {
|
|
45
44
|
if (!auth) {
|
|
@@ -136,6 +135,10 @@ export function createMapResponseToBlob(metadata) {
|
|
|
136
135
|
};
|
|
137
136
|
}();
|
|
138
137
|
}
|
|
138
|
+
export var defaultShouldRetryError = function defaultShouldRetryError(err) {
|
|
139
|
+
var _err$metadata;
|
|
140
|
+
return isFetchNetworkError(err) || isRequestError(err) && !!(err !== null && err !== void 0 && (_err$metadata = err.metadata) !== null && _err$metadata !== void 0 && _err$metadata.statusCode) && err.metadata.statusCode >= 500;
|
|
141
|
+
};
|
|
139
142
|
export var DEFAULT_RETRY_OPTIONS = {
|
|
140
143
|
startTimeoutInMs: 1000,
|
|
141
144
|
// 1 second is generally a good timeout to start
|
|
@@ -159,6 +162,8 @@ function _fetchRetry() {
|
|
|
159
162
|
startTimeoutInMs,
|
|
160
163
|
maxAttempts,
|
|
161
164
|
factor,
|
|
165
|
+
_options$shouldRetryE,
|
|
166
|
+
shouldRetryError,
|
|
162
167
|
attempts,
|
|
163
168
|
timeoutInMs,
|
|
164
169
|
lastError,
|
|
@@ -169,7 +174,7 @@ function _fetchRetry() {
|
|
|
169
174
|
case 0:
|
|
170
175
|
overwriteOptions = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
|
|
171
176
|
options = _objectSpread(_objectSpread({}, DEFAULT_RETRY_OPTIONS), overwriteOptions);
|
|
172
|
-
startTimeoutInMs = options.startTimeoutInMs, maxAttempts = options.maxAttempts, factor = options.factor;
|
|
177
|
+
startTimeoutInMs = options.startTimeoutInMs, maxAttempts = options.maxAttempts, factor = options.factor, _options$shouldRetryE = options.shouldRetryError, shouldRetryError = _options$shouldRetryE === void 0 ? defaultShouldRetryError : _options$shouldRetryE;
|
|
173
178
|
attempts = 0;
|
|
174
179
|
timeoutInMs = startTimeoutInMs;
|
|
175
180
|
waitAndBumpTimeout = /*#__PURE__*/function () {
|
|
@@ -214,7 +219,7 @@ function _fetchRetry() {
|
|
|
214
219
|
}
|
|
215
220
|
throw new RequestError('clientAbortedRequest', metadata, _context4.t0);
|
|
216
221
|
case 18:
|
|
217
|
-
if (
|
|
222
|
+
if (shouldRetryError(_context4.t0)) {
|
|
218
223
|
_context4.next = 20;
|
|
219
224
|
break;
|
|
220
225
|
}
|
|
@@ -14,10 +14,10 @@ export { isFileFetcherError, FileFetcherError } from './error';
|
|
|
14
14
|
export interface CopySourceFile {
|
|
15
15
|
id: string;
|
|
16
16
|
collection?: string;
|
|
17
|
-
authProvider
|
|
17
|
+
authProvider?: AuthProvider;
|
|
18
18
|
}
|
|
19
19
|
export interface CopyDestination extends MediaStoreCopyFileWithTokenParams {
|
|
20
|
-
authProvider
|
|
20
|
+
authProvider?: AuthProvider;
|
|
21
21
|
mediaStore?: MediaApi;
|
|
22
22
|
}
|
|
23
23
|
export interface CopyFileOptions {
|
|
@@ -58,5 +58,7 @@ export declare class FileFetcherImpl implements FileFetcher {
|
|
|
58
58
|
private getUploadingFileStateBase;
|
|
59
59
|
upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds, traceContext?: MediaTraceContext): MediaSubscribable;
|
|
60
60
|
downloadBinary(id: string, name?: string, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
|
|
61
|
+
private copyFileWithToken;
|
|
62
|
+
private copyFileWithIntent;
|
|
61
63
|
copyFile(source: CopySourceFile, destination: CopyDestination, options?: CopyFileOptions, traceContext?: MediaTraceContext): Promise<MediaFile>;
|
|
62
64
|
}
|
|
@@ -19,6 +19,7 @@ export declare function createUrl(url: string, { params, auth }: CreateUrlOption
|
|
|
19
19
|
export declare function extendHeaders(headers?: RequestHeaders, auth?: Auth, traceContext?: Required<MediaTraceContext>): RequestHeaders | undefined;
|
|
20
20
|
export declare function createMapResponseToJson(metadata: RequestMetadata): (response: Response) => Promise<any>;
|
|
21
21
|
export declare function createMapResponseToBlob(metadata: RequestMetadata): (response: Response) => Promise<Blob>;
|
|
22
|
+
export declare const defaultShouldRetryError: (err: any) => boolean;
|
|
22
23
|
export declare const DEFAULT_RETRY_OPTIONS: RetryOptions;
|
|
23
24
|
export declare function cloneRequestError(error: RequestError, extraMetadata: Partial<RequestErrorMetadata>): RequestError;
|
|
24
25
|
export declare function fetchRetry(functionToRetry: () => Promise<Response>, metadata: RequestMetadata, overwriteOptions?: Partial<RetryOptions>): Promise<Response>;
|
|
@@ -11,6 +11,7 @@ export type RetryOptions = {
|
|
|
11
11
|
readonly startTimeoutInMs: number;
|
|
12
12
|
readonly maxAttempts: number;
|
|
13
13
|
readonly factor: number;
|
|
14
|
+
readonly shouldRetryError?: (err: any) => boolean;
|
|
14
15
|
};
|
|
15
16
|
export type ClientOptions = {
|
|
16
17
|
readonly retryOptions?: Partial<RetryOptions>;
|
|
@@ -14,10 +14,10 @@ export { isFileFetcherError, FileFetcherError } from './error';
|
|
|
14
14
|
export interface CopySourceFile {
|
|
15
15
|
id: string;
|
|
16
16
|
collection?: string;
|
|
17
|
-
authProvider
|
|
17
|
+
authProvider?: AuthProvider;
|
|
18
18
|
}
|
|
19
19
|
export interface CopyDestination extends MediaStoreCopyFileWithTokenParams {
|
|
20
|
-
authProvider
|
|
20
|
+
authProvider?: AuthProvider;
|
|
21
21
|
mediaStore?: MediaApi;
|
|
22
22
|
}
|
|
23
23
|
export interface CopyFileOptions {
|
|
@@ -58,5 +58,7 @@ export declare class FileFetcherImpl implements FileFetcher {
|
|
|
58
58
|
private getUploadingFileStateBase;
|
|
59
59
|
upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds, traceContext?: MediaTraceContext): MediaSubscribable;
|
|
60
60
|
downloadBinary(id: string, name?: string, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
|
|
61
|
+
private copyFileWithToken;
|
|
62
|
+
private copyFileWithIntent;
|
|
61
63
|
copyFile(source: CopySourceFile, destination: CopyDestination, options?: CopyFileOptions, traceContext?: MediaTraceContext): Promise<MediaFile>;
|
|
62
64
|
}
|
|
@@ -19,6 +19,7 @@ export declare function createUrl(url: string, { params, auth }: CreateUrlOption
|
|
|
19
19
|
export declare function extendHeaders(headers?: RequestHeaders, auth?: Auth, traceContext?: Required<MediaTraceContext>): RequestHeaders | undefined;
|
|
20
20
|
export declare function createMapResponseToJson(metadata: RequestMetadata): (response: Response) => Promise<any>;
|
|
21
21
|
export declare function createMapResponseToBlob(metadata: RequestMetadata): (response: Response) => Promise<Blob>;
|
|
22
|
+
export declare const defaultShouldRetryError: (err: any) => boolean;
|
|
22
23
|
export declare const DEFAULT_RETRY_OPTIONS: RetryOptions;
|
|
23
24
|
export declare function cloneRequestError(error: RequestError, extraMetadata: Partial<RequestErrorMetadata>): RequestError;
|
|
24
25
|
export declare function fetchRetry(functionToRetry: () => Promise<Response>, metadata: RequestMetadata, overwriteOptions?: Partial<RetryOptions>): Promise<Response>;
|
|
@@ -11,6 +11,7 @@ export type RetryOptions = {
|
|
|
11
11
|
readonly startTimeoutInMs: number;
|
|
12
12
|
readonly maxAttempts: number;
|
|
13
13
|
readonly factor: number;
|
|
14
|
+
readonly shouldRetryError?: (err: any) => boolean;
|
|
14
15
|
};
|
|
15
16
|
export type ClientOptions = {
|
|
16
17
|
readonly retryOptions?: Partial<RetryOptions>;
|