@aws-amplify/storage 4.5.2-next.20 → 4.5.2-next.32

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 (44) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/lib/.tsbuildinfo +3 -0
  3. package/lib/Storage.js +18 -23
  4. package/lib/Storage.js.map +1 -1
  5. package/lib/index.js +0 -4
  6. package/lib/index.js.map +1 -1
  7. package/lib/providers/AWSS3Provider.js +1 -5
  8. package/lib/providers/AWSS3Provider.js.map +1 -1
  9. package/lib-esm/.tsbuildinfo +3 -0
  10. package/lib-esm/Storage.d.ts +0 -4
  11. package/lib-esm/Storage.js +19 -24
  12. package/lib-esm/Storage.js.map +1 -1
  13. package/lib-esm/index.d.ts +0 -4
  14. package/lib-esm/index.js +0 -4
  15. package/lib-esm/index.js.map +1 -1
  16. package/lib-esm/providers/AWSS3Provider.d.ts +0 -4
  17. package/lib-esm/providers/AWSS3Provider.js +2 -6
  18. package/lib-esm/providers/AWSS3Provider.js.map +1 -1
  19. package/package.json +8 -3
  20. package/src/Storage.ts +24 -24
  21. package/src/index.ts +0 -5
  22. package/src/providers/AWSS3Provider.ts +2 -7
  23. package/build.js +0 -5
  24. package/dist/aws-amplify-storage.js +0 -58936
  25. package/dist/aws-amplify-storage.js.map +0 -1
  26. package/dist/aws-amplify-storage.min.js +0 -226
  27. package/dist/aws-amplify-storage.min.js.map +0 -1
  28. package/index.js +0 -7
  29. package/lib/Storage.d.ts +0 -108
  30. package/lib/common/S3ClientUtils.d.ts +0 -33
  31. package/lib/common/StorageConstants.d.ts +0 -4
  32. package/lib/common/StorageErrorStrings.d.ts +0 -16
  33. package/lib/common/StorageUtils.d.ts +0 -4
  34. package/lib/index.d.ts +0 -8
  35. package/lib/providers/AWSS3Provider.d.ts +0 -87
  36. package/lib/providers/AWSS3ProviderManagedUpload.d.ts +0 -41
  37. package/lib/providers/AWSS3UploadTask.d.ts +0 -107
  38. package/lib/providers/axios-http-handler.d.ts +0 -40
  39. package/lib/providers/index.d.ts +0 -1
  40. package/lib/types/AWSS3Provider.d.ts +0 -122
  41. package/lib/types/Provider.d.ts +0 -22
  42. package/lib/types/Storage.d.ts +0 -79
  43. package/lib/types/index.d.ts +0 -3
  44. package/webpack.config.dev.js +0 -6
package/src/Storage.ts CHANGED
@@ -11,7 +11,11 @@
11
11
  * and limitations under the License.
12
12
  */
13
13
 
14
- import { Amplify, ConsoleLogger as Logger, Parser } from '@aws-amplify/core';
14
+ import {
15
+ Amplify,
16
+ ConsoleLogger as Logger,
17
+ parseAWSExports,
18
+ } from '@aws-amplify/core';
15
19
  import { AWSS3Provider } from './providers';
