@aws-amplify/geo 1.1.10 → 1.1.11-geo.6
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 +1175 -36
- package/dist/aws-amplify-geo.js.map +1 -1
- package/dist/aws-amplify-geo.min.js +7 -7
- package/dist/aws-amplify-geo.min.js.map +1 -1
- package/lib/Geo.d.ts +45 -3
- package/lib/Geo.js +214 -5
- package/lib/Geo.js.map +1 -1
- package/lib/Providers/AmazonLocationServiceProvider.d.ts +47 -1
- package/lib/Providers/AmazonLocationServiceProvider.js +455 -6
- package/lib/Providers/AmazonLocationServiceProvider.js.map +1 -1
- package/lib/types/AmazonLocationServiceProvider.d.ts +21 -1
- package/lib/types/Geo.d.ts +48 -1
- package/lib/types/Provider.d.ts +6 -1
- package/lib/types/Provider.js +0 -12
- package/lib/types/Provider.js.map +1 -1
- package/lib/util.d.ts +6 -0
- package/lib/util.js +163 -0
- package/lib/util.js.map +1 -0
- package/lib-esm/Geo.d.ts +45 -3
- package/lib-esm/Geo.js +214 -5
- package/lib-esm/Geo.js.map +1 -1
- package/lib-esm/Providers/AmazonLocationServiceProvider.d.ts +47 -1
- package/lib-esm/Providers/AmazonLocationServiceProvider.js +456 -7
- package/lib-esm/Providers/AmazonLocationServiceProvider.js.map +1 -1
- package/lib-esm/types/AmazonLocationServiceProvider.d.ts +21 -1
- package/lib-esm/types/Geo.d.ts +48 -1
- package/lib-esm/types/Provider.d.ts +6 -1
- package/lib-esm/types/Provider.js +0 -12
- package/lib-esm/types/Provider.js.map +1 -1
- package/lib-esm/util.d.ts +6 -0
- package/lib-esm/util.js +156 -0
- package/lib-esm/util.js.map +1 -0
- package/package.json +3 -3
- package/src/Geo.ts +183 -2
- package/src/Providers/AmazonLocationServiceProvider.ts +478 -7
- package/src/types/AmazonLocationServiceProvider.ts +56 -1
- package/src/types/Geo.ts +73 -2
- package/src/types/Provider.ts +36 -1
- package/src/util.ts +182 -0
- package/lib/types/AmazonLocationServicesProvider.d.ts +0 -4
- package/lib/types/AmazonLocationServicesProvider.js +0 -3
- package/lib/types/AmazonLocationServicesProvider.js.map +0 -1
- package/lib-esm/types/AmazonLocationServicesProvider.d.ts +0 -4
- package/lib-esm/types/AmazonLocationServicesProvider.js +0 -1
- package/lib-esm/types/AmazonLocationServicesProvider.js.map +0 -1
- package/src/types/AmazonLocationServicesProvider.ts +0 -5
package/dist/aws-amplify-geo.js
CHANGED
|
@@ -26465,6 +26465,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
26465
26465
|
/* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
|
|
26466
26466
|
/* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__);
|
|
26467
26467
|
/* harmony import */ var _Providers_AmazonLocationServiceProvider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Providers/AmazonLocationServiceProvider */ "./lib-esm/Providers/AmazonLocationServiceProvider.js");
|
|
26468
|
+
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./util */ "./lib-esm/util.js");
|
|
26468
26469
|
var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
26469
26470
|
function adopt(value) {
|
|
26470
26471
|
return value instanceof P ? value : new P(function (resolve) {
|
|
@@ -26607,6 +26608,33 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
26607
26608
|
};
|
|
26608
26609
|
}
|
|
26609
26610
|
};
|
|
26611
|
+
|
|
26612
|
+
var __read = undefined && undefined.__read || function (o, n) {
|
|
26613
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
26614
|
+
if (!m) return o;
|
|
26615
|
+
var i = m.call(o),
|
|
26616
|
+
r,
|
|
26617
|
+
ar = [],
|
|
26618
|
+
e;
|
|
26619
|
+
|
|
26620
|
+
try {
|
|
26621
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
|
|
26622
|
+
ar.push(r.value);
|
|
26623
|
+
}
|
|
26624
|
+
} catch (error) {
|
|
26625
|
+
e = {
|
|
26626
|
+
error: error
|
|
26627
|
+
};
|
|
26628
|
+
} finally {
|
|
26629
|
+
try {
|
|
26630
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
26631
|
+
} finally {
|
|
26632
|
+
if (e) throw e.error;
|
|
26633
|
+
}
|
|
26634
|
+
}
|
|
26635
|
+
|
|
26636
|
+
return ar;
|
|
26637
|
+
};
|
|
26610
26638
|
/*
|
|
26611
26639
|
* Copyright 2017-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
26612
26640
|
*
|
|
@@ -26623,6 +26651,7 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
26623
26651
|
|
|
26624
26652
|
|
|
26625
26653
|
|
|
26654
|
+
|
|
26626
26655
|
var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["ConsoleLogger"]('Geo');
|
|
26627
26656
|
var DEFAULT_PROVIDER = 'AmazonLocationService';
|
|
26628
26657
|
|
|
@@ -26794,13 +26823,131 @@ function () {
|
|
|
26794
26823
|
|
|
26795
26824
|
GeoClass.prototype.searchByCoordinates = function (coordinates, options) {
|
|
26796
26825
|
return __awaiter(this, void 0, void 0, function () {
|
|
26797
|
-
var _a, providerName, prov, error_2;
|
|
26826
|
+
var _a, providerName, prov, _b, lng, lat, error_2;
|
|
26827
|
+
|
|
26828
|
+
return __generator(this, function (_c) {
|
|
26829
|
+
switch (_c.label) {
|
|
26830
|
+
case 0:
|
|
26831
|
+
_a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
|
|
26832
|
+
prov = this.getPluggable(providerName);
|
|
26833
|
+
_b = __read(coordinates, 2), lng = _b[0], lat = _b[1];
|
|
26834
|
+
_c.label = 1;
|
|
26835
|
+
|
|
26836
|
+
case 1:
|
|
26837
|
+
_c.trys.push([1, 3,, 4]);
|
|
26838
|
+
|
|
26839
|
+
Object(_util__WEBPACK_IMPORTED_MODULE_2__["validateCoordinates"])(lng, lat);
|
|
26840
|
+
return [4
|
|
26841
|
+
/*yield*/
|
|
26842
|
+
, prov.searchByCoordinates(coordinates, options)];
|
|
26843
|
+
|
|
26844
|
+
case 2:
|
|
26845
|
+
return [2
|
|
26846
|
+
/*return*/
|
|
26847
|
+
, _c.sent()];
|
|
26848
|
+
|
|
26849
|
+
case 3:
|
|
26850
|
+
error_2 = _c.sent();
|
|
26851
|
+
logger.debug(error_2);
|
|
26852
|
+
throw error_2;
|
|
26853
|
+
|
|
26854
|
+
case 4:
|
|
26855
|
+
return [2
|
|
26856
|
+
/*return*/
|
|
26857
|
+
];
|
|
26858
|
+
}
|
|
26859
|
+
});
|
|
26860
|
+
});
|
|
26861
|
+
};
|
|
26862
|
+
/**
|
|
26863
|
+
* Create geofences
|
|
26864
|
+
* @param geofences - Single or array of geofence objects to create
|
|
26865
|
+
* @param options? - Optional parameters for creating geofences
|
|
26866
|
+
* @returns {Promise<CreateUpdateGeofenceResults>} - Promise that resolves to an object with:
|
|
26867
|
+
* successes: list of geofences successfully created
|
|
26868
|
+
* errors: list of geofences that failed to create
|
|
26869
|
+
*/
|
|
26870
|
+
|
|
26871
|
+
|
|
26872
|
+
GeoClass.prototype.createGeofences = function (geofences, options) {
|
|
26873
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
26874
|
+
var _a, providerName, prov, geofenceInputArray, error_3;
|
|
26875
|
+
|
|
26876
|
+
return __generator(this, function (_b) {
|
|
26877
|
+
switch (_b.label) {
|
|
26878
|
+
case 0:
|
|
26879
|
+
_a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
|
|
26880
|
+
prov = this.getPluggable(providerName);
|
|
26881
|
+
|
|
26882
|
+
if (!Array.isArray(geofences)) {
|
|
26883
|
+
geofenceInputArray = [geofences];
|
|
26884
|
+
} else {
|
|
26885
|
+
geofenceInputArray = geofences;
|
|
26886
|
+
}
|
|
26887
|
+
|
|
26888
|
+
_b.label = 1;
|
|
26889
|
+
|
|
26890
|
+
case 1:
|
|
26891
|
+
_b.trys.push([1, 3,, 4]); // Validate all geofences are unique and valid before calling Provider
|
|
26892
|
+
|
|
26893
|
+
|
|
26894
|
+
Object(_util__WEBPACK_IMPORTED_MODULE_2__["validateGeofences"])(geofenceInputArray);
|
|
26895
|
+
return [4
|
|
26896
|
+
/*yield*/
|
|
26897
|
+
, prov.createGeofences(geofenceInputArray, options)];
|
|
26898
|
+
|
|
26899
|
+
case 2:
|
|
26900
|
+
return [2
|
|
26901
|
+
/*return*/
|
|
26902
|
+
, _b.sent()];
|
|
26903
|
+
|
|
26904
|
+
case 3:
|
|
26905
|
+
error_3 = _b.sent();
|
|
26906
|
+
logger.debug(error_3);
|
|
26907
|
+
throw error_3;
|
|
26908
|
+
|
|
26909
|
+
case 4:
|
|
26910
|
+
return [2
|
|
26911
|
+
/*return*/
|
|
26912
|
+
];
|
|
26913
|
+
}
|
|
26914
|
+
});
|
|
26915
|
+
});
|
|
26916
|
+
};
|
|
26917
|
+
/**
|
|
26918
|
+
* Update geofences
|
|
26919
|
+
* @param geofences - Single or array of geofence objects to create
|
|
26920
|
+
* @param options? - Optional parameters for creating geofences
|
|
26921
|
+
* @returns {Promise<CreateUpdateGeofenceResults>} - Promise that resolves to an object with:
|
|
26922
|
+
* successes: list of geofences successfully created
|
|
26923
|
+
* errors: list of geofences that failed to create
|
|
26924
|
+
*/
|
|
26925
|
+
|
|
26926
|
+
|
|
26927
|
+
GeoClass.prototype.updateGeofences = function (geofences, options) {
|
|
26928
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
26929
|
+
var _a, providerName, prov, geofenceInputArray, error_4;
|
|
26798
26930
|
|
|
26799
26931
|
return __generator(this, function (_b) {
|
|
26800
26932
|
switch (_b.label) {
|
|
26801
26933
|
case 0:
|
|
26802
26934
|
_a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
|
|
26803
26935
|
prov = this.getPluggable(providerName);
|
|
26936
|
+
|
|
26937
|
+
if (!Array.isArray(geofences)) {
|
|
26938
|
+
geofenceInputArray = [geofences];
|
|
26939
|
+
} else {
|
|
26940
|
+
geofenceInputArray = geofences;
|
|
26941
|
+
} // Validate all geofences are unique and valid
|
|
26942
|
+
|
|
26943
|
+
|
|
26944
|
+
try {
|
|
26945
|
+
Object(_util__WEBPACK_IMPORTED_MODULE_2__["validateGeofences"])(geofenceInputArray);
|
|
26946
|
+
} catch (error) {
|
|
26947
|
+
logger.debug(error);
|
|
26948
|
+
throw error;
|
|
26949
|
+
}
|
|
26950
|
+
|
|
26804
26951
|
_b.label = 1;
|
|
26805
26952
|
|
|
26806
26953
|
case 1:
|
|
@@ -26808,7 +26955,7 @@ function () {
|
|
|
26808
26955
|
|
|
26809
26956
|
return [4
|
|
26810
26957
|
/*yield*/
|
|
26811
|
-
, prov.
|
|
26958
|
+
, prov.updateGeofences(geofenceInputArray, options)];
|
|
26812
26959
|
|
|
26813
26960
|
case 2:
|
|
26814
26961
|
return [2
|
|
@@ -26816,9 +26963,167 @@ function () {
|
|
|
26816
26963
|
, _b.sent()];
|
|
26817
26964
|
|
|
26818
26965
|
case 3:
|
|
26819
|
-
|
|
26820
|
-
logger.debug(
|
|
26821
|
-
throw
|
|
26966
|
+
error_4 = _b.sent();
|
|
26967
|
+
logger.debug(error_4);
|
|
26968
|
+
throw error_4;
|
|
26969
|
+
|
|
26970
|
+
case 4:
|
|
26971
|
+
return [2
|
|
26972
|
+
/*return*/
|
|
26973
|
+
];
|
|
26974
|
+
}
|
|
26975
|
+
});
|
|
26976
|
+
});
|
|
26977
|
+
};
|
|
26978
|
+
/**
|
|
26979
|
+
* Get a single geofence by geofenceId
|
|
26980
|
+
* @param geofenceId: string
|
|
26981
|
+
* @param options?: GeofenceOptions
|
|
26982
|
+
* @returns Promise<Geofence> - Promise that resolves to a geofence object
|
|
26983
|
+
*/
|
|
26984
|
+
|
|
26985
|
+
|
|
26986
|
+
GeoClass.prototype.getGeofence = function (geofenceId, options) {
|
|
26987
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
26988
|
+
var _a, providerName, prov, error_5;
|
|
26989
|
+
|
|
26990
|
+
return __generator(this, function (_b) {
|
|
26991
|
+
switch (_b.label) {
|
|
26992
|
+
case 0:
|
|
26993
|
+
_a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
|
|
26994
|
+
prov = this.getPluggable(providerName);
|
|
26995
|
+
_b.label = 1;
|
|
26996
|
+
|
|
26997
|
+
case 1:
|
|
26998
|
+
_b.trys.push([1, 3,, 4]); // Validate geofenceId is valid before calling Provider
|
|
26999
|
+
|
|
27000
|
+
|
|
27001
|
+
Object(_util__WEBPACK_IMPORTED_MODULE_2__["validateGeofenceId"])(geofenceId);
|
|
27002
|
+
return [4
|
|
27003
|
+
/*yield*/
|
|
27004
|
+
, prov.getGeofence(geofenceId, options)];
|
|
27005
|
+
|
|
27006
|
+
case 2:
|
|
27007
|
+
return [2
|
|
27008
|
+
/*return*/
|
|
27009
|
+
, _b.sent()];
|
|
27010
|
+
|
|
27011
|
+
case 3:
|
|
27012
|
+
error_5 = _b.sent();
|
|
27013
|
+
logger.debug(error_5);
|
|
27014
|
+
throw error_5;
|
|
27015
|
+
|
|
27016
|
+
case 4:
|
|
27017
|
+
return [2
|
|
27018
|
+
/*return*/
|
|
27019
|
+
];
|
|
27020
|
+
}
|
|
27021
|
+
});
|
|
27022
|
+
});
|
|
27023
|
+
};
|
|
27024
|
+
/**
|
|
27025
|
+
* List geofences
|
|
27026
|
+
* @param options?: ListGeofenceOptions
|
|
27027
|
+
* @returns {Promise<ListGeofencesResults>} - Promise that resolves to an object with:
|
|
27028
|
+
* entries: list of geofences - 100 geofences are listed per page
|
|
27029
|
+
* nextToken: token for next page of geofences
|
|
27030
|
+
*/
|
|
27031
|
+
|
|
27032
|
+
|
|
27033
|
+
GeoClass.prototype.listGeofences = function (options) {
|
|
27034
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
27035
|
+
var _a, providerName, prov, error_6;
|
|
27036
|
+
|
|
27037
|
+
return __generator(this, function (_b) {
|
|
27038
|
+
switch (_b.label) {
|
|
27039
|
+
case 0:
|
|
27040
|
+
_a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
|
|
27041
|
+
prov = this.getPluggable(providerName);
|
|
27042
|
+
_b.label = 1;
|
|
27043
|
+
|
|
27044
|
+
case 1:
|
|
27045
|
+
_b.trys.push([1, 3,, 4]);
|
|
27046
|
+
|
|
27047
|
+
return [4
|
|
27048
|
+
/*yield*/
|
|
27049
|
+
, prov.listGeofences(options)];
|
|
27050
|
+
|
|
27051
|
+
case 2:
|
|
27052
|
+
return [2
|
|
27053
|
+
/*return*/
|
|
27054
|
+
, _b.sent()];
|
|
27055
|
+
|
|
27056
|
+
case 3:
|
|
27057
|
+
error_6 = _b.sent();
|
|
27058
|
+
logger.debug(error_6);
|
|
27059
|
+
throw error_6;
|
|
27060
|
+
|
|
27061
|
+
case 4:
|
|
27062
|
+
return [2
|
|
27063
|
+
/*return*/
|
|
27064
|
+
];
|
|
27065
|
+
}
|
|
27066
|
+
});
|
|
27067
|
+
});
|
|
27068
|
+
};
|
|
27069
|
+
/**
|
|
27070
|
+
* Delete geofences
|
|
27071
|
+
* @param geofenceIds: string|string[]
|
|
27072
|
+
* @param options?: GeofenceOptions
|
|
27073
|
+
* @returns {Promise<DeleteGeofencesResults>} - Promise that resolves to an object with:
|
|
27074
|
+
* successes: list of geofences successfully deleted
|
|
27075
|
+
* errors: list of geofences that failed to delete
|
|
27076
|
+
*/
|
|
27077
|
+
|
|
27078
|
+
|
|
27079
|
+
GeoClass.prototype.deleteGeofences = function (geofenceIds, options) {
|
|
27080
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
27081
|
+
var _a, providerName, prov, geofenceIdsInputArray, badGeofenceIds, errorString, error_7;
|
|
27082
|
+
|
|
27083
|
+
return __generator(this, function (_b) {
|
|
27084
|
+
switch (_b.label) {
|
|
27085
|
+
case 0:
|
|
27086
|
+
_a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
|
|
27087
|
+
prov = this.getPluggable(providerName);
|
|
27088
|
+
|
|
27089
|
+
if (!Array.isArray(geofenceIds)) {
|
|
27090
|
+
geofenceIdsInputArray = [geofenceIds];
|
|
27091
|
+
} else {
|
|
27092
|
+
geofenceIdsInputArray = geofenceIds;
|
|
27093
|
+
}
|
|
27094
|
+
|
|
27095
|
+
badGeofenceIds = geofenceIdsInputArray.filter(function (geofenceId) {
|
|
27096
|
+
try {
|
|
27097
|
+
Object(_util__WEBPACK_IMPORTED_MODULE_2__["validateGeofenceId"])(geofenceId);
|
|
27098
|
+
} catch (error) {
|
|
27099
|
+
return false;
|
|
27100
|
+
}
|
|
27101
|
+
});
|
|
27102
|
+
|
|
27103
|
+
if (badGeofenceIds.length > 0) {
|
|
27104
|
+
errorString = "Invalid geofence ids: " + badGeofenceIds;
|
|
27105
|
+
logger.debug(errorString);
|
|
27106
|
+
throw new Error(errorString);
|
|
27107
|
+
}
|
|
27108
|
+
|
|
27109
|
+
_b.label = 1;
|
|
27110
|
+
|
|
27111
|
+
case 1:
|
|
27112
|
+
_b.trys.push([1, 3,, 4]);
|
|
27113
|
+
|
|
27114
|
+
return [4
|
|
27115
|
+
/*yield*/
|
|
27116
|
+
, prov.deleteGeofences(geofenceIdsInputArray, options)];
|
|
27117
|
+
|
|
27118
|
+
case 2:
|
|
27119
|
+
return [2
|
|
27120
|
+
/*return*/
|
|
27121
|
+
, _b.sent()];
|
|
27122
|
+
|
|
27123
|
+
case 3:
|
|
27124
|
+
error_7 = _b.sent();
|
|
27125
|
+
logger.debug(error_7);
|
|
27126
|
+
throw error_7;
|
|
26822
27127
|
|
|
26823
27128
|
case 4:
|
|
26824
27129
|
return [2
|
|
@@ -26996,6 +27301,41 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
26996
27301
|
};
|
|
26997
27302
|
}
|
|
26998
27303
|
};
|
|
27304
|
+
|
|
27305
|
+
var __read = undefined && undefined.__read || function (o, n) {
|
|
27306
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
27307
|
+
if (!m) return o;
|
|
27308
|
+
var i = m.call(o),
|
|
27309
|
+
r,
|
|
27310
|
+
ar = [],
|
|
27311
|
+
e;
|
|
27312
|
+
|
|
27313
|
+
try {
|
|
27314
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
|
|
27315
|
+
ar.push(r.value);
|
|
27316
|
+
}
|
|
27317
|
+
} catch (error) {
|
|
27318
|
+
e = {
|
|
27319
|
+
error: error
|
|
27320
|
+
};
|
|
27321
|
+
} finally {
|
|
27322
|
+
try {
|
|
27323
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
27324
|
+
} finally {
|
|
27325
|
+
if (e) throw e.error;
|
|
27326
|
+
}
|
|
27327
|
+
}
|
|
27328
|
+
|
|
27329
|
+
return ar;
|
|
27330
|
+
};
|
|
27331
|
+
|
|
27332
|
+
var __spread = undefined && undefined.__spread || function () {
|
|
27333
|
+
for (var ar = [], i = 0; i < arguments.length; i++) {
|
|
27334
|
+
ar = ar.concat(__read(arguments[i]));
|
|
27335
|
+
}
|
|
27336
|
+
|
|
27337
|
+
return ar;
|
|
27338
|
+
};
|
|
26999
27339
|
/*
|
|
27000
27340
|
* Copyright 2017-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
27001
27341
|
*
|
|
@@ -27270,59 +27610,443 @@ function () {
|
|
|
27270
27610
|
});
|
|
27271
27611
|
};
|
|
27272
27612
|
/**
|
|
27273
|
-
*
|
|
27613
|
+
* Create geofences inside of a geofence collection
|
|
27614
|
+
* @param geofences - Array of geofence objects to create
|
|
27615
|
+
* @param options? - Optional parameters for creating geofences
|
|
27616
|
+
* @returns {Promise<AmazonLocationServiceCreateUpdateGeofenceResults>} - Promise that resolves to an object with:
|
|
27617
|
+
* successes: list of geofences successfully created
|
|
27618
|
+
* errors: list of geofences that failed to create
|
|
27274
27619
|
*/
|
|
27275
27620
|
|
|
27276
27621
|
|
|
27277
|
-
AmazonLocationServiceProvider.prototype.
|
|
27622
|
+
AmazonLocationServiceProvider.prototype.createGeofences = function (geofences, options) {
|
|
27278
27623
|
return __awaiter(this, void 0, void 0, function () {
|
|
27279
|
-
var
|
|
27624
|
+
var credentialsOK, results;
|
|
27280
27625
|
return __generator(this, function (_a) {
|
|
27281
27626
|
switch (_a.label) {
|
|
27282
27627
|
case 0:
|
|
27283
|
-
_a.trys.push([0, 2,, 3]);
|
|
27284
|
-
|
|
27285
27628
|
return [4
|
|
27286
27629
|
/*yield*/
|
|
27287
|
-
,
|
|
27630
|
+
, this._ensureCredentials()];
|
|
27288
27631
|
|
|
27289
27632
|
case 1:
|
|
27290
|
-
|
|
27291
|
-
if (!credentials) return [2
|
|
27292
|
-
/*return*/
|
|
27293
|
-
, false];
|
|
27294
|
-
cred = _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["Credentials"].shear(credentials);
|
|
27295
|
-
logger.debug('Set credentials for storage. Credentials are:', cred);
|
|
27296
|
-
this._config.credentials = cred;
|
|
27297
|
-
return [2
|
|
27298
|
-
/*return*/
|
|
27299
|
-
, true];
|
|
27633
|
+
credentialsOK = _a.sent();
|
|
27300
27634
|
|
|
27301
|
-
|
|
27302
|
-
|
|
27303
|
-
|
|
27304
|
-
return [2
|
|
27305
|
-
/*return*/
|
|
27306
|
-
, false];
|
|
27635
|
+
if (!credentialsOK) {
|
|
27636
|
+
throw new Error('No credentials');
|
|
27637
|
+
}
|
|
27307
27638
|
|
|
27308
|
-
|
|
27639
|
+
try {
|
|
27640
|
+
this._verifyGeofenceCollections(options === null || options === void 0 ? void 0 : options.collectionName);
|
|
27641
|
+
} catch (error) {
|
|
27642
|
+
logger.debug(error);
|
|
27643
|
+
throw error;
|
|
27644
|
+
}
|
|
27645
|
+
|
|
27646
|
+
return [4
|
|
27647
|
+
/*yield*/
|
|
27648
|
+
, this._batchPutGeofence(geofences, options)];
|
|
27649
|
+
|
|
27650
|
+
case 2:
|
|
27651
|
+
results = _a.sent();
|
|
27309
27652
|
return [2
|
|
27310
27653
|
/*return*/
|
|
27311
|
-
];
|
|
27654
|
+
, results];
|
|
27312
27655
|
}
|
|
27313
27656
|
});
|
|
27314
27657
|
});
|
|
27315
27658
|
};
|
|
27659
|
+
/**
|
|
27660
|
+
* Update geofences inside of a geofence collection
|
|
27661
|
+
* @param geofences - Array of geofence objects to create
|
|
27662
|
+
* @param options? - Optional parameters for creating geofences
|
|
27663
|
+
* @returns {Promise<AmazonLocationServiceCreateUpdateGeofenceResults>} - Promise that resolves to an object with:
|
|
27664
|
+
* successes: list of geofences successfully created
|
|
27665
|
+
* errors: list of geofences that failed to create
|
|
27666
|
+
*/
|
|
27316
27667
|
|
|
27317
|
-
|
|
27318
|
-
|
|
27319
|
-
|
|
27320
|
-
|
|
27321
|
-
|
|
27668
|
+
|
|
27669
|
+
AmazonLocationServiceProvider.prototype.updateGeofences = function (geofences, options) {
|
|
27670
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
27671
|
+
var credentialsOK, results;
|
|
27672
|
+
return __generator(this, function (_a) {
|
|
27673
|
+
switch (_a.label) {
|
|
27674
|
+
case 0:
|
|
27675
|
+
return [4
|
|
27676
|
+
/*yield*/
|
|
27677
|
+
, this._ensureCredentials()];
|
|
27678
|
+
|
|
27679
|
+
case 1:
|
|
27680
|
+
credentialsOK = _a.sent();
|
|
27681
|
+
|
|
27682
|
+
if (!credentialsOK) {
|
|
27683
|
+
throw new Error('No credentials');
|
|
27684
|
+
}
|
|
27685
|
+
|
|
27686
|
+
try {
|
|
27687
|
+
this._verifyGeofenceCollections(options === null || options === void 0 ? void 0 : options.collectionName);
|
|
27688
|
+
} catch (error) {
|
|
27689
|
+
logger.debug(error);
|
|
27690
|
+
throw error;
|
|
27691
|
+
}
|
|
27692
|
+
|
|
27693
|
+
return [4
|
|
27694
|
+
/*yield*/
|
|
27695
|
+
, this._batchPutGeofence(geofences, options)];
|
|
27696
|
+
|
|
27697
|
+
case 2:
|
|
27698
|
+
results = _a.sent();
|
|
27699
|
+
return [2
|
|
27700
|
+
/*return*/
|
|
27701
|
+
, results];
|
|
27702
|
+
}
|
|
27703
|
+
});
|
|
27704
|
+
});
|
|
27705
|
+
};
|
|
27706
|
+
/**
|
|
27707
|
+
* Get geofence from a geofence collection
|
|
27708
|
+
* @param geofenceId:string
|
|
27709
|
+
* @param options?: Optional parameters for getGeofence
|
|
27710
|
+
* @returns {Promise<AmazonLocationServiceGeofence>} - Promise that resolves to a geofence object
|
|
27711
|
+
*/
|
|
27712
|
+
|
|
27713
|
+
|
|
27714
|
+
AmazonLocationServiceProvider.prototype.getGeofence = function (geofenceId, options) {
|
|
27715
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
27716
|
+
var credentialsOK, client, commandInput, command, response, error_3, GeofenceId, CreateTime, UpdateTime, Status, Geometry, geofence;
|
|
27717
|
+
return __generator(this, function (_a) {
|
|
27718
|
+
switch (_a.label) {
|
|
27719
|
+
case 0:
|
|
27720
|
+
return [4
|
|
27721
|
+
/*yield*/
|
|
27722
|
+
, this._ensureCredentials()];
|
|
27723
|
+
|
|
27724
|
+
case 1:
|
|
27725
|
+
credentialsOK = _a.sent();
|
|
27726
|
+
|
|
27727
|
+
if (!credentialsOK) {
|
|
27728
|
+
throw new Error('No credentials');
|
|
27729
|
+
} // Verify geofence collection exists in aws-config.js
|
|
27730
|
+
|
|
27731
|
+
|
|
27732
|
+
try {
|
|
27733
|
+
this._verifyGeofenceCollections(options === null || options === void 0 ? void 0 : options.collectionName);
|
|
27734
|
+
} catch (error) {
|
|
27735
|
+
logger.debug(error);
|
|
27736
|
+
throw error;
|
|
27737
|
+
}
|
|
27738
|
+
|
|
27739
|
+
client = new _aws_sdk_client_location__WEBPACK_IMPORTED_MODULE_2__["LocationClient"]({
|
|
27740
|
+
credentials: this._config.credentials,
|
|
27741
|
+
region: this._config.region,
|
|
27742
|
+
customUserAgent: Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["getAmplifyUserAgent"])()
|
|
27743
|
+
});
|
|
27744
|
+
commandInput = {
|
|
27745
|
+
GeofenceId: geofenceId,
|
|
27746
|
+
CollectionName: (options === null || options === void 0 ? void 0 : options.collectionName) || this._config.geofenceCollections["default"]
|
|
27747
|
+
};
|
|
27748
|
+
command = new _aws_sdk_client_location__WEBPACK_IMPORTED_MODULE_2__["GetGeofenceCommand"](commandInput);
|
|
27749
|
+
_a.label = 2;
|
|
27750
|
+
|
|
27751
|
+
case 2:
|
|
27752
|
+
_a.trys.push([2, 4,, 5]);
|
|
27753
|
+
|
|
27754
|
+
return [4
|
|
27755
|
+
/*yield*/
|
|
27756
|
+
, client.send(command)];
|
|
27757
|
+
|
|
27758
|
+
case 3:
|
|
27759
|
+
response = _a.sent();
|
|
27760
|
+
return [3
|
|
27761
|
+
/*break*/
|
|
27762
|
+
, 5];
|
|
27763
|
+
|
|
27764
|
+
case 4:
|
|
27765
|
+
error_3 = _a.sent();
|
|
27766
|
+
logger.debug(error_3);
|
|
27767
|
+
throw error_3;
|
|
27768
|
+
|
|
27769
|
+
case 5:
|
|
27770
|
+
GeofenceId = response.GeofenceId, CreateTime = response.CreateTime, UpdateTime = response.UpdateTime, Status = response.Status, Geometry = response.Geometry;
|
|
27771
|
+
geofence = {
|
|
27772
|
+
createTime: CreateTime,
|
|
27773
|
+
geofenceId: GeofenceId,
|
|
27774
|
+
geometry: {
|
|
27775
|
+
polygon: Geometry.Polygon
|
|
27776
|
+
},
|
|
27777
|
+
status: Status,
|
|
27778
|
+
updateTime: UpdateTime
|
|
27779
|
+
};
|
|
27780
|
+
return [2
|
|
27781
|
+
/*return*/
|
|
27782
|
+
, geofence];
|
|
27783
|
+
}
|
|
27784
|
+
});
|
|
27785
|
+
});
|
|
27786
|
+
};
|
|
27787
|
+
/**
|
|
27788
|
+
* List geofences from a geofence collection
|
|
27789
|
+
* @param options?: ListGeofenceOptions
|
|
27790
|
+
* @returns {Promise<ListGeofencesResults>} - Promise that resolves to an object with:
|
|
27791
|
+
* entries: list of geofences - 100 geofences are listed per page
|
|
27792
|
+
* nextToken: token for next page of geofences
|
|
27793
|
+
*/
|
|
27794
|
+
|
|
27795
|
+
|
|
27796
|
+
AmazonLocationServiceProvider.prototype.listGeofences = function (options) {
|
|
27797
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
27798
|
+
var credentialsOK, client, listGeofencesInput, command, response, error_4, NextToken, Entries, results;
|
|
27799
|
+
return __generator(this, function (_a) {
|
|
27800
|
+
switch (_a.label) {
|
|
27801
|
+
case 0:
|
|
27802
|
+
return [4
|
|
27803
|
+
/*yield*/
|
|
27804
|
+
, this._ensureCredentials()];
|
|
27805
|
+
|
|
27806
|
+
case 1:
|
|
27807
|
+
credentialsOK = _a.sent();
|
|
27808
|
+
|
|
27809
|
+
if (!credentialsOK) {
|
|
27810
|
+
throw new Error('No credentials');
|
|
27811
|
+
} // Verify geofence collection exists in aws-config.js
|
|
27812
|
+
|
|
27813
|
+
|
|
27814
|
+
try {
|
|
27815
|
+
this._verifyGeofenceCollections(options === null || options === void 0 ? void 0 : options.collectionName);
|
|
27816
|
+
} catch (error) {
|
|
27817
|
+
logger.debug(error);
|
|
27818
|
+
throw error;
|
|
27819
|
+
}
|
|
27820
|
+
|
|
27821
|
+
client = new _aws_sdk_client_location__WEBPACK_IMPORTED_MODULE_2__["LocationClient"]({
|
|
27822
|
+
credentials: this._config.credentials,
|
|
27823
|
+
region: this._config.region,
|
|
27824
|
+
customUserAgent: Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["getAmplifyUserAgent"])()
|
|
27825
|
+
});
|
|
27826
|
+
listGeofencesInput = {
|
|
27827
|
+
NextToken: options === null || options === void 0 ? void 0 : options.nextToken,
|
|
27828
|
+
CollectionName: (options === null || options === void 0 ? void 0 : options.collectionName) || this._config.geofenceCollections["default"]
|
|
27829
|
+
};
|
|
27830
|
+
command = new _aws_sdk_client_location__WEBPACK_IMPORTED_MODULE_2__["ListGeofencesCommand"](listGeofencesInput);
|
|
27831
|
+
_a.label = 2;
|
|
27832
|
+
|
|
27833
|
+
case 2:
|
|
27834
|
+
_a.trys.push([2, 4,, 5]);
|
|
27835
|
+
|
|
27836
|
+
return [4
|
|
27837
|
+
/*yield*/
|
|
27838
|
+
, client.send(command)];
|
|
27839
|
+
|
|
27840
|
+
case 3:
|
|
27841
|
+
response = _a.sent();
|
|
27842
|
+
return [3
|
|
27843
|
+
/*break*/
|
|
27844
|
+
, 5];
|
|
27845
|
+
|
|
27846
|
+
case 4:
|
|
27847
|
+
error_4 = _a.sent();
|
|
27848
|
+
logger.debug(error_4);
|
|
27849
|
+
throw error_4;
|
|
27850
|
+
|
|
27851
|
+
case 5:
|
|
27852
|
+
NextToken = response.NextToken, Entries = response.Entries;
|
|
27853
|
+
results = {
|
|
27854
|
+
entries: Entries.map(function (_a) {
|
|
27855
|
+
var GeofenceId = _a.GeofenceId,
|
|
27856
|
+
CreateTime = _a.CreateTime,
|
|
27857
|
+
UpdateTime = _a.UpdateTime,
|
|
27858
|
+
Status = _a.Status,
|
|
27859
|
+
Polygon = _a.Geometry.Polygon;
|
|
27860
|
+
return {
|
|
27861
|
+
geofenceId: GeofenceId,
|
|
27862
|
+
createTime: CreateTime,
|
|
27863
|
+
updateTime: UpdateTime,
|
|
27864
|
+
status: Status,
|
|
27865
|
+
geometry: {
|
|
27866
|
+
polygon: Polygon
|
|
27867
|
+
}
|
|
27868
|
+
};
|
|
27869
|
+
}),
|
|
27870
|
+
nextToken: NextToken
|
|
27871
|
+
};
|
|
27872
|
+
return [2
|
|
27873
|
+
/*return*/
|
|
27874
|
+
, results];
|
|
27875
|
+
}
|
|
27876
|
+
});
|
|
27877
|
+
});
|
|
27878
|
+
};
|
|
27879
|
+
/**
|
|
27880
|
+
* Delete geofences from a geofence collection
|
|
27881
|
+
* @param geofenceIds: string|string[]
|
|
27882
|
+
* @param options?: GeofenceOptions
|
|
27883
|
+
* @returns {Promise<DeleteGeofencesResults>} - Promise that resolves to an object with:
|
|
27884
|
+
* successes: list of geofences successfully deleted
|
|
27885
|
+
* errors: list of geofences that failed to delete
|
|
27886
|
+
*/
|
|
27887
|
+
|
|
27888
|
+
|
|
27889
|
+
AmazonLocationServiceProvider.prototype.deleteGeofences = function (geofenceIds, options) {
|
|
27890
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
27891
|
+
var credentialsOK, results, batches, count;
|
|
27892
|
+
|
|
27893
|
+
var _this = this;
|
|
27894
|
+
|
|
27895
|
+
return __generator(this, function (_a) {
|
|
27896
|
+
switch (_a.label) {
|
|
27897
|
+
case 0:
|
|
27898
|
+
return [4
|
|
27899
|
+
/*yield*/
|
|
27900
|
+
, this._ensureCredentials()];
|
|
27901
|
+
|
|
27902
|
+
case 1:
|
|
27903
|
+
credentialsOK = _a.sent();
|
|
27904
|
+
|
|
27905
|
+
if (!credentialsOK) {
|
|
27906
|
+
throw new Error('No credentials');
|
|
27907
|
+
} // Verify geofence collection exists in aws-config.js
|
|
27908
|
+
|
|
27909
|
+
|
|
27910
|
+
try {
|
|
27911
|
+
this._verifyGeofenceCollections(options === null || options === void 0 ? void 0 : options.collectionName);
|
|
27912
|
+
} catch (error) {
|
|
27913
|
+
logger.debug(error);
|
|
27914
|
+
throw error;
|
|
27915
|
+
}
|
|
27916
|
+
|
|
27917
|
+
results = {
|
|
27918
|
+
successes: [],
|
|
27919
|
+
errors: []
|
|
27920
|
+
};
|
|
27921
|
+
batches = [];
|
|
27922
|
+
count = 0;
|
|
27923
|
+
|
|
27924
|
+
while (count < geofenceIds.length) {
|
|
27925
|
+
batches.push(geofenceIds.slice(count, count += 10));
|
|
27926
|
+
}
|
|
27927
|
+
|
|
27928
|
+
return [4
|
|
27929
|
+
/*yield*/
|
|
27930
|
+
, Promise.all(batches.map(function (batch) {
|
|
27931
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
27932
|
+
var response, error_5, badGeofenceIds;
|
|
27933
|
+
|
|
27934
|
+
var _a;
|
|
27935
|
+
|
|
27936
|
+
return __generator(this, function (_b) {
|
|
27937
|
+
switch (_b.label) {
|
|
27938
|
+
case 0:
|
|
27939
|
+
_b.trys.push([0, 2,, 3]);
|
|
27940
|
+
|
|
27941
|
+
return [4
|
|
27942
|
+
/*yield*/
|
|
27943
|
+
, this._AmazonLocationServiceBatchDeleteGeofenceCall(batch, (options === null || options === void 0 ? void 0 : options.collectionName) || this._config.geofenceCollections["default"])];
|
|
27944
|
+
|
|
27945
|
+
case 1:
|
|
27946
|
+
response = _b.sent();
|
|
27947
|
+
return [3
|
|
27948
|
+
/*break*/
|
|
27949
|
+
, 3];
|
|
27950
|
+
|
|
27951
|
+
case 2:
|
|
27952
|
+
error_5 = _b.sent(); // If the API call fails, add the geofences to the errors array and move to next batch
|
|
27953
|
+
|
|
27954
|
+
batch.forEach(function (geofenceId) {
|
|
27955
|
+
var errorObject = {
|
|
27956
|
+
geofenceId: geofenceId,
|
|
27957
|
+
error: {
|
|
27958
|
+
code: error_5.message,
|
|
27959
|
+
message: error_5.message
|
|
27960
|
+
}
|
|
27961
|
+
};
|
|
27962
|
+
results.errors.push(errorObject);
|
|
27963
|
+
});
|
|
27964
|
+
return [2
|
|
27965
|
+
/*return*/
|
|
27966
|
+
];
|
|
27967
|
+
|
|
27968
|
+
case 3:
|
|
27969
|
+
badGeofenceIds = response.Errors.map(function (_a) {
|
|
27970
|
+
var geofenceId = _a.geofenceId;
|
|
27971
|
+
return geofenceId;
|
|
27972
|
+
});
|
|
27973
|
+
|
|
27974
|
+
(_a = results.successes).push.apply(_a, __spread(batch.filter(function (Id) {
|
|
27975
|
+
return !badGeofenceIds.includes(Id);
|
|
27976
|
+
})));
|
|
27977
|
+
|
|
27978
|
+
return [2
|
|
27979
|
+
/*return*/
|
|
27980
|
+
];
|
|
27981
|
+
}
|
|
27982
|
+
});
|
|
27983
|
+
});
|
|
27984
|
+
}))];
|
|
27985
|
+
|
|
27986
|
+
case 2:
|
|
27987
|
+
_a.sent();
|
|
27988
|
+
|
|
27989
|
+
return [2
|
|
27990
|
+
/*return*/
|
|
27991
|
+
, results];
|
|
27992
|
+
}
|
|
27993
|
+
});
|
|
27994
|
+
});
|
|
27995
|
+
};
|
|
27996
|
+
/**
|
|
27997
|
+
* @private
|
|
27998
|
+
*/
|
|
27999
|
+
|
|
28000
|
+
|
|
28001
|
+
AmazonLocationServiceProvider.prototype._ensureCredentials = function () {
|
|
28002
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
28003
|
+
var credentials, cred, error_6;
|
|
28004
|
+
return __generator(this, function (_a) {
|
|
28005
|
+
switch (_a.label) {
|
|
28006
|
+
case 0:
|
|
28007
|
+
_a.trys.push([0, 2,, 3]);
|
|
28008
|
+
|
|
28009
|
+
return [4
|
|
28010
|
+
/*yield*/
|
|
28011
|
+
, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["Credentials"].get()];
|
|
28012
|
+
|
|
28013
|
+
case 1:
|
|
28014
|
+
credentials = _a.sent();
|
|
28015
|
+
if (!credentials) return [2
|
|
28016
|
+
/*return*/
|
|
28017
|
+
, false];
|
|
28018
|
+
cred = _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["Credentials"].shear(credentials);
|
|
28019
|
+
logger.debug('Set credentials for storage. Credentials are:', cred);
|
|
28020
|
+
this._config.credentials = cred;
|
|
28021
|
+
return [2
|
|
28022
|
+
/*return*/
|
|
28023
|
+
, true];
|
|
28024
|
+
|
|
28025
|
+
case 2:
|
|
28026
|
+
error_6 = _a.sent();
|
|
28027
|
+
logger.warn('Ensure credentials error. Credentials are:', error_6);
|
|
28028
|
+
return [2
|
|
28029
|
+
/*return*/
|
|
28030
|
+
, false];
|
|
28031
|
+
|
|
28032
|
+
case 3:
|
|
28033
|
+
return [2
|
|
28034
|
+
/*return*/
|
|
28035
|
+
];
|
|
28036
|
+
}
|
|
28037
|
+
});
|
|
28038
|
+
});
|
|
28039
|
+
};
|
|
28040
|
+
|
|
28041
|
+
AmazonLocationServiceProvider.prototype._verifyMapResources = function () {
|
|
28042
|
+
if (!this._config.maps) {
|
|
28043
|
+
var errorString = "No map resources found in amplify config, run 'amplify add geo' to create one and run `amplify push` after";
|
|
28044
|
+
logger.warn(errorString);
|
|
28045
|
+
throw new Error(errorString);
|
|
27322
28046
|
}
|
|
27323
28047
|
|
|
27324
28048
|
if (!this._config.maps["default"]) {
|
|
27325
|
-
var errorString = "No default map resource found in amplify config, run 'amplify add geo' to create one and
|
|
28049
|
+
var errorString = "No default map resource found in amplify config, run 'amplify add geo' to create one and run `amplify push` after";
|
|
27326
28050
|
logger.warn(errorString);
|
|
27327
28051
|
throw new Error(errorString);
|
|
27328
28052
|
}
|
|
@@ -27330,12 +28054,219 @@ function () {
|
|
|
27330
28054
|
|
|
27331
28055
|
AmazonLocationServiceProvider.prototype._verifySearchIndex = function (optionalSearchIndex) {
|
|
27332
28056
|
if ((!this._config.search_indices || !this._config.search_indices["default"]) && !optionalSearchIndex) {
|
|
27333
|
-
var errorString = 'No Search Index found, please run `amplify add geo` to
|
|
28057
|
+
var errorString = 'No Search Index found in amplify config, please run `amplify add geo` to create one and run `amplify push` after.';
|
|
28058
|
+
logger.warn(errorString);
|
|
28059
|
+
throw new Error(errorString);
|
|
28060
|
+
}
|
|
28061
|
+
};
|
|
28062
|
+
|
|
28063
|
+
AmazonLocationServiceProvider.prototype._verifyGeofenceCollections = function (optionalGeofenceCollectionName) {
|
|
28064
|
+
if ((!this._config.geofenceCollections || !this._config.geofenceCollections["default"]) && !optionalGeofenceCollectionName) {
|
|
28065
|
+
var errorString = 'No Geofence Collections found, please run `amplify add geo` to create one and run `amplify push` after.';
|
|
27334
28066
|
logger.warn(errorString);
|
|
27335
28067
|
throw new Error(errorString);
|
|
27336
28068
|
}
|
|
27337
28069
|
};
|
|
27338
28070
|
|
|
28071
|
+
AmazonLocationServiceProvider.prototype._AmazonLocationServiceBatchPutGeofenceCall = function (PascalGeofences, collectionName) {
|
|
28072
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
28073
|
+
var geofenceInput, client, command, response, error_7;
|
|
28074
|
+
return __generator(this, function (_a) {
|
|
28075
|
+
switch (_a.label) {
|
|
28076
|
+
case 0:
|
|
28077
|
+
geofenceInput = {
|
|
28078
|
+
Entries: PascalGeofences,
|
|
28079
|
+
CollectionName: collectionName || this._config.geofenceCollections["default"]
|
|
28080
|
+
};
|
|
28081
|
+
client = new _aws_sdk_client_location__WEBPACK_IMPORTED_MODULE_2__["LocationClient"]({
|
|
28082
|
+
credentials: this._config.credentials,
|
|
28083
|
+
region: this._config.region,
|
|
28084
|
+
customUserAgent: Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["getAmplifyUserAgent"])()
|
|
28085
|
+
});
|
|
28086
|
+
command = new _aws_sdk_client_location__WEBPACK_IMPORTED_MODULE_2__["BatchPutGeofenceCommand"](geofenceInput);
|
|
28087
|
+
_a.label = 1;
|
|
28088
|
+
|
|
28089
|
+
case 1:
|
|
28090
|
+
_a.trys.push([1, 3,, 4]);
|
|
28091
|
+
|
|
28092
|
+
return [4
|
|
28093
|
+
/*yield*/
|
|
28094
|
+
, client.send(command)];
|
|
28095
|
+
|
|
28096
|
+
case 2:
|
|
28097
|
+
response = _a.sent();
|
|
28098
|
+
return [3
|
|
28099
|
+
/*break*/
|
|
28100
|
+
, 4];
|
|
28101
|
+
|
|
28102
|
+
case 3:
|
|
28103
|
+
error_7 = _a.sent();
|
|
28104
|
+
throw error_7;
|
|
28105
|
+
|
|
28106
|
+
case 4:
|
|
28107
|
+
return [2
|
|
28108
|
+
/*return*/
|
|
28109
|
+
, response];
|
|
28110
|
+
}
|
|
28111
|
+
});
|
|
28112
|
+
});
|
|
28113
|
+
};
|
|
28114
|
+
|
|
28115
|
+
AmazonLocationServiceProvider.prototype._batchPutGeofence = function (geofences, options) {
|
|
28116
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
28117
|
+
var PascalGeofences, results, batches;
|
|
28118
|
+
|
|
28119
|
+
var _this = this;
|
|
28120
|
+
|
|
28121
|
+
return __generator(this, function (_a) {
|
|
28122
|
+
switch (_a.label) {
|
|
28123
|
+
case 0:
|
|
28124
|
+
PascalGeofences = geofences.map(function (_a) {
|
|
28125
|
+
var geofenceId = _a.geofenceId,
|
|
28126
|
+
polygon = _a.geometry.polygon;
|
|
28127
|
+
return {
|
|
28128
|
+
GeofenceId: geofenceId,
|
|
28129
|
+
Geometry: {
|
|
28130
|
+
Polygon: polygon
|
|
28131
|
+
}
|
|
28132
|
+
};
|
|
28133
|
+
});
|
|
28134
|
+
results = {
|
|
28135
|
+
successes: [],
|
|
28136
|
+
errors: []
|
|
28137
|
+
};
|
|
28138
|
+
batches = [];
|
|
28139
|
+
|
|
28140
|
+
while (PascalGeofences.length > 0) {
|
|
28141
|
+
// Splice off 10 geofences from input clone due to Amazon Location Service API limit
|
|
28142
|
+
batches.push(PascalGeofences.splice(0, 10));
|
|
28143
|
+
}
|
|
28144
|
+
|
|
28145
|
+
return [4
|
|
28146
|
+
/*yield*/
|
|
28147
|
+
, Promise.all(batches.map(function (batch) {
|
|
28148
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
28149
|
+
var response, error_8;
|
|
28150
|
+
return __generator(this, function (_a) {
|
|
28151
|
+
switch (_a.label) {
|
|
28152
|
+
case 0:
|
|
28153
|
+
_a.trys.push([0, 2,, 3]);
|
|
28154
|
+
|
|
28155
|
+
return [4
|
|
28156
|
+
/*yield*/
|
|
28157
|
+
, this._AmazonLocationServiceBatchPutGeofenceCall(batch, (options === null || options === void 0 ? void 0 : options.collectionName) || this._config.geofenceCollections["default"])];
|
|
28158
|
+
|
|
28159
|
+
case 1:
|
|
28160
|
+
response = _a.sent();
|
|
28161
|
+
return [3
|
|
28162
|
+
/*break*/
|
|
28163
|
+
, 3];
|
|
28164
|
+
|
|
28165
|
+
case 2:
|
|
28166
|
+
error_8 = _a.sent(); // If the API call fails, add the geofences to the errors array and move to next batch
|
|
28167
|
+
|
|
28168
|
+
batch.forEach(function (geofence) {
|
|
28169
|
+
results.errors.push({
|
|
28170
|
+
geofenceId: geofence.GeofenceId,
|
|
28171
|
+
error: {
|
|
28172
|
+
code: 'APIConnectionError',
|
|
28173
|
+
message: error_8.message
|
|
28174
|
+
}
|
|
28175
|
+
});
|
|
28176
|
+
});
|
|
28177
|
+
return [2
|
|
28178
|
+
/*return*/
|
|
28179
|
+
];
|
|
28180
|
+
|
|
28181
|
+
case 3:
|
|
28182
|
+
// Push all successes to results
|
|
28183
|
+
response.Successes.forEach(function (success) {
|
|
28184
|
+
var GeofenceId = success.GeofenceId,
|
|
28185
|
+
CreateTime = success.CreateTime,
|
|
28186
|
+
UpdateTime = success.UpdateTime;
|
|
28187
|
+
results.successes.push({
|
|
28188
|
+
geofenceId: GeofenceId,
|
|
28189
|
+
createTime: CreateTime,
|
|
28190
|
+
updateTime: UpdateTime
|
|
28191
|
+
});
|
|
28192
|
+
}); // Push all errors to results
|
|
28193
|
+
|
|
28194
|
+
response.Errors.forEach(function (error) {
|
|
28195
|
+
var _a = error.Error,
|
|
28196
|
+
Code = _a.Code,
|
|
28197
|
+
Message = _a.Message,
|
|
28198
|
+
GeofenceId = error.GeofenceId;
|
|
28199
|
+
results.errors.push({
|
|
28200
|
+
error: {
|
|
28201
|
+
code: Code,
|
|
28202
|
+
message: Message
|
|
28203
|
+
},
|
|
28204
|
+
geofenceId: GeofenceId
|
|
28205
|
+
});
|
|
28206
|
+
});
|
|
28207
|
+
return [2
|
|
28208
|
+
/*return*/
|
|
28209
|
+
];
|
|
28210
|
+
}
|
|
28211
|
+
});
|
|
28212
|
+
});
|
|
28213
|
+
}))];
|
|
28214
|
+
|
|
28215
|
+
case 1:
|
|
28216
|
+
_a.sent();
|
|
28217
|
+
|
|
28218
|
+
return [2
|
|
28219
|
+
/*return*/
|
|
28220
|
+
, results];
|
|
28221
|
+
}
|
|
28222
|
+
});
|
|
28223
|
+
});
|
|
28224
|
+
};
|
|
28225
|
+
|
|
28226
|
+
AmazonLocationServiceProvider.prototype._AmazonLocationServiceBatchDeleteGeofenceCall = function (geofenceIds, collectionName) {
|
|
28227
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
28228
|
+
var deleteGeofencesInput, client, command, response, error_9;
|
|
28229
|
+
return __generator(this, function (_a) {
|
|
28230
|
+
switch (_a.label) {
|
|
28231
|
+
case 0:
|
|
28232
|
+
deleteGeofencesInput = {
|
|
28233
|
+
GeofenceIds: geofenceIds,
|
|
28234
|
+
CollectionName: collectionName || this._config.geofenceCollections["default"]
|
|
28235
|
+
};
|
|
28236
|
+
client = new _aws_sdk_client_location__WEBPACK_IMPORTED_MODULE_2__["LocationClient"]({
|
|
28237
|
+
credentials: this._config.credentials,
|
|
28238
|
+
region: this._config.region,
|
|
28239
|
+
customUserAgent: Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["getAmplifyUserAgent"])()
|
|
28240
|
+
});
|
|
28241
|
+
command = new _aws_sdk_client_location__WEBPACK_IMPORTED_MODULE_2__["BatchDeleteGeofenceCommand"](deleteGeofencesInput);
|
|
28242
|
+
_a.label = 1;
|
|
28243
|
+
|
|
28244
|
+
case 1:
|
|
28245
|
+
_a.trys.push([1, 3,, 4]);
|
|
28246
|
+
|
|
28247
|
+
return [4
|
|
28248
|
+
/*yield*/
|
|
28249
|
+
, client.send(command)];
|
|
28250
|
+
|
|
28251
|
+
case 2:
|
|
28252
|
+
response = _a.sent();
|
|
28253
|
+
return [3
|
|
28254
|
+
/*break*/
|
|
28255
|
+
, 4];
|
|
28256
|
+
|
|
28257
|
+
case 3:
|
|
28258
|
+
error_9 = _a.sent();
|
|
28259
|
+
throw error_9;
|
|
28260
|
+
|
|
28261
|
+
case 4:
|
|
28262
|
+
return [2
|
|
28263
|
+
/*return*/
|
|
28264
|
+
, response];
|
|
28265
|
+
}
|
|
28266
|
+
});
|
|
28267
|
+
});
|
|
28268
|
+
};
|
|
28269
|
+
|
|
27339
28270
|
AmazonLocationServiceProvider.CATEGORY = 'Geo';
|
|
27340
28271
|
AmazonLocationServiceProvider.PROVIDER_NAME = 'AmazonLocationService';
|
|
27341
28272
|
return AmazonLocationServiceProvider;
|
|
@@ -27359,6 +28290,214 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
27359
28290
|
|
|
27360
28291
|
|
|
27361
28292
|
|
|
28293
|
+
/***/ }),
|
|
28294
|
+
|
|
28295
|
+
/***/ "./lib-esm/util.js":
|
|
28296
|
+
/*!*************************!*\
|
|
28297
|
+
!*** ./lib-esm/util.js ***!
|
|
28298
|
+
\*************************/
|
|
28299
|
+
/*! exports provided: validateCoordinates, validateGeofenceId, validateLinearRing, validatePolygon, validateGeofences */
|
|
28300
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
28301
|
+
|
|
28302
|
+
"use strict";
|
|
28303
|
+
__webpack_require__.r(__webpack_exports__);
|
|
28304
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "validateCoordinates", function() { return validateCoordinates; });
|
|
28305
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "validateGeofenceId", function() { return validateGeofenceId; });
|
|
28306
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "validateLinearRing", function() { return validateLinearRing; });
|
|
28307
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "validatePolygon", function() { return validatePolygon; });
|
|
28308
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "validateGeofences", function() { return validateGeofences; });
|
|
28309
|
+
/* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
|
|
28310
|
+
/* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__);
|
|
28311
|
+
var __read = undefined && undefined.__read || function (o, n) {
|
|
28312
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
28313
|
+
if (!m) return o;
|
|
28314
|
+
var i = m.call(o),
|
|
28315
|
+
r,
|
|
28316
|
+
ar = [],
|
|
28317
|
+
e;
|
|
28318
|
+
|
|
28319
|
+
try {
|
|
28320
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
|
|
28321
|
+
ar.push(r.value);
|
|
28322
|
+
}
|
|
28323
|
+
} catch (error) {
|
|
28324
|
+
e = {
|
|
28325
|
+
error: error
|
|
28326
|
+
};
|
|
28327
|
+
} finally {
|
|
28328
|
+
try {
|
|
28329
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
28330
|
+
} finally {
|
|
28331
|
+
if (e) throw e.error;
|
|
28332
|
+
}
|
|
28333
|
+
}
|
|
28334
|
+
|
|
28335
|
+
return ar;
|
|
28336
|
+
};
|
|
28337
|
+
/*
|
|
28338
|
+
* Copyright 2017-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
28339
|
+
*
|
|
28340
|
+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
28341
|
+
* the License. A copy of the License is located at
|
|
28342
|
+
*
|
|
28343
|
+
* http://aws.amazon.com/apache2.0/
|
|
28344
|
+
*
|
|
28345
|
+
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
28346
|
+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
|
28347
|
+
* and limitations under the License.
|
|
28348
|
+
*/
|
|
28349
|
+
|
|
28350
|
+
|
|
28351
|
+
|
|
28352
|
+
var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["ConsoleLogger"]('Geo');
|
|
28353
|
+
function validateCoordinates(lng, lat) {
|
|
28354
|
+
if (!Number.isFinite(lng) || !Number.isFinite(lat)) {
|
|
28355
|
+
throw new Error("Invalid coordinates: [" + lng + "," + lat + "]");
|
|
28356
|
+
}
|
|
28357
|
+
|
|
28358
|
+
if (lat < -90 || lat > 90) {
|
|
28359
|
+
var errorString = 'Latitude must be between -90 and 90 degrees inclusive.';
|
|
28360
|
+
logger.warn(errorString);
|
|
28361
|
+
throw new Error(errorString);
|
|
28362
|
+
} else if (lng < -180 || lng > 180) {
|
|
28363
|
+
var errorString = 'Longitude must be between -180 and 180 degrees inclusive.';
|
|
28364
|
+
logger.warn(errorString);
|
|
28365
|
+
throw new Error(errorString);
|
|
28366
|
+
}
|
|
28367
|
+
}
|
|
28368
|
+
function validateGeofenceId(geofenceId) {
|
|
28369
|
+
var geofenceIdRegex = /^(?:[\x2D\.0-9A-Z_a-z\xAA\xB2\xB3\xB5\xB9\xBA\xBC-\xBE\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u0660-\u0669\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07C0-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0966-\u096F\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09E6-\u09F1\u09F4-\u09F9\u09FC\u0A05-\u0A0A\u0A0F\u0A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\u0F33\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F-\u1049\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u1090-\u1099\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1369-\u137C\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A16\u1A20-\u1A54\u1A80-\u1A89\u1A90-\u1A99\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B50-\u1B59\u1B83-\u1BA0\u1BAE-\u1BE5\u1C00-\u1C23\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2070\u2071\u2074-\u2079\u207F-\u2089\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2150-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2CFD\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u3192-\u3195\u31A0-\u31BF\u31F0-\u31FF\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA830-\uA835\uA840-\uA873\uA882-\uA8B3\uA8D0-\uA8D9\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA900-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF-\uA9D9\uA9E0-\uA9E4\uA9E6-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA50-\uAA59\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF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B\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCF2\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDD50-\uDD59\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC50-\uDC6C\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD50-\uDD59\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDDA0-\uDDA9\uDEE0-\uDEF2\uDFB0\uDFC0-\uDFD4]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDE70-\uDEBE\uDEC0-\uDEC9\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF50-\uDF59\uDF5B-\uDF61\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE96\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD834[\uDEE0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uDF00-\uDFFF]|\uD86D[\uDC00-\uDF38\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])+$/i; // Check if geofenceId is valid
|
|
28370
|
+
|
|
28371
|
+
if (!geofenceIdRegex.test(geofenceId)) {
|
|
28372
|
+
var errorString = "Invalid geofenceId: " + geofenceId + " Ids can only contain alphanumeric characters, hyphens, underscores and periods.";
|
|
28373
|
+
logger.warn(errorString);
|
|
28374
|
+
throw new Error(errorString);
|
|
28375
|
+
}
|
|
28376
|
+
}
|
|
28377
|
+
function validateLinearRing(linearRing) {
|
|
28378
|
+
// Validate LinearRing size, must be at least 4 points
|
|
28379
|
+
if (linearRing.length < 4) {
|
|
28380
|
+
var errorString = 'LinearRing must contain 4 or more coordinates.';
|
|
28381
|
+
logger.warn(errorString);
|
|
28382
|
+
throw new Error(errorString);
|
|
28383
|
+
} // Validate all coordinates are valid, error with which ones are bad
|
|
28384
|
+
|
|
28385
|
+
|
|
28386
|
+
var badCoordinates = [];
|
|
28387
|
+
linearRing.forEach(function (coordinates) {
|
|
28388
|
+
try {
|
|
28389
|
+
validateCoordinates(coordinates[0], coordinates[1]);
|
|
28390
|
+
} catch (error) {
|
|
28391
|
+
badCoordinates.push({
|
|
28392
|
+
coordinates: coordinates,
|
|
28393
|
+
error: error.message
|
|
28394
|
+
});
|
|
28395
|
+
}
|
|
28396
|
+
});
|
|
28397
|
+
|
|
28398
|
+
if (badCoordinates.length > 0) {
|
|
28399
|
+
var errorString = "One or more of the coordinates are not valid: " + JSON.stringify(badCoordinates);
|
|
28400
|
+
logger.warn(errorString);
|
|
28401
|
+
throw new Error(errorString);
|
|
28402
|
+
} // Validate first and last coordinates are the same
|
|
28403
|
+
|
|
28404
|
+
|
|
28405
|
+
var _a = __read(linearRing[0], 2),
|
|
28406
|
+
lngA = _a[0],
|
|
28407
|
+
latA = _a[1];
|
|
28408
|
+
|
|
28409
|
+
var _b = __read(linearRing[linearRing.length - 1], 2),
|
|
28410
|
+
lngB = _b[0],
|
|
28411
|
+
latB = _b[1];
|
|
28412
|
+
|
|
28413
|
+
if (lngA !== lngB || latA !== latB) {
|
|
28414
|
+
var errorString = "LinearRing's first and last coordinates are not the same";
|
|
28415
|
+
logger.warn(errorString);
|
|
28416
|
+
throw new Error(errorString);
|
|
28417
|
+
}
|
|
28418
|
+
}
|
|
28419
|
+
function validatePolygon(polygon) {
|
|
28420
|
+
if (!Array.isArray(polygon)) {
|
|
28421
|
+
var errorString = "Polygon " + JSON.stringify(polygon) + " is of incorrect structure. It should be an array of 'LinearRing'";
|
|
28422
|
+
logger.warn(errorString);
|
|
28423
|
+
throw new Error(errorString);
|
|
28424
|
+
}
|
|
28425
|
+
|
|
28426
|
+
if (!(polygon.length === 1)) {
|
|
28427
|
+
var errorString = "Polygon " + JSON.stringify(polygon) + " geometry.polygon must have a single LinearRing array";
|
|
28428
|
+
logger.warn(errorString);
|
|
28429
|
+
throw new Error(errorString);
|
|
28430
|
+
}
|
|
28431
|
+
|
|
28432
|
+
var verticesCount = polygon.reduce(function (prev, linearRing) {
|
|
28433
|
+
return prev + linearRing.length;
|
|
28434
|
+
}, 0);
|
|
28435
|
+
|
|
28436
|
+
if (verticesCount > 1000) {
|
|
28437
|
+
var errorString = "Polygon has more than the maximum 1000 vertices.";
|
|
28438
|
+
logger.warn(errorString);
|
|
28439
|
+
throw new Error(errorString);
|
|
28440
|
+
}
|
|
28441
|
+
}
|
|
28442
|
+
function validateGeofences(geofences) {
|
|
28443
|
+
var geofenceIds = {};
|
|
28444
|
+
geofences.forEach(function (geofence) {
|
|
28445
|
+
// verify all required properties are present
|
|
28446
|
+
if (!geofence.geofenceId) {
|
|
28447
|
+
var errorString = "Geofence " + JSON.stringify(geofence) + " is missing geofenceId";
|
|
28448
|
+
logger.warn(errorString);
|
|
28449
|
+
throw new Error(errorString);
|
|
28450
|
+
}
|
|
28451
|
+
|
|
28452
|
+
if (!geofence.geometry) {
|
|
28453
|
+
var errorString = "Geofence " + JSON.stringify(geofence) + " is missing geometry";
|
|
28454
|
+
logger.warn(errorString);
|
|
28455
|
+
throw new Error(errorString);
|
|
28456
|
+
}
|
|
28457
|
+
|
|
28458
|
+
if (!geofence.geometry.polygon) {
|
|
28459
|
+
var errorString = "Geofence " + JSON.stringify(geofence) + " is missing geometry.polygon";
|
|
28460
|
+
logger.warn(errorString);
|
|
28461
|
+
throw new Error(errorString);
|
|
28462
|
+
}
|
|
28463
|
+
|
|
28464
|
+
var geofenceId = geofence.geofenceId,
|
|
28465
|
+
polygon = geofence.geometry.polygon; // Validate geofenceId is valid
|
|
28466
|
+
|
|
28467
|
+
try {
|
|
28468
|
+
validateGeofenceId(geofenceId);
|
|
28469
|
+
} catch (error) {
|
|
28470
|
+
throw error;
|
|
28471
|
+
} // Validate geofenceId is unique
|
|
28472
|
+
|
|
28473
|
+
|
|
28474
|
+
if (geofenceIds[geofenceId]) {
|
|
28475
|
+
var errorString = "Duplicate geofenceId: " + geofenceId;
|
|
28476
|
+
logger.warn(errorString);
|
|
28477
|
+
throw new Error(errorString);
|
|
28478
|
+
} else {
|
|
28479
|
+
geofenceIds[geofenceId] = true;
|
|
28480
|
+
} // Validate polygon length and structure
|
|
28481
|
+
|
|
28482
|
+
|
|
28483
|
+
try {
|
|
28484
|
+
validatePolygon(polygon);
|
|
28485
|
+
} catch (error) {
|
|
28486
|
+
if (error.message === "Polygon has more than the maximum 1000 vertices.") {
|
|
28487
|
+
var errorString = "Geofence " + geofenceId + " has more than the maximum of 1000 vertices";
|
|
28488
|
+
logger.warn(errorString);
|
|
28489
|
+
throw new Error(errorString);
|
|
28490
|
+
}
|
|
28491
|
+
} // Validate LinearRing length, structure, and coordinates
|
|
28492
|
+
|
|
28493
|
+
|
|
28494
|
+
var _a = __read(polygon, 1),
|
|
28495
|
+
linearRing = _a[0];
|
|
28496
|
+
|
|
28497
|
+
validateLinearRing(linearRing);
|
|
28498
|
+
});
|
|
28499
|
+
}
|
|
28500
|
+
|
|
27362
28501
|
/***/ }),
|
|
27363
28502
|
|
|
27364
28503
|
/***/ "@aws-amplify/core":
|