@aws-amplify/storage 5.6.4-api-v6.25 → 5.6.4-api-v6-models.34

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 (48) hide show
  1. package/internals/package.json +8 -0
  2. package/lib/Storage.d.ts +2 -43
  3. package/lib/Storage.js +27 -211
  4. package/lib/common/S3ClientUtils.d.ts +3 -4
  5. package/lib/common/S3ClientUtils.js +2 -5
  6. package/lib/common/StorageUtils.d.ts +2 -0
  7. package/lib/common/StorageUtils.js +16 -1
  8. package/lib/internals/InternalStorage.d.ts +103 -0
  9. package/lib/internals/InternalStorage.js +264 -0
  10. package/lib/internals/index.d.ts +1 -0
  11. package/lib/internals/index.js +7 -0
  12. package/lib/providers/AWSS3Provider.d.ts +12 -6
  13. package/lib/providers/AWSS3Provider.js +21 -16
  14. package/lib/providers/AWSS3ProviderManagedUpload.js +1 -1
  15. package/lib/providers/AWSS3UploadTask.d.ts +1 -1
  16. package/lib/providers/AWSS3UploadTask.js +4 -3
  17. package/lib/tsconfig.tsbuildinfo +1 -1
  18. package/lib/types/Provider.d.ts +16 -8
  19. package/lib/types/Storage.d.ts +6 -8
  20. package/lib-esm/Storage.d.ts +2 -43
  21. package/lib-esm/Storage.js +28 -212
  22. package/lib-esm/common/S3ClientUtils.d.ts +3 -4
  23. package/lib-esm/common/S3ClientUtils.js +3 -6
  24. package/lib-esm/common/StorageUtils.d.ts +2 -0
  25. package/lib-esm/common/StorageUtils.js +15 -1
  26. package/lib-esm/internals/InternalStorage.d.ts +103 -0
  27. package/lib-esm/internals/InternalStorage.js +261 -0
  28. package/lib-esm/internals/index.d.ts +1 -0
  29. package/lib-esm/internals/index.js +3 -0
  30. package/lib-esm/providers/AWSS3Provider.d.ts +12 -6
  31. package/lib-esm/providers/AWSS3Provider.js +22 -17
  32. package/lib-esm/providers/AWSS3ProviderManagedUpload.js +2 -2
  33. package/lib-esm/providers/AWSS3UploadTask.d.ts +1 -1
  34. package/lib-esm/providers/AWSS3UploadTask.js +4 -3
  35. package/lib-esm/tsconfig.tsbuildinfo +1 -1
  36. package/lib-esm/types/Provider.d.ts +16 -8
  37. package/lib-esm/types/Storage.d.ts +6 -8
  38. package/package.json +7 -5
  39. package/src/Storage.ts +10 -283
  40. package/src/common/S3ClientUtils.ts +2 -7
  41. package/src/common/StorageUtils.ts +17 -1
  42. package/src/internals/InternalStorage.ts +476 -0
  43. package/src/internals/index.ts +3 -0
  44. package/src/providers/AWSS3Provider.ts +35 -35
  45. package/src/providers/AWSS3ProviderManagedUpload.ts +0 -1
  46. package/src/providers/AWSS3UploadTask.ts +7 -2
  47. package/src/types/Provider.ts +34 -8
  48. package/src/types/Storage.ts +12 -7
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "@aws-amplify/storage/internals",
3
+ "types": "../lib-esm/internals/index.d.ts",
4
+ "main": "../lib/internals/index.js",
5
+ "module": "../lib-esm/internals/index.js",
6
+ "react-native": "../lib-esm/internals/index.js",
7
+ "sideEffects": false
8
+ }
package/lib/Storage.d.ts CHANGED
@@ -1,54 +1,14 @@
1
1
  import { StorageCopySource, StorageCopyDestination, StorageGetConfig, StorageProvider, StoragePutConfig, StorageRemoveConfig, StorageListConfig, StorageCopyConfig, StorageGetOutput, StoragePutOutput, StorageRemoveOutput, StorageListOutput, StorageCopyOutput, UploadTask, StorageGetPropertiesConfig, StorageGetPropertiesOutput } from './types';
