@aws-amplify/geo 1.2.1 → 1.2.2-geo.3
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 +1062 -51
- 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 +36 -3
- package/lib/Geo.js +170 -5
- package/lib/Geo.js.map +1 -1
- package/lib/Providers/AmazonLocationServiceProvider.d.ts +37 -1
- package/lib/Providers/AmazonLocationServiceProvider.js +409 -8
- 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 +5 -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 +36 -3
- package/lib-esm/Geo.js +170 -5
- package/lib-esm/Geo.js.map +1 -1
- package/lib-esm/Providers/AmazonLocationServiceProvider.d.ts +37 -1
- package/lib-esm/Providers/AmazonLocationServiceProvider.js +410 -9
- 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 +5 -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 +5 -4
- package/src/Geo.ts +144 -2
- package/src/Providers/AmazonLocationServiceProvider.ts +409 -6
- package/src/types/AmazonLocationServiceProvider.ts +56 -1
- package/src/types/Geo.ts +72 -2
- package/src/types/Provider.ts +31 -1
- package/src/util.ts +182 -0
package/lib/util.js
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
/*
|
|
20
|
+
* Copyright 2017-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
21
|
+
*
|
|
22
|
+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
23
|
+
* the License. A copy of the License is located at
|
|
24
|
+
*
|
|
25
|
+
* http://aws.amazon.com/apache2.0/
|
|
26
|
+
*
|
|
27
|
+
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
28
|
+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
|
29
|
+
* and limitations under the License.
|
|
30
|
+
*/
|
|
31
|
+
var core_1 = require("@aws-amplify/core");
|
|
32
|
+
var logger = new core_1.ConsoleLogger('Geo');
|
|
33
|
+
function validateCoordinates(lng, lat) {
|
|
34
|
+
if (!Number.isFinite(lng) || !Number.isFinite(lat)) {
|
|
35
|
+
throw new Error("Invalid coordinates: [" + lng + "," + lat + "]");
|
|
36
|
+
}
|
|
37
|
+
if (lat < -90 || lat > 90) {
|
|
38
|
+
var errorString = 'Latitude must be between -90 and 90 degrees inclusive.';
|
|
39
|
+
logger.debug(errorString);
|
|
40
|
+
throw new Error(errorString);
|
|
41
|
+
}
|
|
42
|
+
else if (lng < -180 || lng > 180) {
|
|
43
|
+
var errorString = 'Longitude must be between -180 and 180 degrees inclusive.';
|
|
44
|
+
logger.debug(errorString);
|
|
45
|
+
throw new Error(errorString);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.validateCoordinates = validateCoordinates;
|
|
49
|
+
function validateGeofenceId(geofenceId) {
|
|
50
|
+
var geofenceIdRegex = /^[-._\p{L}\p{N}]+$/iu;
|
|
51
|
+
// Check if geofenceId is valid
|
|
52
|
+
if (!geofenceIdRegex.test(geofenceId)) {
|
|
53
|
+
var errorString = "Invalid geofenceId: " + geofenceId + " Ids can only contain alphanumeric characters, hyphens, underscores and periods.";
|
|
54
|
+
logger.debug(errorString);
|
|
55
|
+
throw new Error(errorString);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.validateGeofenceId = validateGeofenceId;
|
|
59
|
+
function validateLinearRing(linearRing) {
|
|
60
|
+
// Validate LinearRing size, must be at least 4 points
|
|
61
|
+
if (linearRing.length < 4) {
|
|
62
|
+
var errorString = 'LinearRing must contain 4 or more coordinates.';
|
|
63
|
+
logger.debug(errorString);
|
|
64
|
+
throw new Error(errorString);
|
|
65
|
+
}
|
|
66
|
+
// Validate all coordinates are valid, error with which ones are bad
|
|
67
|
+
var badCoordinates = [];
|
|
68
|
+
linearRing.forEach(function (coordinates) {
|
|
69
|
+
try {
|
|
70
|
+
validateCoordinates(coordinates[0], coordinates[1]);
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
badCoordinates.push({ coordinates: coordinates, error: error.message });
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
if (badCoordinates.length > 0) {
|
|
77
|
+
var errorString = "One or more of the coordinates are not valid: " + JSON.stringify(badCoordinates);
|
|
78
|
+
logger.debug(errorString);
|
|
79
|
+
throw new Error(errorString);
|
|
80
|
+
}
|
|
81
|
+
// Validate first and last coordinates are the same
|
|
82
|
+
var _a = __read(linearRing[0], 2), lngA = _a[0], latA = _a[1];
|
|
83
|
+
var _b = __read(linearRing[linearRing.length - 1], 2), lngB = _b[0], latB = _b[1];
|
|
84
|
+
if (lngA !== lngB || latA !== latB) {
|
|
85
|
+
var errorString = "LinearRing's first and last coordinates are not the same";
|
|
86
|
+
logger.debug(errorString);
|
|
87
|
+
throw new Error(errorString);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.validateLinearRing = validateLinearRing;
|
|
91
|
+
function validatePolygon(polygon) {
|
|
92
|
+
if (!Array.isArray(polygon)) {
|
|
93
|
+
var errorString = "Polygon " + JSON.stringify(polygon) + " is of incorrect structure. It should be an array of 'LinearRing'";
|
|
94
|
+
logger.debug(errorString);
|
|
95
|
+
throw new Error(errorString);
|
|
96
|
+
}
|
|
97
|
+
if (!(polygon.length === 1)) {
|
|
98
|
+
var errorString = "Polygon " + JSON.stringify(polygon) + " geometry.polygon must have a single LinearRing array";
|
|
99
|
+
logger.debug(errorString);
|
|
100
|
+
throw new Error(errorString);
|
|
101
|
+
}
|
|
102
|
+
var verticesCount = polygon.reduce(function (prev, linearRing) { return prev + linearRing.length; }, 0);
|
|
103
|
+
if (verticesCount > 1000) {
|
|
104
|
+
var errorString = "Polygon has more than the maximum 1000 vertices.";
|
|
105
|
+
logger.debug(errorString);
|
|
106
|
+
throw new Error(errorString);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.validatePolygon = validatePolygon;
|
|
110
|
+
function validateGeofences(geofences) {
|
|
111
|
+
var geofenceIds = {};
|
|
112
|
+
geofences.forEach(function (geofence) {
|
|
113
|
+
// verify all required properties are present
|
|
114
|
+
if (!geofence.geofenceId) {
|
|
115
|
+
var errorString = "Geofence " + JSON.stringify(geofence) + " is missing geofenceId";
|
|
116
|
+
logger.debug(errorString);
|
|
117
|
+
throw new Error(errorString);
|
|
118
|
+
}
|
|
119
|
+
if (!geofence.geometry) {
|
|
120
|
+
var errorString = "Geofence " + JSON.stringify(geofence) + " is missing geometry";
|
|
121
|
+
logger.debug(errorString);
|
|
122
|
+
throw new Error(errorString);
|
|
123
|
+
}
|
|
124
|
+
if (!geofence.geometry.polygon) {
|
|
125
|
+
var errorString = "Geofence " + JSON.stringify(geofence) + " is missing geometry.polygon";
|
|
126
|
+
logger.debug(errorString);
|
|
127
|
+
throw new Error(errorString);
|
|
128
|
+
}
|
|
129
|
+
var geofenceId = geofence.geofenceId, polygon = geofence.geometry.polygon;
|
|
130
|
+
// Validate geofenceId is valid
|
|
131
|
+
try {
|
|
132
|
+
validateGeofenceId(geofenceId);
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
throw error;
|
|
136
|
+
}
|
|
137
|
+
// Validate geofenceId is unique
|
|
138
|
+
if (geofenceIds[geofenceId]) {
|
|
139
|
+
var errorString = "Duplicate geofenceId: " + geofenceId;
|
|
140
|
+
logger.debug(errorString);
|
|
141
|
+
throw new Error(errorString);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
geofenceIds[geofenceId] = true;
|
|
145
|
+
}
|
|
146
|
+
// Validate polygon length and structure
|
|
147
|
+
try {
|
|
148
|
+
validatePolygon(polygon);
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
if (error.message === "Polygon has more than the maximum 1000 vertices.") {
|
|
152
|
+
var errorString = "Geofence " + geofenceId + " has more than the maximum of 1000 vertices";
|
|
153
|
+
logger.debug(errorString);
|
|
154
|
+
throw new Error(errorString);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
// Validate LinearRing length, structure, and coordinates
|
|
158
|
+
var _a = __read(polygon, 1), linearRing = _a[0];
|
|
159
|
+
validateLinearRing(linearRing);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
exports.validateGeofences = validateGeofences;
|
|
163
|
+
//# sourceMappingURL=util.js.map
|
package/lib/util.js.map
ADDED
|
@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C,CAAC;IAChC,CAAC,CAAC,CAAC;AACJ,CAAC;AAnED,8CAmEC"}
|
package/lib-esm/Geo.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GeoConfig, Coordinates, SearchByTextOptions, SearchForSuggestionsResults, SearchByCoordinatesOptions, GeoProvider, MapStyle } from './types';
|
|
1
|
+
import { Place, GeoConfig, Coordinates, SearchByTextOptions, SearchForSuggestionsResults, SearchByCoordinatesOptions, GeoProvider, MapStyle, GeofenceInput, GeofenceOptions, SaveGeofencesResults, Geofence, ListGeofenceOptions, ListGeofenceResults, DeleteGeofencesResults } from './types';
|
|
2
2
|
export declare class GeoClass {
|
|
3
3
|
static MODULE: string;
|
|
4
4
|
/**
|
|
@@ -51,7 +51,7 @@ export declare class GeoClass {
|
|
|
51
51
|
* @param {SearchByTextOptions} options? - Optional parameters to the search
|
|
52
52
|
* @returns {Promise<Place[]>} - Promise resolves to a list of Places that match search parameters
|
|
53
53
|
*/
|
|
54
|
-
searchByText(text: string, options?: SearchByTextOptions): Promise<
|
|
54
|
+
searchByText(text: string, options?: SearchByTextOptions): Promise<Place[]>;
|
|
55
55
|
/**
|
|
56
56
|
* Search for search term suggestions based on input text
|
|
57
57
|
* @param {string} text - The text string that is to be search for
|
|
@@ -65,6 +65,39 @@ export declare class GeoClass {
|
|
|
65
65
|
* @param options - Options parameters for the search
|
|
66
66
|
* @returns {Promise<Place>} - Promise that resolves to a place matching search coordinates
|
|
67
67
|
*/
|
|
68
|
-
searchByCoordinates(coordinates: Coordinates, options?: SearchByCoordinatesOptions): Promise<
|
|
68
|
+
searchByCoordinates(coordinates: Coordinates, options?: SearchByCoordinatesOptions): Promise<Place>;
|
|
69
|
+
/**
|
|
70
|
+
* Create geofences
|
|
71
|
+
* @param geofences - Single or array of geofence objects to create
|
|
72
|
+
* @param options? - Optional parameters for creating geofences
|
|
73
|
+
* @returns {Promise<SaveGeofencesResults>} - Promise that resolves to an object with:
|
|
74
|
+
* successes: list of geofences successfully created
|
|
75
|
+
* errors: list of geofences that failed to create
|
|
76
|
+
*/
|
|
77
|
+
saveGeofences(geofences: GeofenceInput | GeofenceInput[], options?: GeofenceOptions): Promise<SaveGeofencesResults>;
|
|
78
|
+
/**
|
|
79
|
+
* Get a single geofence by geofenceId
|
|
80
|
+
* @param geofenceId: string
|
|
81
|
+
* @param options?: GeofenceOptions
|
|
82
|
+
* @returns Promise<Geofence> - Promise that resolves to a geofence object
|
|
83
|
+
*/
|
|
84
|
+
getGeofence(geofenceId: string, options?: GeofenceOptions): Promise<Geofence>;
|
|
85
|
+
/**
|
|
86
|
+
* List geofences
|
|
87
|
+
* @param options?: ListGeofenceOptions
|
|
88
|
+
* @returns {Promise<ListGeofencesResults>} - Promise that resolves to an object with:
|
|
89
|
+
* entries: list of geofences - 100 geofences are listed per page
|
|
90
|
+
* nextToken: token for next page of geofences
|
|
91
|
+
*/
|
|
92
|
+
listGeofences(options?: ListGeofenceOptions): Promise<ListGeofenceResults>;
|
|
93
|
+
/**
|
|
94
|
+
* Delete geofences
|
|
95
|
+
* @param geofenceIds: string|string[]
|
|
96
|
+
* @param options?: GeofenceOptions
|
|
97
|
+
* @returns {Promise<DeleteGeofencesResults>} - Promise that resolves to an object with:
|
|
98
|
+
* successes: list of geofences successfully deleted
|
|
99
|
+
* errors: list of geofences that failed to delete
|
|
100
|
+
*/
|
|
101
|
+
deleteGeofences(geofenceIds: string | string[], options?: GeofenceOptions): Promise<DeleteGeofencesResults>;
|
|
69
102
|
}
|
|
70
103
|
export declare const Geo: GeoClass;
|
package/lib-esm/Geo.js
CHANGED
|
@@ -34,6 +34,22 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
34
34
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
38
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
39
|
+
if (!m) return o;
|
|
40
|
+
var i = m.call(o), r, ar = [], e;
|
|
41
|
+
try {
|
|
42
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
43
|
+
}
|
|
44
|
+
catch (error) { e = { error: error }; }
|
|
45
|
+
finally {
|
|
46
|
+
try {
|
|
47
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
48
|
+
}
|
|
49
|
+
finally { if (e) throw e.error; }
|
|
50
|
+
}
|
|
51
|
+
return ar;
|
|
52
|
+
};
|
|
37
53
|
/*
|
|
38
54
|
* Copyright 2017-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
39
55
|
*
|
|
@@ -48,6 +64,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
48
64
|
*/
|
|
49
65
|
import { Amplify, ConsoleLogger as Logger, parseMobileHubConfig, } from '@aws-amplify/core';
|
|
50
66
|
import { AmazonLocationServiceProvider } from './Providers/AmazonLocationServiceProvider';
|
|
67
|
+
import { validateCoordinates, validateGeofences, validateGeofenceId, } from './util';
|
|
51
68
|
var logger = new Logger('Geo');
|
|
52
69
|
var DEFAULT_PROVIDER = 'AmazonLocationService';
|
|
53
70
|
var GeoClass = /** @class */ (function () {
|
|
@@ -199,21 +216,169 @@ var GeoClass = /** @class */ (function () {
|
|
|
199
216
|
*/
|
|
200
217
|
GeoClass.prototype.searchByCoordinates = function (coordinates, options) {
|
|
201
218
|
return __awaiter(this, void 0, void 0, function () {
|
|
202
|
-
var _a, providerName, prov, error_3;
|
|
219
|
+
var _a, providerName, prov, _b, lng, lat, error_3;
|
|
220
|
+
return __generator(this, function (_c) {
|
|
221
|
+
switch (_c.label) {
|
|
222
|
+
case 0:
|
|
223
|
+
_a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
|
|
224
|
+
prov = this.getPluggable(providerName);
|
|
225
|
+
_b = __read(coordinates, 2), lng = _b[0], lat = _b[1];
|
|
226
|
+
_c.label = 1;
|
|
227
|
+
case 1:
|
|
228
|
+
_c.trys.push([1, 3, , 4]);
|
|
229
|
+
validateCoordinates(lng, lat);
|
|
230
|
+
return [4 /*yield*/, prov.searchByCoordinates(coordinates, options)];
|
|
231
|
+
case 2: return [2 /*return*/, _c.sent()];
|
|
232
|
+
case 3:
|
|
233
|
+
error_3 = _c.sent();
|
|
234
|
+
logger.debug(error_3);
|
|
235
|
+
throw error_3;
|
|
236
|
+
case 4: return [2 /*return*/];
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* Create geofences
|
|
243
|
+
* @param geofences - Single or array of geofence objects to create
|
|
244
|
+
* @param options? - Optional parameters for creating geofences
|
|
245
|
+
* @returns {Promise<SaveGeofencesResults>} - Promise that resolves to an object with:
|
|
246
|
+
* successes: list of geofences successfully created
|
|
247
|
+
* errors: list of geofences that failed to create
|
|
248
|
+
*/
|
|
249
|
+
GeoClass.prototype.saveGeofences = function (geofences, options) {
|
|
250
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
251
|
+
var _a, providerName, prov, geofenceInputArray, error_4;
|
|
203
252
|
return __generator(this, function (_b) {
|
|
204
253
|
switch (_b.label) {
|
|
205
254
|
case 0:
|
|
206
255
|
_a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
|
|
207
256
|
prov = this.getPluggable(providerName);
|
|
257
|
+
if (!Array.isArray(geofences)) {
|
|
258
|
+
geofenceInputArray = [geofences];
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
geofenceInputArray = geofences;
|
|
262
|
+
}
|
|
208
263
|
_b.label = 1;
|
|
209
264
|
case 1:
|
|
210
265
|
_b.trys.push([1, 3, , 4]);
|
|
211
|
-
|
|
266
|
+
// Validate all geofences are unique and valid before calling Provider
|
|
267
|
+
validateGeofences(geofenceInputArray);
|
|
268
|
+
return [4 /*yield*/, prov.saveGeofences(geofenceInputArray, options)];
|
|
212
269
|
case 2: return [2 /*return*/, _b.sent()];
|
|
213
270
|
case 3:
|
|
214
|
-
|
|
215
|
-
logger.debug(
|
|
216
|
-
throw
|
|
271
|
+
error_4 = _b.sent();
|
|
272
|
+
logger.debug(error_4);
|
|
273
|
+
throw error_4;
|
|
274
|
+
case 4: return [2 /*return*/];
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
};
|
|
279
|
+
/**
|
|
280
|
+
* Get a single geofence by geofenceId
|
|
281
|
+
* @param geofenceId: string
|
|
282
|
+
* @param options?: GeofenceOptions
|
|
283
|
+
* @returns Promise<Geofence> - Promise that resolves to a geofence object
|
|
284
|
+
*/
|
|
285
|
+
GeoClass.prototype.getGeofence = function (geofenceId, options) {
|
|
286
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
287
|
+
var _a, providerName, prov, error_5;
|
|
288
|
+
return __generator(this, function (_b) {
|
|
289
|
+
switch (_b.label) {
|
|
290
|
+
case 0:
|
|
291
|
+
_a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
|
|
292
|
+
prov = this.getPluggable(providerName);
|
|
293
|
+
_b.label = 1;
|
|
294
|
+
case 1:
|
|
295
|
+
_b.trys.push([1, 3, , 4]);
|
|
296
|
+
// Validate geofenceId is valid before calling Provider
|
|
297
|
+
validateGeofenceId(geofenceId);
|
|
298
|
+
return [4 /*yield*/, prov.getGeofence(geofenceId, options)];
|
|
299
|
+
case 2: return [2 /*return*/, _b.sent()];
|
|
300
|
+
case 3:
|
|
301
|
+
error_5 = _b.sent();
|
|
302
|
+
logger.debug(error_5);
|
|
303
|
+
throw error_5;
|
|
304
|
+
case 4: return [2 /*return*/];
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
};
|
|
309
|
+
/**
|
|
310
|
+
* List geofences
|
|
311
|
+
* @param options?: ListGeofenceOptions
|
|
312
|
+
* @returns {Promise<ListGeofencesResults>} - Promise that resolves to an object with:
|
|
313
|
+
* entries: list of geofences - 100 geofences are listed per page
|
|
314
|
+
* nextToken: token for next page of geofences
|
|
315
|
+
*/
|
|
316
|
+
GeoClass.prototype.listGeofences = function (options) {
|
|
317
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
318
|
+
var _a, providerName, prov, error_6;
|
|
319
|
+
return __generator(this, function (_b) {
|
|
320
|
+
switch (_b.label) {
|
|
321
|
+
case 0:
|
|
322
|
+
_a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
|
|
323
|
+
prov = this.getPluggable(providerName);
|
|
324
|
+
_b.label = 1;
|
|
325
|
+
case 1:
|
|
326
|
+
_b.trys.push([1, 3, , 4]);
|
|
327
|
+
return [4 /*yield*/, prov.listGeofences(options)];
|
|
328
|
+
case 2: return [2 /*return*/, _b.sent()];
|
|
329
|
+
case 3:
|
|
330
|
+
error_6 = _b.sent();
|
|
331
|
+
logger.debug(error_6);
|
|
332
|
+
throw error_6;
|
|
333
|
+
case 4: return [2 /*return*/];
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
};
|
|
338
|
+
/**
|
|
339
|
+
* Delete geofences
|
|
340
|
+
* @param geofenceIds: string|string[]
|
|
341
|
+
* @param options?: GeofenceOptions
|
|
342
|
+
* @returns {Promise<DeleteGeofencesResults>} - Promise that resolves to an object with:
|
|
343
|
+
* successes: list of geofences successfully deleted
|
|
344
|
+
* errors: list of geofences that failed to delete
|
|
345
|
+
*/
|
|
346
|
+
GeoClass.prototype.deleteGeofences = function (geofenceIds, options) {
|
|
347
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
348
|
+
var _a, providerName, prov, geofenceIdsInputArray, badGeofenceIds, errorString, error_7;
|
|
349
|
+
return __generator(this, function (_b) {
|
|
350
|
+
switch (_b.label) {
|
|
351
|
+
case 0:
|
|
352
|
+
_a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
|
|
353
|
+
prov = this.getPluggable(providerName);
|
|
354
|
+
if (!Array.isArray(geofenceIds)) {
|
|
355
|
+
geofenceIdsInputArray = [geofenceIds];
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
geofenceIdsInputArray = geofenceIds;
|
|
359
|
+
}
|
|
360
|
+
badGeofenceIds = geofenceIdsInputArray.filter(function (geofenceId) {
|
|
361
|
+
try {
|
|
362
|
+
validateGeofenceId(geofenceId);
|
|
363
|
+
}
|
|
364
|
+
catch (error) {
|
|
365
|
+
return false;
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
if (badGeofenceIds.length > 0) {
|
|
369
|
+
errorString = "Invalid geofence ids: " + badGeofenceIds;
|
|
370
|
+
logger.debug(errorString);
|
|
371
|
+
throw new Error(errorString);
|
|
372
|
+
}
|
|
373
|
+
_b.label = 1;
|
|
374
|
+
case 1:
|
|
375
|
+
_b.trys.push([1, 3, , 4]);
|
|
376
|
+
return [4 /*yield*/, prov.deleteGeofences(geofenceIdsInputArray, options)];
|
|
377
|
+
case 2: return [2 /*return*/, _b.sent()];
|
|
378
|
+
case 3:
|
|
379
|
+
error_7 = _b.sent();
|
|
380
|
+
logger.debug(error_7);
|
|
381
|
+
throw error_7;
|
|
217
382
|
case 4: return [2 /*return*/];
|
|
218
383
|
}
|
|
219
384
|
});
|
package/lib-esm/Geo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Geo.js","sourceRoot":"","sources":["../src/Geo.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Geo.js","sourceRoot":"","sources":["../src/Geo.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EACN,OAAO,EACP,aAAa,IAAI,MAAM,EACvB,oBAAoB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,6BAA6B,EAAE,MAAM,2CAA2C,CAAC;AAE1F,O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AAM,IAAI,CAAC,eAAe,CAAC,qBAAqB,EAAE,OAAO,CAAC,EAAA;4BAAjE,sBAAO,SAA0D,EAAC;;;wBAElE,MAAM,CAAC,KAAK,CAAC,OAAK,CAAC,CAAC;wBACpB,MAAM,OAAK,CAAC;;;;;KAEb;IApSM,eAAM,GAAG,KAAK,CAAC;IAqSvB,eAAC;CAAA,AAtSD,IAsSC;SAtSY,QAAQ;AAwSrB,MAAM,CAAC,IAAM,GAAG,GAAG,IAAI,QAAQ,EAAE,CAAC;AAClC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GeoConfig, SearchByTextOptions, SearchByCoordinatesOptions, GeoProvider, Place, AmazonLocationServiceMapStyle, Coordinates, SearchForSuggestionsResults } from '../types';
|
|
1
|
+
import { GeoConfig, SearchByTextOptions, SearchByCoordinatesOptions, GeoProvider, Place, AmazonLocationServiceMapStyle, Coordinates, SearchForSuggestionsResults, GeofenceInput, AmazonLocationServiceGeofenceOptions, AmazonLocationServiceListGeofenceOptions, ListGeofenceResults, SaveGeofencesResults, AmazonLocationServiceGeofence, AmazonLocationServiceDeleteGeofencesResults } from '../types';
|
|
2
2
|
export declare class AmazonLocationServiceProvider implements GeoProvider {
|
|
3
3
|
static CATEGORY: string;
|
|
4
4
|
static PROVIDER_NAME: string;
|
|
@@ -58,10 +58,46 @@ export declare class AmazonLocationServiceProvider implements GeoProvider {
|
|
|
58
58
|
* @returns {Promise<Place>} - Promise that resolves to a place matching search coordinates
|
|
59
59
|
*/
|
|
60
60
|
searchByCoordinates(coordinates: Coordinates, options?: SearchByCoordinatesOptions): Promise<Place>;
|
|
61
|
+
/**
|
|
62
|
+
* Create geofences inside of a geofence collection
|
|
63
|
+
* @param geofences - Array of geofence objects to create
|
|
64
|
+
* @param options? - Optional parameters for creating geofences
|
|
65
|
+
* @returns {Promise<AmazonLocationServiceSaveGeofencesResults>} - Promise that resolves to an object with:
|
|
66
|
+
* successes: list of geofences successfully created
|
|
67
|
+
* errors: list of geofences that failed to create
|
|
68
|
+
*/
|
|
69
|
+
saveGeofences(geofences: GeofenceInput[], options?: AmazonLocationServiceGeofenceOptions): Promise<SaveGeofencesResults>;
|
|
70
|
+
/**
|
|
71
|
+
* Get geofence from a geofence collection
|
|
72
|
+
* @param geofenceId:string
|
|
73
|
+
* @param options?: Optional parameters for getGeofence
|
|
74
|
+
* @returns {Promise<AmazonLocationServiceGeofence>} - Promise that resolves to a geofence object
|
|
75
|
+
*/
|
|
76
|
+
getGeofence(geofenceId: string, options?: AmazonLocationServiceGeofenceOptions): Promise<AmazonLocationServiceGeofence>;
|
|
77
|
+
/**
|
|
78
|
+
* List geofences from a geofence collection
|
|
79
|
+
* @param options?: ListGeofenceOptions
|
|
80
|
+
* @returns {Promise<ListGeofencesResults>} - Promise that resolves to an object with:
|
|
81
|
+
* entries: list of geofences - 100 geofences are listed per page
|
|
82
|
+
* nextToken: token for next page of geofences
|
|
83
|
+
*/
|
|
84
|
+
listGeofences(options?: AmazonLocationServiceListGeofenceOptions): Promise<ListGeofenceResults>;
|
|
85
|
+
/**
|
|
86
|
+
* Delete geofences from a geofence collection
|
|
87
|
+
* @param geofenceIds: string|string[]
|
|
88
|
+
* @param options?: GeofenceOptions
|
|
89
|
+
* @returns {Promise<DeleteGeofencesResults>} - Promise that resolves to an object with:
|
|
90
|
+
* successes: list of geofences successfully deleted
|
|
91
|
+
* errors: list of geofences that failed to delete
|
|
92
|
+
*/
|
|
93
|
+
deleteGeofences(geofenceIds: string[], options?: AmazonLocationServiceGeofenceOptions): Promise<AmazonLocationServiceDeleteGeofencesResults>;
|
|
61
94
|
/**
|
|
62
95
|
* @private
|
|
63
96
|
*/
|
|
64
97
|
private _ensureCredentials;
|
|
65
98
|
private _verifyMapResources;
|
|
66
99
|
private _verifySearchIndex;
|
|
100
|
+
private _verifyGeofenceCollections;
|
|
101
|
+
private _AmazonLocationServiceBatchPutGeofenceCall;
|
|
102
|
+
private _AmazonLocationServiceBatchDeleteGeofenceCall;
|
|
67
103
|
}
|