16
20
  import {
17
21
  StorageCopySource,
@@ -130,11 +134,11 @@ export class Storage {
130
134
  logger.debug('configure Storage');
131
135
  if (!config) return this._config;
132
136
 
133
- const amplifyConfig = Parser.parseMobilehubConfig(config);
137
+ const amplifyConfig = parseAWSExports(config);
134
138
 
135
- const storageKeysFromConfig = Object.keys(amplifyConfig.Storage);
139
+ const storageConfig = amplifyConfig.Storage ?? {};
136
140
 
137
- const storageArrayKeys = [
141
+ const defaultProviderConfigKeys = [
138
142
  'bucket',
139
143
  'region',
140
144
  'level',
@@ -147,32 +151,33 @@ export class Storage {
147
151
  'SSEKMSKeyId',
148
152
  ];
149
153
 
150
- const isInStorageArrayKeys = (k: string) =>
151
- storageArrayKeys.some(x => x === k);
152
- const checkConfigKeysFromArray = (k: string[]) =>
153
- k.find(k => isInStorageArrayKeys(k));
154
+ const hasDefaultProviderConfigKeys = (config: object) =>
155
+ Object.keys(config).find(key => defaultProviderConfigKeys.includes(key));
154
156
 
155
157
  if (
156
- storageKeysFromConfig &&
157
- checkConfigKeysFromArray(storageKeysFromConfig) &&
158
- !amplifyConfig.Storage[DEFAULT_PROVIDER]
158
+ hasDefaultProviderConfigKeys(storageConfig) &&
159
+ !storageConfig[DEFAULT_PROVIDER]
159
160
  ) {
160
- amplifyConfig.Storage[DEFAULT_PROVIDER] = {};
161
+ storageConfig[DEFAULT_PROVIDER] = {};
161
162
  }
162
163
 
163
- Object.entries(amplifyConfig.Storage).map(([key, value]) => {
164
- if (key && isInStorageArrayKeys(key) && value !== undefined) {
165
- amplifyConfig.Storage[DEFAULT_PROVIDER][key] = value;
166
- delete amplifyConfig.Storage[key];
164
+ Object.entries(storageConfig).forEach(([key, value]) => {
165
+ if (
166
+ key &&
167
+ defaultProviderConfigKeys.includes(key) &&
168
+ value !== undefined
169
+ ) {
170
+ storageConfig[DEFAULT_PROVIDER][key] = value;
171
+ delete storageConfig[key];
167
172
  }
168
173
  });
169
174
 
170
175
  // only update new values for each provider
171
- Object.keys(amplifyConfig.Storage).forEach(providerName => {
172
- if (typeof amplifyConfig.Storage[providerName] !== 'string') {
176
+ Object.keys(storageConfig).forEach(providerName => {
177
+ if (typeof storageConfig[providerName] !== 'string') {
173
178
  this._config[providerName] = {
174
179
  ...this._config[providerName],
175
- ...amplifyConfig.Storage[providerName],
180
+ ...storageConfig[providerName],
176
181
  };
177
182
  }
178
183
  });
@@ -440,8 +445,3 @@ const getInstance = () => {
440
445
 
441
446
  export const StorageInstance: Storage = getInstance();
442
447
  Amplify.register(StorageInstance);
443
-
444
- /**
445
- * @deprecated use named import
446
- */
447
- export default Storage;
package/src/index.ts CHANGED
@@ -13,11 +13,6 @@
13
13
 
14
14
  import { Storage, StorageInstance } from './Storage';
15
15
 
16
- /**
17
- * @deprecated use named import
18
- */
19
- export default StorageInstance;
20
-
21
16
  export { Storage as StorageClass, StorageInstance as Storage };
22
17
  export * from './providers';
23
18
  export * from './types';
@@ -13,10 +13,10 @@
13
13
  import {
14
14
  ConsoleLogger as Logger,
15
15
  Credentials,
16
- Parser,
17
16
  ICredentials,
18
17
  StorageHelper,
19
18
  Hub,
19
+ parseAWSExports,
20
20
  } from '@aws-amplify/core';
21
21
  import {
22
22
  S3Client,
@@ -137,7 +137,7 @@ export class AWSS3Provider implements StorageProvider {
137
137
  public configure(config?): object {
138
138
  logger.debug('configure Storage', config);
139
139
  if (!config) return this._config;
140
- const amplifyConfig = Parser.parseMobilehubConfig(config);
140
+ const amplifyConfig = parseAWSExports(config);
141
141
  this._config = Object.assign({}, this._config, amplifyConfig.Storage);
142
142
  if (!this._config.bucket) {
143
143
  logger.debug('Do not have bucket yet');
@@ -857,8 +857,3 @@ export class AWSS3Provider implements StorageProvider {
857
857
  return s3client;
858
858
  }
859
859
  }
860
-
861
- /**
862
- * @deprecated use named import
863
- */
864
- export default AWSS3Provider;
package/build.js DELETED
@@ -1,5 +0,0 @@
1
- 'use strict';
2
-
3
- const build = require('../../scripts/build');
4
-
5
- build(process.argv[2], process.argv[3]);