@aws-amplify/geo 1.3.4 → 1.3.6-geo.14

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,14 @@
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
+ ## [1.3.5](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/geo@1.3.4...@aws-amplify/geo@1.3.5) (2022-05-24)
7
+
8
+ **Note:** Version bump only for package @aws-amplify/geo
9
+
10
+
11
+
12
+
13
+
6
14
  ## [1.3.4](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/geo@1.3.3...@aws-amplify/geo@1.3.4) (2022-05-23)
7
15
 
8
16
  **Note:** Version bump only for package @aws-amplify/geo
@@ -28963,6 +28963,50 @@ function () {
28963
28963
  });
28964
28964
  });
28965
28965
  };
28966
+ /**
28967
+ * Search for search term suggestions based on input text
28968
+ * @param {string} text - The text string that is to be search for
28969
+ * @param {SearchByTextOptions} options? - Optional parameters to the search
28970
+ * @returns {Promise<SearchForSuggestionsResults>} - Resolves to an array of search suggestion strings
28971
+ */
28972
+
28973
+
28974
+ GeoClass.prototype.searchForSuggestions = function (text, options) {
28975
+ return __awaiter(this, void 0, void 0, function () {
28976
+ var _a, providerName, prov, error_2;
28977
+
28978
+ return __generator(this, function (_b) {
28979
+ switch (_b.label) {
28980
+ case 0:
28981
+ _a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
28982
+ prov = this.getPluggable(providerName);
28983
+ _b.label = 1;
28984
+
28985
+ case 1:
28986
+ _b.trys.push([1, 3,, 4]);
28987
+
28988
+ return [4
28989
+ /*yield*/
28990
+ , prov.searchForSuggestions(text, options)];
28991
+
28992
+ case 2:
28993
+ return [2
28994
+ /*return*/
28995
+ , _b.sent()];
28996
+
28997
+ case 3:
28998
+ error_2 = _b.sent();
28999
+ logger.debug(error_2);
29000
+ throw error_2;
29001
+
29002
+ case 4:
29003
+ return [2
29004
+ /*return*/
29005
+ ];
29006
+ }
29007
+ });
29008
+ });
29009
+ };
28966
29010
  /**
28967
29011
  * Reverse geocoding search via a coordinate point on the map
28968
29012
  * @param coordinates - Coordinates array for the search input
@@ -28973,7 +29017,7 @@ function () {
28973
29017
 
28974
29018
  GeoClass.prototype.searchByCoordinates = function (coordinates, options) {
28975
29019
  return __awaiter(this, void 0, void 0, function () {
28976
- var _a, providerName, prov, _b, lng, lat, error_2;
29020
+ var _a, providerName, prov, _b, lng, lat, error_3;
28977
29021
 
28978
29022
  return __generator(this, function (_c) {
28979
29023
  switch (_c.label) {
@@ -28997,9 +29041,9 @@ function () {
28997
29041
  , _c.sent()];
28998
29042
 
28999
29043
  case 3:
29000
- error_2 = _c.sent();
29001
- logger.debug(error_2);
29002
- throw error_2;
29044
+ error_3 = _c.sent();
29045
+ logger.debug(error_3);
29046
+ throw error_3;
29003
29047
 
29004
29048
  case 4:
29005
29049
  return [2
@@ -29021,7 +29065,7 @@ function () {
29021
29065
 
29022
29066
  GeoClass.prototype.saveGeofences = function (geofences, options) {
29023
29067
  return __awaiter(this, void 0, void 0, function () {
29024
- var _a, providerName, prov, geofenceInputArray, error_3;
29068
+ var _a, providerName, prov, geofenceInputArray, error_4;
29025
29069
 
29026
29070
  return __generator(this, function (_b) {
29027
29071
  switch (_b.label) {
@@ -29050,9 +29094,9 @@ function () {
29050
29094
  , _b.sent()];
29051
29095
 
29052
29096
  case 3:
29053
- error_3 = _b.sent();
29054
- logger.debug(error_3);
29055
- throw error_3;
29097
+ error_4 = _b.sent();
29098
+ logger.debug(error_4);
29099
+ throw error_4;
29056
29100
 
29057
29101
  case 4:
29058
29102
  return [2
@@ -29072,7 +29116,7 @@ function () {
29072
29116
 
29073
29117
  GeoClass.prototype.getGeofence = function (geofenceId, options) {
29074
29118
  return __awaiter(this, void 0, void 0, function () {
29075
- var _a, providerName, prov, error_4;
29119
+ var _a, providerName, prov, error_5;
29076
29120
 
29077
29121
  return __generator(this, function (_b) {
29078
29122
  switch (_b.label) {
@@ -29094,9 +29138,9 @@ function () {
29094
29138
  , _b.sent()];
29095
29139
 
29096
29140
  case 3:
29097
- error_4 = _b.sent();
29098
- logger.debug(error_4);
29099
- throw error_4;
29141
+ error_5 = _b.sent();
29142
+ logger.debug(error_5);
29143
+ throw error_5;
29100
29144
 
29101
29145
  case 4:
29102
29146
  return [2
@@ -29117,7 +29161,7 @@ function () {
29117
29161
 
29118
29162
  GeoClass.prototype.listGeofences = function (options) {
29119
29163
  return __awaiter(this, void 0, void 0, function () {
29120
- var _a, providerName, prov, error_5;
29164
+ var _a, providerName, prov, error_6;
29121
29165
 
29122
29166
  return __generator(this, function (_b) {
29123
29167
  switch (_b.label) {
@@ -29139,9 +29183,9 @@ function () {
29139
29183
  , _b.sent()];
29140
29184
 
29141
29185
  case 3:
29142
- error_5 = _b.sent();
29143
- logger.debug(error_5);
29144
- throw error_5;
29186
+ error_6 = _b.sent();
29187
+ logger.debug(error_6);
29188
+ throw error_6;
29145
29189
 
29146
29190
  case 4:
29147
29191
  return [2
@@ -29163,7 +29207,7 @@ function () {
29163
29207
 
29164
29208
  GeoClass.prototype.deleteGeofences = function (geofenceIds, options) {
29165
29209
  return __awaiter(this, void 0, void 0, function () {
29166
- var _a, providerName, prov, geofenceIdsInputArray, error_6;
29210
+ var _a, providerName, prov, geofenceIdsInputArray, error_7;
29167
29211
 
29168
29212
  return __generator(this, function (_b) {
29169
29213
  switch (_b.label) {
@@ -29192,9 +29236,9 @@ function () {
29192
29236
  , _b.sent()];
29193
29237
 
29194
29238
  case 3:
29195
- error_6 = _b.sent();
29196
- logger.debug(error_6);
29197
- throw error_6;
29239
+ error_7 = _b.sent();
29240
+ logger.debug(error_7);
29241
+ throw error_7;
29198
29242
 
29199
29243
  case 4:
29200
29244
  return [2
@@ -29608,6 +29652,99 @@ function () {
29608
29652
  });
29609
29653
  });
29610
29654
  };
29655
+ /**
29656
+ * Search for suggestions based on the input text
29657
+ * @param {string} text - The text string that is to be searched for
29658
+ * @param {SearchByTextOptions} options? - Optional parameters to the search
29659
+ * @returns {Promise<SearchForSuggestionsResults>} - Resolves to an array of search suggestion strings
29660
+ */
29661
+
29662
+
29663
+ AmazonLocationServiceProvider.prototype.searchForSuggestions = function (text, options) {
29664
+ return __awaiter(this, void 0, void 0, function () {
29665
+ var credentialsOK, locationServiceInput, client, command, response, error_2, results;
29666
+ return __generator(this, function (_a) {
29667
+ switch (_a.label) {
29668
+ case 0:
29669
+ return [4
29670
+ /*yield*/
29671
+ , this._ensureCredentials()];
29672
+
29673
+ case 1:
29674
+ credentialsOK = _a.sent();
29675
+
29676
+ if (!credentialsOK) {
29677
+ throw new Error('No credentials');
29678
+ }
29679
+
29680
+ this._verifySearchIndex(options === null || options === void 0 ? void 0 : options.searchIndexName);
29681
+
29682
+ locationServiceInput = {
29683
+ Text: text,
29684
+ IndexName: this._config.search_indices["default"]
29685
+ };
29686
+ /**
29687
+ * Map search options to Amazon Location Service input object
29688
+ */
29689
+
29690
+ if (options) {
29691
+ locationServiceInput.FilterCountries = options.countries;
29692
+ locationServiceInput.MaxResults = options.maxResults;
29693
+
29694
+ if (options.searchIndexName) {
29695
+ locationServiceInput.IndexName = options.searchIndexName;
29696
+ }
29697
+
29698
+ if (options['biasPosition'] && options['searchAreaConstraints']) {
29699
+ throw new Error('BiasPosition and SearchAreaConstraints are mutually exclusive, please remove one or the other from the options object');
29700
+ }
29701
+
29702
+ if (options['biasPosition']) {
29703
+ locationServiceInput.BiasPosition = options['biasPosition'];
29704
+ }
29705
+
29706
+ if (options['searchAreaConstraints']) {
29707
+ locationServiceInput.FilterBBox = options['searchAreaConstraints'];
29708
+ }
29709
+ }
29710
+
29711
+ client = new _aws_sdk_client_location__WEBPACK_IMPORTED_MODULE_2__["LocationClient"]({
29712
+ credentials: this._config.credentials,
29713
+ region: this._config.region,
29714
+ customUserAgent: Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["getAmplifyUserAgent"])()
29715
+ });
29716
+ command = new _aws_sdk_client_location__WEBPACK_IMPORTED_MODULE_2__["SearchPlaceIndexForSuggestionsCommand"](locationServiceInput);
29717
+ _a.label = 2;
29718
+
29719
+ case 2:
29720
+ _a.trys.push([2, 4,, 5]);
29721
+
29722
+ return [4
29723
+ /*yield*/
29724
+ , client.send(command)];
29725
+
29726
+ case 3:
29727
+ response = _a.sent();
29728
+ return [3
29729
+ /*break*/
29730
+ , 5];
29731
+
29732
+ case 4:
29733
+ error_2 = _a.sent();
29734
+ logger.debug(error_2);
29735
+ throw error_2;
29736
+
29737
+ case 5:
29738
+ results = response.Results.map(function (result) {
29739
+ return result.Text;
29740
+ });
29741
+ return [2
29742
+ /*return*/
29743
+ , results];
29744
+ }
29745
+ });
29746
+ });
29747
+ };
29611
29748
  /**
29612
29749
  * Reverse geocoding search via a coordinate point on the map
29613
29750
  * @param coordinates - Coordinates array for the search input
@@ -29618,7 +29755,7 @@ function () {
29618
29755
 
29619
29756
  AmazonLocationServiceProvider.prototype.searchByCoordinates = function (coordinates, options) {
29620
29757
  return __awaiter(this, void 0, void 0, function () {
29621
- var credentialsOK, locationServiceInput, client, command, response, error_2, PascalResults, results;
29758
+ var credentialsOK, locationServiceInput, client, command, response, error_3, PascalResults, results;
29622
29759
  return __generator(this, function (_a) {
29623
29760
  switch (_a.label) {
29624
29761
  case 0:
@@ -29670,9 +29807,9 @@ function () {
29670
29807
  , 5];
29671
29808
 
29672
29809
  case 4:
29673
- error_2 = _a.sent();
29674
- logger.debug(error_2);
29675
- throw error_2;
29810
+ error_3 = _a.sent();
29811
+ logger.debug(error_3);
29812
+ throw error_3;
29676
29813
 
29677
29814
  case 5:
29678
29815
  PascalResults = response.Results.map(function (result) {
@@ -29756,7 +29893,7 @@ function () {
29756
29893
  /*yield*/
