@aws-amplify/geo 2.3.5 → 3.0.1-console-preview.431c340.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 (53) hide show
  1. package/README.md +3 -0
  2. package/lib/Geo.d.ts +3 -9
  3. package/lib/Geo.js +33 -44
  4. package/lib/index.js +4 -2
  5. package/{lib-esm/Providers → lib/providers/location-service}/AmazonLocationServiceProvider.d.ts +3 -7
  6. package/lib/{Providers → providers/location-service}/AmazonLocationServiceProvider.js +66 -62
  7. package/lib/tsconfig.tsbuildinfo +1 -0
  8. package/lib/types/AmazonLocationServiceProvider.d.ts +7 -7
  9. package/lib/types/AmazonLocationServiceProvider.js +0 -1
  10. package/lib/types/Geo.d.ts +28 -45
  11. package/lib/types/Geo.js +0 -1
  12. package/lib/types/Provider.d.ts +0 -1
  13. package/lib/types/Provider.js +0 -1
  14. package/lib/types/index.js +6 -1
  15. package/lib/util.js +19 -19
  16. package/lib-esm/Geo.d.ts +3 -9
  17. package/lib-esm/Geo.js +31 -43
  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 → providers/location-service}/AmazonLocationServiceProvider.js +50 -47
  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.js +17 -18
  30. package/package.json +132 -115
  31. package/src/Geo.ts +12 -35
  32. package/src/{Providers → providers/location-service}/AmazonLocationServiceProvider.ts +55 -56
  33. package/src/types/Geo.ts +1 -17
  34. package/src/types/Provider.ts +0 -3
  35. package/src/util.ts +3 -3
  36. package/lib/.tsbuildinfo +0 -3
  37. package/lib/Geo.js.map +0 -1
  38. package/lib/Providers/AmazonLocationServiceProvider.js.map +0 -1
  39. package/lib/index.js.map +0 -1
  40. package/lib/types/AmazonLocationServiceProvider.js.map +0 -1
  41. package/lib/types/Geo.js.map +0 -1
  42. package/lib/types/Provider.js.map +0 -1
  43. package/lib/types/index.js.map +0 -1
  44. package/lib/util.js.map +0 -1
  45. package/lib-esm/.tsbuildinfo +0 -3
  46. package/lib-esm/Geo.js.map +0 -1
  47. package/lib-esm/Providers/AmazonLocationServiceProvider.js.map +0 -1
  48. package/lib-esm/index.js.map +0 -1
  49. package/lib-esm/types/AmazonLocationServiceProvider.js.map +0 -1
  50. package/lib-esm/types/Geo.js.map +0 -1
  51. package/lib-esm/types/Provider.js.map +0 -1
  52. package/lib-esm/types/index.js.map +0 -1
  53. package/lib-esm/util.js.map +0 -1
package/lib-esm/Geo.js CHANGED
@@ -1,15 +1,21 @@
1
1
  import { __awaiter, __generator, __read } from "tslib";
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import { Amplify, ConsoleLogger as Logger, parseAWSExports, } from '@aws-amplify/core';
5
- import { AmazonLocationServiceProvider } from './Providers/AmazonLocationServiceProvider';
4
+ import { Amplify } from '@aws-amplify/core';
5
+ import { ConsoleLogger as Logger } from '@aws-amplify/core/internals/utils';
6
+ import { AmazonLocationServiceProvider } from './providers/location-service/AmazonLocationServiceProvider';
6
7
  import { validateCoordinates } from './util';
7
8
  var logger = new Logger('Geo');
8
9
  var DEFAULT_PROVIDER = 'AmazonLocationService';
