@aws-amplify/geo 1.2.4 → 1.2.5-geo.11
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 +2020 -137
- 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 -10
- package/lib/Geo.js +140 -20
- package/lib/Geo.js.map +1 -1
- package/lib/Providers/AmazonLocationServiceProvider.d.ts +37 -8
- package/lib/Providers/AmazonLocationServiceProvider.js +405 -53
- package/lib/Providers/AmazonLocationServiceProvider.js.map +1 -1
- package/lib/types/AmazonLocationServiceProvider.d.ts +21 -1
- package/lib/types/Geo.d.ts +48 -2
- package/lib/types/Provider.d.ts +5 -2
- 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 +144 -0
- package/lib/util.js.map +1 -0
- package/lib-esm/Geo.d.ts +36 -10
- package/lib-esm/Geo.js +140 -20
- package/lib-esm/Geo.js.map +1 -1
- package/lib-esm/Providers/AmazonLocationServiceProvider.d.ts +37 -8
- package/lib-esm/Providers/AmazonLocationServiceProvider.js +406 -54
- 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 -2
- package/lib-esm/types/Provider.d.ts +5 -2
- 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 +134 -0
- package/lib-esm/util.js.map +1 -0
- package/package.json +6 -4
- package/src/Geo.ts +118 -20
- package/src/Providers/AmazonLocationServiceProvider.ts +422 -75
- package/src/types/AmazonLocationServiceProvider.ts +56 -1
- package/src/types/Geo.ts +71 -4
- package/src/types/Provider.ts +29 -6
- package/src/util.ts +173 -0
package/lib/types/Geo.d.ts
CHANGED
|
@@ -9,14 +9,18 @@ export interface GeoConfig {
|
|
|
9
9
|
items: string[];
|
|
10
10
|
default: string;
|
|
11
11
|
};
|
|
12
|
+
geofenceCollections?: {
|
|
13
|
+
items: string[];
|
|
14
|
+
default: string;
|
|
15
|
+
};
|
|
12
16
|
};
|
|
13
17
|
}
|
|
14
18
|
export interface MapStyle {
|
|
15
19
|
mapName: string;
|
|
16
20
|
style: string;
|
|
17
21
|
}
|
|
18
|
-
export declare type Latitude = number;
|
|
19
22
|
export declare type Longitude = number;
|
|
23
|
+
export declare type Latitude = number;
|
|
20
24
|
export declare type Coordinates = [Longitude, Latitude];
|
|
21
25
|
export declare type SWLongitude = Longitude;
|
|
22
26
|
export declare type SWLatitude = Latitude;
|
|
@@ -56,4 +60,46 @@ export interface Place {
|
|
|
56
60
|
street?: string;
|
|
57
61
|
subRegion?: string;
|
|
58
62
|
}
|
|
59
|
-
export declare type
|
|
63
|
+
export declare type LinearRing = Coordinates[];
|
|
64
|
+
export declare type GeofencePolygon = LinearRing[];
|
|
65
|
+
export declare type PolygonGeometry = {
|
|
66
|
+
polygon: GeofencePolygon;
|
|
67
|
+
};
|
|
68
|
+
export declare type GeofenceInput = {
|
|
69
|
+
geofenceId: string;
|
|
70
|
+
geometry: PolygonGeometry;
|
|
71
|
+
};
|
|
72
|
+
export declare type GeofenceOptions = {
|
|
73
|
+
providerName?: string;
|
|
74
|
+
};
|
|
75
|
+
export declare type GeofenceError = {
|
|
76
|
+
error: {
|
|
77
|
+
code: string;
|
|
78
|
+
message: string;
|
|
79
|
+
};
|
|
80
|
+
geofenceId: string;
|
|
81
|
+
};
|
|
82
|
+
declare type GeofenceBase = {
|
|
83
|
+
geofenceId: string;
|
|
84
|
+
createTime?: Date;
|
|
85
|
+
updateTime?: Date;
|
|
86
|
+
};
|
|
87
|
+
export declare type Geofence = GeofenceBase & {
|
|
88
|
+
geometry: PolygonGeometry;
|
|
89
|
+
};
|
|
90
|
+
export declare type SaveGeofencesResults = {
|
|
91
|
+
successes: GeofenceBase[];
|
|
92
|
+
errors: GeofenceError[];
|
|
93
|
+
};
|
|
94
|
+
export declare type ListGeofenceOptions = GeofenceOptions & {
|
|
95
|
+
nextToken?: string;
|
|
96
|
+
};
|
|
97
|
+
export declare type ListGeofenceResults = {
|
|
98
|
+
entries: Geofence[];
|
|
99
|
+
nextToken: string;
|
|
100
|
+
};
|
|
101
|
+
export declare type DeleteGeofencesResults = {
|
|
102
|
+
successes: string[];
|
|
103
|
+
errors: GeofenceError[];
|
|
104
|
+
};
|
|
105
|
+
export {};
|
package/lib/types/Provider.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SearchByTextOptions, SearchByCoordinatesOptions,
|
|
1
|
+
import { SearchByTextOptions, SearchByCoordinatesOptions, Coordinates, Place, MapStyle, Geofence, GeofenceInput, GeofenceOptions, ListGeofenceOptions, ListGeofenceResults, SaveGeofencesResults, DeleteGeofencesResults } from './Geo';
|
|
2
2
|
export interface GeoProvider {
|
|
3
3
|
getCategory(): string;
|
|
4
4
|
getProviderName(): string;
|
|
@@ -7,5 +7,8 @@ export interface GeoProvider {
|
|
|
7
7
|
getDefaultMap(): MapStyle;
|
|
8
8
|
searchByText(text: string, options?: SearchByTextOptions): Promise<Place[]>;
|
|
9
9
|
searchByCoordinates(coordinates: Coordinates, options?: SearchByCoordinatesOptions): Promise<Place>;
|
|
10
|
-
|
|
10
|
+
saveGeofences(geofences: GeofenceInput[], options?: GeofenceOptions): Promise<SaveGeofencesResults>;
|
|
11
|
+
getGeofence(geofenceId: string, options?: ListGeofenceOptions): Promise<Geofence>;
|
|
12
|
+
listGeofences(options?: ListGeofenceOptions): Promise<ListGeofenceResults>;
|
|
13
|
+
deleteGeofences(geofenceIds: string[], options?: GeofenceOptions): Promise<DeleteGeofencesResults>;
|
|
11
14
|
}
|
package/lib/types/Provider.js
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2017-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
6
|
-
* the License. A copy of the License is located at
|
|
7
|
-
*
|
|
8
|
-
* http://aws.amazon.com/apache2.0/
|
|
9
|
-
*
|
|
10
|
-
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
11
|
-
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
|
12
|
-
* and limitations under the License.
|
|
13
|
-
*/
|
|
14
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
3
|
//# sourceMappingURL=Provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.js","sourceRoot":"","sources":["../../src/types/Provider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Provider.js","sourceRoot":"","sources":["../../src/types/Provider.ts"],"names":[],"mappings":""}
|
package/lib/util.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Longitude, Latitude, GeofenceInput, GeofencePolygon, LinearRing } from './types';
|
|
2
|
+
export declare function validateCoordinates(lng: Longitude, lat: Latitude): void;
|
|
3
|
+
export declare function validateGeofenceId(geofenceId: string): void;
|
|
4
|
+
export declare function validateLinearRing(linearRing: LinearRing, geofenceId?: string): void;
|
|
5
|
+
export declare function validatePolygon(polygon: GeofencePolygon, geofenceId?: string): void;
|
|
6
|
+
export declare function validateGeofencesInput(geofences: GeofenceInput[]): void;
|
package/lib/util.js
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
/*
|
|
23
|
+
* Copyright 2017-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
24
|
+
*
|
|
25
|
+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
26
|
+
* the License. A copy of the License is located at
|
|
27
|
+
*
|
|
28
|
+
* http://aws.amazon.com/apache2.0/
|
|
29
|
+
*
|
|
30
|
+
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
31
|
+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
|
32
|
+
* and limitations under the License.
|
|
33
|
+
*/
|
|
34
|
+
var boolean_clockwise_1 = __importDefault(require("@turf/boolean-clockwise"));
|
|
35
|
+
function validateCoordinates(lng, lat) {
|
|
36
|
+
if (!Number.isFinite(lng) || !Number.isFinite(lat)) {
|
|
37
|
+
throw new Error("Invalid coordinates: [" + lng + "," + lat + "]");
|
|
38
|
+
}
|
|
39
|
+
if (lat < -90 || lat > 90) {
|
|
40
|
+
throw new Error('Latitude must be between -90 and 90 degrees inclusive.');
|
|
41
|
+
}
|
|
42
|
+
else if (lng < -180 || lng > 180) {
|
|
43
|
+
throw new Error('Longitude must be between -180 and 180 degrees inclusive.');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.validateCoordinates = validateCoordinates;
|
|
47
|
+
function validateGeofenceId(geofenceId) {
|
|
48
|
+
var geofenceIdRegex = /^[-._\p{L}\p{N}]+$/iu;
|
|
49
|
+
// Check if geofenceId is valid
|
|
50
|
+
if (!geofenceIdRegex.test(geofenceId)) {
|
|
51
|
+
throw new Error("Invalid geofenceId: '" + geofenceId + "' - IDs can only contain alphanumeric characters, hyphens, underscores and periods.");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.validateGeofenceId = validateGeofenceId;
|
|
55
|
+
function validateLinearRing(linearRing, geofenceId) {
|
|
56
|
+
var errorPrefix = geofenceId ? geofenceId + ": " : '';
|
|
57
|
+
// Validate LinearRing size, must be at least 4 points
|
|
58
|
+
if (linearRing.length < 4) {
|
|
59
|
+
throw new Error(errorPrefix + "LinearRing must contain 4 or more coordinates.");
|
|
60
|
+
}
|
|
61
|
+
// Validate all coordinates are valid, error with which ones are bad
|
|
62
|
+
var badCoordinates = [];
|
|
63
|
+
linearRing.forEach(function (coordinates) {
|
|
64
|
+
try {
|
|
65
|
+
validateCoordinates(coordinates[0], coordinates[1]);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
badCoordinates.push({ coordinates: coordinates, error: error.message });
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
if (badCoordinates.length > 0) {
|
|
72
|
+
throw new Error(errorPrefix + "One or more of the coordinates in the Polygon LinearRing are not valid: " + JSON.stringify(badCoordinates));
|
|
73
|
+
}
|
|
74
|
+
// Validate first and last coordinates are the same
|
|
75
|
+
var _a = __read(linearRing[0], 2), lngA = _a[0], latA = _a[1];
|
|
76
|
+
var _b = __read(linearRing[linearRing.length - 1], 2), lngB = _b[0], latB = _b[1];
|
|
77
|
+
if (lngA !== lngB || latA !== latB) {
|
|
78
|
+
throw new Error(errorPrefix + "LinearRing's first and last coordinates are not the same");
|
|
79
|
+
}
|
|
80
|
+
if (boolean_clockwise_1.default(linearRing)) {
|
|
81
|
+
throw new Error(errorPrefix + "LinearRing coordinates must be wound counterclockwise");
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.validateLinearRing = validateLinearRing;
|
|
85
|
+
function validatePolygon(polygon, geofenceId) {
|
|
86
|
+
var errorPrefix = geofenceId ? geofenceId + ": " : '';
|
|
87
|
+
if (!Array.isArray(polygon)) {
|
|
88
|
+
throw new Error(errorPrefix + "Polygon is of incorrect structure. It should be an array of LinearRings");
|
|
89
|
+
}
|
|
90
|
+
if (polygon.length < 1) {
|
|
91
|
+
throw new Error(errorPrefix + "Polygon must have a single LinearRing array.");
|
|
92
|
+
}
|
|
93
|
+
if (polygon.length > 1) {
|
|
94
|
+
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.");
|
|
95
|
+
}
|
|
96
|
+
var verticesCount = polygon.reduce(function (prev, linearRing) { return prev + linearRing.length; }, 0);
|
|
97
|
+
if (verticesCount > 1000) {
|
|
98
|
+
throw new Error(errorPrefix + "Polygon has more than the maximum 1000 vertices.");
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.validatePolygon = validatePolygon;
|
|
102
|
+
function validateGeofencesInput(geofences) {
|
|
103
|
+
var geofenceIds = {};
|
|
104
|
+
geofences.forEach(function (geofence) {
|
|
105
|
+
// verify all required properties are present
|
|
106
|
+
// Validate geofenceId exists
|
|
107
|
+
if (!geofence.geofenceId) {
|
|
108
|
+
throw new Error("Geofence '" + geofence + "' is missing geofenceId");
|
|
109
|
+
}
|
|
110
|
+
var geofenceId = geofence.geofenceId;
|
|
111
|
+
validateGeofenceId(geofenceId);
|
|
112
|
+
// Validate geofenceId is unique
|
|
113
|
+
if (geofenceIds[geofenceId]) {
|
|
114
|
+
throw new Error("Duplicate geofenceId: " + geofenceId);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
geofenceIds[geofenceId] = true;
|
|
118
|
+
}
|
|
119
|
+
// Validate geometry exists
|
|
120
|
+
if (!geofence.geometry) {
|
|
121
|
+
throw new Error("Geofence '" + geofenceId + "' is missing geometry");
|
|
122
|
+
}
|
|
123
|
+
var geometry = geofence.geometry;
|
|
124
|
+
// Validate polygon exists
|
|
125
|
+
if (!geometry.polygon) {
|
|
126
|
+
throw new Error("Geofence '" + geofenceId + "' is missing geometry.polygon");
|
|
127
|
+
}
|
|
128
|
+
var polygon = geometry.polygon;
|
|
129
|
+
// Validate polygon length and structure
|
|
130
|
+
try {
|
|
131
|
+
validatePolygon(polygon, geofenceId);
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
if (error.message === "Polygon has more than the maximum 1000 vertices.") {
|
|
135
|
+
throw new Error("Geofence '" + geofenceId + "' has more than the maximum of 1000 vertices");
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// Validate LinearRing length, structure, and coordinates
|
|
139
|
+
var _a = __read(polygon, 1), linearRing = _a[0];
|
|
140
|
+
validateLinearRing(linearRing, geofenceId);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
exports.validateGeofencesInput = validateGeofencesInput;
|
|
144
|
+
//# sourceMappingURL=util.js.map
|
package/lib/util.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;GAWG;AACH,8EAAuD;AAUvD,SAAgB,mBAAmB,CAAC,GAAc,EAAE,GAAa;IAChE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACnD,MAAM,IAAI,KAAK,CAAC,2BAAyB,GAAG,SAAI,GAAG,MAAG,CAAC,CAAC;KACxD;IACD,IAAI,GAAG,GAAG,CAAC,EAAE,IAAI,GAAG,GAAG,EAAE,EAAE;QA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;QAC7B,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,eAAa,QAAQ,4BAAyB,CAAC,CAAC;SAChE;QACO,IAAA,gCAAU,CAAc;QAChC,kBAAkB,CAAC,UAAU,CAAC,CAAC;QAE/B,gCAAgC;QAChC,IAAI,WAAW,CAAC,UAAU,CAAC,EAAE;YAC5B,MAAM,IAAI,KAAK,CAAC,2BAAyB,UAAY,CAAC,CAAC;SACvD;aAAM;YACN,WAAW,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;SAC/B;QAED,2BAA2B;QAC3B,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE;YACvB,MAAM,IAAI,KAAK,CAAC,eAAa,UAAU,0BAAuB,CAAC,CAAC;SAChE;QACO,IAAA,4BAAQ,CAAc;QAE9B,0BAA0B;QAC1B,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;YACtB,MAAM,IAAI,KAAK,CAAC,eAAa,UAAU,kCAA+B,CAAC,CAAC;SACxE;QACO,IAAA,0BAAO,CAAc;QAE7B,wCAAwC;QACxC,IAAI;YACH,eAAe,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;SACrC;QAAC,OAAO,KAAK,EAAE;YACf,IACC,KAAK,CAAC,OAAO,KAAK,kDAAkD,EACnE;gBACD,MAAM,IAAI,KAAK,CACd,eAAa,UAAU,iDAA8C,CACrE,CAAC;aACF;SACD;QAED,yDAAyD;QACnD,IAAA,uBAAsB,EAArB,kBAAqB,CAAC;QAC7B,kBAAkB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACJ,CAAC;AAjDD,wDAiDC"}
|
package/lib-esm/Geo.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GeoConfig, Coordinates, SearchByTextOptions,
|
|
1
|
+
import { Place, GeoConfig, Coordinates, SearchByTextOptions, 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,20 +51,46 @@ 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<
|
|
55
|
-
/**
|
|
56
|
-
* Search for search term suggestions based on input text
|
|
57
|
-
* @param {string} text - The text string that is to be search for
|
|
58
|
-
* @param {SearchByTextOptions} options? - Optional parameters to the search
|
|
59
|
-
* @returns {Promise<SearchForSuggestionsResults>} - Resolves to an array of search suggestion strings
|
|
60
|
-
*/
|
|
61
|
-
searchForSuggestions(text: string, options?: SearchByTextOptions): Promise<SearchForSuggestionsResults>;
|
|
54
|
+
searchByText(text: string, options?: SearchByTextOptions): Promise<Place[]>;
|
|
62
55
|
/**
|
|
63
56
|
* Reverse geocoding search via a coordinate point on the map
|
|
64
57
|
* @param coordinates - Coordinates array for the search input
|
|
65
58
|
* @param options - Options parameters for the search
|
|
66
59
|
* @returns {Promise<Place>} - Promise that resolves to a place matching search coordinates
|
|
67
60
|
*/
|
|
68
|
-
searchByCoordinates(coordinates: Coordinates, options?: SearchByCoordinatesOptions): Promise<
|
|
61
|
+
searchByCoordinates(coordinates: Coordinates, options?: SearchByCoordinatesOptions): Promise<Place>;
|
|
62
|
+
/**
|
|
63
|
+
* Create geofences
|
|
64
|
+
* @param geofences - Single or array of geofence objects to create
|
|
65
|
+
* @param options? - Optional parameters for creating geofences
|
|
66
|
+
* @returns {Promise<SaveGeofencesResults>} - Promise that resolves to an object with:
|
|
67
|
+
* successes: list of geofences successfully created
|
|
68
|
+
* errors: list of geofences that failed to create
|
|
69
|
+
*/
|
|
70
|
+
saveGeofences(geofences: GeofenceInput | GeofenceInput[], options?: GeofenceOptions): Promise<SaveGeofencesResults>;
|
|
71
|
+
/**
|
|
72
|
+
* Get a single geofence by geofenceId
|
|
73
|
+
* @param geofenceId: string
|
|
74
|
+
* @param options?: GeofenceOptions
|
|
75
|
+
* @returns Promise<Geofence> - Promise that resolves to a geofence object
|
|
76
|
+
*/
|
|
77
|
+
getGeofence(geofenceId: string, options?: GeofenceOptions): Promise<Geofence>;
|
|
78
|
+
/**
|
|
79
|
+
* List geofences
|
|
80
|
+
* @param options?: ListGeofenceOptions
|
|
81
|
+
* @returns {Promise<ListGeofencesResults>} - Promise that resolves to an object with:
|
|
82
|
+
* entries: list of geofences - 100 geofences are listed per page
|
|
83
|
+
* nextToken: token for next page of geofences
|
|
84
|
+
*/
|
|
85
|
+
listGeofences(options?: ListGeofenceOptions): Promise<ListGeofenceResults>;
|
|
86
|
+
/**
|
|
87
|
+
* Delete geofences
|
|
88
|
+
* @param geofenceIds: string|string[]
|
|
89
|
+
* @param options?: GeofenceOptions
|
|
90
|
+
* @returns {Promise<DeleteGeofencesResults>} - Promise that resolves to an object with:
|
|
91
|
+
* successes: list of geofences successfully deleted
|
|
92
|
+
* errors: list of geofences that failed to delete
|
|
93
|
+
*/
|
|
94
|
+
deleteGeofences(geofenceIds: string | string[], options?: GeofenceOptions): Promise<DeleteGeofencesResults>;
|
|
69
95
|
}
|
|
70
96
|
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 } from './util';
|
|
51
68
|
var logger = new Logger('Geo');
|
|
52
69
|
var DEFAULT_PROVIDER = 'AmazonLocationService';
|
|
53
70
|
var GeoClass = /** @class */ (function () {
|
|
@@ -164,26 +181,28 @@ var GeoClass = /** @class */ (function () {
|
|
|
164
181
|
});
|
|
165
182
|
};
|
|
166
183
|
/**
|
|
167
|
-
*
|
|
168
|
-
* @param
|
|
169
|
-
* @param
|
|
170
|
-
* @returns {Promise<
|
|
184
|
+
* Reverse geocoding search via a coordinate point on the map
|
|
185
|
+
* @param coordinates - Coordinates array for the search input
|
|
186
|
+
* @param options - Options parameters for the search
|
|
187
|
+
* @returns {Promise<Place>} - Promise that resolves to a place matching search coordinates
|
|
171
188
|
*/
|
|
172
|
-
GeoClass.prototype.
|
|
189
|
+
GeoClass.prototype.searchByCoordinates = function (coordinates, options) {
|
|
173
190
|
return __awaiter(this, void 0, void 0, function () {
|
|
174
|
-
var _a, providerName, prov, error_2;
|
|
175
|
-
return __generator(this, function (
|
|
176
|
-
switch (
|
|
191
|
+
var _a, providerName, prov, _b, lng, lat, error_2;
|
|
192
|
+
return __generator(this, function (_c) {
|
|
193
|
+
switch (_c.label) {
|
|
177
194
|
case 0:
|
|
178
195
|
_a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
|
|
179
196
|
prov = this.getPluggable(providerName);
|
|
180
|
-
_b
|
|
197
|
+
_b = __read(coordinates, 2), lng = _b[0], lat = _b[1];
|
|
198
|
+
_c.label = 1;
|
|
181
199
|
case 1:
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
200
|
+
_c.trys.push([1, 3, , 4]);
|
|
201
|
+
validateCoordinates(lng, lat);
|
|
202
|
+
return [4 /*yield*/, prov.searchByCoordinates(coordinates, options)];
|
|
203
|
+
case 2: return [2 /*return*/, _c.sent()];
|
|
185
204
|
case 3:
|
|
186
|
-
error_2 =
|
|
205
|
+
error_2 = _c.sent();
|
|
187
206
|
logger.debug(error_2);
|
|
188
207
|
throw error_2;
|
|
189
208
|
case 4: return [2 /*return*/];
|
|
@@ -192,23 +211,31 @@ var GeoClass = /** @class */ (function () {
|
|
|
192
211
|
});
|
|
193
212
|
};
|
|
194
213
|
/**
|
|
195
|
-
*
|
|
196
|
-
* @param
|
|
197
|
-
* @param options -
|
|
198
|
-
* @returns {Promise<
|
|
214
|
+
* Create geofences
|
|
215
|
+
* @param geofences - Single or array of geofence objects to create
|
|
216
|
+
* @param options? - Optional parameters for creating geofences
|
|
217
|
+
* @returns {Promise<SaveGeofencesResults>} - Promise that resolves to an object with:
|
|
218
|
+
* successes: list of geofences successfully created
|
|
219
|
+
* errors: list of geofences that failed to create
|
|
199
220
|
*/
|
|
200
|
-
GeoClass.prototype.
|
|
221
|
+
GeoClass.prototype.saveGeofences = function (geofences, options) {
|
|
201
222
|
return __awaiter(this, void 0, void 0, function () {
|
|
202
|
-
var _a, providerName, prov, error_3;
|
|
223
|
+
var _a, providerName, prov, geofenceInputArray, error_3;
|
|
203
224
|
return __generator(this, function (_b) {
|
|
204
225
|
switch (_b.label) {
|
|
205
226
|
case 0:
|
|
206
227
|
_a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
|
|
207
228
|
prov = this.getPluggable(providerName);
|
|
229
|
+
if (!Array.isArray(geofences)) {
|
|
230
|
+
geofenceInputArray = [geofences];
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
geofenceInputArray = geofences;
|
|
234
|
+
}
|
|
208
235
|
_b.label = 1;
|
|
209
236
|
case 1:
|
|
210
237
|
_b.trys.push([1, 3, , 4]);
|
|
211
|
-
return [4 /*yield*/, prov.
|
|
238
|
+
return [4 /*yield*/, prov.saveGeofences(geofenceInputArray, options)];
|
|
212
239
|
case 2: return [2 /*return*/, _b.sent()];
|
|
213
240
|
case 3:
|
|
214
241
|
error_3 = _b.sent();
|
|
@@ -219,6 +246,99 @@ var GeoClass = /** @class */ (function () {
|
|
|
219
246
|
});
|
|
220
247
|
});
|
|
221
248
|
};
|
|
249
|
+
/**
|
|
250
|
+
* Get a single geofence by geofenceId
|
|
251
|
+
* @param geofenceId: string
|
|
252
|
+
* @param options?: GeofenceOptions
|
|
253
|
+
* @returns Promise<Geofence> - Promise that resolves to a geofence object
|
|
254
|
+
*/
|
|
255
|
+
GeoClass.prototype.getGeofence = function (geofenceId, options) {
|
|
256
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
257
|
+
var _a, providerName, prov, error_4;
|
|
258
|
+
return __generator(this, function (_b) {
|
|
259
|
+
switch (_b.label) {
|
|
260
|
+
case 0:
|
|
261
|
+
_a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
|
|
262
|
+
prov = this.getPluggable(providerName);
|
|
263
|
+
_b.label = 1;
|
|
264
|
+
case 1:
|
|
265
|
+
_b.trys.push([1, 3, , 4]);
|
|
266
|
+
return [4 /*yield*/, prov.getGeofence(geofenceId, options)];
|
|
267
|
+
case 2: return [2 /*return*/, _b.sent()];
|
|
268
|
+
case 3:
|
|
269
|
+
error_4 = _b.sent();
|
|
270
|
+
logger.debug(error_4);
|
|
271
|
+
throw error_4;
|
|
272
|
+
case 4: return [2 /*return*/];
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
};
|
|
277
|
+
/**
|
|
278
|
+
* List geofences
|
|
279
|
+
* @param options?: ListGeofenceOptions
|
|
280
|
+
* @returns {Promise<ListGeofencesResults>} - Promise that resolves to an object with:
|
|
281
|
+
* entries: list of geofences - 100 geofences are listed per page
|
|
282
|
+
* nextToken: token for next page of geofences
|
|
283
|
+
*/
|
|
284
|
+
GeoClass.prototype.listGeofences = function (options) {
|
|
285
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
286
|
+
var _a, providerName, prov, error_5;
|
|
287
|
+
return __generator(this, function (_b) {
|
|
288
|
+
switch (_b.label) {
|
|
289
|
+
case 0:
|
|
290
|
+
_a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
|
|
291
|
+
prov = this.getPluggable(providerName);
|
|
292
|
+
_b.label = 1;
|
|
293
|
+
case 1:
|
|
294
|
+
_b.trys.push([1, 3, , 4]);
|
|
295
|
+
return [4 /*yield*/, prov.listGeofences(options)];
|
|
296
|
+
case 2: return [2 /*return*/, _b.sent()];
|
|
297
|
+
case 3:
|
|
298
|
+
error_5 = _b.sent();
|
|
299
|
+
logger.debug(error_5);
|
|
300
|
+
throw error_5;
|
|
301
|
+
case 4: return [2 /*return*/];
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
};
|
|
306
|
+
/**
|
|
307
|
+
* Delete geofences
|
|
308
|
+
* @param geofenceIds: string|string[]
|
|
309
|
+
* @param options?: GeofenceOptions
|
|
310
|
+
* @returns {Promise<DeleteGeofencesResults>} - Promise that resolves to an object with:
|
|
311
|
+
* successes: list of geofences successfully deleted
|
|
312
|
+
* errors: list of geofences that failed to delete
|
|
313
|
+
*/
|
|
314
|
+
GeoClass.prototype.deleteGeofences = function (geofenceIds, options) {
|
|
315
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
316
|
+
var _a, providerName, prov, geofenceIdsInputArray, error_6;
|
|
317
|
+
return __generator(this, function (_b) {
|
|
318
|
+
switch (_b.label) {
|
|
319
|
+
case 0:
|
|
320
|
+
_a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
|
|
321
|
+
prov = this.getPluggable(providerName);
|
|
322
|
+
if (!Array.isArray(geofenceIds)) {
|
|
323
|
+
geofenceIdsInputArray = [geofenceIds];
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
geofenceIdsInputArray = geofenceIds;
|
|
327
|
+
}
|
|
328
|
+
_b.label = 1;
|
|
329
|
+
case 1:
|
|
330
|
+
_b.trys.push([1, 3, , 4]);
|
|
331
|
+
return [4 /*yield*/, prov.deleteGeofences(geofenceIdsInputArray, options)];
|
|
332
|
+
case 2: return [2 /*return*/, _b.sent()];
|
|
333
|
+
case 3:
|
|
334
|
+
error_6 = _b.sent();
|
|
335
|
+
logger.debug(error_6);
|
|
336
|
+
throw error_6;
|
|
337
|
+
case 4: return [2 /*return*/];
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
});
|
|
341
|
+
};
|
|
222
342
|
GeoClass.MODULE = 'Geo';
|
|
223
343
|
return GeoClass;
|
|
224
344
|
}());
|
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,CAA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AA,aAAlB,EAA/B,YAAY,mBAAG,gBAAgB,KAAA,CAAmB;wBACpD,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;wBAI7C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;4BAChC,qBAAqB,GAAG,CAAC,WAAW,CAAC,CAAC;yBACtC;6BAAM;4BACN,qBAAqB,GAAG,WAAW,CAAC;yBACpC;;;;wBAIO,qBAAM,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;IA7PM,eAAM,GAAG,KAAK,CAAC;IA8PvB,eAAC;CAAA,AA/PD,IA+PC;SA/PY,QAAQ;AAiQrB,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,
|
|
1
|
+
import { GeoConfig, SearchByTextOptions, SearchByCoordinatesOptions, GeoProvider, Place, AmazonLocationServiceMapStyle, Coordinates, 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;
|
|
@@ -44,13 +44,6 @@ export declare class AmazonLocationServiceProvider implements GeoProvider {
|
|
|
44
44
|
* @returns {Promise<Place[]>} - Promise resolves to a list of Places that match search parameters
|
|
45
45
|
*/
|
|
46
46
|
searchByText(text: string, options?: SearchByTextOptions): Promise<Place[]>;
|
|
47
|
-
/**
|
|
48
|
-
* Search for suggestions based on the input text
|
|
49
|
-
* @param {string} text - The text string that is to be searched for
|
|
50
|
-
* @param {SearchByTextOptions} options? - Optional parameters to the search
|
|
51
|
-
* @returns {Promise<SearchForSuggestionsResults>} - Resolves to an array of search suggestion strings
|
|
52
|
-
*/
|
|
53
|
-
searchForSuggestions(text: string, options?: SearchByTextOptions): Promise<SearchForSuggestionsResults>;
|
|
54
47
|
/**
|
|
55
48
|
* Reverse geocoding search via a coordinate point on the map
|
|
56
49
|
* @param coordinates - Coordinates array for the search input
|
|
@@ -58,10 +51,46 @@ export declare class AmazonLocationServiceProvider implements GeoProvider {
|
|
|
58
51
|
* @returns {Promise<Place>} - Promise that resolves to a place matching search coordinates
|
|
59
52
|
*/
|
|
60
53
|
searchByCoordinates(coordinates: Coordinates, options?: SearchByCoordinatesOptions): Promise<Place>;
|
|
54
|
+
/**
|
|
55
|
+
* Create geofences inside of a geofence collection
|
|
56
|
+
* @param geofences - Array of geofence objects to create
|
|
57
|
+
* @param options? - Optional parameters for creating geofences
|
|
58
|
+
* @returns {Promise<AmazonLocationServiceSaveGeofencesResults>} - Promise that resolves to an object with:
|
|
59
|
+
* successes: list of geofences successfully created
|
|
60
|
+
* errors: list of geofences that failed to create
|
|
61
|
+
*/
|
|
62
|
+
saveGeofences(geofences: GeofenceInput[], options?: AmazonLocationServiceGeofenceOptions): Promise<SaveGeofencesResults>;
|
|
63
|
+
/**
|
|
64
|
+
* Get geofence from a geofence collection
|
|
65
|
+
* @param geofenceId:string
|
|
66
|
+
* @param options?: Optional parameters for getGeofence
|
|
67
|
+
* @returns {Promise<AmazonLocationServiceGeofence>} - Promise that resolves to a geofence object
|
|
68
|
+
*/
|
|
69
|
+
getGeofence(geofenceId: string, options?: AmazonLocationServiceGeofenceOptions): Promise<AmazonLocationServiceGeofence>;
|
|
70
|
+
/**
|
|
71
|
+
* List geofences from a geofence collection
|
|
72
|
+
* @param options?: ListGeofenceOptions
|
|
73
|
+
* @returns {Promise<ListGeofencesResults>} - Promise that resolves to an object with:
|
|
74
|
+
* entries: list of geofences - 100 geofences are listed per page
|
|
75
|
+
* nextToken: token for next page of geofences
|
|
76
|
+
*/
|
|
77
|
+
listGeofences(options?: AmazonLocationServiceListGeofenceOptions): Promise<ListGeofenceResults>;
|
|
78
|
+
/**
|
|
79
|
+
* Delete geofences from a geofence collection
|
|
80
|
+
* @param geofenceIds: string|string[]
|
|
81
|
+
* @param options?: GeofenceOptions
|
|
82
|
+
* @returns {Promise<DeleteGeofencesResults>} - Promise that resolves to an object with:
|
|
83
|
+
* successes: list of geofences successfully deleted
|
|
84
|
+
* errors: list of geofences that failed to delete
|
|
85
|
+
*/
|
|
86
|
+
deleteGeofences(geofenceIds: string[], options?: AmazonLocationServiceGeofenceOptions): Promise<AmazonLocationServiceDeleteGeofencesResults>;
|
|
61
87
|
/**
|
|
62
88
|
* @private
|
|
63
89
|
*/
|
|
64
90
|
private _ensureCredentials;
|
|
65
91
|
private _verifyMapResources;
|
|
66
92
|
private _verifySearchIndex;
|
|
93
|
+
private _verifyGeofenceCollections;
|
|
94
|
+
private _AmazonLocationServiceBatchPutGeofenceCall;
|
|
95
|
+
private _AmazonLocationServiceBatchDeleteGeofenceCall;
|
|
67
96
|
}
|