29757
29894
  , Promise.all(geofenceBatches.map(function (batch) {
29758
29895
  return __awaiter(_this, void 0, void 0, function () {
29759
- var response, error_3;
29896
+ var response, error_4;
29760
29897
  return __generator(this, function (_a) {
29761
29898
  switch (_a.label) {
29762
29899
  case 0:
@@ -29773,14 +29910,14 @@ function () {
29773
29910
  , 3];
29774
29911
 
29775
29912
  case 2:
29776
- error_3 = _a.sent(); // If the API call fails, add the geofences to the errors array and move to next batch
29913
+ error_4 = _a.sent(); // If the API call fails, add the geofences to the errors array and move to next batch
29777
29914
 
29778
29915
  batch.forEach(function (geofence) {
29779
29916
  results.errors.push({
29780
29917
  geofenceId: geofence.GeofenceId,
29781
29918
  error: {
29782
29919
  code: 'APIConnectionError',
29783
- message: error_3.message
29920
+ message: error_4.message
29784
29921
  }
29785
29922
  });
29786
29923
  });
@@ -29842,7 +29979,7 @@ function () {
29842
29979
 
29843
29980
  AmazonLocationServiceProvider.prototype.getGeofence = function (geofenceId, options) {
29844
29981
  return __awaiter(this, void 0, void 0, function () {
29845
- var credentialsOK, client, commandInput, command, response, error_4, GeofenceId, CreateTime, UpdateTime, Status, Geometry, geofence;
29982
+ var credentialsOK, client, commandInput, command, response, error_5, GeofenceId, CreateTime, UpdateTime, Status, Geometry, geofence;
29846
29983
  return __generator(this, function (_a) {
29847
29984
  switch (_a.label) {
29848
29985
  case 0:
@@ -29892,9 +30029,9 @@ function () {
29892
30029
  , 5];
29893
30030
 
29894
30031
  case 4:
29895
- error_4 = _a.sent();
29896
- logger.debug(error_4);
29897
- throw error_4;
30032
+ error_5 = _a.sent();
30033
+ logger.debug(error_5);
30034
+ throw error_5;
29898
30035
 
29899
30036
  case 5:
29900
30037
  GeofenceId = response.GeofenceId, CreateTime = response.CreateTime, UpdateTime = response.UpdateTime, Status = response.Status, Geometry = response.Geometry;
@@ -29925,7 +30062,7 @@ function () {
29925
30062
 
29926
30063
  AmazonLocationServiceProvider.prototype.listGeofences = function (options) {
29927
30064
  return __awaiter(this, void 0, void 0, function () {
29928
- var credentialsOK, client, listGeofencesInput, command, response, error_5, NextToken, Entries, results;
30065
+ var credentialsOK, client, listGeofencesInput, command, response, error_6, NextToken, Entries, results;
29929
30066
  return __generator(this, function (_a) {
29930
30067
  switch (_a.label) {
29931
30068
  case 0:
@@ -29974,9 +30111,9 @@ function () {
29974
30111
  , 5];
29975
30112
 
29976
30113
  case 4:
29977
- error_5 = _a.sent();
29978
- logger.debug(error_5);
29979
- throw error_5;
30114
+ error_6 = _a.sent();
30115
+ logger.debug(error_6);
30116
+ throw error_6;
29980
30117
 
29981
30118
  case 5:
29982
30119
  NextToken = response.NextToken, Entries = response.Entries;
@@ -30069,7 +30206,7 @@ function () {
30069
30206
  /*yield*/
30070
30207
  , Promise.all(geofenceIdBatches.map(function (batch) {
30071
30208
  return __awaiter(_this, void 0, void 0, function () {
30072
- var response, error_6, badGeofenceIds;
30209
+ var response, error_7, badGeofenceIds;
30073
30210
 
30074
30211
  var _a;
30075
30212
 
@@ -30089,14 +30226,14 @@ function () {
30089
30226
  , 3];
30090
30227
 
30091
30228
  case 2:
30092
- error_6 = _b.sent(); // If the API call fails, add the geofences to the errors array and move to next batch
30229
+ error_7 = _b.sent(); // If the API call fails, add the geofences to the errors array and move to next batch
30093
30230
 
30094
30231
  batch.forEach(function (geofenceId) {
30095
30232
  var errorObject = {
30096
30233
  geofenceId: geofenceId,
30097
30234
  error: {
30098
- code: error_6.message,
30099
- message: error_6.message
30235
+ code: error_7.message,
30236
+ message: error_7.message
30100
30237
  }
30101
30238
  };
30102
30239
  results.errors.push(errorObject);
@@ -30140,7 +30277,7 @@ function () {
30140
30277
 
30141
30278
  AmazonLocationServiceProvider.prototype._ensureCredentials = function () {
30142
30279
  return __awaiter(this, void 0, void 0, function () {
30143
- var credentials, cred, error_7;
30280
+ var credentials, cred, error_8;
30144
30281
  return __generator(this, function (_a) {
30145
30282
  switch (_a.label) {
30146
30283
  case 0:
@@ -30163,8 +30300,8 @@ function () {
30163
30300
  , true];
30164
30301
 
30165
30302
  case 2:
30166
- error_7 = _a.sent();
30167
- logger.debug('Ensure credentials error. Credentials are:', error_7);
30303
+ error_8 = _a.sent();
30304
+ logger.debug('Ensure credentials error. Credentials are:', error_8);
30168
30305
  return [2
30169
30306
  /*return*/
30170
30307
  , false];
@@ -30210,7 +30347,7 @@ function () {
30210
30347
 
30211
30348
  AmazonLocationServiceProvider.prototype._AmazonLocationServiceBatchPutGeofenceCall = function (PascalGeofences, collectionName) {
30212
30349
  return __awaiter(this, void 0, void 0, function () {
30213
- var geofenceInput, client, command, response, error_8;
30350
+ var geofenceInput, client, command, response, error_9;
30214
30351
  return __generator(this, function (_a) {
30215
30352
  switch (_a.label) {
30216
30353
  case 0:
@@ -30240,8 +30377,8 @@ function () {
30240
30377
  , 4];
30241
30378
 
30242
30379
  case 3:
30243
- error_8 = _a.sent();
30244
- throw error_8;
30380
+ error_9 = _a.sent();
30381
+ throw error_9;
30245
30382
 
30246
30383
  case 4:
30247
30384
  return [2
@@ -30254,7 +30391,7 @@ function () {
30254
30391
 
30255
30392
  AmazonLocationServiceProvider.prototype._AmazonLocationServiceBatchDeleteGeofenceCall = function (geofenceIds, collectionName) {
30256
30393
  return __awaiter(this, void 0, void 0, function () {
30257
- var deleteGeofencesInput, client, command, response, error_9;
30394
+ var deleteGeofencesInput, client, command, response, error_10;
30258
30395
  return __generator(this, function (_a) {
30259
30396
  switch (_a.label) {
30260
30397
  case 0:
@@ -30284,8 +30421,8 @@ function () {
30284
30421
  , 4];
30285
30422
 
30286
30423
  case 3:
30287
- error_9 = _a.sent();
30288
- throw error_9;
30424
+ error_10 = _a.sent();
30425
+ throw error_10;
30289
30426
 
30290
30427
  case 4:
30291
30428
  return [2