@aws-amplify/geo 3.0.22 → 3.0.23
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/cjs/Geo.js +5 -6
- package/dist/cjs/Geo.js.map +1 -1
- package/dist/cjs/providers/location-service/AmazonLocationServiceProvider.js +22 -36
- package/dist/cjs/providers/location-service/AmazonLocationServiceProvider.js.map +1 -1
- package/dist/cjs/util.js +7 -7
- package/dist/cjs/util.js.map +1 -1
- package/dist/esm/Geo.d.ts +4 -4
- package/dist/esm/Geo.mjs +5 -6
- package/dist/esm/Geo.mjs.map +1 -1
- package/dist/esm/providers/location-service/AmazonLocationServiceProvider.d.ts +4 -4
- package/dist/esm/providers/location-service/AmazonLocationServiceProvider.mjs +22 -36
- package/dist/esm/providers/location-service/AmazonLocationServiceProvider.mjs.map +1 -1
- package/dist/esm/types/AmazonLocationServiceProvider.d.ts +1 -1
- package/dist/esm/types/Geo.d.ts +24 -24
- package/dist/esm/types/Provider.d.ts +1 -1
- package/dist/esm/util.d.ts +1 -1
- package/dist/esm/util.mjs +7 -7
- package/dist/esm/util.mjs.map +1 -1
- package/package.json +5 -4
- package/src/Geo.ts +16 -16
- package/src/providers/location-service/AmazonLocationServiceProvider.ts +69 -65
- package/src/types/AmazonLocationServiceProvider.ts +4 -4
- package/src/types/Geo.ts +24 -24
- package/src/types/Provider.ts +6 -6
- package/src/util.ts +10 -9
package/src/types/Geo.ts
CHANGED
|
@@ -53,20 +53,20 @@ export type SearchByTextOptions =
|
|
|
53
53
|
| SearchByTextOptionsWithSearchAreaConstraints;
|
|
54
54
|
|
|
55
55
|
// Options object for searchByCoordinates
|
|
56
|
-
export
|
|
56
|
+
export interface SearchByCoordinatesOptions {
|
|
57
57
|
maxResults?: number;
|
|
58
58
|
searchIndexName?: string;
|
|
59
59
|
providerName?: string;
|
|
60
|
-
}
|
|
60
|
+
}
|
|
61
61
|
|
|
62
|
-
export
|
|
62
|
+
export interface searchByPlaceIdOptions {
|
|
63
63
|
searchIndexName?: string;
|
|
64
|
-
}
|
|
64
|
+
}
|
|
65
65
|
|
|
66
66
|
// Geometry object for Place points
|
|
67
|
-
export
|
|
67
|
+
export interface PlaceGeometry {
|
|
68
68
|
point: Coordinates;
|
|
69
|
-
}
|
|
69
|
+
}
|
|
70
70
|
|
|
71
71
|
// Place object with locality information
|
|
72
72
|
export interface Place {
|
|
@@ -88,38 +88,38 @@ export type LinearRing = Coordinates[];
|
|
|
88
88
|
export type GeofencePolygon = LinearRing[];
|
|
89
89
|
|
|
90
90
|
// Geometry object for Polygon
|
|
91
|
-
export
|
|
91
|
+
export interface PolygonGeometry {
|
|
92
92
|
polygon: GeofencePolygon;
|
|
93
|
-
}
|
|
93
|
+
}
|
|
94
94
|
|
|
95
95
|
export type GeofenceId = string;
|
|
96
96
|
|
|
97
97
|
// Geofence object used as input for saveGeofences
|
|
98
|
-
export
|
|
98
|
+
export interface GeofenceInput {
|
|
99
99
|
geofenceId: GeofenceId;
|
|
100
100
|
geometry: PolygonGeometry;
|
|
101
|
-
}
|
|
101
|
+
}
|
|
102
102
|
|
|
103
103
|
// Options object for saveGeofences
|
|
104
|
-
export
|
|
104
|
+
export interface GeofenceOptions {
|
|
105
105
|
providerName?: string;
|
|
106
|
-
}
|
|
106
|
+
}
|
|
107
107
|
|
|
108
108
|
// Error type for errors related to Geofence API calls
|
|
109
|
-
export
|
|
109
|
+
export interface GeofenceError {
|
|
110
110
|
error: {
|
|
111
111
|
code: string;
|
|
112
112
|
message: string;
|
|
113
113
|
};
|
|
114
114
|
geofenceId: GeofenceId;
|
|
115
|
-
}
|
|
115
|
+
}
|
|
116
116
|
|
|
117
117
|
// Base geofence object
|
|
118
|
-
|
|
118
|
+
interface GeofenceBase {
|
|
119
119
|
geofenceId: GeofenceId;
|
|
120
120
|
createTime?: Date;
|
|
121
121
|
updateTime?: Date;
|
|
122
|
-
}
|
|
122
|
+
}
|
|
123
123
|
|
|
124
124
|
// Results object for getGeofence
|
|
125
125
|
export type Geofence = GeofenceBase & {
|
|
@@ -127,10 +127,10 @@ export type Geofence = GeofenceBase & {
|
|
|
127
127
|
};
|
|
128
128
|
|
|
129
129
|
// Results object for saveGeofences
|
|
130
|
-
export
|
|
130
|
+
export interface SaveGeofencesResults {
|
|
131
131
|
successes: GeofenceBase[];
|
|
132
132
|
errors: GeofenceError[];
|
|
133
|
-
}
|
|
133
|
+
}
|
|
134
134
|
|
|
135
135
|
// Options object for listGeofence
|
|
136
136
|
export type ListGeofenceOptions = GeofenceOptions & {
|
|
@@ -138,21 +138,21 @@ export type ListGeofenceOptions = GeofenceOptions & {
|
|
|
138
138
|
};
|
|
139
139
|
|
|
140
140
|
// Results options for listGeofence
|
|
141
|
-
export
|
|
141
|
+
export interface ListGeofenceResults {
|
|
142
142
|
entries: Geofence[];
|
|
143
143
|
nextToken: string | undefined;
|
|
144
|
-
}
|
|
144
|
+
}
|
|
145
145
|
|
|
146
146
|
// Results object for deleteGeofence
|
|
147
|
-
export
|
|
147
|
+
export interface DeleteGeofencesResults {
|
|
148
148
|
successes: GeofenceId[];
|
|
149
149
|
errors: GeofenceError[];
|
|
150
|
-
}
|
|
150
|
+
}
|
|
151
151
|
|
|
152
152
|
// Return type for searchForSuggestions
|
|
153
153
|
export type SearchForSuggestionsResults = SearchForSuggestionsResult[];
|
|
154
154
|
|
|
155
|
-
export
|
|
155
|
+
export interface SearchForSuggestionsResult {
|
|
156
156
|
text: string;
|
|
157
157
|
placeId?: string;
|
|
158
|
-
}
|
|
158
|
+
}
|
package/src/types/Provider.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import {
|
|
4
|
-
SearchByTextOptions,
|
|
5
|
-
SearchByCoordinatesOptions,
|
|
6
|
-
SearchForSuggestionsResults,
|
|
7
4
|
Coordinates,
|
|
8
|
-
|
|
9
|
-
MapStyle,
|
|
5
|
+
DeleteGeofencesResults,
|
|
10
6
|
Geofence,
|
|
11
7
|
GeofenceId,
|
|
12
8
|
GeofenceInput,
|
|
13
9
|
GeofenceOptions,
|
|
14
10
|
ListGeofenceOptions,
|
|
15
11
|
ListGeofenceResults,
|
|
12
|
+
MapStyle,
|
|
13
|
+
Place,
|
|
16
14
|
SaveGeofencesResults,
|
|
17
|
-
|
|
15
|
+
SearchByCoordinatesOptions,
|
|
16
|
+
SearchByTextOptions,
|
|
17
|
+
SearchForSuggestionsResults,
|
|
18
18
|
searchByPlaceIdOptions,
|
|
19
19
|
} from './Geo';
|
|
20
20
|
|
package/src/util.ts
CHANGED
|
@@ -10,21 +10,21 @@ import {
|
|
|
10
10
|
import { UserAgent } from '@aws-sdk/types';
|
|
11
11
|
|
|
12
12
|
import {
|
|
13
|
-
Longitude,
|
|
14
|
-
Latitude,
|
|
15
13
|
GeofenceId,
|
|
16
14
|
GeofenceInput,
|
|
17
15
|
GeofencePolygon,
|
|
16
|
+
Latitude,
|
|
18
17
|
LinearRing,
|
|
18
|
+
Longitude,
|
|
19
19
|
} from './types';
|
|
20
20
|
|
|
21
21
|
export function validateCoordinates(lng: Longitude, lat: Latitude): void {
|
|
22
22
|
if (!Number.isFinite(lng) || !Number.isFinite(lat)) {
|
|
23
23
|
throw new Error(`Invalid coordinates: [${lng},${lat}]`);
|
|
24
24
|
}
|
|
25
|
-
if (lat < -90 ||
|
|
25
|
+
if (lat < -90 || lat > 90) {
|
|
26
26
|
throw new Error('Latitude must be between -90 and 90 degrees inclusive.');
|
|
27
|
-
} else if (lng < -180 ||
|
|
27
|
+
} else if (lng < -180 || lng > 180) {
|
|
28
28
|
throw new Error(
|
|
29
29
|
'Longitude must be between -180 and 180 degrees inclusive.',
|
|
30
30
|
);
|
|
@@ -186,17 +186,18 @@ export function mapSearchOptions(options, locationServiceInput) {
|
|
|
186
186
|
locationServiceModifiedInput.IndexName = options.searchIndexName;
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
if (options
|
|
189
|
+
if (options.biasPosition && options.searchAreaConstraints) {
|
|
190
190
|
throw new Error(
|
|
191
191
|
'BiasPosition and SearchAreaConstraints are mutually exclusive, please remove one or the other from the options object',
|
|
192
192
|
);
|
|
193
193
|
}
|
|
194
|
-
if (options
|
|
195
|
-
locationServiceModifiedInput.BiasPosition = options
|
|
194
|
+
if (options.biasPosition) {
|
|
195
|
+
locationServiceModifiedInput.BiasPosition = options.biasPosition;
|
|
196
196
|
}
|
|
197
|
-
if (options
|
|
198
|
-
locationServiceModifiedInput.FilterBBox = options
|
|
197
|
+
if (options.searchAreaConstraints) {
|
|
198
|
+
locationServiceModifiedInput.FilterBBox = options.searchAreaConstraints;
|
|
199
199
|
}
|
|
200
|
+
|
|
200
201
|
return locationServiceModifiedInput;
|
|
201
202
|
}
|
|
202
203
|
|