@atlaskit/media-client 28.4.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 +17 -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 +94 -26
- 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 +51 -2
- 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 +96 -28
- 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/client/media-store/MediaStore.d.ts +3 -1
- package/dist/types/client/media-store/types.d.ts +7 -0
- 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/client/media-store/MediaStore.d.ts +3 -1
- package/dist/types-ts4.5/client/media-store/types.d.ts +7 -0
- 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,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 UploaderError = /*#__PURE__*/function (_BaseMediaClientError) {
|
|
10
|
-
_inherits(UploaderError, _BaseMediaClientError);
|
|
11
|
-
var _super = _createSuper(UploaderError);
|
|
12
10
|
function UploaderError(reason, id, metadata) {
|
|
13
11
|
var _this;
|
|
14
12
|
_classCallCheck(this, UploaderError);
|
|
15
|
-
_this =
|
|
13
|
+
_this = _callSuper(this, UploaderError, [reason]);
|
|
16
14
|
_this.reason = reason;
|
|
17
15
|
_this.id = id;
|
|
18
16
|
_this.metadata = metadata;
|
|
19
17
|
return _this;
|
|
20
18
|
}
|
|
21
|
-
|
|
19
|
+
_inherits(UploaderError, _BaseMediaClientError);
|
|
20
|
+
return _createClass(UploaderError, [{
|
|
22
21
|
key: "attributes",
|
|
23
22
|
get: function get() {
|
|
24
23
|
var reason = this.reason,
|
|
@@ -35,7 +34,6 @@ export var UploaderError = /*#__PURE__*/function (_BaseMediaClientError) {
|
|
|
35
34
|
};
|
|
36
35
|
}
|
|
37
36
|
}]);
|
|
38
|
-
return UploaderError;
|
|
39
37
|
}(BaseMediaClientError);
|
|
40
38
|
export function isUploaderError(err) {
|
|
41
39
|
return err instanceof UploaderError;
|
|
@@ -5,7 +5,7 @@ export var SimpleHasher = /*#__PURE__*/function () {
|
|
|
5
5
|
function SimpleHasher() {
|
|
6
6
|
_classCallCheck(this, SimpleHasher);
|
|
7
7
|
}
|
|
8
|
-
_createClass(SimpleHasher, [{
|
|
8
|
+
return _createClass(SimpleHasher, [{
|
|
9
9
|
key: "hash",
|
|
10
10
|
value: function hash(blob) {
|
|
11
11
|
return new Promise(function (resolve, reject) {
|
|
@@ -19,5 +19,4 @@ export var SimpleHasher = /*#__PURE__*/function () {
|
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
}]);
|
|
22
|
-
return SimpleHasher;
|
|
23
22
|
}();
|
|
@@ -5,7 +5,7 @@ export var SimpleHasher = /*#__PURE__*/function () {
|
|
|
5
5
|
function SimpleHasher() {
|
|
6
6
|
_classCallCheck(this, SimpleHasher);
|
|
7
7
|
}
|
|
8
|
-
_createClass(SimpleHasher, [{
|
|
8
|
+
return _createClass(SimpleHasher, [{
|
|
9
9
|
key: "hash",
|
|
10
10
|
value: function hash(blob) {
|
|
11
11
|
return new Promise(function (resolve, reject) {
|
|
@@ -19,5 +19,4 @@ export var SimpleHasher = /*#__PURE__*/function () {
|
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
}]);
|
|
22
|
-
return SimpleHasher;
|
|
23
22
|
}();
|
|
@@ -12,7 +12,7 @@ export var WorkerHasher = /*#__PURE__*/function () {
|
|
|
12
12
|
this.workers.push(this.createWorker());
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
_createClass(WorkerHasher, [{
|
|
15
|
+
return _createClass(WorkerHasher, [{
|
|
16
16
|
key: "hash",
|
|
17
17
|
value: function hash(chunk) {
|
|
18
18
|
return this.calculateHashInWorker(chunk);
|
|
@@ -103,5 +103,4 @@ export var WorkerHasher = /*#__PURE__*/function () {
|
|
|
103
103
|
}, this.workers[0]);
|
|
104
104
|
}
|
|
105
105
|
}]);
|
|
106
|
-
return WorkerHasher;
|
|
107
106
|
}();
|
|
@@ -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 MobileUploadError = /*#__PURE__*/function (_BaseMediaClientError) {
|
|
10
|
-
_inherits(MobileUploadError, _BaseMediaClientError);
|
|
11
|
-
var _super = _createSuper(MobileUploadError);
|
|
12
10
|
function MobileUploadError(reason, id, metadata) {
|
|
13
11
|
var _this;
|
|
14
12
|
_classCallCheck(this, MobileUploadError);
|
|
15
|
-
_this =
|
|
13
|
+
_this = _callSuper(this, MobileUploadError, [reason]);
|
|
16
14
|
_this.reason = reason;
|
|
17
15
|
_this.id = id;
|
|
18
16
|
_this.metadata = metadata;
|
|
19
17
|
return _this;
|
|
20
18
|
}
|
|
21
|
-
|
|
19
|
+
_inherits(MobileUploadError, _BaseMediaClientError);
|
|
20
|
+
return _createClass(MobileUploadError, [{
|
|
22
21
|
key: "attributes",
|
|
23
22
|
get: function get() {
|
|
24
23
|
var reason = this.reason,
|
|
@@ -39,7 +38,6 @@ export var MobileUploadError = /*#__PURE__*/function (_BaseMediaClientError) {
|
|
|
39
38
|
};
|
|
40
39
|
}
|
|
41
40
|
}]);
|
|
42
|
-
return MobileUploadError;
|
|
43
41
|
}(BaseMediaClientError);
|
|
44
42
|
export function isMobileUploadError(err) {
|
|
45
43
|
return err instanceof MobileUploadError;
|
|
@@ -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
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type AuthContext, type MediaApiConfig, type Auth } from '@atlaskit/media-core';
|
|
2
2
|
import { type MediaTraceContext } from '@atlaskit/media-common';
|
|
3
3
|
import { type MediaFileArtifacts } from '@atlaskit/media-state';
|
|
4
|
-
import type { ItemsPayload, ImageMetadata, MediaStoreResponse, MediaStoreTouchFileParams, TouchFileDescriptor, MediaStoreTouchFileBody, RejectedTouchFile, MediaStoreRequestOptions, MediaStoreCreateFileFromUploadParams, MediaStoreCreateFileFromUploadBody, MediaStoreGetFileParams, MediaStoreGetFileImageParams, MediaStoreCopyFileWithTokenBody, MediaStoreCopyFileWithTokenParams, AppendChunksToUploadRequestBody, TouchedFiles, MediaApi } from './types';
|
|
4
|
+
import type { ItemsPayload, ImageMetadata, MediaStoreResponse, MediaStoreTouchFileParams, TouchFileDescriptor, MediaStoreTouchFileBody, RejectedTouchFile, MediaStoreRequestOptions, MediaStoreCreateFileFromUploadParams, MediaStoreCreateFileFromUploadBody, MediaStoreGetFileParams, MediaStoreGetFileImageParams, MediaStoreCopyFileWithTokenBody, MediaStoreCopyFileWithTokenParams, AppendChunksToUploadRequestBody, TouchedFiles, MediaApi, CopyFileParams } from './types';
|
|
5
5
|
import { type MediaFile, type MediaUpload } from '../../models/media';
|
|
6
6
|
import { ChunkHashAlgorithm } from '@atlaskit/media-core';
|
|
7
7
|
export declare class MediaStore implements MediaApi {
|
|
@@ -28,6 +28,8 @@ export declare class MediaStore implements MediaApi {
|
|
|
28
28
|
}>;
|
|
29
29
|
appendChunksToUpload(uploadId: string, body: AppendChunksToUploadRequestBody, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
|
|
30
30
|
copyFileWithToken(body: MediaStoreCopyFileWithTokenBody, params: MediaStoreCopyFileWithTokenParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaFile>>;
|
|
31
|
+
copyFile(id: string, params: CopyFileParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaFile>>;
|
|
32
|
+
registerCopyIntents(ids: string[], collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
|
|
31
33
|
request(path: string, options?: MediaStoreRequestOptions, controller?: AbortController, useMediaCdn?: boolean): Promise<Response>;
|
|
32
34
|
testUrl(url: string, options?: {
|
|
33
35
|
traceContext?: MediaTraceContext;
|
|
@@ -113,6 +113,11 @@ export interface SourceFile {
|
|
|
113
113
|
export type MediaStoreCopyFileWithTokenBody = {
|
|
114
114
|
sourceFile: SourceFile;
|
|
115
115
|
};
|
|
116
|
+
export type CopyFileParams = {
|
|
117
|
+
sourceCollection?: string;
|
|
118
|
+
collection?: string;
|
|
119
|
+
replaceFileId?: string;
|
|
120
|
+
};
|
|
116
121
|
export type MediaStoreCopyFileWithTokenParams = {
|
|
117
122
|
readonly collection?: string;
|
|
118
123
|
readonly replaceFileId?: string;
|
|
@@ -166,6 +171,8 @@ export interface MediaApi {
|
|
|
166
171
|
}>;
|
|
167
172
|
appendChunksToUpload: (uploadId: string, body: AppendChunksToUploadRequestBody, collectionName?: string, traceContext?: MediaTraceContext) => Promise<void>;
|
|
168
173
|
copyFileWithToken: (body: MediaStoreCopyFileWithTokenBody, params: MediaStoreCopyFileWithTokenParams, traceContext?: MediaTraceContext) => Promise<MediaStoreResponse<MediaFile>>;
|
|
174
|
+
copyFile: (id: string, params: CopyFileParams) => Promise<MediaStoreResponse<MediaFile>>;
|
|
175
|
+
registerCopyIntents: (ids: string[], collectionName: string) => Promise<void>;
|
|
169
176
|
request: (path: string, options: MediaStoreRequestOptions, controller?: AbortController) => Promise<Response>;
|
|
170
177
|
testUrl: (url: string, options?: {
|
|
171
178
|
traceContext?: MediaTraceContext;
|
|
@@ -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
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type AuthContext, type MediaApiConfig, type Auth } from '@atlaskit/media-core';
|
|
2
2
|
import { type MediaTraceContext } from '@atlaskit/media-common';
|
|
3
3
|
import { type MediaFileArtifacts } from '@atlaskit/media-state';
|
|
4
|
-
import type { ItemsPayload, ImageMetadata, MediaStoreResponse, MediaStoreTouchFileParams, TouchFileDescriptor, MediaStoreTouchFileBody, RejectedTouchFile, MediaStoreRequestOptions, MediaStoreCreateFileFromUploadParams, MediaStoreCreateFileFromUploadBody, MediaStoreGetFileParams, MediaStoreGetFileImageParams, MediaStoreCopyFileWithTokenBody, MediaStoreCopyFileWithTokenParams, AppendChunksToUploadRequestBody, TouchedFiles, MediaApi } from './types';
|
|
4
|
+
import type { ItemsPayload, ImageMetadata, MediaStoreResponse, MediaStoreTouchFileParams, TouchFileDescriptor, MediaStoreTouchFileBody, RejectedTouchFile, MediaStoreRequestOptions, MediaStoreCreateFileFromUploadParams, MediaStoreCreateFileFromUploadBody, MediaStoreGetFileParams, MediaStoreGetFileImageParams, MediaStoreCopyFileWithTokenBody, MediaStoreCopyFileWithTokenParams, AppendChunksToUploadRequestBody, TouchedFiles, MediaApi, CopyFileParams } from './types';
|
|
5
5
|
import { type MediaFile, type MediaUpload } from '../../models/media';
|
|
6
6
|
import { ChunkHashAlgorithm } from '@atlaskit/media-core';
|
|
7
7
|
export declare class MediaStore implements MediaApi {
|
|
@@ -28,6 +28,8 @@ export declare class MediaStore implements MediaApi {
|
|
|
28
28
|
}>;
|
|
29
29
|
appendChunksToUpload(uploadId: string, body: AppendChunksToUploadRequestBody, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
|
|
30
30
|
copyFileWithToken(body: MediaStoreCopyFileWithTokenBody, params: MediaStoreCopyFileWithTokenParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaFile>>;
|
|
31
|
+
copyFile(id: string, params: CopyFileParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaFile>>;
|
|
32
|
+
registerCopyIntents(ids: string[], collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
|
|
31
33
|
request(path: string, options?: MediaStoreRequestOptions, controller?: AbortController, useMediaCdn?: boolean): Promise<Response>;
|
|
32
34
|
testUrl(url: string, options?: {
|
|
33
35
|
traceContext?: MediaTraceContext;
|
|
@@ -113,6 +113,11 @@ export interface SourceFile {
|
|
|
113
113
|
export type MediaStoreCopyFileWithTokenBody = {
|
|
114
114
|
sourceFile: SourceFile;
|
|
115
115
|
};
|
|
116
|
+
export type CopyFileParams = {
|
|
117
|
+
sourceCollection?: string;
|
|
118
|
+
collection?: string;
|
|
119
|
+
replaceFileId?: string;
|
|
120
|
+
};
|
|
116
121
|
export type MediaStoreCopyFileWithTokenParams = {
|
|
117
122
|
readonly collection?: string;
|
|
118
123
|
readonly replaceFileId?: string;
|
|
@@ -166,6 +171,8 @@ export interface MediaApi {
|
|
|
166
171
|
}>;
|
|
167
172
|
appendChunksToUpload: (uploadId: string, body: AppendChunksToUploadRequestBody, collectionName?: string, traceContext?: MediaTraceContext) => Promise<void>;
|
|
168
173
|
copyFileWithToken: (body: MediaStoreCopyFileWithTokenBody, params: MediaStoreCopyFileWithTokenParams, traceContext?: MediaTraceContext) => Promise<MediaStoreResponse<MediaFile>>;
|
|
174
|
+
copyFile: (id: string, params: CopyFileParams) => Promise<MediaStoreResponse<MediaFile>>;
|
|
175
|
+
registerCopyIntents: (ids: string[], collectionName: string) => Promise<void>;
|
|
169
176
|
request: (path: string, options: MediaStoreRequestOptions, controller?: AbortController) => Promise<Response>;
|
|
170
177
|
testUrl: (url: string, options?: {
|
|
171
178
|
traceContext?: MediaTraceContext;
|
|
@@ -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>;
|