2
+ import { InternalStorageClass } from './internals/InternalStorage';
2
3
  /**
3
4
  * Provide storage methods to use AWS S3
4
5
  */
5
- export declare class Storage {
6
- /**
7
- * @private
8
- */
9
- private _config;
10
- private _pluggables;
11
- /**
12
- * Similar to the API module. This weak map allows users to cancel their in-flight request made using the Storage
13
- * module. For every get or put request, a unique AbortConttroller will be generated and injected to it's underlying
14
- * Xhr HTTP handler. This map maintains a mapping of Request to AbortController. When .cancel is invoked, it will
15
- * attempt to retrieve it's corresponding abortController and cancel the in-flight request.
16
- */
17
- private _abortControllerMap;
6
+ export declare class Storage extends InternalStorageClass {
18
7
  /**
19
8
  * @public
20
9
  */
21
10
  vault: Storage;
22
- /**
23
- * Initialize Storage
24
- * @param {Object} config - Configuration object for storage
25
- */
26
- constructor();
27
11
  getModuleName(): string;
28
- /**
29
- * add plugin into Storage category
30
- * @param {Object} pluggable - an instance of the plugin
31
- */
32
- addPluggable(pluggable: StorageProvider): {};
33
- /**
34
- * Get the plugin object
35
- * @param providerName - the name of the plugin
36
- */
37
- getPluggable(providerName: string): StorageProvider;
38
- /**
39
- * Remove the plugin object
40
- * @param providerName - the name of the plugin
41
- */
42
- removePluggable(providerName: string): void;
43
- /**
44
- * Configure Storage
45
- * @param {Object} config - Configuration object for storage
46
- * @return {Object} - Current configuration
47
- */
48
- configure(config?: any): any;
49
- private getAbortController;
50
- private updateRequestToBeCancellable;
51
- private isUploadTask;
52
12
  /**
53
13
  * Cancels an inflight request
54
14
  *
@@ -76,7 +36,6 @@ export declare class Storage {
76
36
  get<T extends Record<string, any> & {
77
37
  download?: boolean;
78
38
  }>(key: string, config?: StorageGetConfig<T>): StorageGetOutput<T>;
79
- isCancelError(error: any): boolean;
80
39
  getProperties<T extends StorageProvider | {
81
40
  [key: string]: any;
82
41
  }>(key: string, config?: StorageGetPropertiesConfig<T>): StorageGetPropertiesOutput<T>;
package/lib/Storage.js CHANGED
@@ -1,6 +1,21 @@
1
1
  "use strict";
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
+ var __extends = (this && this.__extends) || (function () {
5
+ var extendStatics = function (d, b) {
6
+ extendStatics = Object.setPrototypeOf ||
7
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
8
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
9
+ return extendStatics(d, b);
10
+ };
11
+ return function (d, b) {
12
+ if (typeof b !== "function" && b !== null)
13
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
14
+ extendStatics(d, b);
15
+ function __() { this.constructor = d; }
16
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
17
+ };
18
+ })();
4
19
  var __assign = (this && this.__assign) || function () {
5
20
  __assign = Object.assign || function(t) {
6
21
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -12,246 +27,47 @@ var __assign = (this && this.__assign) || function () {
12
27
  };
13
28
  return __assign.apply(this, arguments);
14
29
  };
15
- var __read = (this && this.__read) || function (o, n) {
16
- var m = typeof Symbol === "function" && o[Symbol.iterator];
17
- if (!m) return o;
18
- var i = m.call(o), r, ar = [], e;
19
- try {
20
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
21
- }
22
- catch (error) { e = { error: error }; }
23
- finally {
24
- try {
25
- if (r && !r.done && (m = i["return"])) m.call(i);
26
- }
27
- finally { if (e) throw e.error; }
28
- }
29
- return ar;
30
- };
31
30
  Object.defineProperty(exports, "__esModule", { value: true });
32
31
  exports.StorageInstance = exports.Storage = void 0;
33
32
  var core_1 = require("@aws-amplify/core");
34
- var providers_1 = require("./providers");
35
- var utils_1 = require("./AwsClients/S3/utils");
36
- var AWSS3UploadTask_1 = require("./providers/AWSS3UploadTask");
33
+ var InternalStorage_1 = require("./internals/InternalStorage");
37
34
  var logger = new core_1.ConsoleLogger('StorageClass');
38
35
  var loggerStorageInstance = new core_1.ConsoleLogger('Storage'); // Logging relating to Storage instance management
39
36
  var DEFAULT_PROVIDER = 'AWSS3';
40
37
  /**
41
38
  * Provide storage methods to use AWS S3
42
39
  */
43
- var Storage = /** @class */ (function () {
44
- /**
45
- * Initialize Storage
46
- * @param {Object} config - Configuration object for storage
47
- */
40
+ var Storage = /** @class */ (function (_super) {
41
+ __extends(Storage, _super);
48
42
  function Storage() {
49
- this._config = {};
50
- this._pluggables = [];
51
- this._abortControllerMap = new WeakMap();
52
- logger.debug('Storage Options', this._config);
53
- this.get = this.get.bind(this);
54
- this.put = this.put.bind(this);
55
- this.remove = this.remove.bind(this);
56
- this.list = this.list.bind(this);
43
+ return _super !== null && _super.apply(this, arguments) || this;
57
44
  }
58
45
  Storage.prototype.getModuleName = function () {
59
46
  return 'Storage';
60
47
  };
61
- /**
62
- * add plugin into Storage category
63
- * @param {Object} pluggable - an instance of the plugin
64
- */
65
- Storage.prototype.addPluggable = function (pluggable) {
66
- if (pluggable && pluggable.getCategory() === 'Storage') {
67
- this._pluggables.push(pluggable);
68
- var config = {};
69
- config = pluggable.configure(this._config[pluggable.getProviderName()]);
70
- return config;
71
- }
72
- };
73
- /**
74
- * Get the plugin object
75
- * @param providerName - the name of the plugin
76
- */
77
- Storage.prototype.getPluggable = function (providerName) {
78
- var pluggable = this._pluggables.find(function (pluggable) { return pluggable.getProviderName() === providerName; });
79
- if (pluggable === undefined) {
80
- logger.debug('No plugin found with providerName', providerName);
81
- return null;
82
- }
83
- else
84
- return pluggable;
85
- };
86
- /**
87
- * Remove the plugin object
88
- * @param providerName - the name of the plugin
89
- */
90
- Storage.prototype.removePluggable = function (providerName) {
91
- this._pluggables = this._pluggables.filter(function (pluggable) { return pluggable.getProviderName() !== providerName; });
92
- return;
93
- };
94
- /**
95
- * Configure Storage
96
- * @param {Object} config - Configuration object for storage
97
- * @return {Object} - Current configuration
98
- */
99
- Storage.prototype.configure = function (config) {
100
- var _this = this;
101
- var _a;
102
- logger.debug('configure Storage');
103
- if (!config)
104
- return this._config;
105
- var amplifyConfig = (0, core_1.parseAWSExports)(config);
106
- var storageConfig = (_a = amplifyConfig.Storage) !== null && _a !== void 0 ? _a : {};
107
- var defaultProviderConfigKeys = [
108
- 'bucket',
109
- 'region',
110
- 'level',
111
- 'track',
112
- 'customPrefix',
113
- 'ContentMD5',
114
- 'serverSideEncryption',
115
- 'SSECustomerAlgorithm',
116
- 'SSECustomerKey',
117
- // TODO(AllanZhengYP): remove in V6.
118
- 'SSECustomerKeyMD5',
119
- 'SSEKMSKeyId',
120
- ];
121
- var hasDefaultProviderConfigKeys = function (config) {
122
- return Object.keys(config).find(function (key) { return defaultProviderConfigKeys.includes(key); });
123
- };
124
- if (hasDefaultProviderConfigKeys(storageConfig) &&
125
- !storageConfig[DEFAULT_PROVIDER]) {
126
- storageConfig[DEFAULT_PROVIDER] = {};
127
- }
128
- Object.entries(storageConfig).forEach(function (_a) {
129
- var _b = __read(_a, 2), key = _b[0], value = _b[1];
130
- if (key &&
131
- defaultProviderConfigKeys.includes(key) &&
132
- value !== undefined) {
133
- storageConfig[DEFAULT_PROVIDER][key] = value;
134
- delete storageConfig[key];
135
- }
136
- });
137
- // only update new values for each provider
138
- Object.keys(storageConfig).forEach(function (providerName) {
139
- if (typeof storageConfig[providerName] !== 'string') {
140
- _this._config[providerName] = __assign(__assign({}, _this._config[providerName]), storageConfig[providerName]);
141
- }
142
- });
143
- this._pluggables.forEach(function (pluggable) {
144
- pluggable.configure(_this._config[pluggable.getProviderName()]);
145
- });
146
- if (this._pluggables.length === 0) {
147
- this.addPluggable(new providers_1.AWSS3Provider());
148
- }
149
- return this._config;
150
- };
151
- Storage.prototype.getAbortController = function () {
152
- return new AbortController();
153
- };
154
- Storage.prototype.updateRequestToBeCancellable = function (request, abortController) {
155
- this._abortControllerMap.set(request, abortController);
156
- };
157
- Storage.prototype.isUploadTask = function (x) {
158
- return (typeof x !== 'undefined' &&
159
- typeof x['pause'] === 'function' &&
160
- typeof x['resume'] === 'function');
161
- };
162
48
  Storage.prototype.cancel = function (request, message) {
163
- if (request instanceof AWSS3UploadTask_1.AWSS3UploadTask) {
164
- return request._cancel();
165
- }
166
- var abortController = this._abortControllerMap.get(request);
167
- if (abortController) {
168
- // TODO: [v6] clean up the aborted promise in the weak map.
169
- // Not doing it yet to avoid breaking changes when users may abort a request twice.
170
- abortController.abort(message);
171
- }
172
- else {
173
- logger.debug('The request does not map to any cancel token');
174
- }
49
+ return _super.prototype.cancel.call(this, request, message);
175
50
  };
176
51
  Storage.prototype.copy = function (src, dest, config) {
177
- var provider = (config === null || config === void 0 ? void 0 : config.provider) || DEFAULT_PROVIDER;
178
- var plugin = this._pluggables.find(function (pluggable) { return pluggable.getProviderName() === provider; });
179
- if (plugin === undefined) {
180
- logger.debug('No plugin found with providerName', provider);
181
- return Promise.reject('No plugin found in Storage for the provider');
182
- }
183
- var abortController = this.getAbortController();
184
- if (typeof plugin.copy !== 'function') {
185
- return Promise.reject(".copy is not implemented on provider ".concat(plugin.getProviderName()));
186
- }
187
- var responsePromise = plugin.copy(src, dest, __assign(__assign({}, config), { abortSignal: abortController.signal }));
188
- this.updateRequestToBeCancellable(responsePromise, abortController);
189
- return responsePromise;
52
+ return _super.prototype.copy.call(this, src, dest, config);
190
53
  };
191
54
  Storage.prototype.get = function (key, config) {
192
- var provider = (config === null || config === void 0 ? void 0 : config.provider) || DEFAULT_PROVIDER;
193
- var plugin = this._pluggables.find(function (pluggable) { return pluggable.getProviderName() === provider; });
194
- if (plugin === undefined) {
195
- logger.debug('No plugin found with providerName', provider);
196
- return Promise.reject('No plugin found in Storage for the provider');
197
- }
198
- var abortController = this.getAbortController();
199
- var responsePromise = plugin.get(key, __assign(__assign({}, config), { abortSignal: abortController.signal }));
200
- this.updateRequestToBeCancellable(responsePromise, abortController);
201
- return responsePromise;
202
- };
203
- Storage.prototype.isCancelError = function (error) {
204
- return (0, utils_1.isCancelError)(error);
55
+ return _super.prototype.get.call(this, key, config);
205
56
  };
206
57
  Storage.prototype.getProperties = function (key, config) {
207
- var provider = (config === null || config === void 0 ? void 0 : config.provider) || DEFAULT_PROVIDER;
208
- var plugin = this._pluggables.find(function (pluggable) { return pluggable.getProviderName() === provider; });
209
- if (plugin === undefined) {
210
- logger.debug('No plugin found with providerName', provider);
211
- throw new Error('No plugin found with providerName');
212
- }
213
- var abortController = this.getAbortController();
214
- if (typeof plugin.getProperties !== 'function') {
215
- return Promise.reject(".getProperties is not implemented on provider ".concat(plugin.getProviderName()));
216
- }
217
- var responsePromise = plugin === null || plugin === void 0 ? void 0 : plugin.getProperties(key, __assign({}, config));
218
- this.updateRequestToBeCancellable(responsePromise, abortController);
219
- return responsePromise;
58
+ return _super.prototype.getProperties.call(this, key, config);
220
59
  };
221
60
  Storage.prototype.put = function (key, object, config) {
222
- var provider = (config === null || config === void 0 ? void 0 : config.provider) || DEFAULT_PROVIDER;
223
- var plugin = this._pluggables.find(function (pluggable) { return pluggable.getProviderName() === provider; });
224
- if (plugin === undefined) {
225
- logger.debug('No plugin found with providerName', provider);
226
- return Promise.reject('No plugin found in Storage for the provider');
227
- }
228
- var abortController = this.getAbortController();
229
- var response = plugin.put(key, object, __assign(__assign({}, config), { abortSignal: abortController.signal }));
230
- if (!this.isUploadTask(response)) {
231
- this.updateRequestToBeCancellable(response, abortController);
232
- }
233
- return response;
61
+ return _super.prototype.put.call(this, key, object, config);
234
62
  };
235
63
  Storage.prototype.remove = function (key, config) {
236
- var provider = (config === null || config === void 0 ? void 0 : config.provider) || DEFAULT_PROVIDER;
237
- var plugin = this._pluggables.find(function (pluggable) { return pluggable.getProviderName() === provider; });
238
- if (plugin === undefined) {
239
- logger.debug('No plugin found with providerName', provider);
240
- return Promise.reject('No plugin found in Storage for the provider');
241
- }
242
- return plugin.remove(key, config);
64
+ return _super.prototype.remove.call(this, key, config);
243
65
  };
244
66
  Storage.prototype.list = function (path, config) {
245
- var provider = (config === null || config === void 0 ? void 0 : config.provider) || DEFAULT_PROVIDER;
246
- var plugin = this._pluggables.find(function (pluggable) { return pluggable.getProviderName() === provider; });
247
- if (plugin === undefined) {
248
- logger.debug('No plugin found with providerName', provider);
249
- return Promise.reject('No plugin found in Storage for the provider');
250
- }
251
- return plugin.list(path, config);
67
+ return _super.prototype.list.call(this, path, config);
252
68
  };
253
69
  return Storage;
254
- }());
70
+ }(InternalStorage_1.InternalStorageClass));
255
71
  exports.Storage = Storage;
256
72
  /**
257
73
  * Configure & register Storage singleton instance.
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { ICredentials, StorageAction } from '@aws-amplify/core';
2
+ import { ICredentials } from '@aws-amplify/core';
3
3
  import type { Credentials as AwsCredentials } from '@aws-sdk/types';
4
4
  import type { EventEmitter } from 'events';
5
5
  import { StorageAccessLevel, CustomPrefix } from '../types';
@@ -22,12 +22,11 @@ interface S3InputConfig {
22
22
  useAccelerateEndpoint?: boolean;
23
23
  abortSignal?: AbortSignal;
24
24
  emitter?: EventEmitter;
25
- storageAction: StorageAction;
25
+ userAgentValue?: string;
26
26
  dangerouslyConnectToHttpEndpointForTesting?: boolean;
27
27
  }
28
28
  export interface S3ResolvedConfig extends Omit<S3InputConfig, 'region' | 'credentials'> {
29
29
  region: string;
30
- userAgentValue?: string;
31
30
  credentials: () => Promise<AwsCredentials>;
32
31
  customEndpoint?: string;
33
32
  forcePathStyle?: boolean;
@@ -36,7 +35,7 @@ export interface S3ResolvedConfig extends Omit<S3InputConfig, 'region' | 'creden
36
35
  * A function that persists the s3 configs, so we don't need to
37
36
  * assign each config parameter for every s3 API call.
38
37
  *
39
- * @inernal
38
+ * @internal
40
39
  */
41
40
  export declare const loadS3Config: (config: S3InputConfig) => S3ResolvedConfig;
42
41
  export declare const DEFAULT_PART_SIZE: number;
@@ -109,7 +109,7 @@ exports.credentialsProvider = credentialsProvider;
109
109
  * A function that persists the s3 configs, so we don't need to
110
110
  * assign each config parameter for every s3 API call.
111
111
  *
112
- * @inernal
112
+ * @internal
113
113
  */
114
114
  var loadS3Config = function (config) {
115
115
  if (!config.region) {
@@ -118,10 +118,7 @@ var loadS3Config = function (config) {
118
118
  }
119
119
  return __assign(__assign(__assign({}, config), { region: config.region, credentials: config.credentials
120
120
  ? function () { return Promise.resolve(config.credentials); }
121
- : exports.credentialsProvider, userAgentValue: (0, core_1.getAmplifyUserAgent)({
122
- category: core_1.Category.Storage,
123
- action: config.storageAction,
124
- }) }), (config.dangerouslyConnectToHttpEndpointForTesting
121
+ : exports.credentialsProvider }), (config.dangerouslyConnectToHttpEndpointForTesting
125
122
  ? {
126
123
  customEndpoint: StorageConstants_1.localTestingStorageEndpoint,
127
124
  forcePathStyle: true,
@@ -1,4 +1,6 @@
1
+ import { CustomUserAgentDetails, StorageAction } from '@aws-amplify/core';
1
2
  export declare const byteLength: (x: unknown) => number;
2
3
  export declare const dispatchStorageEvent: (track: boolean, event: string, attrs: any, metrics: any, message: string) => void;
3
4
  export declare const isFile: (x: unknown) => x is File;
4
5
  export declare const isBlob: (x: unknown) => x is Blob;
6
+ export declare const getStorageUserAgentValue: (action: StorageAction, customUserAgentDetails?: CustomUserAgentDetails) => string;
@@ -1,6 +1,17 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isBlob = exports.isFile = exports.dispatchStorageEvent = exports.byteLength = void 0;
14
+ exports.getStorageUserAgentValue = exports.isBlob = exports.isFile = exports.dispatchStorageEvent = exports.byteLength = void 0;
4
15
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
16
  // SPDX-License-Identifier: Apache-2.0
6
17
  var core_1 = require("@aws-amplify/core");
@@ -42,6 +53,10 @@ var isBlob = function (x) {
42
53
  return typeof x !== 'undefined' && x instanceof Blob;
43
54
  };
44
55
  exports.isBlob = isBlob;
56
+ var getStorageUserAgentValue = function (action, customUserAgentDetails) {
57
+ return (0, core_1.getAmplifyUserAgent)(__assign({ category: core_1.Category.Storage, action: action }, customUserAgentDetails));
58
+ };
59
+ exports.getStorageUserAgentValue = getStorageUserAgentValue;
45
60
  var isArrayBuffer = function (x) {
46
61
  return typeof x !== 'undefined' && x instanceof ArrayBuffer;
47
62
  };
@@ -0,0 +1,103 @@
1
+ import { CustomUserAgentDetails } from '@aws-amplify/core';
2
+ import { StorageCopySource, StorageCopyDestination, StorageGetConfig, StorageProvider, StoragePutConfig, StorageRemoveConfig, StorageListConfig, StorageCopyConfig, StorageGetOutput, StoragePutOutput, StorageRemoveOutput, StorageListOutput, StorageCopyOutput, UploadTask, StorageGetPropertiesConfig, StorageGetPropertiesOutput } from '../types';
3
+ /**
4
+ * Provide storage methods to use AWS S3
5
+ */
6
+ export declare class InternalStorageClass {
7
+ /**
8
+ * @private
9
+ */
10
+ private _config;
11
+ private _pluggables;
12
+ /**
13
+ * Similar to the API module. This weak map allows users to cancel their in-flight request made using the Storage
14
+ * module. For every get or put request, a unique AbortConttroller will be generated and injected to it's underlying
15
+ * Xhr HTTP handler. This map maintains a mapping of Request to AbortController. When .cancel is invoked, it will
16
+ * attempt to retrieve it's corresponding abortController and cancel the in-flight request.
17
+ */
18
+ private _abortControllerMap;
19
+ /**
20
+ * Initialize Storage
21
+ * @param {Object} config - Configuration object for storage
22
+ */
23
+ constructor();
24
+ getModuleName(): string;
25
+ /**
26
+ * add plugin into Storage category
27
+ * @param {Object} pluggable - an instance of the plugin
28
+ */
29
+ addPluggable(pluggable: StorageProvider): {};
30
+ /**
31
+ * Get the plugin object
32
+ * @param providerName - the name of the plugin
33
+ */
34
+ getPluggable(providerName: string): StorageProvider;
35
+ /**
36
+ * Remove the plugin object
37
+ * @param providerName - the name of the plugin
38
+ */
39
+ removePluggable(providerName: string): void;
40
+ /**
41
+ * Configure Storage
42
+ * @param {Object} config - Configuration object for storage
43
+ * @return {Object} - Current configuration
44
+ */
45
+ configure(config?: any): any;
46
+ private getAbortController;
47
+ private updateRequestToBeCancellable;
48
+ private isUploadTask;
49
+ /**
50
+ * Cancels an inflight request
51
+ *
52
+ * @param request - The request to cancel
53
+ * @param [message] - A message to include in the cancelation exception
54
+ */
55
+ cancel(request: Promise<any> | UploadTask, message?: string, customUserAgentDetails?: CustomUserAgentDetails): void | Promise<boolean>;
56
+ /**
57
+ * Copies a file from src to dest.
58
+ *
59
+ * @param src - The source object.
60
+ * @param dest - The destination object.
61
+ * @param [config] - config for the Storage operation.
62
+ * @return A promise resolves to the copied object's key.
63
+ */
64
+ copy<T extends Record<string, any>>(src: StorageCopySource, dest: StorageCopyDestination, config?: StorageCopyConfig<T>, customUserAgentDetails?: CustomUserAgentDetails): StorageCopyOutput<T>;
65
+ /**
66
+ * Get a presigned URL of the file or the object data when download:true
67
+ *
68
+ * @param key - key of the object
69
+ * @param [config] - config for the Storage operation.
70
+ * @return - A promise resolves to either a presigned url or the object
71
+ */
72
+ get<T extends Record<string, any> & {
73
+ download?: boolean;
74
+ }>(key: string, config?: StorageGetConfig<T>, customUserAgentDetails?: CustomUserAgentDetails): StorageGetOutput<T>;
75
+ isCancelError(error: any): boolean;
76
+ getProperties<T extends StorageProvider | {
77
+ [key: string]: any;
78
+ }>(key: string, config?: StorageGetPropertiesConfig<T>, customUserAgentDetails?: CustomUserAgentDetails): StorageGetPropertiesOutput<T>;
79
+ /**
80
+ * Put a file in storage bucket specified to configure method
81
+ * @param key - key of the object
82
+ * @param object - File to be put in bucket
83
+ * @param [config] - { level : private|protected|public, contentType: MIME Types,
84
+ * progressCallback: function }
85
+ * @return - promise resolves to object on success
86
+ */
87
+ put<T extends Record<string, any>>(key: string, object: any, config?: StoragePutConfig<T>, customUserAgentDetails?: CustomUserAgentDetails): StoragePutOutput<T>;
88
+ /**
89
+ * Remove the object for specified key
90
+ * @param key - key of the object
91
+ * @param [config] - { level : private|protected|public }
92
+ * @return - Promise resolves upon successful removal of the object
93
+ */
94
+ remove<T extends Record<string, any>>(key: string, config?: StorageRemoveConfig<T>, customUserAgentDetails?: CustomUserAgentDetails): StorageRemoveOutput<T>;
95
+ /**
96
+ * List bucket objects relative to the level and prefix specified
97
+ * @param path - the path that contains objects
98
+ * @param [config] - { level : private|protected|public, maxKeys: NUMBER }
99
+ * @return - Promise resolves to list of keys for all objects in path
100
+ */
101
+ list<T extends Record<string, any>>(key: string, config?: StorageListConfig<T>, customUserAgentDetails?: CustomUserAgentDetails): StorageListOutput<T>;
102
+ }
103
+ export declare const InternalStorage: InternalStorageClass;