@aws-amplify/geo 2.3.6-api-v6-models.b3abc9b.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.
Files changed (56) hide show
  1. package/lib/Geo.d.ts +3 -9
  2. package/lib/Geo.js +137 -243
  3. package/lib/index.js +4 -2
  4. package/{lib-esm/Providers → lib/providers/location-service}/AmazonLocationServiceProvider.d.ts +3 -7
  5. package/lib/providers/location-service/AmazonLocationServiceProvider.js +618 -0
  6. package/lib/tsconfig.tsbuildinfo +1 -0
  7. package/lib/types/AmazonLocationServiceProvider.d.ts +7 -7
  8. package/lib/types/AmazonLocationServiceProvider.js +0 -1
  9. package/lib/types/Geo.d.ts +28 -45
  10. package/lib/types/Geo.js +0 -1
  11. package/lib/types/Provider.d.ts +0 -1
  12. package/lib/types/Provider.js +0 -1
  13. package/lib/types/index.js +6 -1
  14. package/lib/util.d.ts +4 -0
  15. package/lib/util.js +51 -36
  16. package/lib-esm/Geo.d.ts +3 -9
  17. package/lib-esm/Geo.js +136 -243
  18. package/lib-esm/index.js +1 -1
  19. package/{lib/Providers → lib-esm/providers/location-service}/AmazonLocationServiceProvider.d.ts +3 -7
  20. package/lib-esm/providers/location-service/AmazonLocationServiceProvider.js +614 -0
  21. package/lib-esm/tsconfig.tsbuildinfo +1 -0
  22. package/lib-esm/types/AmazonLocationServiceProvider.d.ts +7 -7
  23. package/lib-esm/types/AmazonLocationServiceProvider.js +1 -1
  24. package/lib-esm/types/Geo.d.ts +28 -45
  25. package/lib-esm/types/Geo.js +1 -1
  26. package/lib-esm/types/Provider.d.ts +0 -1
  27. package/lib-esm/types/Provider.js +1 -1
  28. package/lib-esm/types/index.js +5 -1
  29. package/lib-esm/util.d.ts +4 -0
  30. package/lib-esm/util.js +45 -34
  31. package/package.json +26 -12
  32. package/src/Geo.ts +12 -36
  33. package/src/{Providers → providers/location-service}/AmazonLocationServiceProvider.ts +65 -68
  34. package/src/types/Geo.ts +1 -17
  35. package/src/types/Provider.ts +0 -3
  36. package/src/util.ts +24 -3
  37. package/lib/.tsbuildinfo +0 -3
  38. package/lib/Geo.js.map +0 -1
  39. package/lib/Providers/AmazonLocationServiceProvider.js +0 -737
  40. package/lib/Providers/AmazonLocationServiceProvider.js.map +0 -1
  41. package/lib/index.js.map +0 -1
  42. package/lib/types/AmazonLocationServiceProvider.js.map +0 -1
  43. package/lib/types/Geo.js.map +0 -1
  44. package/lib/types/Provider.js.map +0 -1
  45. package/lib/types/index.js.map +0 -1
  46. package/lib/util.js.map +0 -1
  47. package/lib-esm/.tsbuildinfo +0 -3
  48. package/lib-esm/Geo.js.map +0 -1
  49. package/lib-esm/Providers/AmazonLocationServiceProvider.js +0 -735
  50. package/lib-esm/Providers/AmazonLocationServiceProvider.js.map +0 -1
  51. package/lib-esm/index.js.map +0 -1
  52. package/lib-esm/types/AmazonLocationServiceProvider.js.map +0 -1
  53. package/lib-esm/types/Geo.js.map +0 -1
  54. package/lib-esm/types/Provider.js.map +0 -1
  55. package/lib-esm/types/index.js.map +0 -1
  56. package/lib-esm/util.js.map +0 -1
