Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/geo location services config #13303

Merged
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c3e159e
fix: Kebab case to Camel case config props
nadetastic Jan 27, 2024
38164f8
fix: Typo on I18n comment
nadetastic Jan 30, 2024
2e8f146
address fix in tests
nadetastic Feb 1, 2024
edd34bc
Resolve build error
nadetastic Feb 1, 2024
099e9a3
Resolve build error
nadetastic Feb 1, 2024
1daab2a
Merge branch 'main' into fix/geo-location-services-config
nadetastic Feb 1, 2024
13e9cee
resolve PR failures
nadetastic Feb 1, 2024
0009a84
Merge branch 'fix/geo-location-services-config' of https://github.com…
nadetastic Feb 1, 2024
a7e7980
Merge branch 'main' into fix/geo-location-services-config
kvramyasri7 Feb 2, 2024
8e8f46e
update Geo tests
nadetastic Feb 16, 2024
11467af
Merge branch 'main' into fix/geo-location-services-config
nadetastic Feb 16, 2024
f50912b
Integ test check
nadetastic Mar 13, 2024
e3e8fcd
integ test
nadetastic Mar 13, 2024
971a645
integ test
nadetastic Mar 13, 2024
4f5f706
Merge branch 'main' into fix/geo-location-services-config
nadetastic Mar 25, 2024
f1b31f7
fix parseAWSExports duplicating "search_indices" and "searchIndicies"
nadetastic Mar 26, 2024
8771bcd
Merge branch 'main' into fix/geo-location-services-config
nadetastic Mar 26, 2024
eb12bd7
fix prettier error
ashika112 Apr 27, 2024
cb97136
Merge branch 'main' of github.com:ashika112/amplify-js into fix/geo-l…
ashika112 Apr 27, 2024
003f84d
fix bundle size test
ashika112 Apr 27, 2024
c023153
Merge branch 'main' of github.com:aws-amplify/amplify-js into fix/geo…
ashika112 Apr 27, 2024
438f25c
fix: update parseAWSExports
Apr 27, 2024
27fb817
cleanup
Apr 27, 2024
8719a92
update bundle size
Apr 27, 2024
31af65d
cleanup
Apr 27, 2024
82690c8
chore: cleanup
Apr 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 31 additions & 0 deletions packages/core/__tests__/parseAWSExports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ describe('parseAWSExports', () => {
items: ['geoJSSearchExample'],
default: 'geoJSSearchExample',
},
geofenceCollections: {
items: ['geofenceCollection-dev'],
default: 'geofenceCollection-dev',
},
region,
};
const amazonLocationServiceV4 = {
Expand All @@ -49,6 +53,10 @@ describe('parseAWSExports', () => {
items: ['geoJSSearchExample'],
default: 'geoJSSearchExample',
},
geofenceCollections: {
items: ['geofenceCollection-dev'],
default: 'geofenceCollection-dev',
},
region,
};
const restEndpoint1 = {
Expand Down Expand Up @@ -189,6 +197,29 @@ describe('parseAWSExports', () => {
).toStrictEqual(expected);
});

it('should parse valid aws-exports.js for Geo', () => {
const expected = {
Geo: {
LocationService: amazonLocationServiceV4,
},
};
// aws-exports.js has geo "search_indices" in snake_case
expect(
parseAWSExports({
aws_project_region: 'us-west-2',
geo: { amazon_location_service: amazonLocationService },
}),
).toStrictEqual(expected);

// aws-exports.js has geo "searchIndices" in camelCase
expect(
parseAWSExports({
aws_project_region: 'us-west-2',
geo: { amazon_location_service: amazonLocationServiceV4 },
}),
).toStrictEqual(expected);
});

it('should fallback to IAM auth mode if Appsync auth type is invalid', () => {
expect(
parseAWSExports({
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/parseAWSExports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,11 @@ export const parseAWSExports = (
? {
LocationService: {
...amazon_location_service,
ashika112 marked this conversation as resolved.
Show resolved Hide resolved
searchIndices: amazon_location_service.search_indices,
maps: amazon_location_service.maps,
geofenceCollections: amazon_location_service.geofenceCollections,
searchIndices:
amazon_location_service.search_indices ??
amazon_location_service.searchIndices,
ashika112 marked this conversation as resolved.
Show resolved Hide resolved
region: amazon_location_service.region,
},
}
Expand Down
Original file line number Diff line number Diff line change
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,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GG : )

};

/**
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