@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/package.json CHANGED
@@ -1,117 +1,134 @@
1
1
  {
2
- "name": "@aws-amplify/geo",
3
- "version": "2.3.5",
4
- "description": "Geo category for aws-amplify",
5
- "main": "./lib/index.js",
6
- "module": "./lib-esm/index.js",
7
- "typings": "./lib-esm/index.d.ts",
8
- "react-native": {
9
- "./lib/index": "./lib-esm/index.js"
10
- },
11
- "publishConfig": {
12
- "access": "public"
13
- },
14
- "sideEffects": [
15
- "./lib/geo/geo.js",
16
- "./lib-esm/geo/geo.js"
17
- ],
18
- "scripts": {
19
- "test": "yarn run lint && jest -w 1 --coverage",
20
- "test:size": "size-limit",
21
- "build-with-test": "yarn test && yarn run build",
22
- "build:cjs": "node ./build es5 && webpack && webpack --config ./webpack.config.dev.js",
23
- "build:esm": "node ./build es6",
24
- "build:cjs:watch": "node ./build es5 --watch",
25
- "build:esm:watch": "rimraf lib-esm && node ./build es6 --watch",
26
- "build": "yarn clean && yarn build:esm && yarn run build:cjs",
27
- "clean": "npm run clean:size && rimraf lib-esm lib dist",
28
- "clean:size": "rimraf dual-publish-tmp tmp*",
29
- "format": "echo \"Not implemented\"",
30
- "lint": "tslint '{__tests__,src}/**/*.ts' && npm run ts-coverage",
31
- "ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 86.56"
32
- },
33
- "repository": {
34
- "type": "git",
35
- "url": "https://github.com/aws-amplify/amplify-js.git"
36
- },
37
- "author": "Amazon Web Services",
38
- "license": "Apache-2.0",
39
- "bugs": {
40
- "url": "https://github.com/aws/aws-amplify/issues"
41
- },
42
- "homepage": "https://aws-amplify.github.io/",
43
- "files": [
44
- "lib",
45
- "lib-esm",
46
- "src"
47
- ],
48
- "dependencies": {
49
- "@aws-amplify/core": "5.8.5",
50
- "@aws-sdk/client-location": "3.186.3",
51
- "@turf/boolean-clockwise": "6.5.0",
52
- "camelcase-keys": "6.2.2",
53
- "tslib": "^1.8.0"
54
- },
55
- "size-limit": [
56
- {
57
- "name": "Geo (top-level class)",
58
- "path": "./lib-esm/index.js",
59
- "import": "{ Amplify, Geo }",
60
- "limit": "52.12 kB"
61
- }
62
- ],
63
- "jest": {
64
- "globals": {
65
- "ts-jest": {
66
- "diagnostics": true,
67
- "tsConfig": {
68
- "lib": [
69
- "es5",
70
- "es2015",
71
- "dom",
72
- "esnext.asynciterable",
73
- "es2019.object"
74
- ],
75
- "allowJs": true,
76
- "esModuleInterop": true,
77
- "downlevelIteration": true
78
- }
79
- }
80
- },
81
- "transform": {
82
- "^.+\\.(js|jsx|ts|tsx)$": "ts-jest"
83
- },
84
- "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(tsx?|jsx?)$",
85
- "testPathIgnorePatterns": [
86
- "__tests__/model.ts",
87
- "__tests__/schema.ts",
88
- "__tests__/helpers.ts",
89
- "__tests__/testData.ts",
90
- "__tests__/testUtils.ts"
91
- ],
92
- "moduleFileExtensions": [
93
- "ts",
94
- "tsx",
95
- "js",
96
- "json",
97
- "jsx"
98
- ],
99
- "testEnvironment": "jsdom",
100
- "testURL": "http://localhost/",
101
- "coverageThreshold": {
102
- "global": {
103
- "branches": 0,
104
- "functions": 0,
105
- "lines": 0,
106
- "statements": 0
107
- }
108
- },
109
- "coveragePathIgnorePatterns": [
110
- "/node_modules/",
111
- "dist",
112
- "lib",
113
- "lib-esm"
114
- ]
115
- },
116
- "gitHead": "c3a06153e3ffe05dd65485a22b1f99aabe9b3d83"
2
+ "name": "@aws-amplify/geo",
3
+ "version": "3.0.1-console-preview.431c340.0+431c340",
4
+ "description": "Geo category for aws-amplify",
5
+ "main": "./lib/index.js",
6
+ "module": "./lib-esm/index.js",
7
+ "typings": "./lib-esm/index.d.ts",
8
+ "react-native": {
9
+ "./lib/index": "./lib-esm/index.js"
10
+ },
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "sideEffects": [
15
+ "./lib/geo/geo.js",
16
+ "./lib-esm/geo/geo.js"
17
+ ],
18
+ "scripts": {
19
+ "test": "yarn run lint && jest -w 1 --coverage",
20
+ "test:size": "size-limit",
21
+ "build-with-test": "yarn test && yarn run build",
22
+ "build:cjs": "rimraf lib && tsc -m commonjs --outDir lib && webpack && webpack --config ./webpack.config.dev.js",
23
+ "build:esm": "rimraf lib-esm && tsc -m esnext --outDir lib-esm",
24
+ "build:cjs:watch": "rimraf lib && tsc -m commonjs --outDir lib --watch",
25
+ "build:esm:watch": "rimraf lib-esm && tsc -m esnext --outDir lib-esm --watch",
26
+ "build": "yarn clean && yarn build:esm && yarn run build:cjs",
27
+ "clean": "npm run clean:size && rimraf lib-esm lib dist",
28
+ "clean:size": "rimraf dual-publish-tmp tmp*",
29
+ "format": "echo \"Not implemented\"",
30
+ "lint": "tslint '{__tests__,src}/**/*.ts' && npm run ts-coverage",
31
+ "ts-coverage": "typescript-coverage-report -p ./tsconfig.json -t 84.00"
32
+ },
33
+ "typesVersions": {
34
+ ">=4.0": {
35
+ "*": [
36
+ "./lib-esm/index.d.ts"
37
+ ],
38
+ "pinpoint": [
39
+ "./lib-esm/providers/pinpoint/AmazonLocationServiceProvider.d.ts"
40
+ ]
41
+ }
42
+ },
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "https://github.com/aws-amplify/amplify-js.git"
46
+ },
47
+ "author": "Amazon Web Services",
48
+ "license": "Apache-2.0",
49
+ "bugs": {
50
+ "url": "https://github.com/aws/aws-amplify/issues"
51
+ },
52
+ "homepage": "https://aws-amplify.github.io/",
53
+ "files": [
54
+ "lib",
55
+ "lib-esm",
56
+ "src"
57
+ ],
58
+ "dependencies": {
59
+ "@aws-sdk/client-location": "3.398.0",
60
+ "@turf/boolean-clockwise": "6.5.0",
61
+ "camelcase-keys": "6.2.2",
62
+ "tslib": "^2.5.0"
63
+ },
64
+ "peerDependencies": {
65
+ "@aws-amplify/core": "6.0.1-console-preview.431c340.0+431c340"
66
+ },
67
+ "devDependencies": {
68
+ "@aws-amplify/core": "6.0.1-console-preview.431c340.0+431c340",
69
+ "typescript": "5.0.2"
70
+ },
71
+ "size-limit": [
72
+ {
73
+ "name": "Geo (top-level class)",
74
+ "path": "./lib-esm/index.js",
75
+ "import": "{ Amplify, Geo }",
76
+ "limit": "52.12 kB"
77
+ }
78
+ ],
79
+ "jest": {
80
+ "globals": {
81
+ "ts-jest": {
82
+ "diagnostics": true,
83
+ "tsConfig": {
84
+ "lib": [
85
+ "es5",
86
+ "es2015",
87
+ "dom",
88
+ "esnext.asynciterable",
89
+ "es2019.object"
90
+ ],
91
+ "allowJs": true,
92
+ "noEmitOnError": false,
93
+ "esModuleInterop": true,
94
+ "downlevelIteration": true
95
+ }
96
+ }
97
+ },
98
+ "transform": {
99
+ "^.+\\.(js|jsx|ts|tsx)$": "ts-jest"
100
+ },
101
+ "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(tsx?|jsx?)$",
102
+ "testPathIgnorePatterns": [
103
+ "__tests__/model.ts",
104
+ "__tests__/schema.ts",
105
+ "__tests__/helpers.ts",
106
+ "__tests__/testData.ts",
107
+ "__tests__/testUtils.ts"
108
+ ],
109
+ "moduleFileExtensions": [
110
+ "ts",
111
+ "tsx",
112
+ "js",
113
+ "json",
114
+ "jsx"
115
+ ],
116
+ "testEnvironment": "jsdom",
117
+ "testURL": "http://localhost/",
118
+ "coverageThreshold": {
119
+ "global": {
120
+ "branches": 0,
121
+ "functions": 0,
122
+ "lines": 0,
123
+ "statements": 0
124
+ }
125
+ },
126
+ "coveragePathIgnorePatterns": [
127
+ "node_modules",
128
+ "dist",
129
+ "lib",
130
+ "lib-esm"
131
+ ]
132
+ },
133
+ "gitHead": "431c340469e40ebed677872def2feb216ce151fe"
117
134
  }
