From fa02396112561ff9a202fbd528839ed3e9855117 Mon Sep 17 00:00:00 2001 From: Ashwin Kumar Date: Sat, 27 Apr 2024 17:18:44 -0700 Subject: [PATCH] Fix/geo location services config (#13303) * 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 Co-authored-by: Dan Kiuna Co-authored-by: ashika112 Co-authored-by: Ashwin Kumar --- packages/aws-amplify/package.json | 6 +++--- packages/core/__tests__/parseAWSExports.test.ts | 16 ++++++++++------ packages/core/src/parseAWSExports.ts | 17 ++++++++--------- .../AmazonLocationServiceProvider.ts | 9 ++++----- 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/packages/aws-amplify/package.json b/packages/aws-amplify/package.json index 04526e4a6a9..b2ab1341bd1 100644 --- a/packages/aws-amplify/package.json +++ b/packages/aws-amplify/package.json @@ -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", @@ -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)", @@ -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)", diff --git a/packages/core/__tests__/parseAWSExports.test.ts b/packages/core/__tests__/parseAWSExports.test.ts index 4e26fc34b2d..1ad4520f7d5 100644 --- a/packages/core/__tests__/parseAWSExports.test.ts +++ b/packages/core/__tests__/parseAWSExports.test.ts @@ -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: { @@ -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 = { @@ -114,7 +118,7 @@ describe('parseAWSExports', () => { }, }, Geo: { - LocationService: amazonLocationServiceV4, + LocationService: expectedAmazonLocationServiceV4, }, Storage: { S3: { diff --git a/packages/core/src/parseAWSExports.ts b/packages/core/src/parseAWSExports.ts index 5bb29e1be37..295c9e211e8 100644 --- a/packages/core/src/parseAWSExports.ts +++ b/packages/core/src/parseAWSExports.ts @@ -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 diff --git a/packages/geo/src/providers/location-service/AmazonLocationServiceProvider.ts b/packages/geo/src/providers/location-service/AmazonLocationServiceProvider.ts index 1e466020357..b5248d5ccbc 100644 --- a/packages/geo/src/providers/location-service/AmazonLocationServiceProvider.ts +++ b/packages/geo/src/providers/location-service/AmazonLocationServiceProvider.ts @@ -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, }; /** @@ -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, }; /** @@ -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); @@ -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) {