@aws-amplify/geo 2.3.6-unstable.7762f1a.0 → 3.0.0
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/lib/Geo.d.ts +3 -9
- package/lib/Geo.js +137 -243
- package/lib/index.js +4 -2
- package/{lib-esm/Providers → lib/providers/location-service}/AmazonLocationServiceProvider.d.ts +3 -7
- package/lib/providers/location-service/AmazonLocationServiceProvider.js +618 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/types/AmazonLocationServiceProvider.d.ts +7 -7
- package/lib/types/AmazonLocationServiceProvider.js +0 -1
- package/lib/types/Geo.d.ts +28 -45
- package/lib/types/Geo.js +0 -1
- package/lib/types/Provider.d.ts +0 -1
- package/lib/types/Provider.js +0 -1
- package/lib/types/index.js +6 -1
- package/lib/util.d.ts +4 -0
- package/lib/util.js +51 -36
- package/lib-esm/Geo.d.ts +3 -9
- package/lib-esm/Geo.js +136 -243
- package/lib-esm/index.js +1 -1
- package/{lib/Providers → lib-esm/providers/location-service}/AmazonLocationServiceProvider.d.ts +3 -7
- package/lib-esm/providers/location-service/AmazonLocationServiceProvider.js +614 -0
- package/lib-esm/tsconfig.tsbuildinfo +1 -0
- package/lib-esm/types/AmazonLocationServiceProvider.d.ts +7 -7
- package/lib-esm/types/AmazonLocationServiceProvider.js +1 -1
- package/lib-esm/types/Geo.d.ts +28 -45
- package/lib-esm/types/Geo.js +1 -1
- package/lib-esm/types/Provider.d.ts +0 -1
- package/lib-esm/types/Provider.js +1 -1
- package/lib-esm/types/index.js +5 -1
- package/lib-esm/util.d.ts +4 -0
- package/lib-esm/util.js +45 -34
- package/package.json +26 -12
- package/src/Geo.ts +12 -36
- package/src/{Providers → providers/location-service}/AmazonLocationServiceProvider.ts +65 -68
- package/src/types/Geo.ts +1 -17
- package/src/types/Provider.ts +0 -3
- package/src/util.ts +24 -3
- package/lib/.tsbuildinfo +0 -3
- package/lib/Geo.js.map +0 -1
- package/lib/Providers/AmazonLocationServiceProvider.js +0 -737
- package/lib/Providers/AmazonLocationServiceProvider.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/types/AmazonLocationServiceProvider.js.map +0 -1
- package/lib/types/Geo.js.map +0 -1
- package/lib/types/Provider.js.map +0 -1
- package/lib/types/index.js.map +0 -1
- package/lib/util.js.map +0 -1
- package/lib-esm/.tsbuildinfo +0 -3
- package/lib-esm/Geo.js.map +0 -1
- package/lib-esm/Providers/AmazonLocationServiceProvider.js +0 -735
- package/lib-esm/Providers/AmazonLocationServiceProvider.js.map +0 -1
- package/lib-esm/index.js.map +0 -1
- package/lib-esm/types/AmazonLocationServiceProvider.js.map +0 -1
- package/lib-esm/types/Geo.js.map +0 -1
- package/lib-esm/types/Provider.js.map +0 -1
- package/lib-esm/types/index.js.map +0 -1
- package/lib-esm/util.js.map +0 -1
package/lib/Geo.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Place,
|
|
1
|
+
import { Place, Coordinates, SearchByTextOptions, SearchByCoordinatesOptions, GeoProvider, MapStyle, GeofenceId, GeofenceInput, GeofenceOptions, SaveGeofencesResults, Geofence, ListGeofenceOptions, ListGeofenceResults, DeleteGeofencesResults, searchByPlaceIdOptions } from './types';
|
|
2
2
|
export declare class GeoClass {
|
|
3
3
|
static MODULE: string;
|
|
4
4
|
/**
|
|
@@ -16,7 +16,7 @@ export declare class GeoClass {
|
|
|
16
16
|
* add plugin into Geo category
|
|
17
17
|
* @param {Object} pluggable - an instance of the plugin
|
|
18
18
|
*/
|
|
19
|
-
addPluggable(pluggable: GeoProvider):
|
|
19
|
+
addPluggable(pluggable: GeoProvider): void;
|
|
20
20
|
/**
|
|
21
21
|
* Get the plugin object
|
|
22
22
|
* @param providerName - the name of the plugin
|
|
@@ -27,12 +27,6 @@ export declare class GeoClass {
|
|
|
27
27
|
* @param providerName - the name of the plugin
|
|
28
28
|
*/
|
|
29
29
|
removePluggable(providerName: string): void;
|
|
30
|
-
/**
|
|
31
|
-
* Configure Geo
|
|
32
|
-
* @param {Object} config - Configuration object for Geo
|
|
33
|
-
* @return {Object} - Current configuration
|
|
34
|
-
*/
|
|
35
|
-
configure(config?: any): GeoConfig;
|
|
36
30
|
/**
|
|
37
31
|
* Get the map resources that are currently available through the provider
|
|
38
32
|
* @param {string} provider
|
|
@@ -65,7 +59,7 @@ export declare class GeoClass {
|
|
|
65
59
|
* @param {searchByPlaceIdOptions} options? - Optional parameters to the search
|
|
66
60
|
* @returns {Promise<Place>} - Resolves to a place with the given placeId
|
|
67
61
|
*/
|
|
68
|
-
searchByPlaceId(placeId: string, options?: searchByPlaceIdOptions): Promise<Place>;
|
|
62
|
+
searchByPlaceId(placeId: string, options?: searchByPlaceIdOptions): Promise<Place | undefined>;
|
|
69
63
|
/**
|
|
70
64
|
* Reverse geocoding search via a coordinate point on the map
|
|
71
65
|
* @param coordinates - Coordinates array for the search input
|
package/lib/Geo.js
CHANGED
|
@@ -1,212 +1,148 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
exports.Geo = exports.GeoClass = void 0;
|
|
4
4
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
5
|
// SPDX-License-Identifier: Apache-2.0
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
const core_1 = require("@aws-amplify/core");
|
|
7
|
+
const AmazonLocationServiceProvider_1 = require("./providers/location-service/AmazonLocationServiceProvider");
|
|
8
|
+
const util_1 = require("./util");
|
|
9
|
+
const logger = new core_1.ConsoleLogger('Geo');
|
|
10
|
+
const DEFAULT_PROVIDER = 'AmazonLocationService';
|
|
11
|
+
class GeoClass {
|
|
12
|
+
constructor() {
|
|
13
13
|
this._config = {};
|
|
14
14
|
this._pluggables = [];
|
|
15
|
+
const amplifyConfig = core_1.Amplify.getConfig() ?? {};
|
|
16
|
+
this._config = Object.assign({}, this._config, amplifyConfig.Geo);
|
|
17
|
+
const locationProvider = new AmazonLocationServiceProvider_1.AmazonLocationServiceProvider(amplifyConfig.Geo);
|
|
18
|
+
this._pluggables.push(locationProvider);
|
|
15
19
|
logger.debug('Geo Options', this._config);
|
|
16
20
|
}
|
|
17
21
|
/**
|
|
18
22
|
* get the name of the module category
|
|
19
23
|
* @returns {string} name of the module category
|
|
20
24
|
*/
|
|
21
|
-
|
|
25
|
+
getModuleName() {
|
|
22
26
|
return GeoClass.MODULE;
|
|
23
|
-
}
|
|
27
|
+
}
|
|
24
28
|
/**
|
|
25
29
|
* add plugin into Geo category
|
|
26
30
|
* @param {Object} pluggable - an instance of the plugin
|
|
27
31
|
*/
|
|
28
|
-
|
|
32
|
+
addPluggable(pluggable) {
|
|
29
33
|
if (pluggable && pluggable.getCategory() === 'Geo') {
|
|
30
34
|
this._pluggables.push(pluggable);
|
|
31
|
-
var config = pluggable.configure(this._config[pluggable.getProviderName()]);
|
|
32
|
-
return config;
|
|
33
35
|
}
|
|
34
|
-
}
|
|
36
|
+
}
|
|
35
37
|
/**
|
|
36
38
|
* Get the plugin object
|
|
37
39
|
* @param providerName - the name of the plugin
|
|
38
40
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
getPluggable(providerName) {
|
|
42
|
+
const pluggable = this._pluggables.find(pluggable => pluggable.getProviderName() === providerName);
|
|
41
43
|
if (pluggable === undefined) {
|
|
42
44
|
logger.debug('No plugin found with providerName', providerName);
|
|
43
45
|
throw new Error('No plugin found in Geo for the provider');
|
|
44
46
|
}
|
|
45
47
|
else
|
|
46
48
|
return pluggable;
|
|
47
|
-
}
|
|
49
|
+
}
|
|
48
50
|
/**
|
|
49
51
|
* Remove the plugin object
|
|
50
52
|
* @param providerName - the name of the plugin
|
|
51
53
|
*/
|
|
52
|
-
|
|
53
|
-
this._pluggables = this._pluggables.filter(
|
|
54
|
+
removePluggable(providerName) {
|
|
55
|
+
this._pluggables = this._pluggables.filter(pluggable => pluggable.getProviderName() !== providerName);
|
|
54
56
|
return;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Configure Geo
|
|
58
|
-
* @param {Object} config - Configuration object for Geo
|
|
59
|
-
* @return {Object} - Current configuration
|
|
60
|
-
*/
|
|
61
|
-
GeoClass.prototype.configure = function (config) {
|
|
62
|
-
var _this = this;
|
|
63
|
-
logger.debug('configure Geo');
|
|
64
|
-
if (!config)
|
|
65
|
-
return this._config;
|
|
66
|
-
var amplifyConfig = core_1.parseAWSExports(config);
|
|
67
|
-
this._config = Object.assign({}, this._config, amplifyConfig.Geo, config);
|
|
68
|
-
this._pluggables.forEach(function (pluggable) {
|
|
69
|
-
pluggable.configure(_this._config[pluggable.getProviderName()]);
|
|
70
|
-
});
|
|
71
|
-
if (this._pluggables.length === 0) {
|
|
72
|
-
this.addPluggable(new AmazonLocationServiceProvider_1.AmazonLocationServiceProvider());
|
|
73
|
-
}
|
|
74
|
-
return this._config;
|
|
75
|
-
};
|
|
57
|
+
}
|
|
76
58
|
/**
|
|
77
59
|
* Get the map resources that are currently available through the provider
|
|
78
60
|
* @param {string} provider
|
|
79
61
|
* @returns - Array of available map resources
|
|
80
62
|
*/
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
var prov = this.getPluggable(provider);
|
|
63
|
+
getAvailableMaps(provider = DEFAULT_PROVIDER) {
|
|
64
|
+
const prov = this.getPluggable(provider);
|
|
84
65
|
return prov.getAvailableMaps();
|
|
85
|
-
}
|
|
66
|
+
}
|
|
86
67
|
/**
|
|
87
68
|
* Get the map resource set as default in amplify config
|
|
88
69
|
* @param {string} provider
|
|
89
70
|
* @returns - Map resource set as the default in amplify config
|
|
90
71
|
*/
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
var prov = this.getPluggable(provider);
|
|
72
|
+
getDefaultMap(provider = DEFAULT_PROVIDER) {
|
|
73
|
+
const prov = this.getPluggable(provider);
|
|
94
74
|
return prov.getDefaultMap();
|
|
95
|
-
}
|
|
75
|
+
}
|
|
96
76
|
/**
|
|
97
77
|
* Search by text input with optional parameters
|
|
98
78
|
* @param {string} text - The text string that is to be searched for
|
|
99
79
|
* @param {SearchByTextOptions} options? - Optional parameters to the search
|
|
100
80
|
* @returns {Promise<Place[]>} - Promise resolves to a list of Places that match search parameters
|
|
101
81
|
*/
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
return [4 /*yield*/, prov.searchByText(text, options)];
|
|
114
|
-
case 2: return [2 /*return*/, _b.sent()];
|
|
115
|
-
case 3:
|
|
116
|
-
error_1 = _b.sent();
|
|
117
|
-
logger.debug(error_1);
|
|
118
|
-
throw error_1;
|
|
119
|
-
case 4: return [2 /*return*/];
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
};
|
|
82
|
+
async searchByText(text, options) {
|
|
83
|
+
const { providerName = DEFAULT_PROVIDER } = options || {};
|
|
84
|
+
const prov = this.getPluggable(providerName);
|
|
85
|
+
try {
|
|
86
|
+
return await prov.searchByText(text, options);
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
logger.debug(error);
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
124
93
|
/**
|
|
125
94
|
* Search for search term suggestions based on input text
|
|
126
95
|
* @param {string} text - The text string that is to be search for
|
|
127
96
|
* @param {SearchByTextOptions} options? - Optional parameters to the search
|
|
128
97
|
* @returns {Promise<SearchForSuggestionsResults>} - Resolves to an array of search suggestion strings
|
|
129
98
|
*/
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
return [4 /*yield*/, prov.searchForSuggestions(text, options)];
|
|
142
|
-
case 2: return [2 /*return*/, _b.sent()];
|
|
143
|
-
case 3:
|
|
144
|
-
error_2 = _b.sent();
|
|
145
|
-
logger.debug(error_2);
|
|
146
|
-
throw error_2;
|
|
147
|
-
case 4: return [2 /*return*/];
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
};
|
|
99
|
+
async searchForSuggestions(text, options) {
|
|
100
|
+
const { providerName = DEFAULT_PROVIDER } = options || {};
|
|
101
|
+
const prov = this.getPluggable(providerName);
|
|
102
|
+
try {
|
|
103
|
+
return await prov.searchForSuggestions(text, options);
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
logger.debug(error);
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
152
110
|
/**
|
|
153
111
|
* Search for location by unique ID
|
|
154
112
|
* @param {string} placeId - Unique ID of the location that is to be searched for
|
|
155
113
|
* @param {searchByPlaceIdOptions} options? - Optional parameters to the search
|
|
156
114
|
* @returns {Promise<Place>} - Resolves to a place with the given placeId
|
|
157
115
|
*/
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return [4 /*yield*/, prov.searchByPlaceId(placeId, options)];
|
|
170
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
171
|
-
case 3:
|
|
172
|
-
error_3 = _a.sent();
|
|
173
|
-
logger.debug(error_3);
|
|
174
|
-
throw error_3;
|
|
175
|
-
case 4: return [2 /*return*/];
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
};
|
|
116
|
+
async searchByPlaceId(placeId, options) {
|
|
117
|
+
const providerName = DEFAULT_PROVIDER;
|
|
118
|
+
const prov = this.getPluggable(providerName);
|
|
119
|
+
try {
|
|
120
|
+
return await prov.searchByPlaceId(placeId, options);
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
logger.debug(error);
|
|
124
|
+
throw error;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
180
127
|
/**
|
|
181
128
|
* Reverse geocoding search via a coordinate point on the map
|
|
182
129
|
* @param coordinates - Coordinates array for the search input
|
|
183
130
|
* @param options - Options parameters for the search
|
|
184
131
|
* @returns {Promise<Place>} - Promise that resolves to a place matching search coordinates
|
|
185
132
|
*/
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
return [4 /*yield*/, prov.searchByCoordinates(coordinates, options)];
|
|
200
|
-
case 2: return [2 /*return*/, _c.sent()];
|
|
201
|
-
case 3:
|
|
202
|
-
error_4 = _c.sent();
|
|
203
|
-
logger.debug(error_4);
|
|
204
|
-
throw error_4;
|
|
205
|
-
case 4: return [2 /*return*/];
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
};
|
|
133
|
+
async searchByCoordinates(coordinates, options) {
|
|
134
|
+
const { providerName = DEFAULT_PROVIDER } = options || {};
|
|
135
|
+
const prov = this.getPluggable(providerName);
|
|
136
|
+
const [lng, lat] = coordinates;
|
|
137
|
+
try {
|
|
138
|
+
(0, util_1.validateCoordinates)(lng, lat);
|
|
139
|
+
return await prov.searchByCoordinates(coordinates, options);
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
logger.debug(error);
|
|
143
|
+
throw error;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
210
146
|
/**
|
|
211
147
|
* Create geofences
|
|
212
148
|
* @param geofences - Single or array of geofence objects to create
|
|
@@ -215,62 +151,42 @@ var GeoClass = /** @class */ (function () {
|
|
|
215
151
|
* successes: list of geofences successfully created
|
|
216
152
|
* errors: list of geofences that failed to create
|
|
217
153
|
*/
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
case 3:
|
|
238
|
-
error_5 = _b.sent();
|
|
239
|
-
logger.debug(error_5);
|
|
240
|
-
throw error_5;
|
|
241
|
-
case 4: return [2 /*return*/];
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
});
|
|
245
|
-
};
|
|
154
|
+
async saveGeofences(geofences, options) {
|
|
155
|
+
const { providerName = DEFAULT_PROVIDER } = options || {};
|
|
156
|
+
const prov = this.getPluggable(providerName);
|
|
157
|
+
// If single geofence input, make it an array for batch call
|
|
158
|
+
let geofenceInputArray;
|
|
159
|
+
if (!Array.isArray(geofences)) {
|
|
160
|
+
geofenceInputArray = [geofences];
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
geofenceInputArray = geofences;
|
|
164
|
+
}
|
|
165
|
+
try {
|
|
166
|
+
return await prov.saveGeofences(geofenceInputArray, options);
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
logger.debug(error);
|
|
170
|
+
throw error;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
246
173
|
/**
|
|
247
174
|
* Get a single geofence by geofenceId
|
|
248
175
|
* @param geofenceId: GeofenceId - The string id of the geofence to get
|
|
249
176
|
* @param options?: GeofenceOptions - Optional parameters for getting a geofence
|
|
250
177
|
* @returns Promise<Geofence> - Promise that resolves to a geofence object
|
|
251
178
|
*/
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
return [4 /*yield*/, prov.getGeofence(geofenceId, options)];
|
|
264
|
-
case 2: return [2 /*return*/, _b.sent()];
|
|
265
|
-
case 3:
|
|
266
|
-
error_6 = _b.sent();
|
|
267
|
-
logger.debug(error_6);
|
|
268
|
-
throw error_6;
|
|
269
|
-
case 4: return [2 /*return*/];
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
|
-
});
|
|
273
|
-
};
|
|
179
|
+
async getGeofence(geofenceId, options) {
|
|
180
|
+
const { providerName = DEFAULT_PROVIDER } = options || {};
|
|
181
|
+
const prov = this.getPluggable(providerName);
|
|
182
|
+
try {
|
|
183
|
+
return await prov.getGeofence(geofenceId, options);
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
logger.debug(error);
|
|
187
|
+
throw error;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
274
190
|
/**
|
|
275
191
|
* List geofences
|
|
276
192
|
* @param options?: ListGeofenceOptions
|
|
@@ -278,28 +194,17 @@ var GeoClass = /** @class */ (function () {
|
|
|
278
194
|
* entries: list of geofences - 100 geofences are listed per page
|
|
279
195
|
* nextToken: token for next page of geofences
|
|
280
196
|
*/
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
return [4 /*yield*/, prov.listGeofences(options)];
|
|
293
|
-
case 2: return [2 /*return*/, _b.sent()];
|
|
294
|
-
case 3:
|
|
295
|
-
error_7 = _b.sent();
|
|
296
|
-
logger.debug(error_7);
|
|
297
|
-
throw error_7;
|
|
298
|
-
case 4: return [2 /*return*/];
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
});
|
|
302
|
-
};
|
|
197
|
+
async listGeofences(options) {
|
|
198
|
+
const { providerName = DEFAULT_PROVIDER } = options || {};
|
|
199
|
+
const prov = this.getPluggable(providerName);
|
|
200
|
+
try {
|
|
201
|
+
return await prov.listGeofences(options);
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
logger.debug(error);
|
|
205
|
+
throw error;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
303
208
|
/**
|
|
304
209
|
* Delete geofences
|
|
305
210
|
* @param geofenceIds: string|string[]
|
|
@@ -308,38 +213,27 @@ var GeoClass = /** @class */ (function () {
|
|
|
308
213
|
* successes: list of geofences successfully deleted
|
|
309
214
|
* errors: list of geofences that failed to delete
|
|
310
215
|
*/
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
throw error_8;
|
|
334
|
-
case 4: return [2 /*return*/];
|
|
335
|
-
}
|
|
336
|
-
});
|
|
337
|
-
});
|
|
338
|
-
};
|
|
339
|
-
GeoClass.MODULE = 'Geo';
|
|
340
|
-
return GeoClass;
|
|
341
|
-
}());
|
|
216
|
+
async deleteGeofences(geofenceIds, options) {
|
|
217
|
+
const { providerName = DEFAULT_PROVIDER } = options || {};
|
|
218
|
+
const prov = this.getPluggable(providerName);
|
|
219
|
+
// If single geofence input, make it an array for batch call
|
|
220
|
+
let geofenceIdsInputArray;
|
|
221
|
+
if (!Array.isArray(geofenceIds)) {
|
|
222
|
+
geofenceIdsInputArray = [geofenceIds];
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
geofenceIdsInputArray = geofenceIds;
|
|
226
|
+
}
|
|
227
|
+
// Delete geofences
|
|
228
|
+
try {
|
|
229
|
+
return await prov.deleteGeofences(geofenceIdsInputArray, options);
|
|
230
|
+
}
|
|
231
|
+
catch (error) {
|
|
232
|
+
logger.debug(error);
|
|
233
|
+
throw error;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
GeoClass.MODULE = 'Geo';
|
|
342
238
|
exports.GeoClass = GeoClass;
|
|
343
239
|
exports.Geo = new GeoClass();
|
|
344
|
-
core_1.Amplify.register(exports.Geo);
|
|
345
|
-
//# sourceMappingURL=Geo.js.map
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Geo = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
3
5
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
6
|
// SPDX-License-Identifier: Apache-2.0
|
|
5
7
|
var Geo_1 = require("./Geo");
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
+
Object.defineProperty(exports, "Geo", { enumerable: true, get: function () { return Geo_1.Geo; } });
|
|
9
|
+
tslib_1.__exportStar(require("./types"), exports);
|
package/{lib-esm/Providers → lib/providers/location-service}/AmazonLocationServiceProvider.d.ts
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GeoConfig, SearchByTextOptions, SearchByCoordinatesOptions, GeoProvider, Place, AmazonLocationServiceMapStyle, Coordinates, SearchForSuggestionsResults, GeofenceId, GeofenceInput, AmazonLocationServiceGeofenceOptions, AmazonLocationServiceListGeofenceOptions, ListGeofenceResults, SaveGeofencesResults, AmazonLocationServiceGeofence, AmazonLocationServiceDeleteGeofencesResults, searchByPlaceIdOptions } from '
|
|
1
|
+
import { GeoConfig, SearchByTextOptions, SearchByCoordinatesOptions, GeoProvider, Place, AmazonLocationServiceMapStyle, Coordinates, SearchForSuggestionsResults, GeofenceId, GeofenceInput, AmazonLocationServiceGeofenceOptions, AmazonLocationServiceListGeofenceOptions, ListGeofenceResults, SaveGeofencesResults, AmazonLocationServiceGeofence, AmazonLocationServiceDeleteGeofencesResults, searchByPlaceIdOptions } from '../../types';
|
|
2
2
|
export declare class AmazonLocationServiceProvider implements GeoProvider {
|
|
3
3
|
static CATEGORY: string;
|
|
4
4
|
static PROVIDER_NAME: string;
|
|
@@ -6,6 +6,7 @@ export declare class AmazonLocationServiceProvider implements GeoProvider {
|
|
|
6
6
|
* @private
|
|
7
7
|
*/
|
|
8
8
|
private _config;
|
|
9
|
+
private _credentials;
|
|
9
10
|
/**
|
|
10
11
|
* Initialize Geo with AWS configurations
|
|
11
12
|
* @param {Object} config - Configuration object for Geo
|
|
@@ -21,12 +22,6 @@ export declare class AmazonLocationServiceProvider implements GeoProvider {
|
|
|
21
22
|
* @returns {string} name of the provider
|
|
22
23
|
*/
|
|
23
24
|
getProviderName(): string;
|
|
24
|
-
/**
|
|
25
|
-
* Configure Geo part with aws configuration
|
|
26
|
-
* @param {Object} config - Configuration of the Geo
|
|
27
|
-
* @return {Object} - Current configuration
|
|
28
|
-
*/
|
|
29
|
-
configure(config?: any): object;
|
|
30
25
|
/**
|
|
31
26
|
* Get the map resources that are currently available through the provider
|
|
32
27
|
* @returns {AmazonLocationServiceMapStyle[]}- Array of available map resources
|
|
@@ -97,6 +92,7 @@ export declare class AmazonLocationServiceProvider implements GeoProvider {
|
|
|
97
92
|
* @private
|
|
98
93
|
*/
|
|
99
94
|
private _ensureCredentials;
|
|
95
|
+
private _refreshConfig;
|
|
100
96
|
private _verifyMapResources;
|
|
101
97
|
private _verifySearchIndex;
|
|
102
98
|
private _verifyGeofenceCollections;
|