Environment details
- API: Address Validation API
- OS type and version: any
- Library version and other environment information:
@googlemaps/extended-component-library:v0.6.14
Steps to reproduce
First of all, I want to say that 0.6.14 seems to have some serious changes as for the "patch" version. After the update from 0.6.13->0.6.14 our code stopped working.
- Call the Address Validation API and receive the
response
const { suggestedAction } = suggestValidationAction(response)
- Result:
suggestedAction value is incorrect (best scenario) or the whole function fails (worst scenario)
Code example
const response = await $fetch(
`https://addressvalidation.googleapis.com/v1:validateAddress?key=${googleMapsApiKey}`,
{
method: 'POST',
body: {
address: {
regionCode: address.countryIsoCode,
locality: address.city,
addressLines: [address.street],
postalCode: address.zipcode,
},
},
}
)
const { suggestedAction } = suggestValidationAction(response)
Stack trace
TypeError: can't access property "some", result.address.components is undefined
hasSuspiciousComponent suggest_validation_action.ts:53
suggestValidationAction suggest_validation_action.ts:151
I see two issues with the changes introduced in 0.6.14
1. The response argument type of suggestValidationAction function was changed from AddressValidationResponse to AddressValidation.
This is not reflected in the documentation (e.g. README: https://github.com/googlemaps/extended-component-library/blob/main/src/address_validation/README.md#examples)
It means that this code:
...
response = await AddressValidation.validateAddress(request);
const {suggestedAction} = suggestValidationAction(response);
will no longer work. Instead you have to pass response.result which is unintuitive and is a breaking change.
2. The Address interface addressComponents was changed to components
The field addressComponents is now components in the Address interface. This is simply incorrect, as the API response has addressComponents, not components!
This can be easily verified using this demo: https://developers.google.com/maps/documentation/address-validation/demo
This causes the problem I pasted in the stacktrace above, there is no components field in the response, so it fails to run .some() function on it and the whole function breaks.
Environment details
@googlemaps/extended-component-library:v0.6.14Steps to reproduce
First of all, I want to say that
0.6.14seems to have some serious changes as for the "patch" version. After the update from0.6.13->0.6.14our code stopped working.responseconst { suggestedAction } = suggestValidationAction(response)suggestedActionvalue is incorrect (best scenario) or the whole function fails (worst scenario)Code example
Stack trace
I see two issues with the changes introduced in
0.6.141. The
responseargument type ofsuggestValidationActionfunction was changed fromAddressValidationResponsetoAddressValidation.This is not reflected in the documentation (e.g. README: https://github.com/googlemaps/extended-component-library/blob/main/src/address_validation/README.md#examples)
It means that this code:
will no longer work. Instead you have to pass
response.resultwhich is unintuitive and is a breaking change.2. The Address interface
addressComponentswas changed tocomponentsThe field
addressComponentsis nowcomponentsin theAddressinterface. This is simply incorrect, as the API response hasaddressComponents, notcomponents!This can be easily verified using this demo: https://developers.google.com/maps/documentation/address-validation/demo
This causes the problem I pasted in the stacktrace above, there is no
componentsfield in the response, so it fails to run.some()function on it and the whole function breaks.