Skip to content

Commit

Permalink
Fix/geo location services config (#13303)
Browse files Browse the repository at this point in the history
* fix: Kebab case to Camel case config props

* fix: Typo on I18n comment

* address fix in tests

* Resolve build error

* Resolve build error

* resolve PR failures

* update Geo tests

* Integ test check

* integ test

* integ test

* fix parseAWSExports duplicating "search_indices" and "searchIndicies"

* fix prettier error

* fix bundle size test

* fix: update parseAWSExports

* cleanup

* update bundle size

* cleanup

* chore: cleanup

---------

Co-authored-by: Dan Kiuna <dkkiuna11@gmail.com>
Co-authored-by: Dan Kiuna <dankiuna@gmail.com>
Co-authored-by: ashika112 <akasivis@amazon.com>
Co-authored-by: Ashwin Kumar <ashwsrir@amazon.com>
  • Loading branch information
5 people committed Apr 28, 2024
1 parent 89ecc6d commit fa02396
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 23 deletions.
6 changes: 3 additions & 3 deletions packages/aws-amplify/package.json
Expand Up @@ -335,7 +335,7 @@
"name": "[API] generateClient (AppSync)",
"path": "./dist/esm/api/index.mjs",
"import": "{ generateClient }",
"limit": "39.99 kB"
"limit": "40.09 kB"
},
{
"name": "[API] REST API handlers",
Expand Down Expand Up @@ -383,7 +383,7 @@
"name": "[Auth] confirmSignIn (Cognito)",
"path": "./dist/esm/auth/index.mjs",
"import": "{ confirmSignIn }",
"limit": "28.09 kB"
"limit": "28.10 kB"
},
{
"name": "[Auth] updateMFAPreference (Cognito)",
Expand Down Expand Up @@ -455,7 +455,7 @@
"name": "[Auth] OAuth Auth Flow (Cognito)",
"path": "./dist/esm/auth/index.mjs",
"import": "{ signInWithRedirect, signOut, fetchAuthSession }",
"limit": "21.45 kB"
"limit": "21.47 kB"
},
{
"name": "[Storage] copy (S3)",
Expand Down
16 changes: 10 additions & 6 deletions packages/core/__tests__/parseAWSExports.test.ts
Expand Up @@ -27,9 +27,13 @@ describe('parseAWSExports', () => {
items: ['geoJSSearchExample'],
default: 'geoJSSearchExample',
},
geofenceCollections: {
items: ['geofenceCollection-dev'],
default: 'geofenceCollection-dev',
},
region,
};
const amazonLocationServiceV4 = {
const expectedAmazonLocationServiceV4 = {
maps: {
items: {
geoJsExampleMap1: {
Expand All @@ -41,14 +45,14 @@ describe('parseAWSExports', () => {
},
default: 'geoJsExampleMap1',
},
search_indices: {
items: ['geoJSSearchExample'],
default: 'geoJSSearchExample',
},
searchIndices: {
items: ['geoJSSearchExample'],
default: 'geoJSSearchExample',
},
geofenceCollections: {
items: ['geofenceCollection-dev'],
default: 'geofenceCollection-dev',
},
region,
};
const restEndpoint1 = {
Expand Down Expand Up @@ -114,7 +118,7 @@ describe('parseAWSExports', () => {
},
},
Geo: {
LocationService: amazonLocationServiceV4,
LocationService: expectedAmazonLocationServiceV4,
},
Storage: {
S3: {
Expand Down
17 changes: 8 additions & 9 deletions packages/core/src/parseAWSExports.ts
Expand Up @@ -249,15 +249,14 @@ export const parseAWSExports = (
// Geo
if (geo) {
const { amazon_location_service } = geo;
(amplifyConfig as any).Geo = amazon_location_service
? {
LocationService: {
...amazon_location_service,
searchIndices: amazon_location_service.search_indices,
region: amazon_location_service.region,
},
}
: { ...geo };
amplifyConfig.Geo = {
LocationService: {
maps: amazon_location_service.maps,
geofenceCollections: amazon_location_service.geofenceCollections,
searchIndices: amazon_location_service.search_indices,
region: amazon_location_service.region,
},
};
}

// REST API
Expand Down
Expand Up @@ -151,7 +151,7 @@ export class AmazonLocationServiceProvider implements GeoProvider {
*/
let locationServiceInput: SearchPlaceIndexForTextCommandInput = {
Text: text,
IndexName: this._config.search_indices.default,
IndexName: this._config.searchIndices.default,
};

/**
Expand Down Expand Up @@ -217,7 +217,7 @@ export class AmazonLocationServiceProvider implements GeoProvider {
*/
let locationServiceInput: SearchPlaceIndexForSuggestionsCommandInput = {
Text: text,
IndexName: this._config.search_indices.default,
IndexName: this._config.searchIndices.default,
};

/**
Expand Down Expand Up @@ -286,8 +286,7 @@ export class AmazonLocationServiceProvider implements GeoProvider {

const searchByPlaceIdInput: GetPlaceCommandInput = {
PlaceId: placeId,
IndexName:
options?.searchIndexName || this._config.search_indices.default,
IndexName: options?.searchIndexName || this._config.searchIndices.default,
};
const command = new GetPlaceCommand(searchByPlaceIdInput);

Expand Down Expand Up @@ -325,7 +324,7 @@ export class AmazonLocationServiceProvider implements GeoProvider {

const locationServiceInput: SearchPlaceIndexForPositionCommandInput = {
Position: coordinates,
IndexName: this._config.search_indices.default,
IndexName: this._config.searchIndices.default,
};

if (options) {
Expand Down

0 comments on commit fa02396

Please sign in to comment.