package/src/Geo.ts CHANGED
@@ -1,11 +1,8 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import {
4
- Amplify,
5
- ConsoleLogger as Logger,
6
- parseAWSExports,
7
- } from '@aws-amplify/core';
8
- import { AmazonLocationServiceProvider } from './Providers/AmazonLocationServiceProvider';
3
+ import { Amplify } from '@aws-amplify/core';
4
+ import { ConsoleLogger as Logger } from '@aws-amplify/core/internals/utils';
5
+ import { AmazonLocationServiceProvider } from './providers/location-service/AmazonLocationServiceProvider';
9
6
 
10
7
  import { validateCoordinates } from './util';
11
8
 
@@ -42,6 +39,15 @@ export class GeoClass {
42
39
  constructor() {
43
40
  this._config = {};
44
41
  this._pluggables = [];
42
+
43
+ const amplifyConfig = Amplify.getConfig() ?? {};
44
+ this._config = Object.assign({}, this._config, amplifyConfig.Geo);
45
+
46
+ const locationProvider = new AmazonLocationServiceProvider(
47
+ amplifyConfig.Geo
48
+ );
49
+ this._pluggables.push(locationProvider);
50
+
45
51
  logger.debug('Geo Options', this._config);
46
52
  }
47
53
 
@@ -60,11 +66,6 @@ export class GeoClass {
60
66
  public addPluggable(pluggable: GeoProvider) {
61
67
  if (pluggable && pluggable.getCategory() === 'Geo') {
62
68
  this._pluggables.push(pluggable);
63
- const config = pluggable.configure(
64
- this._config[pluggable.getProviderName()]
65
- );
66
-
67
- return config;
68
69
  }
69
70
  }
70
71
 
@@ -93,29 +94,6 @@ export class GeoClass {
93
94
  return;
94
95
  }
95
96
 
96
- /**
97
- * Configure Geo
98
- * @param {Object} config - Configuration object for Geo
99
- * @return {Object} - Current configuration
100
- */
101
- configure(config?) {
102
- logger.debug('configure Geo');
103
-
104
- if (!config) return this._config;
105
-
106
- const amplifyConfig = parseAWSExports(config);
107
- this._config = Object.assign({}, this._config, amplifyConfig.Geo, config);
108
-
109
- this._pluggables.forEach(pluggable => {
110
- pluggable.configure(this._config[pluggable.getProviderName()]);
111
- });
112
-
113
- if (this._pluggables.length === 0) {
114
- this.addPluggable(new AmazonLocationServiceProvider());
115
- }
116
- return this._config;
117
- }
118
-
119
97
  /**
120
98
  * Get the map resources that are currently available through the provider
121
99
  * @param {string} provider
@@ -331,4 +309,3 @@ export class GeoClass {
331
309
  }
332
310
 
333
311
  export const Geo = new GeoClass();
334
- Amplify.register(Geo);
@@ -2,11 +2,11 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import camelcaseKeys from 'camelcase-keys';
4
4
 
5
+ import { Amplify, fetchAuthSession } from '@aws-amplify/core';
5
6
  import {
6
7
  ConsoleLogger as Logger,
7
- Credentials,
8
8
  getAmplifyUserAgentObject,
9
- } from '@aws-amplify/core';
9
+ } from '@aws-amplify/core/internals/utils';
10
10
  import {
11
11
  Place as PlaceResult,
12
12
  LocationClient,
@@ -38,7 +38,7 @@ import {
38
38
  mapSearchOptions,
39
39
  validateGeofenceId,
40
40
  validateGeofencesInput,
41
- } from '../util';
41
+ } from '../../util';
42
42
 
43
43
  import {
44
44
  GeoConfig,
@@ -60,7 +60,8 @@ import {
60
60
  GeofencePolygon,
61
61
  AmazonLocationServiceDeleteGeofencesResults,
62
62
  searchByPlaceIdOptions,
63
- } from '../types';
63
+ AmazonLocationServiceBatchGeofenceErrorMessages,
64
+ } from '../../types';
64
65
 
65
66
  const logger = new Logger('AmazonLocationServiceProvider');
66
67
 
@@ -72,6 +73,7 @@ export class AmazonLocationServiceProvider implements GeoProvider {
72
73
  * @private
73
74
  */
74
75
  private _config;
76
+ private _credentials;
75
77
 
76
78
  /**
77
79
  * Initialize Geo with AWS configurations
@@ -98,18 +100,6 @@ export class AmazonLocationServiceProvider implements GeoProvider {
98
100
  return AmazonLocationServiceProvider.PROVIDER_NAME;
99
101
  }
100
102
 
101
- /**
102
- * Configure Geo part with aws configuration
103
- * @param {Object} config - Configuration of the Geo
104
- * @return {Object} - Current configuration
105
- */
106
- public configure(config?): object {
107
- logger.debug('configure Amazon Location Service Provider', config);
108
- if (!config) return this._config;
109
- this._config = Object.assign({}, this._config, config);
110
- return this._config;
111
- }
112
-
113
103
  /**
114
104
  * Get the map resources that are currently available through the provider
115
105
  * @returns {AmazonLocationServiceMapStyle[]}- Array of available map resources
@@ -179,7 +169,7 @@ export class AmazonLocationServiceProvider implements GeoProvider {
179
169
  }
180
170
 
181
171
  const client = new LocationClient({
182
- credentials: this._config.credentials,
172
+ credentials: this._credentials,
183
173
  region: this._config.region,
184
174
  customUserAgent: getAmplifyUserAgentObject(),
185
175
  });
@@ -203,7 +193,7 @@ export class AmazonLocationServiceProvider implements GeoProvider {
203
193
  );
204
194
  const results: Place[] = camelcaseKeys(PascalResults, {
205
195
  deep: true,
206
- }) as undefined as Place[];
196
+ }) as unknown as Place[];
207
197
 
208
198
  return results;
209
199
  }
@@ -245,7 +235,7 @@ export class AmazonLocationServiceProvider implements GeoProvider {
245
235
  }
246
236
 
247
237
  const client = new LocationClient({
248
- credentials: this._config.credentials,
238
+ credentials: this._credentials,
249
239
  region: this._config.region,
250
240
  customUserAgent: getAmplifyUserAgentObject(),
251
241
  });
@@ -293,7 +283,7 @@ export class AmazonLocationServiceProvider implements GeoProvider {
293
283
  this._verifyPlaceId(placeId);
294
284
 
295
285
  const client = new LocationClient({
296
- credentials: this._config.credentials,
286
+ credentials: this._credentials,
297
287
  region: this._config.region,
298
288
  customUserAgent: getAmplifyUserAgentObject(),
299
289
  });
@@ -351,7 +341,7 @@ export class AmazonLocationServiceProvider implements GeoProvider {
351
341
  }
352
342
 
353
343
  const client = new LocationClient({
354
- credentials: this._config.credentials,
344
+ credentials: this._credentials,
355
345
  region: this._config.region,
356
346
  customUserAgent: getAmplifyUserAgentObject(),
357
347
  });
@@ -448,10 +438,10 @@ export class AmazonLocationServiceProvider implements GeoProvider {
448
438
  // If the API call fails, add the geofences to the errors array and move to next batch
449
439
  batch.forEach(geofence => {
450
440
  results.errors.push({
451
- geofenceId: geofence.GeofenceId,
441
+ geofenceId: geofence.GeofenceId!,
452
442
  error: {
453
443
  code: 'APIConnectionError',
454
- message: error.message,
444
+ message: (error as Error).message,
455
445
  },
456
446
  });
457
447
  });
@@ -459,27 +449,25 @@ export class AmazonLocationServiceProvider implements GeoProvider {
459
449
  }
460
450
 
461
451
  // Push all successes to results
462
- response.Successes.forEach(success => {
452
+ response.Successes?.forEach(success => {
463
453
  const { GeofenceId, CreateTime, UpdateTime } = success;
464
454
  results.successes.push({
465
- geofenceId: GeofenceId,
455
+ geofenceId: GeofenceId!,
466
456
  createTime: CreateTime,
467
457
  updateTime: UpdateTime,
468
458
  });
469
459
  });
470
460
 
471
461
  // Push all errors to results
472
- response.Errors.forEach(error => {
473
- const {
474
- Error: { Code, Message },
475
- GeofenceId,
476
- } = error;
462
+ response.Errors?.forEach(error => {
463
+ const { Error, GeofenceId } = error;
464
+ const { Code, Message } = Error!;
477
465
  results.errors.push({
478
466
  error: {
479
- code: Code,
480
- message: Message,
467
+ code: Code!,
468
+ message: Message!,
481
469
  },
482
- geofenceId: GeofenceId,
470
+ geofenceId: GeofenceId!,
483
471
  });
484
472
  });
485
473
  })
@@ -515,7 +503,7 @@ export class AmazonLocationServiceProvider implements GeoProvider {
515
503
 
516
504
  // Create Amazon Location Service Client
517
505
  const client = new LocationClient({
518
- credentials: this._config.credentials,
506
+ credentials: this._credentials,
519
507
  region: this._config.region,
520
508
  customUserAgent: getAmplifyUserAgentObject(),
521
509
  });
@@ -541,9 +529,9 @@ export class AmazonLocationServiceProvider implements GeoProvider {
541
529
  const { GeofenceId, CreateTime, UpdateTime, Status, Geometry } = response;
542
530
  const geofence: AmazonLocationServiceGeofence = {
543
531
  createTime: CreateTime,
544
- geofenceId: GeofenceId,
532
+ geofenceId: GeofenceId!,
545
533
  geometry: {
546
- polygon: Geometry.Polygon as GeofencePolygon,
534
+ polygon: Geometry!.Polygon as GeofencePolygon,
547
535
  },
548
536
  status: Status as AmazonLocationServiceGeofenceStatus,
549
537
  updateTime: UpdateTime,
@@ -577,7 +565,7 @@ export class AmazonLocationServiceProvider implements GeoProvider {
577
565
 
578
566
  // Create Amazon Location Service Client
579
567
  const client = new LocationClient({
580
- credentials: this._config.credentials,
568
+ credentials: this._credentials,
581
569
  region: this._config.region,
582
570
  customUserAgent: getAmplifyUserAgentObject(),
583
571
  });
@@ -607,21 +595,15 @@ export class AmazonLocationServiceProvider implements GeoProvider {
607
595
  const { NextToken, Entries } = response;
608
596
 
609
597
  const results: ListGeofenceResults = {
610
- entries: Entries.map(
611
- ({
612
- GeofenceId,
613
- CreateTime,
614
- UpdateTime,
615
- Status,
616
- Geometry: { Polygon },
617
- }) => {
598
+ entries: Entries!.map(
599
+ ({ GeofenceId, CreateTime, UpdateTime, Status, Geometry }) => {
618
600
  return {
619
- geofenceId: GeofenceId,
601
+ geofenceId: GeofenceId!,
620
602
  createTime: CreateTime,
621
603
  updateTime: UpdateTime,
622
604
  status: Status,
623
605
  geometry: {
624
- polygon: Polygon as GeofencePolygon,
606
+ polygon: Geometry!.Polygon as GeofencePolygon,
625
607
  },
626
608
  };
627
609
  }
@@ -693,8 +675,10 @@ export class AmazonLocationServiceProvider implements GeoProvider {
693
675
  const errorObject = {
694
676
  geofenceId,
695
677
  error: {
696
- code: error.message,
697
- message: error.message,
678
+ code: (error as Error)
679
+ .message as AmazonLocationServiceBatchGeofenceErrorMessages,
680
+ message: (error as Error)
681
+ .message as AmazonLocationServiceBatchGeofenceErrorMessages,
698
682
  },
699
683
  };
700
684
  results.errors.push(errorObject);
@@ -718,11 +702,13 @@ export class AmazonLocationServiceProvider implements GeoProvider {
718
702
  */
719
703
  private async _ensureCredentials(): Promise<boolean> {
720
704
  try {
721
- const credentials = await Credentials.get();
705
+ const credentials = (await fetchAuthSession()).credentials;
722
706
  if (!credentials) return false;
723
- const cred = Credentials.shear(credentials);
724
- logger.debug('Set credentials for storage. Credentials are:', cred);
725
- this._config.credentials = cred;
707
+ logger.debug(
708
+ 'Set credentials for storage. Credentials are:',
709
+ credentials
710
+ );
711
+ this._credentials = credentials;
726
712
  return true;
727
713
  } catch (error) {
728
714
  logger.debug('Ensure credentials error. Credentials are:', error);
@@ -730,7 +716,18 @@ export class AmazonLocationServiceProvider implements GeoProvider {
730
716
  }
731
717
  }
732
718
 
719
+ private _refreshConfig() {
720
+ this._config = Amplify.getConfig().Geo?.LocationService;
721
+ if (!this._config) {
722
+ const errorString =
723
+ "No Geo configuration found in amplify config, run 'amplify add geo' to create one and run `amplify push` after";
724
+ logger.debug(errorString);
725
+ throw new Error(errorString);
726
+ }
727
+ }
728
+
733
729
  private _verifyMapResources() {
730
+ this._refreshConfig();
734
731
  if (!this._config.maps) {
735
732
  const errorString =
736
733
  "No map resources found in amplify config, run 'amplify add geo' to create one and run `amplify push` after";
@@ -746,8 +743,9 @@ export class AmazonLocationServiceProvider implements GeoProvider {
746
743
  }
747
744
 
748
745
  private _verifySearchIndex(optionalSearchIndex?: string) {
746
+ this._refreshConfig();
749
747
  if (
750
- (!this._config.search_indices || !this._config.search_indices.default) &&
748
+ (!this._config.searchIndices || !this._config.searchIndices.default) &&
751
749
  !optionalSearchIndex
752
750
  ) {
753
751
  const errorString =
@@ -758,6 +756,7 @@ export class AmazonLocationServiceProvider implements GeoProvider {
758
756
  }
759
757
 
760
758
  private _verifyGeofenceCollections(optionalGeofenceCollectionName?: string) {
759
+ this._refreshConfig();
761
760
  if (
762
761
  (!this._config.geofenceCollections ||
763
762
  !this._config.geofenceCollections.default) &&
@@ -782,7 +781,7 @@ export class AmazonLocationServiceProvider implements GeoProvider {
782
781
  };
783
782
 
784
783
  const client = new LocationClient({
785
- credentials: this._config.credentials,
784
+ credentials: this._credentials,
786
785
  region: this._config.region,
787
786
  customUserAgent: getAmplifyUserAgentObject(),
788
787
  });
@@ -809,7 +808,7 @@ export class AmazonLocationServiceProvider implements GeoProvider {
809
808
  };
810
809
 
811
810
  const client = new LocationClient({
812
- credentials: this._config.credentials,
811
+ credentials: this._credentials,
813
812
  region: this._config.region,
814
813
  customUserAgent: getAmplifyUserAgentObject(),
815
814
  });
package/src/types/Geo.ts CHANGED
@@ -1,23 +1,7 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  // configuration shape for the Geo class
4
- export interface GeoConfig {
5
- region?: string;
6
- AmazonLocationService?: {
7
- maps?: {
8
- items: {};
9
- default: string;
10
- };
11
- search_indices?: {
12
- items: string[];
13
- default: string;
14
- };
15
- geofenceCollections?: {
16
- items: string[];
17
- default: string;
18
- };
19
- };
20
- }
4
+ export { GeoConfig } from '@aws-amplify/core';
21
5
 
22
6
  // Data held about maps in aws-exports
23
7
  export interface MapStyle {
@@ -25,9 +25,6 @@ export interface GeoProvider {
25
25
  // get provider name
26
26
  getProviderName(): string;
27
27
 
28
- // configure your provider
29
- configure(config: object): object;
30
-
31
28
  // get the available map resources
32
29
  getAvailableMaps(): MapStyle[];
33
30