package/lib/Geo.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Place, GeoConfig, Coordinates, SearchByTextOptions, SearchByCoordinatesOptions, GeoProvider, MapStyle, GeofenceId, GeofenceInput, GeofenceOptions, SaveGeofencesResults, Geofence, ListGeofenceOptions, ListGeofenceResults, DeleteGeofencesResults, searchByPlaceIdOptions } from './types';
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): object;
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
- var tslib_1 = require("tslib");
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
- var core_1 = require("@aws-amplify/core");
7
- var AmazonLocationServiceProvider_1 = require("./Providers/AmazonLocationServiceProvider");
8
- var util_1 = require("./util");
9
- var logger = new core_1.ConsoleLogger('Geo');
10
- var DEFAULT_PROVIDER = 'AmazonLocationService';
11
- var GeoClass = /** @class */ (function () {
12
- function GeoClass() {
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
- GeoClass.prototype.getModuleName = function () {
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
- GeoClass.prototype.addPluggable = function (pluggable) {
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
- GeoClass.prototype.getPluggable = function (providerName) {
40
- var pluggable = this._pluggables.find(function (pluggable) { return pluggable.getProviderName() === providerName; });
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
- GeoClass.prototype.removePluggable = function (providerName) {
53
- this._pluggables = this._pluggables.filter(function (pluggable) { return pluggable.getProviderName() !== providerName; });
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
- GeoClass.prototype.getAvailableMaps = function (provider) {
82
- if (provider === void 0) { provider = DEFAULT_PROVIDER; }
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
- GeoClass.prototype.getDefaultMap = function (provider) {
92
- if (provider === void 0) { provider = DEFAULT_PROVIDER; }
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
- GeoClass.prototype.searchByText = function (text, options) {
103
- return tslib_1.__awaiter(this, void 0, void 0, function () {
104
- var _a, providerName, prov, error_1;
105
- return tslib_1.__generator(this, function (_b) {
106
- switch (_b.label) {
107
- case 0:
108
- _a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
109
- prov = this.getPluggable(providerName);
110
- _b.label = 1;
111
- case 1:
112
- _b.trys.push([1, 3, , 4]);
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
- GeoClass.prototype.searchForSuggestions = function (text, options) {
131
- return tslib_1.__awaiter(this, void 0, void 0, function () {
132
- var _a, providerName, prov, error_2;
133
- return tslib_1.__generator(this, function (_b) {
134
- switch (_b.label) {
135
- case 0:
136
- _a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
137
- prov = this.getPluggable(providerName);
138
- _b.label = 1;
139
- case 1:
140
- _b.trys.push([1, 3, , 4]);
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
- GeoClass.prototype.searchByPlaceId = function (placeId, options) {
159
- return tslib_1.__awaiter(this, void 0, void 0, function () {
160
- var providerName, prov, error_3;
161
- return tslib_1.__generator(this, function (_a) {
162
- switch (_a.label) {
163
- case 0:
164
- providerName = DEFAULT_PROVIDER;
165
- prov = this.getPluggable(providerName);
166
- _a.label = 1;
167
- case 1:
168
- _a.trys.push([1, 3, , 4]);
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
- GeoClass.prototype.searchByCoordinates = function (coordinates, options) {
187
- return tslib_1.__awaiter(this, void 0, void 0, function () {
188
- var _a, providerName, prov, _b, lng, lat, error_4;
189
- return tslib_1.__generator(this, function (_c) {
190
- switch (_c.label) {
191
- case 0:
192
- _a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
193
- prov = this.getPluggable(providerName);
194
- _b = tslib_1.__read(coordinates, 2), lng = _b[0], lat = _b[1];
195
- _c.label = 1;
196
- case 1:
197
- _c.trys.push([1, 3, , 4]);
198
- util_1.validateCoordinates(lng, lat);
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
- GeoClass.prototype.saveGeofences = function (geofences, options) {
219
- return tslib_1.__awaiter(this, void 0, void 0, function () {
220
- var _a, providerName, prov, geofenceInputArray, error_5;
221
- return tslib_1.__generator(this, function (_b) {
222
- switch (_b.label) {
223
- case 0:
224
- _a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
225
- prov = this.getPluggable(providerName);
226
- if (!Array.isArray(geofences)) {
227
- geofenceInputArray = [geofences];
228
- }
229
- else {
230
- geofenceInputArray = geofences;
231
- }
232
- _b.label = 1;
233
- case 1:
234
- _b.trys.push([1, 3, , 4]);
235
- return [4 /*yield*/, prov.saveGeofences(geofenceInputArray, options)];
236
- case 2: return [2 /*return*/, _b.sent()];
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
- GeoClass.prototype.getGeofence = function (geofenceId, options) {
253
- return tslib_1.__awaiter(this, void 0, void 0, function () {
254
- var _a, providerName, prov, error_6;
255
- return tslib_1.__generator(this, function (_b) {
256
- switch (_b.label) {
257
- case 0:
258
- _a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
259
- prov = this.getPluggable(providerName);
260
- _b.label = 1;
261
- case 1:
262
- _b.trys.push([1, 3, , 4]);
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
- GeoClass.prototype.listGeofences = function (options) {
282
- return tslib_1.__awaiter(this, void 0, void 0, function () {
283
- var _a, providerName, prov, error_7;
284
- return tslib_1.__generator(this, function (_b) {
285
- switch (_b.label) {
286
- case 0:
287
- _a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
288
- prov = this.getPluggable(providerName);
289
- _b.label = 1;
290
- case 1:
291
- _b.trys.push([1, 3, , 4]);
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
- GeoClass.prototype.deleteGeofences = function (geofenceIds, options) {
312
- return tslib_1.__awaiter(this, void 0, void 0, function () {
313
- var _a, providerName, prov, geofenceIdsInputArray, error_8;
314
- return tslib_1.__generator(this, function (_b) {
315
- switch (_b.label) {
316
- case 0:
317
- _a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
318
- prov = this.getPluggable(providerName);
319
- if (!Array.isArray(geofenceIds)) {
320
- geofenceIdsInputArray = [geofenceIds];
321
- }
322
- else {
323
- geofenceIdsInputArray = geofenceIds;
324
- }
325
- _b.label = 1;
326
- case 1:
327
- _b.trys.push([1, 3, , 4]);
328
- return [4 /*yield*/, prov.deleteGeofences(geofenceIdsInputArray, options)];
329
- case 2: return [2 /*return*/, _b.sent()];
330
- case 3:
331
- error_8 = _b.sent();
332
- logger.debug(error_8);
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.Geo = Geo_1.Geo;
7
- //# sourceMappingURL=index.js.map
8
+ Object.defineProperty(exports, "Geo", { enumerable: true, get: function () { return Geo_1.Geo; } });
9
+ tslib_1.__exportStar(require("./types"), exports);
@@ -1,4 +1,4 @@
1
- import { GeoConfig, SearchByTextOptions, SearchByCoordinatesOptions, GeoProvider, Place, AmazonLocationServiceMapStyle, Coordinates, SearchForSuggestionsResults, GeofenceId, GeofenceInput, AmazonLocationServiceGeofenceOptions, AmazonLocationServiceListGeofenceOptions, ListGeofenceResults, SaveGeofencesResults, AmazonLocationServiceGeofence, AmazonLocationServiceDeleteGeofencesResults, searchByPlaceIdOptions } from '../types';
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;