@aws-amplify/storage 4.3.12-unstable.2 → 4.4.1-unstable.1

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 CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [4.4.0](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/storage@4.3.11...@aws-amplify/storage@4.4.0) (2021-09-22)
7
+
8
+
9
+ ### Features
10
+
11
+ * **@aws-amplify/storage:** Storage category public API Typescript improvement ([1c3b281](https://github.com/aws-amplify/amplify-js/commit/1c3b281d564db8745d3085489643bb33ac067177))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [4.3.11](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/storage@4.3.10...@aws-amplify/storage@4.3.11) (2021-09-17)
7
18
 
8
19
  **Note:** Version bump only for package @aws-amplify/storage
@@ -47295,149 +47295,6 @@ var __assign = undefined && undefined.__assign || function () {
47295
47295
  return __assign.apply(this, arguments);
47296
47296
  };
47297
47297
 
47298
- var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
47299
- function adopt(value) {
47300
- return value instanceof P ? value : new P(function (resolve) {
47301
- resolve(value);
47302
- });
47303
- }
47304
-
47305
- return new (P || (P = Promise))(function (resolve, reject) {
47306
- function fulfilled(value) {
47307
- try {
47308
- step(generator.next(value));
47309
- } catch (e) {
47310
- reject(e);
47311
- }
47312
- }
47313
-
47314
- function rejected(value) {
47315
- try {
47316
- step(generator["throw"](value));
47317
- } catch (e) {
47318
- reject(e);
47319
- }
47320
- }
47321
-
47322
- function step(result) {
47323
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
47324
- }
47325
-
47326
- step((generator = generator.apply(thisArg, _arguments || [])).next());
47327
- });
47328
- };
47329
-
47330
- var __generator = undefined && undefined.__generator || function (thisArg, body) {
47331
- var _ = {
47332
- label: 0,
47333
- sent: function sent() {
47334
- if (t[0] & 1) throw t[1];
47335
- return t[1];
47336
- },
47337
- trys: [],
47338
- ops: []
47339
- },
47340
- f,
47341
- y,
47342
- t,
47343
- g;
47344
- return g = {
47345
- next: verb(0),
47346
- "throw": verb(1),
47347
- "return": verb(2)
47348
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
47349
- return this;
47350
- }), g;
47351
-
47352
- function verb(n) {
47353
- return function (v) {
47354
- return step([n, v]);
47355
- };
47356
- }
47357
-
47358
- function step(op) {
47359
- if (f) throw new TypeError("Generator is already executing.");
47360
-
47361
- while (_) {
47362
- try {
47363
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
47364
- if (y = 0, t) op = [op[0] & 2, t.value];
47365
-
47366
- switch (op[0]) {
47367
- case 0:
47368
- case 1:
47369
- t = op;
47370
- break;
47371
-
47372
- case 4:
47373
- _.label++;
47374
- return {
47375
- value: op[1],
47376
- done: false
47377
- };
47378
-
47379
- case 5:
47380
- _.label++;
47381
- y = op[1];
47382
- op = [0];
47383
- continue;
47384
-
47385
- case 7:
47386
- op = _.ops.pop();
47387
-
47388
- _.trys.pop();
47389
-
47390
- continue;
47391
-
47392
- default:
47393
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
47394
- _ = 0;
47395
- continue;
47396
- }
47397
-
47398
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
47399
- _.label = op[1];
47400
- break;
47401
- }
47402
-
47403
- if (op[0] === 6 && _.label < t[1]) {
47404
- _.label = t[1];
47405
- t = op;
47406
- break;
47407
- }
47408
-
47409
- if (t && _.label < t[2]) {
47410
- _.label = t[2];
47411
-
47412
- _.ops.push(op);
47413
-
47414
- break;
47415
- }
47416
-
47417
- if (t[2]) _.ops.pop();
47418
-
47419
- _.trys.pop();
47420
-
47421
- continue;
47422
- }
47423
-
47424
- op = body.call(thisArg, _);
47425
- } catch (e) {
47426
- op = [6, e];
47427
- y = 0;
47428
- } finally {
47429
- f = t = 0;
47430
- }
47431
- }
47432
-
47433
- if (op[0] & 5) throw op[1];
47434
- return {
47435
- value: op[0] ? op[1] : void 0,
47436
- done: true
47437
- };
47438
- }
47439
- };
47440
-
47441
47298
  var __read = undefined && undefined.__read || function (o, n) {
47442
47299
  var m = typeof Symbol === "function" && o[Symbol.iterator];
47443
47300
  if (!m) return o;
@@ -47606,8 +47463,8 @@ var Storage = function () {
47606
47463
  /**
47607
47464
  * Cancels an inflight request
47608
47465
  *
47609
- * @param {Promise<any>} request - The request to cancel
47610
- * @param {string} [message] - A message to include in the cancelation exception
47466
+ * @param request - The request to cancel
47467
+ * @param [message] - A message to include in the cancelation exception
47611
47468
  */
47612
47469
 
47613
47470
 
@@ -47620,19 +47477,11 @@ var Storage = function () {
47620
47477
  logger.debug('The request does not map to any cancel token');
47621
47478
  }
47622
47479
  };
47623
- /**
47624
- * Copies a file from the src key to dest key.
47625
- *
47626
- * @param {string} src - key of the source object.
47627
- * @param {string} dest - key of the destination object.
47628
- * @param {any} [config] - config.
47629
- * @return {Promise<any>} - A promise resolves to the copied object's key.
47630
- */
47631
-
47632
47480
 
47633
47481
  Storage.prototype.copy = function (src, dest, config) {
47634
- var _a = (config || {}).provider,
47635
- provider = _a === void 0 ? DEFAULT_PROVIDER : _a;
47482
+ var _a;
47483
+
47484
+ var provider = ((_a = config) === null || _a === void 0 ? void 0 : _a.provider) || DEFAULT_PROVIDER;
47636
47485
 
47637
47486
  var prov = this._pluggables.find(function (pluggable) {
47638
47487
  return pluggable.getProviderName() === provider;
@@ -47644,24 +47493,22 @@ var Storage = function () {
47644
47493
  }
47645
47494
 
47646
47495
  var cancelTokenSource = this.getCancellableTokenSource();
47496
+
47497
+ if (typeof prov.copy !== 'function') {
47498
+ return Promise.reject(".copy is not implemented on provider " + prov.getProviderName());
47499
+ }
47500
+
47647
47501
  var responsePromise = prov.copy(src, dest, __assign(__assign({}, config), {
47648
47502
  cancelTokenSource: cancelTokenSource
47649
47503
  }));
47650
47504
  this.updateRequestToBeCancellable(responsePromise, cancelTokenSource);
47651
47505
  return responsePromise;
47652
47506
  };
47653
- /**
47654
- * Get a presigned URL of the file or the object data when download:true
47655
- *
47656
- * @param {string} key - key of the object
47657
- * @param {Object} [config] - { level : private|protected|public, download: true|false }
47658
- * @return - A promise resolves to either a presigned url or the object
47659
- */
47660
-
47661
47507
 
47662
47508
  Storage.prototype.get = function (key, config) {
47663
- var _a = (config || {}).provider,
47664
- provider = _a === void 0 ? DEFAULT_PROVIDER : _a;
47509
+ var _a;
47510
+
47511
+ var provider = ((_a = config) === null || _a === void 0 ? void 0 : _a.provider) || DEFAULT_PROVIDER;
47665
47512
 
47666
47513
  var prov = this._pluggables.find(function (pluggable) {
47667
47514
  return pluggable.getProviderName() === provider;
@@ -47683,19 +47530,11 @@ var Storage = function () {
47683
47530
  Storage.prototype.isCancelError = function (error) {
47684
47531
  return axios__WEBPACK_IMPORTED_MODULE_2___default.a.isCancel(error);
47685
47532
  };
47686
- /**
47687
- * Put a file in storage bucket specified to configure method
47688
- * @param {string} key - key of the object
47689
- * @param {Object} object - File to be put in bucket
47690
- * @param {Object} [config] - { level : private|protected|public, contentType: MIME Types,
47691
- * progressCallback: function }
47692
- * @return - promise resolves to object on success
47693
- */
47694
-
47695
47533
 
47696
47534
  Storage.prototype.put = function (key, object, config) {
47697
- var _a = (config || {}).provider,
47698
- provider = _a === void 0 ? DEFAULT_PROVIDER : _a;
47535
+ var _a;
47536
+
47537
+ var provider = ((_a = config) === null || _a === void 0 ? void 0 : _a.provider) || DEFAULT_PROVIDER;
47699
47538
 
47700
47539
  var prov = this._pluggables.find(function (pluggable) {
47701
47540
  return pluggable.getProviderName() === provider;
@@ -47713,67 +47552,39 @@ var Storage = function () {
47713
47552
  this.updateRequestToBeCancellable(responsePromise, cancelTokenSource);
47714
47553
  return responsePromise;
47715
47554
  };
47716
- /**
47717
- * Remove the object for specified key
47718
- * @param {string} key - key of the object
47719
- * @param {Object} [config] - { level : private|protected|public }
47720
- * @return - Promise resolves upon successful removal of the object
47721
- */
47722
-
47723
47555
 
47724
47556
  Storage.prototype.remove = function (key, config) {
47725
- return __awaiter(this, void 0, void 0, function () {
47726
- var _a, provider, prov;
47727
-
47728
- return __generator(this, function (_b) {
47729
- _a = (config || {}).provider, provider = _a === void 0 ? DEFAULT_PROVIDER : _a;
47730
- prov = this._pluggables.find(function (pluggable) {
47731
- return pluggable.getProviderName() === provider;
47732
- });
47557
+ var _a;
47733
47558
 
47734
- if (prov === undefined) {
47735
- logger.debug('No plugin found with providerName', provider);
47736
- return [2
47737
- /*return*/
47738
- , Promise.reject('No plugin found in Storage for the provider')];
47739
- }
47559
+ var provider = ((_a = config) === null || _a === void 0 ? void 0 : _a.provider) || DEFAULT_PROVIDER;
47740
47560
 
47741
- return [2
47742
- /*return*/
47743
- , prov.remove(key, config)];
47744
- });
47561
+ var prov = this._pluggables.find(function (pluggable) {
47562
+ return pluggable.getProviderName() === provider;
47745
47563
  });
47746
- };
47747
- /**
47748
- * List bucket objects relative to the level and prefix specified
47749
- * @param {String} path - the path that contains objects
47750
- * @param {Object} [config] - { level : private|protected|public, maxKeys: NUMBER }
47751
- * @return - Promise resolves to list of keys for all objects in path
47752
- */
47753
47564
 
47565
+ if (prov === undefined) {
47566
+ logger.debug('No plugin found with providerName', provider);
47567
+ return Promise.reject('No plugin found in Storage for the provider');
47568
+ }
47754
47569
 
47755
- Storage.prototype.list = function (path, config) {
47756
- return __awaiter(this, void 0, void 0, function () {
47757
- var _a, provider, prov;
47570
+ return prov.remove(key, config);
47571
+ };
47758
47572
 
47759
- return __generator(this, function (_b) {
47760
- _a = (config || {}).provider, provider = _a === void 0 ? DEFAULT_PROVIDER : _a;
47761
- prov = this._pluggables.find(function (pluggable) {
47762
- return pluggable.getProviderName() === provider;
47763
- });
47573
+ Storage.prototype.list = function (path, config) {
47574
+ var _a;
47764
47575
 
47765
- if (prov === undefined) {
47766
- logger.debug('No plugin found with providerName', provider);
47767
- return [2
47768
- /*return*/
47769
- , Promise.reject('No plugin found in Storage for the provider')];
47770
- }
47576
+ var provider = ((_a = config) === null || _a === void 0 ? void 0 : _a.provider) || DEFAULT_PROVIDER;
47771
47577
 
47772
- return [2
47773
- /*return*/
47774
- , prov.list(path, config)];
47775
- });
47578
+ var prov = this._pluggables.find(function (pluggable) {
47579
+ return pluggable.getProviderName() === provider;
47776
47580
  });
47581
+
47582
+ if (prov === undefined) {
47583
+ logger.debug('No plugin found with providerName', provider);
47584
+ return Promise.reject('No plugin found in Storage for the provider');
47585
+ }
47586
+
47587
+ return prov.list(path, config);
47777
47588
  };
47778
47589
 
47779
47590
  return Storage;