@aws-amplify/geo 1.2.5-geo.7 → 1.2.5-unstable.10
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/dist/aws-amplify-geo.js +86 -208
- package/dist/aws-amplify-geo.js.map +1 -1
- package/dist/aws-amplify-geo.min.js +6 -6
- package/dist/aws-amplify-geo.min.js.map +1 -1
- package/lib/Geo.d.ts +4 -11
- package/lib/Geo.js +22 -50
- package/lib/Geo.js.map +1 -1
- package/lib/Providers/AmazonLocationServiceProvider.d.ts +2 -9
- package/lib/Providers/AmazonLocationServiceProvider.js +47 -104
- package/lib/Providers/AmazonLocationServiceProvider.js.map +1 -1
- package/lib/types/Geo.d.ts +6 -6
- package/lib/types/Provider.d.ts +2 -3
- package/lib/util.d.ts +4 -4
- package/lib/util.js +16 -11
- package/lib/util.js.map +1 -1
- package/lib-esm/Geo.d.ts +4 -11
- package/lib-esm/Geo.js +22 -50
- package/lib-esm/Geo.js.map +1 -1
- package/lib-esm/Providers/AmazonLocationServiceProvider.d.ts +2 -9
- package/lib-esm/Providers/AmazonLocationServiceProvider.js +48 -105
- package/lib-esm/Providers/AmazonLocationServiceProvider.js.map +1 -1
- package/lib-esm/types/Geo.d.ts +6 -6
- package/lib-esm/types/Provider.d.ts +2 -3
- package/lib-esm/util.d.ts +4 -4
- package/lib-esm/util.js +16 -11
- package/lib-esm/util.js.map +1 -1
- package/package.json +3 -3
- package/src/Geo.ts +4 -24
- package/src/Providers/AmazonLocationServiceProvider.ts +18 -88
- package/src/types/Geo.ts +8 -9
- package/src/types/Provider.ts +3 -9
- package/src/util.ts +23 -14
package/dist/aws-amplify-geo.js
CHANGED
|
@@ -28933,50 +28933,6 @@ function () {
|
|
|
28933
28933
|
});
|
|
28934
28934
|
});
|
|
28935
28935
|
};
|
|
28936
|
-
/**
|
|
28937
|
-
* Search for search term suggestions based on input text
|
|
28938
|
-
* @param {string} text - The text string that is to be search for
|
|
28939
|
-
* @param {SearchByTextOptions} options? - Optional parameters to the search
|
|
28940
|
-
* @returns {Promise<SearchForSuggestionsResults>} - Resolves to an array of search suggestion strings
|
|
28941
|
-
*/
|
|
28942
|
-
|
|
28943
|
-
|
|
28944
|
-
GeoClass.prototype.searchForSuggestions = function (text, options) {
|
|
28945
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
28946
|
-
var _a, providerName, prov, error_2;
|
|
28947
|
-
|
|
28948
|
-
return __generator(this, function (_b) {
|
|
28949
|
-
switch (_b.label) {
|
|
28950
|
-
case 0:
|
|
28951
|
-
_a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
|
|
28952
|
-
prov = this.getPluggable(providerName);
|
|
28953
|
-
_b.label = 1;
|
|
28954
|
-
|
|
28955
|
-
case 1:
|
|
28956
|
-
_b.trys.push([1, 3,, 4]);
|
|
28957
|
-
|
|
28958
|
-
return [4
|
|
28959
|
-
/*yield*/
|
|
28960
|
-
, prov.searchForSuggestions(text, options)];
|
|
28961
|
-
|
|
28962
|
-
case 2:
|
|
28963
|
-
return [2
|
|
28964
|
-
/*return*/
|
|
28965
|
-
, _b.sent()];
|
|
28966
|
-
|
|
28967
|
-
case 3:
|
|
28968
|
-
error_2 = _b.sent();
|
|
28969
|
-
logger.debug(error_2);
|
|
28970
|
-
throw error_2;
|
|
28971
|
-
|
|
28972
|
-
case 4:
|
|
28973
|
-
return [2
|
|
28974
|
-
/*return*/
|
|
28975
|
-
];
|
|
28976
|
-
}
|
|
28977
|
-
});
|
|
28978
|
-
});
|
|
28979
|
-
};
|
|
28980
28936
|
/**
|
|
28981
28937
|
* Reverse geocoding search via a coordinate point on the map
|
|
28982
28938
|
* @param coordinates - Coordinates array for the search input
|
|
@@ -28987,7 +28943,7 @@ function () {
|
|
|
28987
28943
|
|
|
28988
28944
|
GeoClass.prototype.searchByCoordinates = function (coordinates, options) {
|
|
28989
28945
|
return __awaiter(this, void 0, void 0, function () {
|
|
28990
|
-
var _a, providerName, prov, _b, lng, lat,
|
|
28946
|
+
var _a, providerName, prov, _b, lng, lat, error_2;
|
|
28991
28947
|
|
|
28992
28948
|
return __generator(this, function (_c) {
|
|
28993
28949
|
switch (_c.label) {
|
|
@@ -29011,9 +28967,9 @@ function () {
|
|
|
29011
28967
|
, _c.sent()];
|
|
29012
28968
|
|
|
29013
28969
|
case 3:
|
|
29014
|
-
|
|
29015
|
-
logger.debug(
|
|
29016
|
-
throw
|
|
28970
|
+
error_2 = _c.sent();
|
|
28971
|
+
logger.debug(error_2);
|
|
28972
|
+
throw error_2;
|
|
29017
28973
|
|
|
29018
28974
|
case 4:
|
|
29019
28975
|
return [2
|
|
@@ -29035,7 +28991,7 @@ function () {
|
|
|
29035
28991
|
|
|
29036
28992
|
GeoClass.prototype.saveGeofences = function (geofences, options) {
|
|
29037
28993
|
return __awaiter(this, void 0, void 0, function () {
|
|
29038
|
-
var _a, providerName, prov, geofenceInputArray,
|
|
28994
|
+
var _a, providerName, prov, geofenceInputArray, error_3;
|
|
29039
28995
|
|
|
29040
28996
|
return __generator(this, function (_b) {
|
|
29041
28997
|
switch (_b.label) {
|
|
@@ -29064,9 +29020,9 @@ function () {
|
|
|
29064
29020
|
, _b.sent()];
|
|
29065
29021
|
|
|
29066
29022
|
case 3:
|
|
29067
|
-
|
|
29068
|
-
logger.debug(
|
|
29069
|
-
throw
|
|
29023
|
+
error_3 = _b.sent();
|
|
29024
|
+
logger.debug(error_3);
|
|
29025
|
+
throw error_3;
|
|
29070
29026
|
|
|
29071
29027
|
case 4:
|
|
29072
29028
|
return [2
|
|
@@ -29078,15 +29034,15 @@ function () {
|
|
|
29078
29034
|
};
|
|
29079
29035
|
/**
|
|
29080
29036
|
* Get a single geofence by geofenceId
|
|
29081
|
-
* @param geofenceId: string
|
|
29082
|
-
* @param options?: GeofenceOptions
|
|
29037
|
+
* @param geofenceId: GeofenceId - The string id of the geofence to get
|
|
29038
|
+
* @param options?: GeofenceOptions - Optional parameters for getting a geofence
|
|
29083
29039
|
* @returns Promise<Geofence> - Promise that resolves to a geofence object
|
|
29084
29040
|
*/
|
|
29085
29041
|
|
|
29086
29042
|
|
|
29087
29043
|
GeoClass.prototype.getGeofence = function (geofenceId, options) {
|
|
29088
29044
|
return __awaiter(this, void 0, void 0, function () {
|
|
29089
|
-
var _a, providerName, prov,
|
|
29045
|
+
var _a, providerName, prov, error_4;
|
|
29090
29046
|
|
|
29091
29047
|
return __generator(this, function (_b) {
|
|
29092
29048
|
switch (_b.label) {
|
|
@@ -29108,9 +29064,9 @@ function () {
|
|
|
29108
29064
|
, _b.sent()];
|
|
29109
29065
|
|
|
29110
29066
|
case 3:
|
|
29111
|
-
|
|
29112
|
-
logger.debug(
|
|
29113
|
-
throw
|
|
29067
|
+
error_4 = _b.sent();
|
|
29068
|
+
logger.debug(error_4);
|
|
29069
|
+
throw error_4;
|
|
29114
29070
|
|
|
29115
29071
|
case 4:
|
|
29116
29072
|
return [2
|
|
@@ -29131,7 +29087,7 @@ function () {
|
|
|
29131
29087
|
|
|
29132
29088
|
GeoClass.prototype.listGeofences = function (options) {
|
|
29133
29089
|
return __awaiter(this, void 0, void 0, function () {
|
|
29134
|
-
var _a, providerName, prov,
|
|
29090
|
+
var _a, providerName, prov, error_5;
|
|
29135
29091
|
|
|
29136
29092
|
return __generator(this, function (_b) {
|
|
29137
29093
|
switch (_b.label) {
|
|
@@ -29153,9 +29109,9 @@ function () {
|
|
|
29153
29109
|
, _b.sent()];
|
|
29154
29110
|
|
|
29155
29111
|
case 3:
|
|
29156
|
-
|
|
29157
|
-
logger.debug(
|
|
29158
|
-
throw
|
|
29112
|
+
error_5 = _b.sent();
|
|
29113
|
+
logger.debug(error_5);
|
|
29114
|
+
throw error_5;
|
|
29159
29115
|
|
|
29160
29116
|
case 4:
|
|
29161
29117
|
return [2
|
|
@@ -29177,7 +29133,7 @@ function () {
|
|
|
29177
29133
|
|
|
29178
29134
|
GeoClass.prototype.deleteGeofences = function (geofenceIds, options) {
|
|
29179
29135
|
return __awaiter(this, void 0, void 0, function () {
|
|
29180
|
-
var _a, providerName, prov, geofenceIdsInputArray,
|
|
29136
|
+
var _a, providerName, prov, geofenceIdsInputArray, error_6;
|
|
29181
29137
|
|
|
29182
29138
|
return __generator(this, function (_b) {
|
|
29183
29139
|
switch (_b.label) {
|
|
@@ -29206,9 +29162,9 @@ function () {
|
|
|
29206
29162
|
, _b.sent()];
|
|
29207
29163
|
|
|
29208
29164
|
case 3:
|
|
29209
|
-
|
|
29210
|
-
logger.debug(
|
|
29211
|
-
throw
|
|
29165
|
+
error_6 = _b.sent();
|
|
29166
|
+
logger.debug(error_6);
|
|
29167
|
+
throw error_6;
|
|
29212
29168
|
|
|
29213
29169
|
case 4:
|
|
29214
29170
|
return [2
|
|
@@ -29622,99 +29578,6 @@ function () {
|
|
|
29622
29578
|
});
|
|
29623
29579
|
});
|
|
29624
29580
|
};
|
|
29625
|
-
/**
|
|
29626
|
-
* Search for suggestions based on the input text
|
|
29627
|
-
* @param {string} text - The text string that is to be searched for
|
|
29628
|
-
* @param {SearchByTextOptions} options? - Optional parameters to the search
|
|
29629
|
-
* @returns {Promise<SearchForSuggestionsResults>} - Resolves to an array of search suggestion strings
|
|
29630
|
-
*/
|
|
29631
|
-
|
|
29632
|
-
|
|
29633
|
-
AmazonLocationServiceProvider.prototype.searchForSuggestions = function (text, options) {
|
|
29634
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
29635
|
-
var credentialsOK, locationServiceInput, client, command, response, error_2, results;
|
|
29636
|
-
return __generator(this, function (_a) {
|
|
29637
|
-
switch (_a.label) {
|
|
29638
|
-
case 0:
|
|
29639
|
-
return [4
|
|
29640
|
-
/*yield*/
|
|
29641
|
-
, this._ensureCredentials()];
|
|
29642
|
-
|
|
29643
|
-
case 1:
|
|
29644
|
-
credentialsOK = _a.sent();
|
|
29645
|
-
|
|
29646
|
-
if (!credentialsOK) {
|
|
29647
|
-
throw new Error('No credentials');
|
|
29648
|
-
}
|
|
29649
|
-
|
|
29650
|
-
this._verifySearchIndex(options === null || options === void 0 ? void 0 : options.searchIndexName);
|
|
29651
|
-
|
|
29652
|
-
locationServiceInput = {
|
|
29653
|
-
Text: text,
|
|
29654
|
-
IndexName: this._config.search_indices["default"]
|
|
29655
|
-
};
|
|
29656
|
-
/**
|
|
29657
|
-
* Map search options to Amazon Location Service input object
|
|
29658
|
-
*/
|
|
29659
|
-
|
|
29660
|
-
if (options) {
|
|
29661
|
-
locationServiceInput.FilterCountries = options.countries;
|
|
29662
|
-
locationServiceInput.MaxResults = options.maxResults;
|
|
29663
|
-
|
|
29664
|
-
if (options.searchIndexName) {
|
|
29665
|
-
locationServiceInput.IndexName = options.searchIndexName;
|
|
29666
|
-
}
|
|
29667
|
-
|
|
29668
|
-
if (options['biasPosition'] && options['searchAreaConstraints']) {
|
|
29669
|
-
throw new Error('BiasPosition and SearchAreaConstraints are mutually exclusive, please remove one or the other from the options object');
|
|
29670
|
-
}
|
|
29671
|
-
|
|
29672
|
-
if (options['biasPosition']) {
|
|
29673
|
-
locationServiceInput.BiasPosition = options['biasPosition'];
|
|
29674
|
-
}
|
|
29675
|
-
|
|
29676
|
-
if (options['searchAreaConstraints']) {
|
|
29677
|
-
locationServiceInput.FilterBBox = options['searchAreaConstraints'];
|
|
29678
|
-
}
|
|
29679
|
-
}
|
|
29680
|
-
|
|
29681
|
-
client = new _aws_sdk_client_location__WEBPACK_IMPORTED_MODULE_2__["LocationClient"]({
|
|
29682
|
-
credentials: this._config.credentials,
|
|
29683
|
-
region: this._config.region,
|
|
29684
|
-
customUserAgent: Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["getAmplifyUserAgent"])()
|
|
29685
|
-
});
|
|
29686
|
-
command = new _aws_sdk_client_location__WEBPACK_IMPORTED_MODULE_2__["SearchPlaceIndexForSuggestionsCommand"](locationServiceInput);
|
|
29687
|
-
_a.label = 2;
|
|
29688
|
-
|
|
29689
|
-
case 2:
|
|
29690
|
-
_a.trys.push([2, 4,, 5]);
|
|
29691
|
-
|
|
29692
|
-
return [4
|
|
29693
|
-
/*yield*/
|
|
29694
|
-
, client.send(command)];
|
|
29695
|
-
|
|
29696
|
-
case 3:
|
|
29697
|
-
response = _a.sent();
|
|
29698
|
-
return [3
|
|
29699
|
-
/*break*/
|
|
29700
|
-
, 5];
|
|
29701
|
-
|
|
29702
|
-
case 4:
|
|
29703
|
-
error_2 = _a.sent();
|
|
29704
|
-
logger.debug(error_2);
|
|
29705
|
-
throw error_2;
|
|
29706
|
-
|
|
29707
|
-
case 5:
|
|
29708
|
-
results = response.Results.map(function (result) {
|
|
29709
|
-
return result.Text;
|
|
29710
|
-
});
|
|
29711
|
-
return [2
|
|
29712
|
-
/*return*/
|
|
29713
|
-
, results];
|
|
29714
|
-
}
|
|
29715
|
-
});
|
|
29716
|
-
});
|
|
29717
|
-
};
|
|
29718
29581
|
/**
|
|
29719
29582
|
* Reverse geocoding search via a coordinate point on the map
|
|
29720
29583
|
* @param coordinates - Coordinates array for the search input
|
|
@@ -29725,7 +29588,7 @@ function () {
|
|
|
29725
29588
|
|
|
29726
29589
|
AmazonLocationServiceProvider.prototype.searchByCoordinates = function (coordinates, options) {
|
|
29727
29590
|
return __awaiter(this, void 0, void 0, function () {
|
|
29728
|
-
var credentialsOK, locationServiceInput, client, command, response,
|
|
29591
|
+
var credentialsOK, locationServiceInput, client, command, response, error_2, PascalResults, results;
|
|
29729
29592
|
return __generator(this, function (_a) {
|
|
29730
29593
|
switch (_a.label) {
|
|
29731
29594
|
case 0:
|
|
@@ -29777,9 +29640,9 @@ function () {
|
|
|
29777
29640
|
, 5];
|
|
29778
29641
|
|
|
29779
29642
|
case 4:
|
|
29780
|
-
|
|
29781
|
-
logger.debug(
|
|
29782
|
-
throw
|
|
29643
|
+
error_2 = _a.sent();
|
|
29644
|
+
logger.debug(error_2);
|
|
29645
|
+
throw error_2;
|
|
29783
29646
|
|
|
29784
29647
|
case 5:
|
|
29785
29648
|
PascalResults = response.Results.map(function (result) {
|
|
@@ -29807,13 +29670,17 @@ function () {
|
|
|
29807
29670
|
|
|
29808
29671
|
AmazonLocationServiceProvider.prototype.saveGeofences = function (geofences, options) {
|
|
29809
29672
|
return __awaiter(this, void 0, void 0, function () {
|
|
29810
|
-
var credentialsOK, PascalGeofences, results,
|
|
29673
|
+
var credentialsOK, PascalGeofences, results, geofenceBatches, apiLimit;
|
|
29811
29674
|
|
|
29812
29675
|
var _this = this;
|
|
29813
29676
|
|
|
29814
29677
|
return __generator(this, function (_a) {
|
|
29815
29678
|
switch (_a.label) {
|
|
29816
29679
|
case 0:
|
|
29680
|
+
if (geofences.length < 1) {
|
|
29681
|
+
throw new Error('Geofence input array is empty');
|
|
29682
|
+
}
|
|
29683
|
+
|
|
29817
29684
|
return [4
|
|
29818
29685
|
/*yield*/
|
|
29819
29686
|
, this._ensureCredentials()];
|
|
@@ -29848,18 +29715,18 @@ function () {
|
|
|
29848
29715
|
successes: [],
|
|
29849
29716
|
errors: []
|
|
29850
29717
|
};
|
|
29851
|
-
|
|
29718
|
+
geofenceBatches = [];
|
|
29852
29719
|
|
|
29853
29720
|
while (PascalGeofences.length > 0) {
|
|
29854
|
-
|
|
29855
|
-
|
|
29721
|
+
apiLimit = 10;
|
|
29722
|
+
geofenceBatches.push(PascalGeofences.splice(0, apiLimit));
|
|
29856
29723
|
}
|
|
29857
29724
|
|
|
29858
29725
|
return [4
|
|
29859
29726
|
/*yield*/
|
|
29860
|
-
, Promise.all(
|
|
29727
|
+
, Promise.all(geofenceBatches.map(function (batch) {
|
|
29861
29728
|
return __awaiter(_this, void 0, void 0, function () {
|
|
29862
|
-
var response,
|
|
29729
|
+
var response, error_3;
|
|
29863
29730
|
return __generator(this, function (_a) {
|
|
29864
29731
|
switch (_a.label) {
|
|
29865
29732
|
case 0:
|
|
@@ -29876,14 +29743,14 @@ function () {
|
|
|
29876
29743
|
, 3];
|
|
29877
29744
|
|
|
29878
29745
|
case 2:
|
|
29879
|
-
|
|
29746
|
+
error_3 = _a.sent(); // If the API call fails, add the geofences to the errors array and move to next batch
|
|
29880
29747
|
|
|
29881
29748
|
batch.forEach(function (geofence) {
|
|
29882
29749
|
results.errors.push({
|
|
29883
29750
|
geofenceId: geofence.GeofenceId,
|
|
29884
29751
|
error: {
|
|
29885
29752
|
code: 'APIConnectionError',
|
|
29886
|
-
message:
|
|
29753
|
+
message: error_3.message
|
|
29887
29754
|
}
|
|
29888
29755
|
});
|
|
29889
29756
|
});
|
|
@@ -29945,7 +29812,7 @@ function () {
|
|
|
29945
29812
|
|
|
29946
29813
|
AmazonLocationServiceProvider.prototype.getGeofence = function (geofenceId, options) {
|
|
29947
29814
|
return __awaiter(this, void 0, void 0, function () {
|
|
29948
|
-
var credentialsOK, client, commandInput, command, response,
|
|
29815
|
+
var credentialsOK, client, commandInput, command, response, error_4, GeofenceId, CreateTime, UpdateTime, Status, Geometry, geofence;
|
|
29949
29816
|
return __generator(this, function (_a) {
|
|
29950
29817
|
switch (_a.label) {
|
|
29951
29818
|
case 0:
|
|
@@ -29995,9 +29862,9 @@ function () {
|
|
|
29995
29862
|
, 5];
|
|
29996
29863
|
|
|
29997
29864
|
case 4:
|
|
29998
|
-
|
|
29999
|
-
logger.debug(
|
|
30000
|
-
throw
|
|
29865
|
+
error_4 = _a.sent();
|
|
29866
|
+
logger.debug(error_4);
|
|
29867
|
+
throw error_4;
|
|
30001
29868
|
|
|
30002
29869
|
case 5:
|
|
30003
29870
|
GeofenceId = response.GeofenceId, CreateTime = response.CreateTime, UpdateTime = response.UpdateTime, Status = response.Status, Geometry = response.Geometry;
|
|
@@ -30028,7 +29895,7 @@ function () {
|
|
|
30028
29895
|
|
|
30029
29896
|
AmazonLocationServiceProvider.prototype.listGeofences = function (options) {
|
|
30030
29897
|
return __awaiter(this, void 0, void 0, function () {
|
|
30031
|
-
var credentialsOK, client, listGeofencesInput, command, response,
|
|
29898
|
+
var credentialsOK, client, listGeofencesInput, command, response, error_5, NextToken, Entries, results;
|
|
30032
29899
|
return __generator(this, function (_a) {
|
|
30033
29900
|
switch (_a.label) {
|
|
30034
29901
|
case 0:
|
|
@@ -30077,9 +29944,9 @@ function () {
|
|
|
30077
29944
|
, 5];
|
|
30078
29945
|
|
|
30079
29946
|
case 4:
|
|
30080
|
-
|
|
30081
|
-
logger.debug(
|
|
30082
|
-
throw
|
|
29947
|
+
error_5 = _a.sent();
|
|
29948
|
+
logger.debug(error_5);
|
|
29949
|
+
throw error_5;
|
|
30083
29950
|
|
|
30084
29951
|
case 5:
|
|
30085
29952
|
NextToken = response.NextToken, Entries = response.Entries;
|
|
@@ -30121,13 +29988,17 @@ function () {
|
|
|
30121
29988
|
|
|
30122
29989
|
AmazonLocationServiceProvider.prototype.deleteGeofences = function (geofenceIds, options) {
|
|
30123
29990
|
return __awaiter(this, void 0, void 0, function () {
|
|
30124
|
-
var credentialsOK, badGeofenceIds, results,
|
|
29991
|
+
var credentialsOK, badGeofenceIds, results, geofenceIdBatches, count;
|
|
30125
29992
|
|
|
30126
29993
|
var _this = this;
|
|
30127
29994
|
|
|
30128
29995
|
return __generator(this, function (_a) {
|
|
30129
29996
|
switch (_a.label) {
|
|
30130
29997
|
case 0:
|
|
29998
|
+
if (geofenceIds.length < 1) {
|
|
29999
|
+
throw new Error('GeofenceId input array is empty');
|
|
30000
|
+
}
|
|
30001
|
+
|
|
30131
30002
|
return [4
|
|
30132
30003
|
/*yield*/
|
|
30133
30004
|
, this._ensureCredentials()];
|
|
@@ -30157,18 +30028,18 @@ function () {
|
|
|
30157
30028
|
successes: [],
|
|
30158
30029
|
errors: []
|
|
30159
30030
|
};
|
|
30160
|
-
|
|
30031
|
+
geofenceIdBatches = [];
|
|
30161
30032
|
count = 0;
|
|
30162
30033
|
|
|
30163
30034
|
while (count < geofenceIds.length) {
|
|
30164
|
-
|
|
30035
|
+
geofenceIdBatches.push(geofenceIds.slice(count, count += 10));
|
|
30165
30036
|
}
|
|
30166
30037
|
|
|
30167
30038
|
return [4
|
|
30168
30039
|
/*yield*/
|
|
30169
|
-
, Promise.all(
|
|
30040
|
+
, Promise.all(geofenceIdBatches.map(function (batch) {
|
|
30170
30041
|
return __awaiter(_this, void 0, void 0, function () {
|
|
30171
|
-
var response,
|
|
30042
|
+
var response, error_6, badGeofenceIds;
|
|
30172
30043
|
|
|
30173
30044
|
var _a;
|
|
30174
30045
|
|
|
@@ -30188,14 +30059,14 @@ function () {
|
|
|
30188
30059
|
, 3];
|
|
30189
30060
|
|
|
30190
30061
|
case 2:
|
|
30191
|
-
|
|
30062
|
+
error_6 = _b.sent(); // If the API call fails, add the geofences to the errors array and move to next batch
|
|
30192
30063
|
|
|
30193
30064
|
batch.forEach(function (geofenceId) {
|
|
30194
30065
|
var errorObject = {
|
|
30195
30066
|
geofenceId: geofenceId,
|
|
30196
30067
|
error: {
|
|
30197
|
-
code:
|
|
30198
|
-
message:
|
|
30068
|
+
code: error_6.message,
|
|
30069
|
+
message: error_6.message
|
|
30199
30070
|
}
|
|
30200
30071
|
};
|
|
30201
30072
|
results.errors.push(errorObject);
|
|
@@ -30239,7 +30110,7 @@ function () {
|
|
|
30239
30110
|
|
|
30240
30111
|
AmazonLocationServiceProvider.prototype._ensureCredentials = function () {
|
|
30241
30112
|
return __awaiter(this, void 0, void 0, function () {
|
|
30242
|
-
var credentials, cred,
|
|
30113
|
+
var credentials, cred, error_7;
|
|
30243
30114
|
return __generator(this, function (_a) {
|
|
30244
30115
|
switch (_a.label) {
|
|
30245
30116
|
case 0:
|
|
@@ -30262,8 +30133,8 @@ function () {
|
|
|
30262
30133
|
, true];
|
|
30263
30134
|
|
|
30264
30135
|
case 2:
|
|
30265
|
-
|
|
30266
|
-
logger.debug('Ensure credentials error. Credentials are:',
|
|
30136
|
+
error_7 = _a.sent();
|
|
30137
|
+
logger.debug('Ensure credentials error. Credentials are:', error_7);
|
|
30267
30138
|
return [2
|
|
30268
30139
|
/*return*/
|
|
30269
30140
|
, false];
|
|
@@ -30309,7 +30180,7 @@ function () {
|
|
|
30309
30180
|
|
|
30310
30181
|
AmazonLocationServiceProvider.prototype._AmazonLocationServiceBatchPutGeofenceCall = function (PascalGeofences, collectionName) {
|
|
30311
30182
|
return __awaiter(this, void 0, void 0, function () {
|
|
30312
|
-
var geofenceInput, client, command, response,
|
|
30183
|
+
var geofenceInput, client, command, response, error_8;
|
|
30313
30184
|
return __generator(this, function (_a) {
|
|
30314
30185
|
switch (_a.label) {
|
|
30315
30186
|
case 0:
|
|
@@ -30339,8 +30210,8 @@ function () {
|
|
|
30339
30210
|
, 4];
|
|
30340
30211
|
|
|
30341
30212
|
case 3:
|
|
30342
|
-
|
|
30343
|
-
throw
|
|
30213
|
+
error_8 = _a.sent();
|
|
30214
|
+
throw error_8;
|
|
30344
30215
|
|
|
30345
30216
|
case 4:
|
|
30346
30217
|
return [2
|
|
@@ -30353,7 +30224,7 @@ function () {
|
|
|
30353
30224
|
|
|
30354
30225
|
AmazonLocationServiceProvider.prototype._AmazonLocationServiceBatchDeleteGeofenceCall = function (geofenceIds, collectionName) {
|
|
30355
30226
|
return __awaiter(this, void 0, void 0, function () {
|
|
30356
|
-
var deleteGeofencesInput, client, command, response,
|
|
30227
|
+
var deleteGeofencesInput, client, command, response, error_9;
|
|
30357
30228
|
return __generator(this, function (_a) {
|
|
30358
30229
|
switch (_a.label) {
|
|
30359
30230
|
case 0:
|
|
@@ -30383,8 +30254,8 @@ function () {
|
|
|
30383
30254
|
, 4];
|
|
30384
30255
|
|
|
30385
30256
|
case 3:
|
|
30386
|
-
|
|
30387
|
-
throw
|
|
30257
|
+
error_9 = _a.sent();
|
|
30258
|
+
throw error_9;
|
|
30388
30259
|
|
|
30389
30260
|
case 4:
|
|
30390
30261
|
return [2
|
|
@@ -30481,9 +30352,9 @@ function validateCoordinates(lng, lat) {
|
|
|
30481
30352
|
throw new Error("Invalid coordinates: [" + lng + "," + lat + "]");
|
|
30482
30353
|
}
|
|
30483
30354
|
|
|
30484
|
-
if (lat < -90 ||
|
|
30355
|
+
if (lat < -90 || 90 < lat) {
|
|
30485
30356
|
throw new Error('Latitude must be between -90 and 90 degrees inclusive.');
|
|
30486
|
-
} else if (lng < -180 ||
|
|
30357
|
+
} else if (lng < -180 || 180 < lng) {
|
|
30487
30358
|
throw new Error('Longitude must be between -180 and 180 degrees inclusive.');
|
|
30488
30359
|
}
|
|
30489
30360
|
}
|
|
@@ -30495,9 +30366,10 @@ function validateGeofenceId(geofenceId) {
|
|
|
30495
30366
|
}
|
|
30496
30367
|
}
|
|
30497
30368
|
function validateLinearRing(linearRing, geofenceId) {
|
|
30498
|
-
// Validate LinearRing size, must be at least 4 points
|
|
30369
|
+
var errorPrefix = geofenceId ? geofenceId + ": " : ''; // Validate LinearRing size, must be at least 4 points
|
|
30370
|
+
|
|
30499
30371
|
if (linearRing.length < 4) {
|
|
30500
|
-
throw new Error(
|
|
30372
|
+
throw new Error(errorPrefix + "LinearRing must contain 4 or more coordinates.");
|
|
30501
30373
|
} // Validate all coordinates are valid, error with which ones are bad
|
|
30502
30374
|
|
|
30503
30375
|
|
|
@@ -30514,7 +30386,7 @@ function validateLinearRing(linearRing, geofenceId) {
|
|
|
30514
30386
|
});
|
|
30515
30387
|
|
|
30516
30388
|
if (badCoordinates.length > 0) {
|
|
30517
|
-
throw new Error(
|
|
30389
|
+
throw new Error(errorPrefix + "One or more of the coordinates in the Polygon LinearRing are not valid: " + JSON.stringify(badCoordinates));
|
|
30518
30390
|
} // Validate first and last coordinates are the same
|
|
30519
30391
|
|
|
30520
30392
|
|
|
@@ -30527,24 +30399,26 @@ function validateLinearRing(linearRing, geofenceId) {
|
|
|
30527
30399
|
latB = _b[1];
|
|
30528
30400
|
|
|
30529
30401
|
if (lngA !== lngB || latA !== latB) {
|
|
30530
|
-
throw new Error(
|
|
30402
|
+
throw new Error(errorPrefix + "LinearRing's first and last coordinates are not the same");
|
|
30531
30403
|
}
|
|
30532
30404
|
|
|
30533
30405
|
if (Object(_turf_boolean_clockwise__WEBPACK_IMPORTED_MODULE_0__["default"])(linearRing)) {
|
|
30534
|
-
throw new Error(
|
|
30406
|
+
throw new Error(errorPrefix + "LinearRing coordinates must be wound counterclockwise");
|
|
30535
30407
|
}
|
|
30536
30408
|
}
|
|
30537
30409
|
function validatePolygon(polygon, geofenceId) {
|
|
30410
|
+
var errorPrefix = geofenceId ? geofenceId + ": " : '';
|
|
30411
|
+
|
|
30538
30412
|
if (!Array.isArray(polygon)) {
|
|
30539
|
-
throw new Error(
|
|
30413
|
+
throw new Error(errorPrefix + "Polygon is of incorrect structure. It should be an array of LinearRings");
|
|
30540
30414
|
}
|
|
30541
30415
|
|
|
30542
30416
|
if (polygon.length < 1) {
|
|
30543
|
-
throw new Error(
|
|
30417
|
+
throw new Error(errorPrefix + "Polygon must have a single LinearRing array.");
|
|
30544
30418
|
}
|
|
30545
30419
|
|
|
30546
30420
|
if (polygon.length > 1) {
|
|
30547
|
-
throw new Error(
|
|
30421
|
+
throw new Error(errorPrefix + "Polygon must have a single LinearRing array. Note: We do not currently support polygons with holes, multipolygons, polygons that are wound clockwise, or that cross the antimeridian.");
|
|
30548
30422
|
}
|
|
30549
30423
|
|
|
30550
30424
|
var verticesCount = polygon.reduce(function (prev, linearRing) {
|
|
@@ -30552,8 +30426,12 @@ function validatePolygon(polygon, geofenceId) {
|
|
|
30552
30426
|
}, 0);
|
|
30553
30427
|
|
|
30554
30428
|
if (verticesCount > 1000) {
|
|
30555
|
-
throw new Error(
|
|
30429
|
+
throw new Error(errorPrefix + "Polygon has more than the maximum 1000 vertices.");
|
|
30556
30430
|
}
|
|
30431
|
+
|
|
30432
|
+
polygon.forEach(function (linearRing) {
|
|
30433
|
+
validateLinearRing(linearRing, geofenceId);
|
|
30434
|
+
});
|
|
30557
30435
|
}
|
|
30558
30436
|
function validateGeofencesInput(geofences) {
|
|
30559
30437
|
var geofenceIds = {};
|
|
@@ -30589,7 +30467,7 @@ function validateGeofencesInput(geofences) {
|
|
|
30589
30467
|
try {
|
|
30590
30468
|
validatePolygon(polygon, geofenceId);
|
|
30591
30469
|
} catch (error) {
|
|
30592
|
-
if (error.message
|
|
30470
|
+
if (error.message.includes('Polygon has more than the maximum 1000 vertices.')) {
|
|
30593
30471
|
throw new Error("Geofence '" + geofenceId + "' has more than the maximum of 1000 vertices");
|
|
30594
30472
|
}
|
|
30595
30473
|
} // Validate LinearRing length, structure, and coordinates
|