9
- var GeoClass = /** @class */ (function () {
10
+ export var GeoClass = /** @class */ (function () {
10
11
  function GeoClass() {
12
+ var _a;
11
13
  this._config = {};
12
14
  this._pluggables = [];
15
+ var amplifyConfig = (_a = Amplify.getConfig()) !== null && _a !== void 0 ? _a : {};
16
+ this._config = Object.assign({}, this._config, amplifyConfig.Geo);
17
+ var locationProvider = new AmazonLocationServiceProvider(amplifyConfig.Geo);
18
+ this._pluggables.push(locationProvider);
13
19
  logger.debug('Geo Options', this._config);
14
20
  }
15
21
  /**
@@ -26,8 +32,6 @@ var GeoClass = /** @class */ (function () {
26
32
  GeoClass.prototype.addPluggable = function (pluggable) {
27
33
  if (pluggable && pluggable.getCategory() === 'Geo') {
28
34
  this._pluggables.push(pluggable);
29
- var config = pluggable.configure(this._config[pluggable.getProviderName()]);
30
- return config;
31
35
  }
32
36
  };
33
37
  /**
@@ -51,26 +55,6 @@ var GeoClass = /** @class */ (function () {
51
55
  this._pluggables = this._pluggables.filter(function (pluggable) { return pluggable.getProviderName() !== providerName; });
52
56
  return;
53
57
  };
54
- /**
55
- * Configure Geo
56
- * @param {Object} config - Configuration object for Geo
57
- * @return {Object} - Current configuration
58
- */
59
- GeoClass.prototype.configure = function (config) {
60
- var _this = this;
61
- logger.debug('configure Geo');
62
- if (!config)
63
- return this._config;
64
- var amplifyConfig = parseAWSExports(config);
65
- this._config = Object.assign({}, this._config, amplifyConfig.Geo, config);
66
- this._pluggables.forEach(function (pluggable) {
67
- pluggable.configure(_this._config[pluggable.getProviderName()]);
68
- });
69
- if (this._pluggables.length === 0) {
70
- this.addPluggable(new AmazonLocationServiceProvider());
71
- }
72
- return this._config;
73
- };
74
58
  /**
75
59
  * Get the map resources that are currently available through the provider
76
60
  * @param {string} provider
@@ -99,11 +83,12 @@ var GeoClass = /** @class */ (function () {
99
83
  */
100
84
  GeoClass.prototype.searchByText = function (text, options) {
101
85
  return __awaiter(this, void 0, void 0, function () {
102
- var _a, providerName, prov, error_1;
86
+ var providerName, prov, error_1;
87
+ var _a;
103
88
  return __generator(this, function (_b) {
104
89
  switch (_b.label) {
105
90
  case 0:
106
- _a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
91
+ providerName = (_a = (options || {}).providerName, _a === void 0 ? DEFAULT_PROVIDER : _a);
107
92
  prov = this.getPluggable(providerName);
108
93
  _b.label = 1;
109
94
  case 1:
@@ -127,11 +112,12 @@ var GeoClass = /** @class */ (function () {
127
112
  */
128
113
  GeoClass.prototype.searchForSuggestions = function (text, options) {
129
114
  return __awaiter(this, void 0, void 0, function () {
130
- var _a, providerName, prov, error_2;
115
+ var providerName, prov, error_2;
116
+ var _a;
131
117
  return __generator(this, function (_b) {
132
118
  switch (_b.label) {
133
119
  case 0:
134
- _a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
120
+ providerName = (_a = (options || {}).providerName, _a === void 0 ? DEFAULT_PROVIDER : _a);
135
121
  prov = this.getPluggable(providerName);
136
122
  _b.label = 1;
137
123
  case 1:
@@ -183,13 +169,14 @@ var GeoClass = /** @class */ (function () {
183
169
  */
184
170
  GeoClass.prototype.searchByCoordinates = function (coordinates, options) {
185
171
  return __awaiter(this, void 0, void 0, function () {
186
- var _a, providerName, prov, _b, lng, lat, error_4;
172
+ var providerName, prov, lng, lat, error_4;
173
+ var _a, _b;
187
174
  return __generator(this, function (_c) {
188
175
  switch (_c.label) {
189
176
  case 0:
190
- _a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
177
+ providerName = (_a = (options || {}).providerName, _a === void 0 ? DEFAULT_PROVIDER : _a);
191
178
  prov = this.getPluggable(providerName);
192
- _b = __read(coordinates, 2), lng = _b[0], lat = _b[1];
179
+ lng = (_b = __read(coordinates, 2), _b[0]), lat = _b[1];
193
180
  _c.label = 1;
194
181
  case 1:
195
182
  _c.trys.push([1, 3, , 4]);
@@ -215,11 +202,12 @@ var GeoClass = /** @class */ (function () {
215
202
  */
216
203
  GeoClass.prototype.saveGeofences = function (geofences, options) {
217
204
  return __awaiter(this, void 0, void 0, function () {
218
- var _a, providerName, prov, geofenceInputArray, error_5;
205
+ var providerName, prov, geofenceInputArray, error_5;
206
+ var _a;
219
207
  return __generator(this, function (_b) {
220
208
  switch (_b.label) {
221
209
  case 0:
222
- _a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
210
+ providerName = (_a = (options || {}).providerName, _a === void 0 ? DEFAULT_PROVIDER : _a);
223
211
  prov = this.getPluggable(providerName);
224
212
  if (!Array.isArray(geofences)) {
225
213
  geofenceInputArray = [geofences];
@@ -249,11 +237,12 @@ var GeoClass = /** @class */ (function () {
249
237
  */
250
238
  GeoClass.prototype.getGeofence = function (geofenceId, options) {
251
239
  return __awaiter(this, void 0, void 0, function () {
252
- var _a, providerName, prov, error_6;
240
+ var providerName, prov, error_6;
241
+ var _a;
253
242
  return __generator(this, function (_b) {
254
243
  switch (_b.label) {
255
244
  case 0:
256
- _a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
245
+ providerName = (_a = (options || {}).providerName, _a === void 0 ? DEFAULT_PROVIDER : _a);
257
246
  prov = this.getPluggable(providerName);
258
247
  _b.label = 1;
259
248
  case 1:
@@ -278,11 +267,12 @@ var GeoClass = /** @class */ (function () {
278
267
  */
279
268
  GeoClass.prototype.listGeofences = function (options) {
280
269
  return __awaiter(this, void 0, void 0, function () {
281
- var _a, providerName, prov, error_7;
270
+ var providerName, prov, error_7;
271
+ var _a;
282
272
  return __generator(this, function (_b) {
283
273
  switch (_b.label) {
284
274
  case 0:
285
- _a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
275
+ providerName = (_a = (options || {}).providerName, _a === void 0 ? DEFAULT_PROVIDER : _a);
286
276
  prov = this.getPluggable(providerName);
287
277
  _b.label = 1;
288
278
  case 1:
@@ -308,11 +298,12 @@ var GeoClass = /** @class */ (function () {
308
298
  */
309
299
  GeoClass.prototype.deleteGeofences = function (geofenceIds, options) {
310
300
  return __awaiter(this, void 0, void 0, function () {
311
- var _a, providerName, prov, geofenceIdsInputArray, error_8;
301
+ var providerName, prov, geofenceIdsInputArray, error_8;
302
+ var _a;
312
303
  return __generator(this, function (_b) {
313
304
  switch (_b.label) {
314
305
  case 0:
315
- _a = (options || {}).providerName, providerName = _a === void 0 ? DEFAULT_PROVIDER : _a;
306
+ providerName = (_a = (options || {}).providerName, _a === void 0 ? DEFAULT_PROVIDER : _a);
316
307
  prov = this.getPluggable(providerName);
317
308
  if (!Array.isArray(geofenceIds)) {
318
309
  geofenceIdsInputArray = [geofenceIds];
@@ -337,7 +328,4 @@ var GeoClass = /** @class */ (function () {
337
328
  GeoClass.MODULE = 'Geo';
338
329
  return GeoClass;
339
330
  }());
340
- export { GeoClass };
341
331
  export var Geo = new GeoClass();
342
- Amplify.register(Geo);
343
- //# sourceMappingURL=Geo.js.map
package/lib-esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  export { Geo } from './Geo';
4
- //# sourceMappingURL=index.js.map
4
+ export * from './types';
@@ -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;
@@ -1,12 +1,13 @@
1
- import { __assign, __awaiter, __generator, __read, __spread } from "tslib";
1
+ import { __assign, __awaiter, __generator, __read, __spreadArray } from "tslib";
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  import camelcaseKeys from 'camelcase-keys';
5
- import { ConsoleLogger as Logger, Credentials, getAmplifyUserAgentObject, } from '@aws-amplify/core';
5
+ import { Amplify, fetchAuthSession } from '@aws-amplify/core';
6
+ import { ConsoleLogger as Logger, getAmplifyUserAgentObject, } from '@aws-amplify/core/internals/utils';
6
7
  import { LocationClient, SearchPlaceIndexForTextCommand, SearchPlaceIndexForSuggestionsCommand, SearchPlaceIndexForPositionCommand, BatchPutGeofenceCommand, GetPlaceCommand, GetGeofenceCommand, ListGeofencesCommand, BatchDeleteGeofenceCommand, } from '@aws-sdk/client-location';
7
- import { mapSearchOptions, validateGeofenceId, validateGeofencesInput, } from '../util';
8
+ import { mapSearchOptions, validateGeofenceId, validateGeofencesInput, } from '../../util';
8
9
  var logger = new Logger('AmazonLocationServiceProvider');
9
- var AmazonLocationServiceProvider = /** @class */ (function () {
10
+ export var AmazonLocationServiceProvider = /** @class */ (function () {
10
11
  /**
11
12
  * Initialize Geo with AWS configurations
12
13
  * @param {Object} config - Configuration object for Geo
@@ -29,18 +30,6 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
29
30
  AmazonLocationServiceProvider.prototype.getProviderName = function () {
30
31
  return AmazonLocationServiceProvider.PROVIDER_NAME;
31
32
  };
32
- /**
33
- * Configure Geo part with aws configuration
34
- * @param {Object} config - Configuration of the Geo
35
- * @return {Object} - Current configuration
36
- */
37
- AmazonLocationServiceProvider.prototype.configure = function (config) {
38
- logger.debug('configure Amazon Location Service Provider', config);
39
- if (!config)
40
- return this._config;
41
- this._config = Object.assign({}, this._config, config);
42
- return this._config;
43
- };
44
33
  /**
45
34
  * Get the map resources that are currently available through the provider
46
35
  * @returns {AmazonLocationServiceMapStyle[]}- Array of available map resources
@@ -96,7 +85,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
96
85
  locationServiceInput = __assign(__assign({}, locationServiceInput), mapSearchOptions(options, locationServiceInput));
97
86
  }
98
87
  client = new LocationClient({
99
- credentials: this._config.credentials,
88
+ credentials: this._credentials,
100
89
  region: this._config.region,
101
90
  customUserAgent: getAmplifyUserAgentObject(),
102
91
  });
@@ -151,7 +140,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
151
140
  locationServiceInput = __assign(__assign({}, locationServiceInput), mapSearchOptions(options, locationServiceInput));
152
141
  }
153
142
  client = new LocationClient({
154
- credentials: this._config.credentials,
143
+ credentials: this._credentials,
155
144
  region: this._config.region,
156
145
  customUserAgent: getAmplifyUserAgentObject(),
157
146
  });
@@ -198,7 +187,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
198
187
  this._verifySearchIndex(options === null || options === void 0 ? void 0 : options.searchIndexName);
199
188
  this._verifyPlaceId(placeId);
200
189
  client = new LocationClient({
201
- credentials: this._config.credentials,
190
+ credentials: this._credentials,
202
191
  region: this._config.region,
203
192
  customUserAgent: getAmplifyUserAgentObject(),
204
193
  });
@@ -257,7 +246,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
257
246
  locationServiceInput.MaxResults = options.maxResults;
258
247
  }
259
248
  client = new LocationClient({
260
- credentials: this._config.credentials,
249
+ credentials: this._credentials,
261
250
  region: this._config.region,
262
251
  customUserAgent: getAmplifyUserAgentObject(),
263
252
  });
@@ -336,16 +325,17 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
336
325
  }
337
326
  return [4 /*yield*/, Promise.all(geofenceBatches.map(function (batch) { return __awaiter(_this, void 0, void 0, function () {
338
327
  var response, error_5;
339
- return __generator(this, function (_a) {
340
- switch (_a.label) {
328
+ var _a, _b;
329
+ return __generator(this, function (_c) {
330
+ switch (_c.label) {
341
331
  case 0:
342
- _a.trys.push([0, 2, , 3]);
332
+ _c.trys.push([0, 2, , 3]);
343
333
  return [4 /*yield*/, this._AmazonLocationServiceBatchPutGeofenceCall(batch, (options === null || options === void 0 ? void 0 : options.collectionName) || this._config.geofenceCollections.default)];
344
334
  case 1:
345
- response = _a.sent();
335
+ response = _c.sent();
346
336
  return [3 /*break*/, 3];
347
337
  case 2:
348
- error_5 = _a.sent();
338
+ error_5 = _c.sent();
349
339
  // If the API call fails, add the geofences to the errors array and move to next batch
350
340
  batch.forEach(function (geofence) {
351
341
  results.errors.push({
@@ -359,7 +349,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
359
349
  return [2 /*return*/];
360
350
  case 3:
361
351
  // Push all successes to results
362
- response.Successes.forEach(function (success) {
352
+ (_a = response.Successes) === null || _a === void 0 ? void 0 : _a.forEach(function (success) {
363
353
  var GeofenceId = success.GeofenceId, CreateTime = success.CreateTime, UpdateTime = success.UpdateTime;
364
354
  results.successes.push({
365
355
  geofenceId: GeofenceId,
@@ -368,8 +358,10 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
368
358
  });
369
359
  });
370
360
  // Push all errors to results
371
- response.Errors.forEach(function (error) {
372
- var _a = error.Error, Code = _a.Code, Message = _a.Message, GeofenceId = error.GeofenceId;
361
+ (_b = response.Errors) === null || _b === void 0 ? void 0 : _b.forEach(function (error) {
362
+ var _a;
363
+ var Error = error.Error, GeofenceId = error.GeofenceId;
364
+ var Code = (_a = Error, _a.Code), Message = _a.Message;
373
365
  results.errors.push({
374
366
  error: {
375
367
  code: Code,
@@ -416,7 +408,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
416
408
  }
417
409
  validateGeofenceId(geofenceId);
418
410
  client = new LocationClient({
419
- credentials: this._config.credentials,
411
+ credentials: this._credentials,
420
412
  region: this._config.region,
421
413
  customUserAgent: getAmplifyUserAgentObject(),
422
414
  });
@@ -479,7 +471,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
479
471
  throw error;
480
472
  }
481
473
  client = new LocationClient({
482
- credentials: this._config.credentials,
474
+ credentials: this._credentials,
483
475
  region: this._config.region,
484
476
  customUserAgent: getAmplifyUserAgentObject(),
485
477
  });
@@ -503,14 +495,14 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
503
495
  NextToken = response.NextToken, Entries = response.Entries;
504
496
  results = {
505
497
  entries: Entries.map(function (_a) {
506
- var GeofenceId = _a.GeofenceId, CreateTime = _a.CreateTime, UpdateTime = _a.UpdateTime, Status = _a.Status, Polygon = _a.Geometry.Polygon;
498
+ var GeofenceId = _a.GeofenceId, CreateTime = _a.CreateTime, UpdateTime = _a.UpdateTime, Status = _a.Status, Geometry = _a.Geometry;
507
499
  return {
508
500
  geofenceId: GeofenceId,
509
501
  createTime: CreateTime,
510
502
  updateTime: UpdateTime,
511
503
  status: Status,
512
504
  geometry: {
513
- polygon: Polygon,
505
+ polygon: Geometry.Polygon,
514
506
  },
515
507
  };
516
508
  }),
@@ -555,7 +547,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
555
547
  }
556
548
  });
557
549
  if (badGeofenceIds.length > 0) {
558
- throw new Error("Invalid geofence ids: " + badGeofenceIds.join(', '));
550
+ throw new Error("Invalid geofence ids: ".concat(badGeofenceIds.join(', ')));
559
551
  }
560
552
  results = {
561
553
  successes: [],
@@ -584,8 +576,10 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
584
576
  var errorObject = {
585
577
  geofenceId: geofenceId,
586
578
  error: {
587
- code: error_8.message,
588
- message: error_8.message,
579
+ code: error_8
580
+ .message,
581
+ message: error_8
582
+ .message,
589
583
  },
590
584
  };
591
585
  results.errors.push(errorObject);
@@ -596,7 +590,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
596
590
  var geofenceId = _a.geofenceId;
597
591
  return geofenceId;
598
592
  });
599
- (_a = results.successes).push.apply(_a, __spread(batch.filter(function (Id) { return !badGeofenceIds.includes(Id); })));
593
+ (_a = results.successes).push.apply(_a, __spreadArray([], __read(batch.filter(function (Id) { return !badGeofenceIds.includes(Id); })), false));
600
594
  return [2 /*return*/];
601
595
  }
602
596
  });
@@ -613,19 +607,18 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
613
607
  */
614
608
  AmazonLocationServiceProvider.prototype._ensureCredentials = function () {
615
609
  return __awaiter(this, void 0, void 0, function () {
616
- var credentials, cred, error_9;
610
+ var credentials, error_9;
617
611
  return __generator(this, function (_a) {
618
612
  switch (_a.label) {
619
613
  case 0:
620
614
  _a.trys.push([0, 2, , 3]);
621
- return [4 /*yield*/, Credentials.get()];
615
+ return [4 /*yield*/, fetchAuthSession()];
622
616
  case 1:
623
- credentials = _a.sent();
617
+ credentials = (_a.sent()).credentials;
624
618
  if (!credentials)
625
619
  return [2 /*return*/, false];
626
- cred = Credentials.shear(credentials);
627
- logger.debug('Set credentials for storage. Credentials are:', cred);
628
- this._config.credentials = cred;
620
+ logger.debug('Set credentials for storage. Credentials are:', credentials);
621
+ this._credentials = credentials;
629
622
  return [2 /*return*/, true];
630
623
  case 2:
631
624
  error_9 = _a.sent();
@@ -636,7 +629,17 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
636
629
  });
637
630
  });
638
631
  };
632
+ AmazonLocationServiceProvider.prototype._refreshConfig = function () {
633
+ var _a;
634
+ this._config = (_a = Amplify.getConfig().Geo) === null || _a === void 0 ? void 0 : _a.LocationService;
635
+ if (!this._config) {
636
+ var errorString = "No Geo configuration found in amplify config, run 'amplify add geo' to create one and run `amplify push` after";
637
+ logger.debug(errorString);
638
+ throw new Error(errorString);
639
+ }
640
+ };
639
641
  AmazonLocationServiceProvider.prototype._verifyMapResources = function () {
642
+ this._refreshConfig();
640
643
  if (!this._config.maps) {
641
644
  var errorString = "No map resources found in amplify config, run 'amplify add geo' to create one and run `amplify push` after";
642
645
  logger.debug(errorString);
@@ -649,7 +652,8 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
649
652
  }
650
653
  };
651
654
  AmazonLocationServiceProvider.prototype._verifySearchIndex = function (optionalSearchIndex) {
652
- if ((!this._config.search_indices || !this._config.search_indices.default) &&
655
+ this._refreshConfig();
656
+ if ((!this._config.searchIndices || !this._config.searchIndices.default) &&
653
657
  !optionalSearchIndex) {
654
658
  var errorString = 'No Search Index found in amplify config, please run `amplify add geo` to create one and run `amplify push` after.';
655
659
  logger.debug(errorString);
@@ -657,6 +661,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
657
661
  }
658
662
  };
659
663
  AmazonLocationServiceProvider.prototype._verifyGeofenceCollections = function (optionalGeofenceCollectionName) {
664
+ this._refreshConfig();
660
665
  if ((!this._config.geofenceCollections ||
661
666
  !this._config.geofenceCollections.default) &&
662
667
  !optionalGeofenceCollectionName) {
@@ -676,7 +681,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
676
681
  CollectionName: collectionName || this._config.geofenceCollections.default,
677
682
  };
678
683
  client = new LocationClient({
679
- credentials: this._config.credentials,
684
+ credentials: this._credentials,
680
685
  region: this._config.region,
681
686
  customUserAgent: getAmplifyUserAgentObject(),
682
687
  });
@@ -707,7 +712,7 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
707
712
  CollectionName: collectionName || this._config.geofenceCollections.default,
708
713
  };
709
714
  client = new LocationClient({
710
- credentials: this._config.credentials,
715
+ credentials: this._credentials,
711
716
  region: this._config.region,
712
717
  customUserAgent: getAmplifyUserAgentObject(),
713
718
  });
@@ -731,5 +736,3 @@ var AmazonLocationServiceProvider = /** @class */ (function () {
731
736
  AmazonLocationServiceProvider.PROVIDER_NAME = 'AmazonLocationService';
732
737
  return AmazonLocationServiceProvider;
733
738
  }());
734
- export { AmazonLocationServiceProvider };
735
- //# sourceMappingURL=AmazonLocationServiceProvider.js.map